[FFmpeg-cvslog] hwaccel: mpeg2: decode first field, if requested.

Gwenole Beauchesne git at videolan.org
Sun Apr 8 21:08:02 CEST 2012


ffmpeg | branch: master | Gwenole Beauchesne <gb.devel at gmail.com> | Sun Mar 18 09:46:58 2012 +0100| [9cb150c9ab520eba5636bbcf925db6a70e67f3e5] | committer: Martin Storsjö

hwaccel: mpeg2: decode first field, if requested.

If user opted to present fields as they come, then the first field
picture needs to be submitted to the HW for decoding. In particular,
this fixes MPEG-2 decoding of interlaced streams.

Tested on Intel Cedar Trail, Sandy Bridge and Ivy Bridge platforms.
Someone reported on the ffmpeg-devel@ list this also works on DXVA
(Windows) and other Linux platforms (NVIDIA, through the VA wrapper).

This also means a similar patch to non-hwaccel VDPAU may be necessary.

Note: I believe the SLICE_FLAG_ALLOW_FIELD is useless since the first
field shall always be submitted to the HW anyway. Nobody uses HW accels
(dxva, vaapi, vdpau, etc.) without that flag though.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9cb150c9ab520eba5636bbcf925db6a70e67f3e5
---

 libavcodec/mpeg12.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 27765b3..8cdc704 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1590,6 +1590,12 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
             return -1;
         }
 
+        if (s->avctx->hwaccel &&
+            (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
+            if (s->avctx->hwaccel->end_frame(s->avctx) < 0)
+                av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode first field\n");
+        }
+
         for (i = 0; i < 4; i++) {
             s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i];
             if (s->picture_structure == PICT_BOTTOM_FIELD) {



More information about the ffmpeg-cvslog mailing list