ext/ffmpeg/gstffmpegcodecmap.c: Add more specific width/height for DV video so that it negotiates more automatically.

Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ff_vid_caps_new),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_with_codecid):
Add more specific width/height for DV video so that it negotiates more
automatically.
Try to avoid accessing NULL caps.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps):
Add some more debuggin to the caps generation.
This commit is contained in:
Wim Taymans 2008-05-26 09:19:53 +00:00
parent 2a2f93fd72
commit b150447eae
3 changed files with 61 additions and 10 deletions

View file

@ -1,3 +1,14 @@
2008-05-26 Wim Taymans <wim.taymans@collabora.co.uk>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ff_vid_caps_new),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_with_codecid):
Add more specific width/height for DV video so that it negotiates more
automatically.
Try to avoid accessing NULL caps.
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps):
Add some more debuggin to the caps generation.
2008-05-26 Sebastian Dröge <slomo@circular-chaos.org> 2008-05-26 Sebastian Dröge <slomo@circular-chaos.org>
* Makefile.am: * Makefile.am:

View file

@ -116,6 +116,24 @@ gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
} }
break; break;
} }
case CODEC_ID_DVVIDEO:
{
const static gint widths[] = { 720, 720 };
const static gint heights[] = { 576, 480 };
GstCaps *temp;
gint n_sizes = G_N_ELEMENTS (widths);
caps = gst_caps_new_empty ();
for (i = 0; i < n_sizes; i++) {
temp = gst_caps_new_simple (mimetype,
"width", G_TYPE_INT, widths[i],
"height", G_TYPE_INT, heights[i],
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
gst_caps_append (caps, temp);
}
break;
}
default: default:
caps = gst_caps_new_simple (mimetype, caps = gst_caps_new_simple (mimetype,
"width", GST_TYPE_INT_RANGE, 16, 4096, "width", GST_TYPE_INT_RANGE, 16, 4096,
@ -1212,22 +1230,31 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
if (caps == NULL) { if (caps == NULL) {
if (bpp != 0) { if (bpp != 0) {
if (r_mask != 0) { if (r_mask != 0) {
caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb", if (a_mask) {
caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
"bpp", G_TYPE_INT, bpp,
"depth", G_TYPE_INT, depth,
"red_mask", G_TYPE_INT, r_mask,
"green_mask", G_TYPE_INT, g_mask,
"blue_mask", G_TYPE_INT, b_mask,
"alpha_mask", G_TYPE_INT, a_mask,
"endianness", G_TYPE_INT, endianness, NULL);
}
else {
caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
"bpp", G_TYPE_INT, bpp, "bpp", G_TYPE_INT, bpp,
"depth", G_TYPE_INT, depth, "depth", G_TYPE_INT, depth,
"red_mask", G_TYPE_INT, r_mask, "red_mask", G_TYPE_INT, r_mask,
"green_mask", G_TYPE_INT, g_mask, "green_mask", G_TYPE_INT, g_mask,
"blue_mask", G_TYPE_INT, b_mask, "blue_mask", G_TYPE_INT, b_mask,
"endianness", G_TYPE_INT, endianness, NULL); "endianness", G_TYPE_INT, endianness, NULL);
if (a_mask) { }
gst_caps_set_simple (caps, "alpha_mask", G_TYPE_INT, a_mask, NULL);
}
} else { } else {
caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb", caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
"bpp", G_TYPE_INT, bpp, "bpp", G_TYPE_INT, bpp,
"depth", G_TYPE_INT, depth, "depth", G_TYPE_INT, depth,
"endianness", G_TYPE_INT, endianness, NULL); "endianness", G_TYPE_INT, endianness, NULL);
if (context) { if (caps && context) {
gst_ffmpeg_set_palette (caps, context); gst_ffmpeg_set_palette (caps, context);
} }
} }
@ -1705,7 +1732,6 @@ gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
break; break;
} }
} }
default: default:
break; break;
} }

View file

@ -287,20 +287,30 @@ gst_ffmpegenc_getcaps (GstPad * pad)
enum PixelFormat pixfmt; enum PixelFormat pixfmt;
GstCaps *caps = NULL; GstCaps *caps = NULL;
GST_DEBUG_OBJECT (ffmpegenc, "getting caps");
/* audio needs no special care */ /* audio needs no special care */
if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) { if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
return gst_caps_copy (gst_pad_get_pad_template_caps (pad)); caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
GST_DEBUG_OBJECT (ffmpegenc, "audio caps, return template %"GST_PTR_FORMAT, caps);
return caps;
} }
/* cached */ /* cached */
if (oclass->sinkcaps) { if (oclass->sinkcaps) {
return gst_caps_copy (oclass->sinkcaps); caps = gst_caps_copy (oclass->sinkcaps);
GST_DEBUG_OBJECT (ffmpegenc, "return cached caps %"GST_PTR_FORMAT, caps);
return caps;
} }
/* create cache etc. */ /* create cache etc. */
ctx = avcodec_alloc_context (); ctx = avcodec_alloc_context ();
if (!ctx) { if (!ctx) {
return gst_caps_copy (gst_pad_get_pad_template_caps (pad)); caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
GST_DEBUG_OBJECT (ffmpegenc, "no context, return template caps %"GST_PTR_FORMAT, caps);
return caps;
} }
/* set some default properties */ /* set some default properties */
@ -321,6 +331,7 @@ gst_ffmpegenc_getcaps (GstPad * pad)
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
_shut_up_I_am_probing = TRUE; _shut_up_I_am_probing = TRUE;
#endif #endif
GST_DEBUG_OBJECT (ffmpegenc, "probing caps");
for (pixfmt = 0; pixfmt < PIX_FMT_NB; pixfmt++) { for (pixfmt = 0; pixfmt < PIX_FMT_NB; pixfmt++) {
GstCaps *tmpcaps; GstCaps *tmpcaps;
@ -350,9 +361,12 @@ gst_ffmpegenc_getcaps (GstPad * pad)
/* make sure we have something */ /* make sure we have something */
if (!caps) { if (!caps) {
return gst_caps_copy (gst_pad_get_pad_template_caps (pad)); caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
GST_DEBUG_OBJECT (ffmpegenc, "probing gave nothing, return template %"GST_PTR_FORMAT, caps);
return caps;
} }
GST_DEBUG_OBJECT (ffmpegenc, "probed caps gave %"GST_PTR_FORMAT, caps);
oclass->sinkcaps = gst_caps_copy (caps); oclass->sinkcaps = gst_caps_copy (caps);
return caps; return caps;