Build Fix -- Remove some duplicate symbol defs to appease ld.
[sxemacs] / src / media / media.c
index 386026c..51d53d3 100644 (file)
@@ -21,6 +21,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
 #include "lisp.h"
+#include <ent/ent.h>
 
 #include "buffer.h"
 
@@ -49,13 +50,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 #endif
 
 Lisp_Object Qmedia_streamp;
-Lisp_Object Qunknown;
 Lisp_Object Qunavailable;
 /* media property syms */
 Lisp_Object Qdemux, Qcodec, Qnchannels, Qsamplerate;
 Lisp_Object Qbitrate, Qabitrate, Qvbitrate;
-Lisp_Object Qwidth, Qheight, Qaspect, Qdriver, Qkind, Qfifo, Quri, Qtype;
-Lisp_Object Qaudio, Qvideo, Qimage;
+Lisp_Object Qaspect, Qdriver, Qkind, Qfifo, Quri;
+Lisp_Object Qaudio, Qvideo;
 
 static void determine_stream_type(Lisp_Media_Stream *ms, media_driver);
 static void media_stream_print(Lisp_Object, Lisp_Object, int);
@@ -138,7 +138,7 @@ static void determine_stream_type(Lisp_Media_Stream *ms, media_driver preferred)
 
 \f
 /*****************************************************************/
-/*                         media streams                        */
+/*                         media streams                        */
 /*****************************************************************/
 static Lisp_Object media_stream_mark(Lisp_Object obj)
 {
@@ -352,12 +352,12 @@ media_stream_hash (Lisp_Object obj, int depth)
 }
 
 static const struct lrecord_description media_stream_description[] = {
-        { XD_LISP_OBJECT, offsetof(Lisp_Media_Stream, first) },
-        { XD_LISP_OBJECT, offsetof(Lisp_Media_Stream, last) },
+       { XD_LISP_OBJECT, offsetof(Lisp_Media_Stream, first) },
+       { XD_LISP_OBJECT, offsetof(Lisp_Media_Stream, last) },
        { XD_INT, offsetof(Lisp_Media_Stream, kind) },
        { XD_INT, offsetof(Lisp_Media_Stream, driver) },
-        { XD_OPAQUE_PTR, offsetof(Lisp_Media_Stream, kind_properties) },
-        { XD_OPAQUE_PTR, offsetof(Lisp_Media_Stream, stream_data) },
+       { XD_OPAQUE_PTR, offsetof(Lisp_Media_Stream, kind_properties) },
+       { XD_OPAQUE_PTR, offsetof(Lisp_Media_Stream, stream_data) },
        { XD_END }
 };
 
@@ -370,7 +370,7 @@ DEFINE_LRECORD_IMPLEMENTATION("media_stream", media_stream,
 
 \f
 /*****************************************************************/
-/*                         media substreams                     */
+/*                         media substreams                     */
 /*****************************************************************/
 
 static void
@@ -440,7 +440,7 @@ media_substream_print_audio(media_substream *mss, Lisp_Object printcharfun)
                break;
        }
 
-       if (mtap->samplerate) 
+       if (mtap->samplerate)
                write_fmt_str(printcharfun, ", %d Hz, %d Bit",
                              mtap->samplerate,
                              mtap->samplewidth);
@@ -804,7 +804,7 @@ Return a list of input formats in the underlying media libraries.
        temp = media_ffmpeg_available_formats();
 #endif
        formats = recons(formats, temp);
-       
+
 #ifdef HAVE_SNDFILE
        temp = Qnil;
 #endif
@@ -1079,7 +1079,7 @@ the second element to the second one and so on.
             (mss = media_substream_next(mss))) {
                mtype_video_properties *mtvp;
                long int num = 0, den = 0;
-               Lisp_Object tmp;
+               Lisp_Object tmp = Qnil;
 
                if (LIKELY(media_substream_type(mss) != MTYPE_VIDEO)) {
                        continue;
@@ -1101,10 +1101,12 @@ the second element to the second one and so on.
                        num = mtvp->width;
                        den = mtvp->height;
                }
-                       
+
                if (LIKELY(NILP(quotientp))) {
-                       tmp = make_float((fpfloat)num / (fpfloat)den);
-               } 
+                       assert(den != 0);
+                       if( den != 0)
+                               tmp = make_float((fpfloat)num / (fpfloat)den);
+               }
 #if defined HAVE_MPQ && defined WITH_GMP
                else {
                        tmp = make_bigq(num, den);
@@ -1297,6 +1299,47 @@ sxe_msf_FLT_down(void *d, void *s, size_t len)
        return;
 }
 
+DEFINE_MEDIA_SAMPLE_FORMAT_SIMPLE(sxe_msf_DBL);
+
+static void
+sxe_msf_DBL_up(void *d, void *s, size_t len)
+{
+       /* convert double samples to internal format (S24in32) */
+       size_t i;
+       int32_t *dst = d;
+       double *src = s;
+
+       /* len is the number of samples (== #frame * #channels) */
+       MEDIA_DEBUG_FMT("upsampling DBL->internal: %u samples\n", len);
+
+       for (i = 0; i < len; i++) {
+               dst[i] = (int32_t)(src[i] * SXE_MAX_S24);
+       }
+       MEDIA_DEBUG_FMT("s00:%f d00:%d  s01:%f d01:%d\n",
+                       src[0], dst[0], src[1], dst[1]);
+
+       return;
+}
+
+static void
+sxe_msf_DBL_down(void *d, void *s, size_t len)
+{
+       /* convert samples from internal format (S24in32) to double */
+       int i;
+       float *dst = d;
+       int32_t *src = s;
+
+       /* len is the number of samples (== #frame * #channels) */
+       MEDIA_DEBUG_FMT("downsampling internal->DBL: %u samples\n", len);
+
+       for (i = len-1; i >= 0; i--) {
+               dst[i] = (double)(src[i]) / SXE_MAX_S24;
+       }
+       MEDIA_DEBUG_FMT("d00:%f  d01:%f\n", dst[0], dst[1]);
+
+       return;
+}
+
 /* `effects' */
 DEFINE_MEDIA_SAMPLE_EFFECT(sxe_mse_1ch_to_2ch, _sxe_mse_1ch_to_2ch);