[FFmpeg-devel] [PATCH] lavc/mpeg2dec: fix MPEG2 VA-API interlace decoding issue.
Jun Zhao
mypopydev at gmail.com
Mon Sep 17 14:21:31 EEST 2018
From: Jun Zhao <jun.zhao at intel.com>
For interlaced frame, it has to call slice_end() for both fields. And
VASliceParameterBufferMPEG2::slice_vertical_position is supposed to be
the position in the picture but not field in this case.
Signed-off-by: Dong, Jerry <jerry.dong at intel.com>
Signed-off-by: Jun Zhao <jun.zhao at intel.com>
---
libavcodec/mpeg12dec.c | 9 +++++++++
libavcodec/vaapi_mpeg2.c | 2 +-
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 83e5378..c21f133 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2546,6 +2546,15 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
s2->er.error_count += s2->thread_context[i]->er.error_count;
s->slice_count = 0;
}
+
+ if (s2->first_field) {
+ /* slice ends for the first field */
+ ret = slice_end(avctx, picture);
+ av_assert1(ret == 0);
+ if (ret < 0)
+ return ret;
+ }
+
if (last_code == 0 || last_code == SLICE_MIN_START_CODE) {
ret = mpeg_decode_postinit(avctx);
if (ret < 0) {
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index aaed434..b159f49 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -156,7 +156,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
.slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
.macroblock_offset = macroblock_offset,
.slice_horizontal_position = s->mb_x,
- .slice_vertical_position = s->mb_y >> (s->picture_structure != PICT_FRAME),
+ .slice_vertical_position = s->mb_y,
.quantiser_scale_code = quantiser_scale_code,
.intra_slice_flag = intra_slice_flag,
};
--
1.7.1
More information about the ffmpeg-devel
mailing list