From b150447eaee4057527ce5abe06f55155683afef3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 26 May 2008 09:19:53 +0000 Subject: [PATCH] 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. --- ChangeLog | 11 ++++++++++ ext/ffmpeg/gstffmpegcodecmap.c | 38 ++++++++++++++++++++++++++++------ ext/ffmpeg/gstffmpegenc.c | 22 ++++++++++++++++---- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc617c3eb4..717a6389f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-05-26 Wim Taymans + + * 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 * Makefile.am: diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c index 9a3fe8377b..81ec863f87 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.c +++ b/ext/ffmpeg/gstffmpegcodecmap.c @@ -116,6 +116,24 @@ gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id, } 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: caps = gst_caps_new_simple (mimetype, "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 (bpp != 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, "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, "endianness", G_TYPE_INT, endianness, NULL); - if (a_mask) { - gst_caps_set_simple (caps, "alpha_mask", G_TYPE_INT, a_mask, NULL); - } + } } else { caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb", "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness", G_TYPE_INT, endianness, NULL); - if (context) { + if (caps && context) { gst_ffmpeg_set_palette (caps, context); } } @@ -1705,7 +1732,6 @@ gst_ffmpeg_caps_with_codecid (enum CodecID codec_id, break; } } - default: break; } diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c index 04e51b43e6..5f84675d46 100644 --- a/ext/ffmpeg/gstffmpegenc.c +++ b/ext/ffmpeg/gstffmpegenc.c @@ -287,20 +287,30 @@ gst_ffmpegenc_getcaps (GstPad * pad) enum PixelFormat pixfmt; GstCaps *caps = NULL; + GST_DEBUG_OBJECT (ffmpegenc, "getting caps"); + /* audio needs no special care */ 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 */ 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. */ ctx = avcodec_alloc_context (); 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 */ @@ -321,6 +331,7 @@ gst_ffmpegenc_getcaps (GstPad * pad) #ifndef GST_DISABLE_GST_DEBUG _shut_up_I_am_probing = TRUE; #endif + GST_DEBUG_OBJECT (ffmpegenc, "probing caps"); for (pixfmt = 0; pixfmt < PIX_FMT_NB; pixfmt++) { GstCaps *tmpcaps; @@ -350,9 +361,12 @@ gst_ffmpegenc_getcaps (GstPad * pad) /* make sure we have something */ 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); return caps;