...
 
Commits (4)
common @ cd5507ae
Subproject commit 2c2bce01ed5ed1d1684bd76a334477398009ef4a Subproject commit cd5507ae3df8dc48c07df9e37878846b6b79faa1
...@@ -69,7 +69,6 @@ GST_PLUGIN_DEFINE ( ...@@ -69,7 +69,6 @@ GST_PLUGIN_DEFINE (
plugin_init, plugin_init,
FFMPEG_VERSION, FFMPEG_VERSION,
"LGPL", "LGPL",
"(c) 2003 The FFMPEG team",
"FFMpeg", "FFMpeg",
"http://ffmpeg.sourceforge.net/" "http://ffmpeg.sourceforge.net/"
) )
...@@ -36,39 +36,33 @@ ...@@ -36,39 +36,33 @@
* See below for why we use this. * See below for why we use this.
*/ */
#define GST_FF_VID_CAPS_NEW(name, mimetype, props...) \ #define GST_FF_VID_CAPS_NEW(mimetype, props...) \
(context != NULL) ? \ (context != NULL) ? \
GST_CAPS_NEW (name, \ gst_caps_new_simple (mimetype, \
mimetype, \ "width", G_TYPE_INT, context->width, \
"width", GST_PROPS_INT (context->width), \ "height", G_TYPE_INT, context->height, \
"height", GST_PROPS_INT (context->height),\ "framerate", G_TYPE_DOUBLE, 1. * context->frame_rate / \
"framerate", GST_PROPS_FLOAT ( \ context->frame_rate_base, \
1.*context->frame_rate/ \ ##props, NULL) \
context->frame_rate_base) , \ : \
##props) \ gst_caps_new_simple (mimetype, \
: \ "width", GST_TYPE_INT_RANGE, 16, 4096, \
GST_CAPS_NEW (name, \ "height", GST_TYPE_INT_RANGE, 16, 4096, \
mimetype, \ "framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE, \
"width", GST_PROPS_INT_RANGE (16, 4096), \ ##props, NULL)
"height", GST_PROPS_INT_RANGE (16, 4096), \
"framerate", GST_PROPS_FLOAT_RANGE (0, \
G_MAXFLOAT) , \
##props)
/* same for audio - now with channels/sample rate /* same for audio - now with channels/sample rate
*/ */
#define GST_FF_AUD_CAPS_NEW(name, mimetype, props...) \ #define GST_FF_AUD_CAPS_NEW(mimetype, props...) \
(context != NULL) ? \ (context != NULL) ? \
GST_CAPS_NEW (name, \ gst_caps_new_simple (mimetype, \
mimetype, \ "rate", G_TYPE_INT, context->sample_rate, \
"rate", GST_PROPS_INT (context->sample_rate), \ "channels", G_TYPE_INT, context->channels, \
"channels", GST_PROPS_INT (context->channels) , \ ##props, NULL) \
##props) \ : \
: \ gst_caps_new_simple (mimetype, \
GST_CAPS_NEW (name, \ ##props, NULL)
mimetype, \
##props)
/* Convert a FFMPEG codec ID and optional AVCodecContext /* Convert a FFMPEG codec ID and optional AVCodecContext
* to a GstCaps. If the context is ommitted, no fixed values * to a GstCaps. If the context is ommitted, no fixed values
...@@ -86,88 +80,66 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -86,88 +80,66 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
switch (codec_id) { switch (codec_id) {
case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG1VIDEO:
/* this caps doesn't need width/height/framerate */ /* this caps doesn't need width/height/framerate */
caps = GST_CAPS_NEW ("ffmpeg_mpeg1video", caps = gst_caps_new_simple ("video/mpeg",
"video/mpeg", "mpegversion", G_TYPE_INT, 1,
"mpegversion", GST_PROPS_INT (1), "systemstream", G_TYPE_BOOLEAN, FALSE,
"systemstream", GST_PROPS_BOOLEAN (FALSE) NULL);
);
break; break;
case CODEC_ID_H263P: case CODEC_ID_H263P:
case CODEC_ID_H263I: case CODEC_ID_H263I:
case CODEC_ID_H263: case CODEC_ID_H263:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_h263", caps = GST_FF_VID_CAPS_NEW ("video/x-h263");
"video/x-h263"
);
break; break;
case CODEC_ID_RV10: case CODEC_ID_RV10:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_rv10", caps = GST_FF_VID_CAPS_NEW ("video/x-pn-realvideo",
"video/x-pn-realvideo", "systemstream", G_TYPE_BOOLEAN, FALSE,
"systemstream", GST_PROPS_BOOLEAN (FALSE) NULL);
);
break; break;
case CODEC_ID_MP2: case CODEC_ID_MP2:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mp2", caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
"audio/mpeg", "layer", G_TYPE_INT, 2,
"layer", GST_PROPS_INT (2) NULL);
);
break; break;
case CODEC_ID_MP3LAME: case CODEC_ID_MP3LAME:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mp3", caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
"audio/mpeg", "layer", G_TYPE_INT, 3,
"layer", GST_PROPS_INT (3) NULL);
);
break; break;
case CODEC_ID_VORBIS: /* FIXME? vorbis or ogg? */ /* FIXME: This could become problematic when we fully switched to seperation
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_vorbis", of ogg and vorbis, because ffmpeg does ass ume ogg == ogg/vorbis
"application/ogg", Maybe we want to disable this? */
NULL case CODEC_ID_VORBIS:
); caps = GST_FF_AUD_CAPS_NEW ("application/ogg");
break; break;
case CODEC_ID_AC3: case CODEC_ID_AC3:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_ac3", caps = GST_FF_AUD_CAPS_NEW ("audio/x-ac3");
"audio/x-ac3",
NULL
);
break; break;
case CODEC_ID_MJPEG: case CODEC_ID_MJPEG:
case CODEC_ID_MJPEGB: case CODEC_ID_MJPEGB:
/*case CODEC_ID_LJPEG:*/ /*case CODEC_ID_LJPEG:*/
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_mjpeg", caps = GST_FF_VID_CAPS_NEW ("video/x-jpeg");
"video/x-jpeg"
);
break; break;
case CODEC_ID_MPEG4: case CODEC_ID_MPEG4:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_mpeg4", caps = GST_FF_VID_CAPS_NEW ("video/mpeg",
"video/mpeg", "mpegversion", G_TYPE_INT, 4,
"mpegversion", GST_PROPS_INT (4), "systemstream", G_TYPE_BOOLEAN, FALSE,
"systemstream", GST_PROPS_BOOLEAN (FALSE) NULL);
); gst_caps_append(caps,
caps = gst_caps_append(caps, GST_FF_VID_CAPS_NEW ("video/x-divx",
GST_FF_VID_CAPS_NEW ("ffmpeg_divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
"video/x-divx", NULL));
"divxversion", GST_PROPS_INT (5) gst_caps_append(caps,
)); GST_FF_VID_CAPS_NEW ("video/x-xvid"));
caps = gst_caps_append(caps, gst_caps_append(caps,
GST_FF_VID_CAPS_NEW ("ffmpeg_divx", GST_FF_VID_CAPS_NEW ("video/x-3ivx"));
"video/x-divx",
"divxversion", GST_PROPS_INT (4)
));
caps = gst_caps_append(caps,
GST_FF_VID_CAPS_NEW ("ffmpeg_xvid",
"video/x-xvid"
));
caps = gst_caps_append(caps,
GST_FF_VID_CAPS_NEW ("ffmpeg_3ivx",
"video/x-3ivx"
));
break; break;
/* weird quasi-codecs for the demuxers only */ /* weird quasi-codecs for the demuxers only */
...@@ -176,112 +148,93 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -176,112 +148,93 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
return gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, context); return gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, context);
case CODEC_ID_MSMPEG4V1: case CODEC_ID_MSMPEG4V1:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v1", caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
"video/x-msmpeg", "msmpegversion", G_TYPE_INT, 41,
"msmpegversion", GST_PROPS_INT (41) NULL);
);
break; break;
case CODEC_ID_MSMPEG4V2: case CODEC_ID_MSMPEG4V2:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v2", caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
"video/x-msmpeg", "msmpegversion", G_TYPE_INT, 42,
"msmpegversion", GST_PROPS_INT (42) NULL);
);
break; break;
case CODEC_ID_MSMPEG4V3: case CODEC_ID_MSMPEG4V3:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v3", caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
"video/x-msmpeg", "msmpegversion", G_TYPE_INT, 43,
"msmpegversion", GST_PROPS_INT (43) NULL);
); gst_caps_append(caps,
caps = gst_caps_append(caps, GST_FF_VID_CAPS_NEW ("video/x-divx",
GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v3_divx3", "divxversion", G_TYPE_INT, 3,
"video/x-divx", NULL));
"divxversion", GST_PROPS_INT (3)
));
break; break;
case CODEC_ID_WMV1: case CODEC_ID_WMV1:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_wmv1", caps = GST_FF_VID_CAPS_NEW ("video/x-wmv",
"video/x-wmv", "wmvversion", G_TYPE_INT, 1,
"wmvversion", GST_PROPS_INT (1) NULL);
);
break; break;
case CODEC_ID_WMV2: case CODEC_ID_WMV2:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_wmv2", caps = GST_FF_VID_CAPS_NEW ("video/x-wmv",
"video/x-wmv", "wmvversion", G_TYPE_INT, 2,
"wmvversion", GST_PROPS_INT (2) NULL);
);
break; break;
case CODEC_ID_SVQ1: case CODEC_ID_SVQ1:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_svq1", caps = GST_FF_VID_CAPS_NEW ("video/x-svq",
"video/x-svq", "svqversion", G_TYPE_INT, 1,
"svqversion", GST_PROPS_INT (1) NULL);
);
break; break;
case CODEC_ID_SVQ3: case CODEC_ID_SVQ3:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_svq3", caps = GST_FF_VID_CAPS_NEW ("video/x-svq",
"video/x-svq", "svqversion", G_TYPE_INT, 1,
"svqversion", GST_PROPS_INT (3) NULL);
);
break; break;
case CODEC_ID_DVAUDIO: case CODEC_ID_DVAUDIO:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_dvaudio", caps = GST_FF_AUD_CAPS_NEW ("audio/x-dv");
"audio/x-dv",
NULL
);
break; break;
case CODEC_ID_DVVIDEO: case CODEC_ID_DVVIDEO:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_dvvideo", caps = GST_FF_VID_CAPS_NEW ("video/dv");
"video/dv"
);
break; break;
case CODEC_ID_WMAV1: case CODEC_ID_WMAV1:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_wma1", caps = GST_FF_AUD_CAPS_NEW ("audio/x-wma",
"audio/x-wma", "wmaversion", G_TYPE_INT, 1,
"wmaversion", GST_PROPS_INT (1), "flags1", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
"flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT), "flags2", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
"flags2", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT), "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
"block_align", GST_PROPS_INT_RANGE (0, G_MAXINT), "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT,
"bitrate", GST_PROPS_INT_RANGE (0, G_MAXINT) NULL);
);
break; break;
case CODEC_ID_WMAV2: case CODEC_ID_WMAV2:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_wma2", caps = GST_FF_AUD_CAPS_NEW ("audio/x-wma",
"audio/x-wma", "wmaversion", G_TYPE_INT, 2,
"wmaversion", GST_PROPS_INT (2), "flags1", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
"flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT), "flags2", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
"flags2", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT), "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
"block_align", GST_PROPS_INT_RANGE (0, G_MAXINT), "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT,
"bitrate", GST_PROPS_INT_RANGE (0, G_MAXINT) NULL);
);
break; break;
case CODEC_ID_MACE3: case CODEC_ID_MACE3:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mace3", caps = GST_FF_AUD_CAPS_NEW ("audio/x-mace",
"audio/x-mace", "maceversion", G_TYPE_INT, 3,
"maceversion", GST_PROPS_INT (3) NULL);
);
break; break;
case CODEC_ID_MACE6: case CODEC_ID_MACE6:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mace6", caps = GST_FF_AUD_CAPS_NEW ("audio/x-mace",
"audio/x-mace", "maceversion", G_TYPE_INT, 6,
"maceversion", GST_PROPS_INT (6) NULL);
);
break; break;
case CODEC_ID_HUFFYUV: case CODEC_ID_HUFFYUV:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_huffyuv", caps = GST_FF_VID_CAPS_NEW ("video/x-huffyuv");
"video/x-huffyuv"
);
break; break;
case CODEC_ID_CYUV: case CODEC_ID_CYUV:
...@@ -289,42 +242,33 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -289,42 +242,33 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break; break;
case CODEC_ID_H264: case CODEC_ID_H264:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_h264", caps = GST_FF_VID_CAPS_NEW ("video/x-h264");
"video/x-h264"
);
break; break;
case CODEC_ID_INDEO3: case CODEC_ID_INDEO3:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_indeo3", caps = GST_FF_VID_CAPS_NEW ("video/x-indeo",
"video/x-indeo", "indeoversion", G_TYPE_INT, 3,
"indeoversion", GST_PROPS_INT (3) NULL);
);
break; break;
case CODEC_ID_VP3: case CODEC_ID_VP3:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_vp3", caps = GST_FF_VID_CAPS_NEW ("video/x-vp3");
"video/x-vp3" gst_caps_append(caps,
); GST_FF_VID_CAPS_NEW ("video/x-theora"));
caps = gst_caps_append(caps,
GST_FF_VID_CAPS_NEW ("ffmpeg_theora",
"video/x-theora"
));
break; break;
case CODEC_ID_AAC: case CODEC_ID_AAC:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mpeg2aac", caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
"audio/mpeg", "systemstream", G_TYPE_BOOLEAN, FALSE,
"systemstream", GST_PROPS_BOOLEAN (FALSE), "mpegversion", G_TYPE_INT, 2,
"mpegversion", GST_PROPS_INT (2) NULL);
);
break; break;
case CODEC_ID_MPEG4AAC: case CODEC_ID_MPEG4AAC:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mpeg4aac", caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
"audio/mpeg", "systemstream", G_TYPE_BOOLEAN, FALSE,
"systemstream", GST_PROPS_BOOLEAN (FALSE), "mpegversion", G_TYPE_INT, 4,
"mpegversion", GST_PROPS_INT (4) NULL);
);
break; break;
case CODEC_ID_ASV1: case CODEC_ID_ASV1:
...@@ -332,16 +276,13 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -332,16 +276,13 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break; break;
case CODEC_ID_FFV1: case CODEC_ID_FFV1:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_ffv1", caps = GST_FF_VID_CAPS_NEW ("video/x-ffv",
"video/x-ffv", "ffvversion", G_TYPE_INT, 1,
"ffvversion", GST_PROPS_INT (1) NULL);
);
break; break;
case CODEC_ID_4XM: case CODEC_ID_4XM:
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_4xmvideo", caps = GST_FF_VID_CAPS_NEW ("video/x-4xm");
"video/x-4xm"
);
break; break;
/* weird quasi-codecs for the demuxers only */ /* weird quasi-codecs for the demuxers only */
...@@ -391,55 +332,45 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -391,55 +332,45 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break; break;
} }
caps = GST_FF_AUD_CAPS_NEW ( caps = GST_FF_AUD_CAPS_NEW ("audio/x-raw-int",
"ffmpeg_pcmaudio", "width", G_TYPE_INT, width,
"audio/x-raw-int", "depth", G_TYPE_INT, depth,
"width", GST_PROPS_INT (width), "endianness", G_TYPE_INT, endianness,
"depth", GST_PROPS_INT (depth), "signed", G_TYPE_BOOLEAN, signedness,
"endianness", GST_PROPS_INT (endianness), NULL);
"signed", GST_PROPS_BOOLEAN (signedness)
);
} while (0); } while (0);
break; break;
case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_MULAW:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mulawaudio", caps = GST_FF_AUD_CAPS_NEW ("audio/x-mulaw");
"audio/x-mulaw",
NULL);
break; break;
case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_ALAW:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_alawaudio", caps = GST_FF_AUD_CAPS_NEW ("audio/x-alaw");
"audio/x-alaw",
NULL);
break; break;
case CODEC_ID_ADPCM_IMA_QT: case CODEC_ID_ADPCM_IMA_QT:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_ima_qt", caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
"audio/x-adpcm", "layout", G_TYPE_STRING, "quicktime",
"layout", GST_PROPS_STRING ("quicktime") NULL);
);
break; break;
case CODEC_ID_ADPCM_IMA_WAV: case CODEC_ID_ADPCM_IMA_WAV:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_ima_wav", caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
"audio/x-adpcm", "layout", G_TYPE_STRING, "wav",
"layout", GST_PROPS_STRING ("wav") NULL);
);
break; break;
case CODEC_ID_ADPCM_MS: case CODEC_ID_ADPCM_MS:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_ms", caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
"audio/x-adpcm", "layout", G_TYPE_STRING, "microsoft",
"layout", GST_PROPS_STRING ("microsoft") NULL);
);
break; break;
case CODEC_ID_ADPCM_4XM: case CODEC_ID_ADPCM_4XM:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_4xm", caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
"audio/x-adpcm", "layout", G_TYPE_STRING, "4xm",
"layout", GST_PROPS_STRING ("4xm") NULL);
);
break; break;
case CODEC_ID_AMR_NB: case CODEC_ID_AMR_NB:
...@@ -447,17 +378,15 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -447,17 +378,15 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break; break;
case CODEC_ID_RA_144: case CODEC_ID_RA_144:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_realaudio_144", caps = GST_FF_AUD_CAPS_NEW ("audio/x-pn-realaudio",
"audio/x-pn-realaudio", "bitrate", G_TYPE_INT, 14400,
"bitrate", GST_PROPS_INT (14400) NULL);
);
break; break;
case CODEC_ID_RA_288: case CODEC_ID_RA_288:
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_realaudio_288", caps = GST_FF_AUD_CAPS_NEW ("audio/x-pn-realaudio",
"audio/x-pn-realaudio", "bitrate", G_TYPE_INT, 28800,
"bitrate", GST_PROPS_INT (28800) NULL);
);
break; break;
default: default:
...@@ -466,15 +395,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, ...@@ -466,15 +395,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
} }
if (caps != NULL) { if (caps != NULL) {
char *str = g_strdup_printf("The caps that belongs to codec_id=%d", char *str = gst_caps_to_string (caps);
codec_id); GST_DEBUG ("caps for codec_id=%d: %s", codec_id, str);
gst_caps_debug(caps, str);
g_free(str); g_free(str);
} else { } else {
char *str = g_strdup_printf("No caps found for codec_id=%d", GST_WARNING ("No caps found for codec_id=%d", codec_id);
codec_id);
gst_caps_debug(caps, str);
g_free(str);
} }
return caps; return caps;
...@@ -521,7 +446,7 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, ...@@ -521,7 +446,7 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt,
/* .. */ /* .. */
break; break;
case PIX_FMT_RGBA32: case PIX_FMT_RGBA32:
bpp = depth = 32; bpp = 32; depth = 24;
endianness = G_BIG_ENDIAN; endianness = G_BIG_ENDIAN;
#if (G_BYTE_ORDER == G_BIG_ENDIAN) #if (G_BYTE_ORDER == G_BIG_ENDIAN)
r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff; r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff;
...@@ -551,32 +476,26 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, ...@@ -551,32 +476,26 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt,
} }
if (bpp != 0) { if (bpp != 0) {
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_rawvideo", caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
"video/x-raw-rgb", "bpp", G_TYPE_INT, bpp,
"bpp", GST_PROPS_INT (bpp), "depth", G_TYPE_INT, depth,
"depth", GST_PROPS_INT (depth), "red_mask", G_TYPE_INT, r_mask,
"red_mask", GST_PROPS_INT (r_mask), "green_mask", G_TYPE_INT, g_mask,
"green_mask", GST_PROPS_INT (g_mask), "blue_mask", G_TYPE_INT, b_mask,
"blue_mask", GST_PROPS_INT (b_mask), "endianness", G_TYPE_INT, endianness,
"endianness", GST_PROPS_INT (endianness) NULL);
);
} else if (fmt) { } else if (fmt) {
caps = GST_FF_VID_CAPS_NEW ("ffmpeg_rawvideo", caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv",
"video/x-raw-yuv", "format", GST_TYPE_FOURCC, fmt,
"format", GST_PROPS_FOURCC (fmt) NULL);
);
} }
if (caps != NULL) { if (caps != NULL) {
char *str = g_strdup_printf("The caps that belongs to pix_fmt=%d", char *str = gst_caps_to_string (caps);
pix_fmt); GST_DEBUG ("caps for pix_fmt=%d: %s", pix_fmt, str);
gst_caps_debug(caps, str);
g_free(str); g_free(str);
} else { } else {
char *str = g_strdup_printf("No caps found for pix_fmt=%d", GST_WARNING ("No caps found for pix_fmt=%d", pix_fmt);
pix_fmt);
gst_caps_debug(caps, str);
g_free(str);
} }
return caps; return caps;
...@@ -610,25 +529,20 @@ gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt, ...@@ -610,25 +529,20 @@ gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
} }
if (bpp) { if (bpp) {
caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_rawaudio", caps = GST_FF_AUD_CAPS_NEW ("audio/x-raw-int",
"audio/x-raw-int", "signed", G_TYPE_BOOLEAN, signedness,
"signed", GST_PROPS_BOOLEAN (signedness), "endianness", G_TYPE_INT, G_BYTE_ORDER,
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "width", G_TYPE_INT, bpp,
"width", GST_PROPS_INT (bpp), "depth", G_TYPE_INT, bpp,
"depth", GST_PROPS_INT (bpp) NULL);
);
} }
if (caps != NULL) { if (caps != NULL) {
char *str = g_strdup_printf("The caps that belongs to sample_fmt=%d", char *str = gst_caps_to_string (caps);
sample_fmt); GST_DEBUG ("caps for sample_fmt=%d: %s", sample_fmt, str);
gst_caps_debug(caps, str);
g_free(str); g_free(str);
} else { } else {
char *str = g_strdup_printf("No caps found for sample_fmt=%d", GST_WARNING ("No caps found for sample_fmt=%d", sample_fmt);
sample_fmt);
gst_caps_debug(caps, str);
g_free(str);
} }
return caps; return caps;
...@@ -645,7 +559,7 @@ GstCaps * ...@@ -645,7 +559,7 @@ GstCaps *
gst_ffmpeg_codectype_to_caps (enum CodecType codec_type, gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
AVCodecContext *context) AVCodecContext *context)
{ {
GstCaps *caps = NULL; GstCaps *caps;
switch (codec_type) { switch (codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
...@@ -655,10 +569,11 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type, ...@@ -655,10 +569,11 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
GstCaps *temp; GstCaps *temp;
enum PixelFormat i; enum PixelFormat i;
caps = gst_caps_new_empty ();
for (i = 0; i < PIX_FMT_NB; i++) { for (i = 0; i < PIX_FMT_NB; i++) {
temp = gst_ffmpeg_pixfmt_to_caps (i, NULL); temp = gst_ffmpeg_pixfmt_to_caps (i, NULL);
if (temp != NULL) { if (temp != NULL) {
caps = gst_caps_append (caps, temp); gst_caps_append (caps, temp);
} }
} }
} }
...@@ -671,10 +586,11 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type, ...@@ -671,10 +586,11 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
GstCaps *temp; GstCaps *temp;
enum SampleFormat i; enum SampleFormat i;
caps = gst_caps_new_empty ();
for (i = 0; i <= SAMPLE_FMT_S16; i++) { for (i = 0; i <= SAMPLE_FMT_S16; i++) {
temp = gst_ffmpeg_smpfmt_to_caps (i, NULL); temp = gst_ffmpeg_smpfmt_to_caps (i, NULL);
if (temp != NULL) { if (temp != NULL) {
caps = gst_caps_append (caps, temp); gst_caps_append (caps, temp);
} }
} }
} }
...@@ -682,6 +598,7 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type, ...@@ -682,6 +598,7 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
default: default:
/* .. */ /* .. */
caps = NULL;
break; break;
} }
...@@ -693,59 +610,54 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type, ...@@ -693,59 +610,54 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
* when needed. * when needed.
*/ */
static void static void
gst_ffmpeg_caps_to_extradata (GstCaps *caps, gst_ffmpeg_caps_to_extradata (const GstCaps *caps,
AVCodecContext *context) AVCodecContext *context)
{ {
GstStructure *structure;
const gchar *mimetype; const gchar *mimetype;
mimetype = gst_caps_get_mime(caps); g_return_if_fail (gst_caps_get_size (caps) == 1);
structure = gst_caps_get_structure (caps, 0);
mimetype = gst_structure_get_name (structure);
if (!strcmp(mimetype, "audio/x-wma")) { if (!strcmp(mimetype, "audio/x-wma")) {
gint flags1, flags2, wmaversion = 0;
if (!gst_caps_has_property (caps, "flags1")) { if (!gst_structure_get_int (structure, "flags1", &flags1) &&
g_warning ("Caps without flags1 property for %s", mimetype); !gst_structure_get_int (structure, "flags2", &flags2) &&
return; !gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
} g_warning ("invalid caps for audio/x-wma");
if (!gst_caps_has_property (caps, "flags2")) {
g_warning ("Caps without flags2 property for %s", mimetype);
return; return;
} }
if (gst_caps_has_property (caps, "wmaversion")) { /*
gint wmaversion = 0; * Rebuild context data from flags1 & flags2
gint value; * see wmadec in ffmpeg/libavcodec/wmadec.c
*/
/* gst_structure_get_int (structure, "wmaversion", &wmaversion);
* Rebuild context data from flags1 & flags2 switch (wmaversion) {
* see wmadec in ffmpeg/libavcodec/wmadec.c case 1:
*/ /* FIXME: is this freed with g_free? If not, don't use g_malloc */
gst_caps_get_int (caps, "wmaversion", &wmaversion); context->extradata = (guint8 *) g_malloc0 (4);
switch (wmaversion) { ((guint8 *)context->extradata)[0] = flags1;
case 1: ((guint8 *)context->extradata)[2] = flags2;
context->extradata = (guint8 *) g_malloc0 (4); context->extradata_size = 4;
gst_caps_get_int (caps, "flags1", &value); break;
((guint8 *)context->extradata)[0] = value; case 2:
gst_caps_get_int (caps, "flags2", &value); /* FIXME: is this freed with g_free? If not, don't use g_malloc */
((guint8 *)context->extradata)[2] = value; context->extradata = (guint8 *) g_malloc0 (6);
context->extradata_size = 4; ((guint8 *) context->extradata)[0] = flags1;
break; ((guint8 *) context->extradata)[1] = flags1 >> 8;
case 2: ((guint8 *) context->extradata)[2] = flags1 >> 16;
context->extradata = (guint8 *) g_malloc0 (6); ((guint8 *) context->extradata)[3] = flags1 >> 24;
gst_caps_get_int (caps, "flags1", &value); ((guint8 *) context->extradata)[4] = flags2;
((guint8 *) context->extradata)[0] = value; ((guint8 *) context->extradata)[5] = flags2 >> 8;
((guint8 *) context->extradata)[1] = value >> 8; context->extradata_size = 6;
((guint8 *) context->extradata)[2] = value >> 16; break;
((guint8 *) context->extradata)[3] = value >> 24; default:
gst_caps_get_int (caps, "flags2", &value); g_warning ("Unknown wma version %d\n", wmaversion);
((guint8 *) context->extradata)[4] = value; break;
((guint8 *) context->extradata)[5] = value >> 8;
context->extradata_size = 6;
break;
default:
g_warning ("Unknown wma version %d\n", wmaversion);
break;
}
} }
} }
} }
...@@ -758,50 +670,30 @@ gst_ffmpeg_caps_to_extradata (GstCaps *caps, ...@@ -758,50 +670,30 @@ gst_ffmpeg_caps_to_extradata (GstCaps *caps,
*/ */
static void static void
gst_ffmpeg_caps_to_smpfmt (GstCaps *caps, gst_ffmpeg_caps_to_smpfmt (const GstCaps *caps,
AVCodecContext *context) AVCodecContext *context)
{ {
if (gst_caps_has_property_typed (caps, "width", GstStructure *structure;
GST_PROPS_INT_TYPE) && gint depth = 0, width = 0, endianness = 0;
gst_caps_has_property_typed (caps, "depth", gboolean signedness = FALSE;
GST_PROPS_INT_TYPE) &&
gst_caps_has_property_typed (caps, "signed", g_return_if_fail (gst_caps_get_size (caps) == 1);
GST_PROPS_BOOLEAN_TYPE) && structure = gst_caps_get_structure (caps, 0);
gst_caps_has_property_typed (caps, "endianness",
GST_PROPS_INT_TYPE)) { if (gst_structure_get_int (structure, "width", &width) &&
gint depth = 0, width = 0, endianness = 0; gst_structure_get_int (structure, "depth", &depth) &&
gboolean signedness = FALSE; gst_structure_get_int (structure, "signed", &signedness) &&
gst_caps_get (caps, gst_structure_get_int (structure, "endianness", &endianness)) {
"width", &width,
"depth", &depth,
"endianness", &endianness,
"signed", &signedness,
NULL);
if (width == 16 && depth == 16 && if (width == 16 && depth == 16 &&
endianness == G_BYTE_ORDER && signedness == TRUE) { endianness == G_BYTE_ORDER && signedness == TRUE) {
context->sample_fmt = SAMPLE_FMT_S16; context->sample_fmt = SAMPLE_FMT_S16;
} }
} }
if (gst_caps_has_property_typed (caps, "channels", gst_structure_get_int (structure, "channels", &context->channels);
GST_PROPS_INT_TYPE)) { gst_structure_get_int (structure, "rate", &context->sample_rate);
gst_caps_get_int (caps, "channels", &context->channels); gst_structure_get_int (structure, "block_align", &context->block_align);
} gst_structure_get_int (structure, "bitrate", &context->bit_rate);
if (gst_caps_has_property_typed (caps, "rate",
GST_PROPS_INT_TYPE)) {
gst_caps_get_int (caps, "rate", &context->sample_rate);
}
if (gst_caps_has_property_typed (caps, "block_align",
GST_PROPS_INT_TYPE)) {
gst_caps_get_int (caps, "block_align", &context->block_align);
}
if (gst_caps_has_property_typed (caps, "bitrate",
GST_PROPS_INT_TYPE)) {
gst_caps_get_int (caps, "bitrate", &context->bit_rate);
}
gst_ffmpeg_caps_to_extradata (caps, context); gst_ffmpeg_caps_to_extradata (caps, context);
} }
...@@ -814,33 +706,27 @@ gst_ffmpeg_caps_to_smpfmt (GstCaps *caps, ...@@ -814,33 +706,27 @@ gst_ffmpeg_caps_to_smpfmt (GstCaps *caps,
*/ */
static void static void
gst_ffmpeg_caps_to_pixfmt (GstCaps *caps, gst_ffmpeg_caps_to_pixfmt (const GstCaps *caps,
AVCodecContext *context) AVCodecContext *context)
{ {
if (gst_caps_has_property_typed (caps, "width", GstStructure *structure;
GST_PROPS_INT_TYPE) && gdouble fps;
gst_caps_has_property_typed (caps, "height",
GST_PROPS_INT_TYPE)) { g_return_if_fail (gst_caps_get_size (caps) == 1);
gst_caps_get (caps, structure = gst_caps_get_structure (caps, 0);
"width", &context->width,
"height", &context->height, gst_structure_get_int (structure, "width", &context->width);
NULL); gst_structure_get_int (structure, "height", &context->height);
}
if (gst_caps_has_property_typed (caps, "framerate", if (gst_structure_get_double (structure, "framerate", &fps)) {
GST_PROPS_FLOAT_TYPE)) {
gfloat fps;
gst_caps_get_float (caps, "framerate", &fps);
context->frame_rate = fps * DEFAULT_FRAME_RATE_BASE; context->frame_rate = fps * DEFAULT_FRAME_RATE_BASE;
context->frame_rate_base = DEFAULT_FRAME_RATE_BASE; context->frame_rate_base = DEFAULT_FRAME_RATE_BASE;
} }
if (strcmp (gst_caps_get_mime (caps), "video/x-raw-yuv") == 0) { if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
if (gst_caps_has_property_typed (caps, "format", guint32 fourcc;
GST_PROPS_FOURCC_TYPE)) {
guint32 fourcc; if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
gst_caps_get_fourcc_int (caps, "format", &fourcc);
switch (fourcc) { switch (fourcc) {
case GST_MAKE_FOURCC ('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y','U','Y','2'):
context->pix_fmt = PIX_FMT_YUV422; context->pix_fmt = PIX_FMT_YUV422;
...@@ -864,21 +750,18 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps, ...@@ -864,21 +750,18 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
#endif #endif
} }
} }
} else if (strcmp (gst_caps_get_mime (caps), "video/x-raw-rgb") == 0) { } else if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb") == 0) {
if (gst_caps_has_property_typed (caps, "bpp", GST_PROPS_INT_TYPE) && gint bpp = 0, rmask = 0, endianness = 0;
gst_caps_has_property_typed (caps, "red_mask", GST_PROPS_INT_TYPE)) {
gint bpp = 0, rmask = 0, endianness = 0; if (gst_structure_get_int (structure, "bpp", &bpp) &&
gst_structure_get_int (structure, "endianness", &endianness) &&
gst_caps_get (caps, "bpp", &bpp, gst_structure_get_int (structure, "red_mask", &rmask)) {
"red_mask", &rmask,
"endianness", &endianness, NULL);
switch (bpp) { switch (bpp) {
case 32: case 32:
#if (G_BYTE_ORDER == G_BIG_ENDIAN) #if (G_BYTE_ORDER == G_BIG_ENDIAN)
if (rmask == 0xff0000) if (rmask == 0x00ff0000)
#else #else
if (rmask == 0x0000ff) if (rmask == 0x0000ff00)
#endif #endif
context->pix_fmt = PIX_FMT_RGBA32; context->pix_fmt = PIX_FMT_RGBA32;
break; break;
...@@ -913,7 +796,7 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps, ...@@ -913,7 +796,7 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
void void
gst_ffmpeg_caps_to_codectype (enum CodecType type, gst_ffmpeg_caps_to_codectype (enum CodecType type,
GstCaps *caps, const GstCaps *caps,
AVCodecContext *context) AVCodecContext *context)
{ {
if (context == NULL) if (context == NULL)
...@@ -950,60 +833,42 @@ gst_ffmpeg_formatid_to_caps (const gchar *format_name) ...@@ -950,60 +833,42 @@ gst_ffmpeg_formatid_to_caps (const gchar *format_name)
GstCaps *caps = NULL; GstCaps *caps = NULL;
if (!strcmp (format_name, "mpeg")) { if (!strcmp (format_name, "mpeg")) {
caps = GST_CAPS_NEW ("ffmpeg_mpeg", caps = gst_caps_new_simple ("video/mpeg",
"video/mpeg", "systemstream", G_TYPE_BOOLEAN, TRUE,
"systemstream", GST_PROPS_BOOLEAN (TRUE) NULL);
);
} else if (!strcmp (format_name, "mpegts")) { } else if (!strcmp (format_name, "mpegts")) {
caps = GST_CAPS_NEW ("ffmpeg_mpegts", caps = gst_caps_new_simple ("video/mpegts",
"video/mpegts", "systemstream", G_TYPE_BOOLEAN, TRUE,
"systemstream", GST_PROPS_BOOLEAN (TRUE) NULL);
);
} else if (!strcmp (format_name, "rm")) { } else if (!strcmp (format_name, "rm")) {
caps = GST_CAPS_NEW ("ffmpeg_rm", caps = gst_caps_new_simple ("ffmpeg_rm", "audio/x-pn-realvideo",
"audio/x-pn-realvideo", "systemstream", G_TYPE_BOOLEAN, TRUE,
"systemstream", GST_PROPS_BOOLEAN (TRUE) NULL);
);
} else if (!strcmp (format_name, "asf")) { } else if (!strcmp (format_name, "asf")) {
caps = GST_CAPS_NEW ("ffmpeg_asf", caps = gst_caps_new_simple ("video/x-ms-asf",
"video/x-ms-asf", NULL);
NULL
);
} else if (!strcmp (format_name, "avi")) { } else if (!strcmp (format_name, "avi")) {
caps = GST_CAPS_NEW ("ffmpeg_avi", caps = gst_caps_new_simple ("video/x-msvideo",
"video/x-msvideo", NULL);
NULL
);
} else if (!strcmp (format_name, "wav")) { } else if (!strcmp (format_name, "wav")) {
caps = GST_CAPS_NEW ("ffmpeg_wav", caps = gst_caps_new_simple ("video/x-wav",
"video/x-wav", NULL);
NULL
);
} else if (!strcmp (format_name, "swf")) { } else if (!strcmp (format_name, "swf")) {
caps = GST_CAPS_NEW ("ffmpeg_swf", caps = gst_caps_new_simple ("application/x-shockwave-flash",
"application/x-shockwave-flash", NULL);
NULL
);
} else if (!strcmp (format_name, "au")) { } else if (!strcmp (format_name, "au")) {
caps = GST_CAPS_NEW ("ffmpeg_au", caps = gst_caps_new_simple ("audio/x-au",
"audio/x-au", NULL);
NULL
);
} else if (!strcmp (format_name, "mov")) { } else if (!strcmp (format_name, "mov")) {
caps = GST_CAPS_NEW ("ffmpeg_quicktime", caps = gst_caps_new_simple ("video/quicktime",
"video/quicktime", NULL);
NULL
);
} else if (!strcmp (format_name, "dv")) { } else if (!strcmp (format_name, "dv")) {
caps = GST_CAPS_NEW ("ffmpeg_dv", caps = gst_caps_new_simple ("video/x-dv",
"video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE,
"systemstream", GST_PROPS_BOOLEAN (TRUE) NULL);
);
} else if (!strcmp (format_name, "4xm")) { } else if (!strcmp (format_name, "4xm")) {
caps = GST_CAPS_NEW ("ffmpeg_4xm", caps = gst_caps_new_simple ("video/x-4xm",
"video/x-4xm", NULL);
NULL
);
} else { } else {
/* unknown! */ /* unknown! */
} }
...@@ -1019,16 +884,19 @@ gst_ffmpeg_formatid_to_caps (const gchar *format_name) ...@@ -1019,16 +884,19 @@ gst_ffmpeg_formatid_to_caps (const gchar *format_name)
*/ */
enum CodecID enum CodecID
gst_ffmpeg_caps_to_codecid (GstCaps *caps, gst_ffmpeg_caps_to_codecid (const GstCaps *caps,
AVCodecContext *context) AVCodecContext *context)
{ {
enum CodecID id = CODEC_ID_NONE; enum CodecID id = CODEC_ID_NONE;
const gchar *mimetype; const gchar *mimetype;
const GstStructure *structure;
gboolean video = FALSE, audio = FALSE; /* we want to be sure! */ gboolean video = FALSE, audio = FALSE; /* we want to be sure! */
g_return_val_if_fail (caps != NULL, CODEC_ID_NONE); g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
mimetype = gst_caps_get_mime(caps); structure = gst_caps_get_structure (caps, 0);
mimetype = gst_structure_get_name (structure);
if (!strcmp (mimetype, "video/x-raw-rgb")) { if (!strcmp (mimetype, "video/x-raw-rgb")) {
...@@ -1038,9 +906,9 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1038,9 +906,9 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
gint bpp = 0, endianness = 0, rmask = 0; gint bpp = 0, endianness = 0, rmask = 0;
enum PixelFormat pix_fmt = -1; enum PixelFormat pix_fmt = -1;
gst_caps_get (caps, "bpp", &bpp, gst_structure_get_int (structure, "bpp", &bpp);
"endianness", &endianness, gst_structure_get_int (structure, "endianness", &endianness);
"rmask", &rmask, NULL); gst_structure_get_int (structure, "rmask", &rmask);
switch (bpp) { switch (bpp) {
case 15: case 15:
...@@ -1091,7 +959,7 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1091,7 +959,7 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
guint32 fmt_fcc = 0; guint32 fmt_fcc = 0;
enum PixelFormat pix_fmt = -1; enum PixelFormat pix_fmt = -1;
gst_caps_get_fourcc_int (caps, "format", &fmt_fcc); gst_structure_get_fourcc (structure, "format", &fmt_fcc);
switch (fmt_fcc) { switch (fmt_fcc) {
case GST_MAKE_FOURCC ('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y','U','Y','2'):
...@@ -1128,51 +996,49 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1128,51 +996,49 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
gint depth = 0, width = 0, endianness = 0; gint depth = 0, width = 0, endianness = 0;
gboolean signedness = FALSE; /* bla default value */ gboolean signedness = FALSE; /* bla default value */
if (gst_caps_has_property(caps, "signed")) { gst_structure_get_int (structure, "endianness", &endianness);
gst_caps_get_int(caps, "endianness", &endianness); gst_structure_get_boolean (structure, "signed", &signedness);
gst_caps_get_boolean(caps, "signed", &signedness); gst_structure_get_int (structure, "width", &width);
gst_caps_get_int(caps, "width", &width); gst_structure_get_int (structure, "depth", &depth);
gst_caps_get_int(caps, "depth", &depth);
if (context) { if (context) {
context->sample_rate = 0; context->sample_rate = 0;
context->channels = 0; context->channels = 0;
gst_caps_get_int(caps, "channels", &context->channels); gst_structure_get_int (structure, "channels", &context->channels);
gst_caps_get_int(caps, "rate", &context->sample_rate); gst_structure_get_int (structure, "rate", &context->sample_rate);
} }
if (depth == width) { if (depth == width) {
switch (depth) { switch (depth) {
case 8: case 8:
if (signedness) { if (signedness) {
id = CODEC_ID_PCM_S8; id = CODEC_ID_PCM_S8;
} else { } else {
id = CODEC_ID_PCM_U8; id = CODEC_ID_PCM_U8;
} }
break; break;
case 16: case 16:
switch (endianness) { switch (endianness) {
case G_BIG_ENDIAN: case G_BIG_ENDIAN:
if (signedness) { if (signedness) {
id = CODEC_ID_PCM_S16BE; id = CODEC_ID_PCM_S16BE;
} else { } else {
id = CODEC_ID_PCM_U16BE; id = CODEC_ID_PCM_U16BE;
} }
break; break;
case G_LITTLE_ENDIAN: case G_LITTLE_ENDIAN:
if (signedness) { if (signedness) {
id = CODEC_ID_PCM_S16LE; id = CODEC_ID_PCM_S16LE;
} else { } else {
id = CODEC_ID_PCM_U16LE; id = CODEC_ID_PCM_U16LE;
} }
break; break;
} }
break; break;
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
audio = TRUE; audio = TRUE;
}
} }
} }
...@@ -1205,11 +1071,9 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1205,11 +1071,9 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
gboolean sys_strm = TRUE; gboolean sys_strm = TRUE;
gint mpegversion = 0; gint mpegversion = 0;
if (gst_caps_has_property(caps, "systemstream")) { gst_structure_get_boolean (structure, "systemstream", &sys_strm);
gst_caps_get_boolean(caps, "systemstream", &sys_strm); gst_structure_get_int (structure, "mpegversion", &mpegversion);
} if (!sys_strm) {
if (!sys_strm && gst_caps_has_property(caps, "mpegversion")) {
gst_caps_get_int(caps, "mpegversion", &mpegversion);
switch (mpegversion) { switch (mpegversion) {
case 1: case 1:
id = CODEC_ID_MPEG1VIDEO; id = CODEC_ID_MPEG1VIDEO;
...@@ -1233,26 +1097,24 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1233,26 +1097,24 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE; video = TRUE;
} else if (!strcmp(mimetype, "video/x-wmv")) { } else if (!strcmp(mimetype, "video/x-wmv")) {
gint wmvversion = 0;
gst_structure_get_int (structure, "wmvversion", &wmvversion);
switch (wmvversion) {
case 1:
id = CODEC_ID_WMV1;
break;
case 2:
id = CODEC_ID_WMV2;
break;
default:
/* ... */
break;
}
if (gst_caps_has_property (caps, "wmvversion")) { if (id != CODEC_ID_NONE) {
gint wmvversion = 0; video = TRUE;
gst_caps_get_int (caps, "wmvversion", &wmvversion);
switch (wmvversion) {
case 1:
id = CODEC_ID_WMV1;
break;
case 2:
id = CODEC_ID_WMV2;
break;
default:
/* ... */
break;
}
if (id != CODEC_ID_NONE) {
video = TRUE;
}
} }
} else if (!strcmp(mimetype, "application/ogg")) { } else if (!strcmp(mimetype, "application/ogg")) {
...@@ -1260,30 +1122,26 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1260,30 +1122,26 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
id = CODEC_ID_VORBIS; id = CODEC_ID_VORBIS;
} else if (!strcmp(mimetype, "audio/mpeg")) { } else if (!strcmp(mimetype, "audio/mpeg")) {
gint layer = 0;
gint mpegversion = 0;
if (gst_caps_has_property (caps, "layer")) { gst_structure_get_int (structure, "layer", &layer);
gint layer = 0; switch (layer) {
case 1:
gst_caps_get_int (caps, "layer", &layer); case 2:
switch (layer) { id = CODEC_ID_MP2;
case 1: break;
case 2: case 3:
id = CODEC_ID_MP2; id = CODEC_ID_MP3LAME;
break; break;
case 3: default:
id = CODEC_ID_MP3LAME; /* ... */
break; break;
default: }
/* ... */
break;
}
} else if (gst_caps_has_property (caps, "mpegversion")) {
gint mpegversion = 0;
gst_caps_get_int (caps, "mpegversion", &mpegversion); gst_structure_get_int (structure, "mpegversion", &mpegversion);
if (mpegversion == 4) { if (mpegversion == 4) {
id = CODEC_ID_MPEG4AAC; id = CODEC_ID_MPEG4AAC;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1291,22 +1149,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1291,22 +1149,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
} }
} else if (!strcmp(mimetype, "audio/x-wma")) { } else if (!strcmp(mimetype, "audio/x-wma")) {
gint wmaversion = 0;
if (gst_caps_has_property (caps, "wmaversion")) {
gint wmaversion = 0; gst_structure_get_int (structure, "wmaversion", &wmaversion);
gst_caps_get_int (caps, "wmaversion", &wmaversion); switch (wmaversion) {
switch (wmaversion) { case 1:
case 1: id = CODEC_ID_WMAV1;
id = CODEC_ID_WMAV1; break;
break; case 2:
case 2: id = CODEC_ID_WMAV2;
id = CODEC_ID_WMAV2; break;
break; default:
default: /* ... */
/* ... */ break;
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1318,25 +1174,23 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1318,25 +1174,23 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
id = CODEC_ID_AC3; id = CODEC_ID_AC3;
} else if (!strcmp(mimetype, "video/x-msmpeg")) { } else if (!strcmp(mimetype, "video/x-msmpeg")) {
gint msmpegversion = 0;
if (gst_caps_has_property (caps, "msmpegversion")) {
gint msmpegversion = 0; gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
gst_caps_get_int (caps, "msmpegversion", &msmpegversion); switch (msmpegversion) {
switch (msmpegversion) { case 41:
case 41: id = CODEC_ID_MSMPEG4V1;
id = CODEC_ID_MSMPEG4V1; break;
break; case 42:
case 42: id = CODEC_ID_MSMPEG4V2;
id = CODEC_ID_MSMPEG4V2; break;
break; case 43:
case 43: id = CODEC_ID_MSMPEG4V3;
id = CODEC_ID_MSMPEG4V3; break;
break; default:
default: /* ... */
/* ... */ break;
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1344,22 +1198,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1344,22 +1198,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
} }
} else if (!strcmp(mimetype, "video/x-svq")) { } else if (!strcmp(mimetype, "video/x-svq")) {
gint svqversion = 0;
if (gst_caps_has_property (caps, "svqversion")) {
gint svqversion = 0; gst_structure_get_int (structure, "svqversion", &svqversion);
gst_caps_get_int (caps, "svqversion", &svqversion); switch (svqversion) {
switch (svqversion) { case 1:
case 1: id = CODEC_ID_SVQ1;
id = CODEC_ID_SVQ1; break;
break; case 3:
case 3: id = CODEC_ID_SVQ3;
id = CODEC_ID_SVQ3; break;
break; default:
default: /* ... */
/* ... */ break;
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1372,22 +1224,19 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1372,22 +1224,19 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE; video = TRUE;
} else if (!strcmp (mimetype, "audio/x-mace")) { } else if (!strcmp (mimetype, "audio/x-mace")) {
gint maceversion = 0;
if (gst_caps_has_property (caps, "maceversion")) {
gint maceversion; gst_structure_get_int (structure, "maceversion", &maceversion);
switch (maceversion) {
gst_caps_get_int (caps, "maceversion", &maceversion); case 3:
switch (maceversion) { id = CODEC_ID_MACE3;
case 3: break;
id = CODEC_ID_MACE3; case 6:
break; id = CODEC_ID_MACE6;
case 6: break;
id = CODEC_ID_MACE6; default:
break; /* ... */
default: break;
/* ... */
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1401,19 +1250,16 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1401,19 +1250,16 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE; video = TRUE;
} else if (!strcmp (mimetype, "video/x-indeo")) { } else if (!strcmp (mimetype, "video/x-indeo")) {
gint indeoversion = 0;
if (gst_caps_has_property (caps, "indeoversion")) {
gint indeoversion = 0; gst_structure_get_int (structure, "indeoversion", &indeoversion);
switch (indeoversion) {
gst_caps_get_int (caps, "indeoversion", &indeoversion); case 3:
switch (indeoversion) { id = CODEC_ID_INDEO3;
case 3: break;
id = CODEC_ID_INDEO3; default:
break; /* ... */
default: break;
/* ... */
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1421,23 +1267,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1421,23 +1267,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
} }
} else if (!strcmp (mimetype, "video/x-divx")) { } else if (!strcmp (mimetype, "video/x-divx")) {
gint divxversion = 0;
if (gst_caps_has_property (caps, "divxversion")) {
gint divxversion = 0; gst_structure_get_int (structure, "divxversion", &divxversion);
switch (divxversion) {
gst_caps_get_int (caps, "divxversion", &divxversion); case 3:
switch (divxversion) { id = CODEC_ID_MSMPEG4V3;
case 3: break;
id = CODEC_ID_MSMPEG4V3; case 4:
break; case 5:
case 4: id = CODEC_ID_MPEG4;
case 5: break;
id = CODEC_ID_MPEG4; default:
break; /* ... */
default: break;
/* ... */
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1451,19 +1294,16 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1451,19 +1294,16 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE; video = TRUE;
} else if (!strcmp (mimetype, "video/x-ffv")) { } else if (!strcmp (mimetype, "video/x-ffv")) {
gint ffvversion = 0;
if (gst_caps_has_property (caps, "ffvversion")) {
gint ffvversion = 0; gst_structure_get_int (structure, "ffvversion", &ffvversion);
switch (ffvversion) {
gst_caps_get_int (caps, "ffvversion", &ffvversion); case 1:
switch (ffvversion) { id = CODEC_ID_FFV1;
case 1: break;
id = CODEC_ID_FFV1; default:
break; /* ... */
default: break;
/* ... */
break;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1471,20 +1311,19 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1471,20 +1311,19 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
} }
} else if (!strcmp (mimetype, "x-adpcm")) { } else if (!strcmp (mimetype, "x-adpcm")) {
const gchar *layout;
if (gst_caps_has_property (caps, "layout")) {
const gchar *layout = ""; layout = gst_structure_get_string (structure, "layout");
if (layout == NULL) {
gst_caps_get_string (caps, "layout", &layout); /* break */
if (!strcmp (layout, "quicktime")) { } else if (!strcmp (layout, "quicktime")) {
id = CODEC_ID_ADPCM_IMA_QT; id = CODEC_ID_ADPCM_IMA_QT;
} else if (!strcmp (layout, "microsoft")) { } else if (!strcmp (layout, "microsoft")) {
id = CODEC_ID_ADPCM_MS; id = CODEC_ID_ADPCM_MS;
} else if (!strcmp (layout, "wav")) { } else if (!strcmp (layout, "wav")) {
id = CODEC_ID_ADPCM_IMA_WAV; id = CODEC_ID_ADPCM_IMA_WAV;
} else if (!strcmp (layout, "4xm")) { } else if (!strcmp (layout, "4xm")) {
id = CODEC_ID_ADPCM_4XM; id = CODEC_ID_ADPCM_4XM;
}
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
...@@ -1513,8 +1352,8 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -1513,8 +1352,8 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
} }
if (id != CODEC_ID_NONE) { if (id != CODEC_ID_NONE) {
char *str = g_strdup_printf("The id=%d belongs to this caps", id); char *str = gst_caps_to_string (caps);
gst_caps_debug(caps, str); GST_DEBUG ("The id=%d belongs to the caps %s", id, str);
g_free(str); g_free(str);
} }
......
...@@ -49,7 +49,7 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type, ...@@ -49,7 +49,7 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
*/ */
enum CodecID enum CodecID
gst_ffmpeg_caps_to_codecid (GstCaps *caps, gst_ffmpeg_caps_to_codecid (const GstCaps *caps,
AVCodecContext *context); AVCodecContext *context);
/* caps_to_codectype () transforms a GstCaps that belongs to /* caps_to_codectype () transforms a GstCaps that belongs to
...@@ -58,7 +58,7 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps, ...@@ -58,7 +58,7 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
void void
gst_ffmpeg_caps_to_codectype (enum CodecType type, gst_ffmpeg_caps_to_codectype (enum CodecType type,
GstCaps *caps, const GstCaps *caps,
AVCodecContext *context); AVCodecContext *context);
/* _formatid_to_caps () is meant for muxers/demuxers, it /* _formatid_to_caps () is meant for muxers/demuxers, it
......
...@@ -32,35 +32,38 @@ ...@@ -32,35 +32,38 @@
#include "gstffmpegcodecmap.h" #include "gstffmpegcodecmap.h"
#define GST_TYPE_FFMPEGCSP \ GST_DEBUG_CATEGORY_STATIC (debug_ffmpeg_csp);
#define GST_CAT_DEFAULT debug_ffmpeg_csp
#define GST_TYPE_FFMPEG_CSP \
(gst_ffmpegcsp_get_type()) (gst_ffmpegcsp_get_type())
#define GST_FFMPEGCSP(obj) \ #define GST_FFMPEG_CSP(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGCSP,GstFFMpegCsp)) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEG_CSP,GstFFMpegCsp))
#define GST_FFMPEGCSP_CLASS(klass) \ #define GST_FFMPEG_CSP_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGCSP,GstFFMpegCsp)) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEG_CSP,GstFFMpegCsp))
#define GST_IS_FFMPEGCSP(obj) \ #define GST_IS_FFMPEG_CSP(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGCSP)) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEG_CSP))
#define GST_IS_FFMPEGCSP_CLASS(obj) \ #define GST_IS_FFMPEG_CSP_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGCSP)) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEG_CSP))
typedef struct _GstFFMpegCsp GstFFMpegCsp; typedef struct _GstFFMpegCsp GstFFMpegCsp;
typedef struct _GstFFMpegCspClass GstFFMpegCspClass; typedef struct _GstFFMpegCspClass GstFFMpegCspClass;
struct _GstFFMpegCsp { struct _GstFFMpegCsp {
GstElement element; GstElement element;
GstPad *sinkpad, *srcpad;
gint width, height; GstPad * sinkpad;
gfloat fps; GstPad * srcpad;
enum PixelFormat gboolean need_caps_nego;
from_pixfmt,
to_pixfmt;
AVFrame *from_frame,
*to_frame;
GstCaps *sinkcaps;
GstBufferPool *pool; gint width;
gint height;
gdouble fps;
enum PixelFormat from_pixfmt;
enum PixelFormat to_pixfmt;
AVFrame * from_frame;
AVFrame * to_frame;
}; };
struct _GstFFMpegCspClass { struct _GstFFMpegCspClass {
...@@ -88,176 +91,92 @@ enum { ...@@ -88,176 +91,92 @@ enum {