[1/2] lavc/qsvdec: set complete_frame flags for non-interlaced frames.

Message ID 1521452016-25232-1-git-send-email-zhong.li@intel.com
State New
Headers show
Series
  • [1/2] lavc/qsvdec: set complete_frame flags for non-interlaced frames.
Related show

Commit Message

Li, Zhong March 19, 2018, 9:33 a.m.
Set the flag MFX_BITSTREAM_COMPLETE_FRAME when it is a completed frame.
This can fix vc1 decoding segment fault issues because can't set the start
code correctly.
See: ./avconv -hwaccel qsv -c:v vc1_qsv -i /fate-suite/vc1/SA00040.vc1
-vf "hwdownload, format=nv12" -f rawvideo /dev/null

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 libavcodec/qsvdec.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Maxym Dmytrychenko March 19, 2018, 9:59 a.m. | #1
MFX_BITSTREAM_COMPLETE_FRAME support can be added as a param
 or can be only such if() conditions sufficient for all cases and streams ?

On Mon, Mar 19, 2018 at 10:33 AM, Zhong Li <zhong.li@intel.com> wrote:

> Set the flag MFX_BITSTREAM_COMPLETE_FRAME when it is a completed frame.
> This can fix vc1 decoding segment fault issues because can't set the start
> code correctly.
> See: ./avconv -hwaccel qsv -c:v vc1_qsv -i /fate-suite/vc1/SA00040.vc1
> -vf "hwdownload, format=nv12" -f rawvideo /dev/null
>
> Signed-off-by: Zhong Li <zhong.li@intel.com>
> ---
>  libavcodec/qsvdec.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index c74ec68..dc44865 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -321,6 +321,9 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext *q,
>          bs.DataLength = avpkt->size;
>          bs.MaxLength  = bs.DataLength;
>          bs.TimeStamp  = avpkt->pts;
> +        if (avctx->field_order == AV_FIELD_UNKNOWN ||
> +            avctx->field_order == AV_FIELD_PROGRESSIVE)
> +            bs.DataFlag   |= MFX_BITSTREAM_COMPLETE_FRAME;
>      }
>
>      sync = av_mallocz(sizeof(*sync));
> --
> 1.8.3.1
>
> _______________________________________________
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
Li, Zhong March 20, 2018, 6:38 a.m. | #2
> From: libav-devel [mailto:libav-devel-bounces@libav.org] On Behalf Of
> Maxym Dmytrychenko
> Sent: Monday, March 19, 2018 5:59 PM
> To: libav development <libav-devel@libav.org>
> Subject: Re: [libav-devel] [PATCH 1/2] lavc/qsvdec: set complete_frame flags
> for non-interlaced frames.
> 
>  MFX_BITSTREAM_COMPLETE_FRAME support can be added as a param
> or can be only such if() conditions sufficient for all cases and streams ?

Yes, I think this flag is a common flag for all codecs (Not only for VC1.). According to the comments of MFX_BITSTREAM_COMPLETE_FRAME and grep it in MSDK sample_utils.cpp.
I have run the full decoding test internally for all codecs. 
Everything is ok but expect h264. Some interlace videos is treated as AV_FIELD_UNKNOWN(see https://github.com/libav/libav/blob/master/libavcodec/h264_parser.c#L463 ) thus making some h264 clips decoding failed.
I will update this patch. Thanks for your review!

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index c74ec68..dc44865 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -321,6 +321,9 @@  static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
         bs.DataLength = avpkt->size;
         bs.MaxLength  = bs.DataLength;
         bs.TimeStamp  = avpkt->pts;
+        if (avctx->field_order == AV_FIELD_UNKNOWN ||
+            avctx->field_order == AV_FIELD_PROGRESSIVE)
+            bs.DataFlag   |= MFX_BITSTREAM_COMPLETE_FRAME;
     }
 
     sync = av_mallocz(sizeof(*sync));