From f503ef97f757a3a61d91150a1d1eb20557d5ee29 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 1 Apr 2012 20:19:36 +0200 Subject: [PATCH] mpeg2dec: add crop metadata when buffer is still writable --- ext/mpeg2dec/gstmpeg2dec.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ext/mpeg2dec/gstmpeg2dec.c b/ext/mpeg2dec/gstmpeg2dec.c index 5b1716eaee..89d1df74a0 100644 --- a/ext/mpeg2dec/gstmpeg2dec.c +++ b/ext/mpeg2dec/gstmpeg2dec.c @@ -705,6 +705,19 @@ handle_picture (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info) gst_video_frame_unmap (frame); gst_buffer_unref (frame->buffer); } + + if (mpeg2dec->use_cropping) { + GstVideoCropMeta *crop; + + crop = gst_buffer_add_video_crop_meta (outbuf); + /* we can do things slightly more efficient when we know that + * downstream understands clipping */ + crop->x = 0; + crop->y = 0; + crop->width = mpeg2dec->width; + crop->height = mpeg2dec->height; + } + gst_video_frame_map (frame, &mpeg2dec->vinfo, outbuf, GST_MAP_WRITE); buf[0] = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); @@ -942,17 +955,6 @@ handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info) * array of buffers */ gst_buffer_ref (outbuf); - if (mpeg2dec->use_cropping) { - GstVideoCropMeta *crop; - - crop = gst_buffer_add_video_crop_meta (outbuf); - /* we can do things slightly more efficient when we know that - * downstream understands clipping */ - crop->x = 0; - crop->y = 0; - crop->width = mpeg2dec->width; - crop->height = mpeg2dec->height; - } #if 0 /* do cropping if the target region is smaller than the input one */ if (mpeg2dec->decoded_width != mpeg2dec->width ||