diff --git a/ChangeLog b/ChangeLog index c4be79eebe..42051968a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-17 Julien MOUTTE + + * gst/ffmpegcolorspace/gstffmpegcolorspace.c: + (gst_ffmpegcsp_get_unit_size): We are asked to compute a buffer size + from caps, let's use the caps... + 2005-10-17 Thomas Vander Stichele * configure.ac: diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c index 211f5dc4ff..253d404654 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c @@ -305,17 +305,28 @@ static gboolean gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, guint * size) { - GstFFMpegCsp *space; + GstFFMpegCsp *space = NULL; + GstStructure *structure = NULL; + AVCodecContext *ctx = NULL; + gint width, height; g_return_val_if_fail (size, FALSE); space = GST_FFMPEGCSP (btrans); - if (gst_caps_is_equal (caps, GST_PAD_CAPS (btrans->srcpad))) { - *size = avpicture_get_size (space->to_pixfmt, space->width, space->height); - } else if (gst_caps_is_equal (caps, GST_PAD_CAPS (btrans->sinkpad))) { - *size = - avpicture_get_size (space->from_pixfmt, space->width, space->height); - } + + structure = gst_caps_get_structure (caps, 0); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "height", &height); + + ctx = avcodec_alloc_context (); + + g_assert (ctx != NULL); + + gst_ffmpegcsp_caps_with_codectype (CODEC_TYPE_VIDEO, caps, ctx); + + *size = avpicture_get_size (ctx->pix_fmt, width, height); + + av_free (ctx); return TRUE; }