From b4f055fe0f8ea291c72d87eb6f348fe7d743e753 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 28 Feb 2006 10:39:19 +0000 Subject: [PATCH] gst/ffmpegcolorspace/gstffmpegcolorspace.c: Don't ignore return code from ffmpeg convert function. Original commit message from CVS: * gst/ffmpegcolorspace/gstffmpegcolorspace.c: (gst_ffmpegcsp_transform): Don't ignore return code from ffmpeg convert function. * gst/ffmpegcolorspace/imgconvert.c: (img_convert): Split out some long statements to ease debugging. --- ChangeLog | 9 +++++++++ gst/ffmpegcolorspace/gstffmpegcolorspace.c | 11 ++++++++++- gst/ffmpegcolorspace/imgconvert.c | 14 ++++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20fabf5..8ba94a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-28 Wim Taymans + + * gst/ffmpegcolorspace/gstffmpegcolorspace.c: + (gst_ffmpegcsp_transform): + Don't ignore return code from ffmpeg convert function. + + * gst/ffmpegcolorspace/imgconvert.c: (img_convert): + Split out some long statements to ease debugging. + 2006-02-27 Jan Schmidt * ext/libvisual/visual.c: (gst_visual_init), diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c index c5911df..f46b2c6 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c @@ -429,6 +429,7 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf, GstBuffer * outbuf) { GstFFMpegCsp *space; + gint result; space = GST_FFMPEGCSP (btrans); @@ -449,8 +450,10 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf, GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height); /* and convert */ - img_convert (&space->to_frame, space->to_pixfmt, + result = img_convert (&space->to_frame, space->to_pixfmt, &space->from_frame, space->from_pixfmt, space->width, space->height); + if (result == -1) + goto not_supported; /* copy timestamps */ gst_buffer_stamp (outbuf, inbuf); @@ -465,6 +468,12 @@ unknown_format: ("attempting to convert colorspaces between unknown formats")); return GST_FLOW_NOT_NEGOTIATED; } +not_supported: + { + GST_ELEMENT_ERROR (space, CORE, NOT_IMPLEMENTED, (NULL), + ("cannot convert between formats")); + return GST_FLOW_NOT_SUPPORTED; + } } gboolean diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index dc9cc6c..6d90433 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -2109,6 +2109,7 @@ img_convert (AVPicture * dst, int dst_pix_fmt, x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift); y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf); + /* there must be filters for conversion at least from and to YUV444 format */ switch (xy_shift) { @@ -2156,11 +2157,15 @@ img_convert (AVPicture * dst, int dst_pix_fmt, #define GEN_MASK(x) ((1<<(x))-1) #define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x)) - for (i = 1; i <= 2; i++) + for (i = 1; i <= 2; i++) { + gint w, h; + + w = DIV_ROUND_UP_X (dst_width, dst_pix->x_chroma_shift); + h = DIV_ROUND_UP_X (dst_height, dst_pix->y_chroma_shift); + resize_func (dst->data[i], dst->linesize[i], - src->data[i], src->linesize[i], - DIV_ROUND_UP_X (dst_width, dst_pix->x_chroma_shift), - DIV_ROUND_UP_X (dst_height, dst_pix->y_chroma_shift)); + src->data[i], src->linesize[i], w, h); + } /* if yuv color space conversion is needed, we do it here on the destination image */ if (dst_pix->color_type != src_pix->color_type) { @@ -2228,6 +2233,7 @@ no_chroma_filter: if (img_convert (tmp, int_pix_fmt, src, src_pix_fmt, src_width, src_height) < 0) goto fail1; + if (img_convert (dst, dst_pix_fmt, tmp, int_pix_fmt, dst_width, dst_height) < 0) goto fail1; -- 2.7.4