#include <config.h>
#include "lisp.h"
+#include <ent/ent.h>
#include "buffer.h"
#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);
\f
/*****************************************************************/
-/* media streams */
+/* media streams */
/*****************************************************************/
static Lisp_Object media_stream_mark(Lisp_Object obj)
{
Lisp_Media_Stream *ms = (Lisp_Media_Stream*)header;
media_substream *mss = NULL;
+ if(ms == NULL)
+ return;
if (media_stream_meths(ms) &&
media_stream_meth(ms, close))
media_stream_meth(ms, close)(media_stream_data(ms));
}
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 }
};
\f
/*****************************************************************/
-/* media substreams */
+/* media substreams */
/*****************************************************************/
static void
write_c_string("#<audio ", printcharfun);
if (mtap->name || mtap->codec_name) {
- char *buf = alloca(64);
if (mtap->name && mtap->codec_name)
- snprintf(buf, 63, "%s (%s)",
- mtap->name, mtap->codec_name);
+ write_fmt_str(printcharfun, "%s (%s)",
+ mtap->name, mtap->codec_name);
else if (mtap->name)
- snprintf(buf, 63, "%s [???]", mtap->name);
+ write_fmt_str(printcharfun, "%s [???]", mtap->name);
else if (mtap->codec_name)
- snprintf(buf, 63, "??? (%s)", mtap->codec_name);
-
- write_c_string(buf, printcharfun);
+ write_fmt_str(printcharfun, "??? (%s)", mtap->codec_name);
} else
write_c_string("???", printcharfun);
break;
}
- if (mtap->samplerate) {
- char *buf;
- buf = alloca(48);
- snprintf(buf, 47, ", %d Hz, %d Bit",
- mtap->samplerate,
- mtap->samplewidth);
- write_c_string(buf, printcharfun);
- }
+ if (mtap->samplerate)
+ write_fmt_str(printcharfun, ", %d Hz, %d Bit",
+ mtap->samplerate,
+ mtap->samplewidth);
- if (mtap->bitrate) {
- char *buf;
- buf = alloca(24);
- snprintf(buf, 23, ", %d kb/s", mtap->bitrate/1000);
- write_c_string(buf, printcharfun);
- }
+ if (mtap->bitrate)
+ write_fmt_str(printcharfun, ", %d kb/s", mtap->bitrate/1000);
write_c_string(">", printcharfun);
}
write_c_string("#<video ", printcharfun);
if (mtvp->name || mtvp->codec_name) {
- char *buf = alloca(64);
if (mtvp->name && mtvp->codec_name)
- snprintf(buf, 63, "%s (%s)",
- mtvp->name, mtvp->codec_name);
+ write_fmt_str(printcharfun, "%s (%s)",
+ mtvp->name, mtvp->codec_name);
else if (mtvp->name)
- snprintf(buf, 63, "%s [???]", mtvp->name);
+ write_fmt_str(printcharfun, "%s [???]", mtvp->name);
else if (mtvp->codec_name)
- snprintf(buf, 63, "??? (%s)", mtvp->codec_name);
-
- write_c_string(buf, printcharfun);
+ write_fmt_str(printcharfun, "??? (%s)", mtvp->codec_name);
} else
write_c_string("???", printcharfun);
- if (mtvp->bitrate) {
- char *buf = alloca(24);
- snprintf(buf, 23, ", %d kb/s", mtvp->bitrate);
- write_c_string(buf, printcharfun);
- }
+ if (mtvp->bitrate)
+ write_fmt_str(printcharfun, ", %d kb/s", mtvp->bitrate);
if (mtvp->width && mtvp->height) {
- char *buf = alloca(48);
if (mtvp->aspect_num > 1 && mtvp->aspect_den >= 1)
- snprintf(buf, 47, ", %dx%d (%d/%d)",
- mtvp->width, mtvp->height,
- mtvp->aspect_num, mtvp->aspect_den);
+ write_fmt_str(printcharfun, ", %dx%d (%d/%d)",
+ mtvp->width, mtvp->height,
+ mtvp->aspect_num, mtvp->aspect_den);
else
- snprintf(buf, 47, ", %dx%d (%.2f/1)",
- mtvp->width, mtvp->height,
- (double)mtvp->width/(double)mtvp->height);
- write_c_string(buf, printcharfun);
+ write_fmt_str(printcharfun, ", %dx%d (%.2f/1)",
+ mtvp->width, mtvp->height,
+ (double)mtvp->width/(double)mtvp->height);
}
write_c_string(">", printcharfun);
}
}
case DATA_IS_DATA: {
mkind_string_properties *sprops;
- char *data_ext;
+ char *data_ext = NULL;
int data_len = 0;
- media_stream_kind(ms) = MKIND_STRING;
-
- /* initialise a new file properties structure */
- sprops = xnew_and_zero(mkind_string_properties);
-
/* copy the filename also as C string */
TO_EXTERNAL_FORMAT(LISP_STRING, data,
MALLOC, (data_ext, data_len),
Qbinary);
- data_ext[data_len] = '\0';
- sprops->name = NULL;
- sprops->stream_data = data_ext;
- sprops->size = data_len;
- /* assign the file properties */
- media_stream_kind_properties(ms).sprops = sprops;
+ if (data_ext != NULL) {
+ media_stream_kind(ms) = MKIND_STRING;
- determine_stream_type(ms, pref);
+ /* initialise a new file properties structure */
+ sprops = xnew_and_zero(mkind_string_properties);
+
+ data_ext[data_len] = '\0';
+ sprops->name = NULL;
+ sprops->stream_data = data_ext;
+ sprops->size = data_len;
+
+ /* assign the file properties */
+ media_stream_kind_properties(ms).sprops = sprops;
+
+ determine_stream_type(ms, pref);
+ }
break;
}
case DATA_IS_URL: {
temp = media_ffmpeg_available_formats();
#endif
formats = recons(formats, temp);
-
+
#ifdef HAVE_SNDFILE
temp = Qnil;
#endif
return formats;
}
-static inline void __attribute__((always_inline, artificial))
+static inline void __attribute__((always_inline))
__add_prop(Lisp_Object *reslist, Lisp_Object key, Lisp_Object val)
{
*reslist = Fcons(Fcons(key, val), *reslist);
break;
}
+ __add_prop(&resdl, Qdriver, Qunavailable);
switch (media_stream_driver(ms)) {
case MDRIVER_INTERNAL:
__add_prop(&resdl, Qdriver, Qinternal);
#endif
break;
+ case MDRIVER_XINE:
+ break;
+
+ case MDRIVER_GSTREAMER:
+ break;
+
case MDRIVER_UNKNOWN:
case NUMBER_OF_MEDIA_DRIVERS:
default:
(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;
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);
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);
defsymbol(&Qsndfile, "sndfile");
#endif
defsymbol(&Qunknown, "unknown");
+ defsymbol(&Qunavailable, "unavailable");
}
void vars_of_media(void)