Commit 54307b35 authored by Zhong Li's avatar Zhong Li Committed by Maxym Dmytrychenko

lavc/qsvdec: set complete_frame flags for progressive picture

Set the flag MFX_BITSTREAM_COMPLETE_FRAME when it is a progressive picture.
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

v2: fix some h264 interlaced clips regression
a. field_order of some h264 interlaced video (e.g: cama3_vtc_b.avc) is marked as AV_FIELD_UNKNOWN
   in h264_parser.c. This is not a completed frames.
   So only set the MFX_BITSTREAM_COMPLETE_FRAME when it is progressive.
b. some clips have both progressive and interlaced frames (e.g.CAPAMA3_Sand_F.264),
   the parsed field_order maybe changed druing the decoding progress.

This patch has been verified for other codecs(mpeg2/hevc/vp8).
Signed-off-by: 's avatarZhong Li <zhong.li@intel.com>
Signed-off-by: 's avatarMaxym Dmytrychenko <maxim.d33@gmail.com>
parent cca5e4f0
...@@ -323,6 +323,8 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, ...@@ -323,6 +323,8 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
bs.DataLength = avpkt->size; bs.DataLength = avpkt->size;
bs.MaxLength = bs.DataLength; bs.MaxLength = bs.DataLength;
bs.TimeStamp = avpkt->pts; bs.TimeStamp = avpkt->pts;
if (avctx->field_order == AV_FIELD_PROGRESSIVE)
bs.DataFlag |= MFX_BITSTREAM_COMPLETE_FRAME;
} }
sync = av_mallocz(sizeof(*sync)); sync = av_mallocz(sizeof(*sync));
...@@ -516,6 +518,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, ...@@ -516,6 +518,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
pkt->data, pkt->size, pkt->pts, pkt->dts, pkt->data, pkt->size, pkt->pts, pkt->dts,
pkt->pos); pkt->pos);
avctx->field_order = q->parser->field_order;
/* TODO: flush delayed frames on reinit */ /* TODO: flush delayed frames on reinit */
if (q->parser->format != q->orig_pix_fmt || if (q->parser->format != q->orig_pix_fmt ||
FFALIGN(q->parser->coded_width, 16) != FFALIGN(avctx->coded_width, 16) || FFALIGN(q->parser->coded_width, 16) != FFALIGN(avctx->coded_width, 16) ||
...@@ -540,7 +543,6 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, ...@@ -540,7 +543,6 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
avctx->height = q->parser->height; avctx->height = q->parser->height;
avctx->coded_width = FFALIGN(q->parser->coded_width, 16); avctx->coded_width = FFALIGN(q->parser->coded_width, 16);
avctx->coded_height = FFALIGN(q->parser->coded_height, 16); avctx->coded_height = FFALIGN(q->parser->coded_height, 16);
avctx->field_order = q->parser->field_order;
avctx->level = q->avctx_internal->level; avctx->level = q->avctx_internal->level;
avctx->profile = q->avctx_internal->profile; avctx->profile = q->avctx_internal->profile;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment