From 746a33e720a80f9b6fc53b32791ff73136d5621c Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Mon, 17 Oct 2005 09:34:26 +0000 Subject: [PATCH] gst/ffmpegcolorspace/gstffmpegcolorspace.c: We are asked to compute a buffer size from caps, let's use the caps... Original commit message from CVS: 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... --- ChangeLog | 6 ++++++ gst/ffmpegcolorspace/gstffmpegcolorspace.c | 25 ++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4be79e..4205196 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 211f5dc..253d404 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; } -- 2.7.4