aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2013-08-21 05:04:46 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2013-09-22 16:08:35 +0200
commit2aa8e33d7d86fbc4a4060c363a5733067c160654 (patch)
treea2ffa32b10eca8832b2cfbb4065d1caef8205b5f
parent05b7a635dc1e5266fb367ce8b0019a0830317879 (diff)
downloadffmpeg-2aa8e33d7d86fbc4a4060c363a5733067c160654.tar.gz
Fix nonsense MPEG-4 hwaccel code.
Issues with the code: 1) The skip_bits_long breaks packed B-frames since we skip of the packed frame, even for VDPAU. 2) Calling ff_h263_find_resync_marker_reverse is nonsense for MPEG-4, and for H.263 the only code using this (vaapi_mpeg4) explicitly reverts this change! 3) mb_x/mb_y are always 0 when vaapi_mpeg4_decode_slice, so doing computations with them is just obfuscation 4) due to not updating mb_y the code would always go into the error resilience case, causing nonsense error messages and maybe further issues. While tested to fix the data provided to the decoder in case of VDPAU so it is the same as for the non-hwaccel code, the VA-API code was not tested to still work, and adding regression testing even as a quick hack is much more complicated for it. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
-rw-r--r--libavcodec/h263dec.c7
-rw-r--r--libavcodec/vaapi_mpeg4.c13
2 files changed, 5 insertions, 15 deletions
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 52ab7797f3..56c4b78550 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -170,9 +170,10 @@ static int decode_slice(MpegEncContext *s){
if (s->avctx->hwaccel) {
const uint8_t *start= s->gb.buffer + get_bits_count(&s->gb)/8;
- const uint8_t *end = ff_h263_find_resync_marker(s, start + 1, s->gb.buffer_end);
- skip_bits_long(&s->gb, 8*(end - start));
- return s->avctx->hwaccel->decode_slice(s->avctx, start, end - start);
+ ret = s->avctx->hwaccel->decode_slice(s->avctx, start, s->gb.buffer_end - start);
+ // ensure we exit decode loop
+ s->mb_y = s->mb_height;
+ return ret;
}
if(s->partitioned_frame){
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index bcc0ebabab..5923b07fcd 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -122,25 +122,14 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
av_dlog(avctx, "vaapi_mpeg4_decode_slice(): buffer %p, size %d\n", buffer, size);
- /* video_plane_with_short_video_header() contains all GOBs
- * in-order, and this is what VA API (Intel backend) expects: only
- * a single slice param. So fake macroblock_number for FFmpeg so
- * that we don't call vaapi_mpeg4_decode_slice() again
- */
- if (avctx->codec->id == AV_CODEC_ID_H263)
- size = s->gb.buffer_end - buffer;
-
/* Fill in VASliceParameterBufferMPEG4 */
slice_param = (VASliceParameterBufferMPEG4 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
if (!slice_param)
return -1;
slice_param->macroblock_offset = get_bits_count(&s->gb) % 8;
- slice_param->macroblock_number = s->mb_y * s->mb_width + s->mb_x;
+ slice_param->macroblock_number = 0;
slice_param->quant_scale = s->qscale;
- if (avctx->codec->id == AV_CODEC_ID_H263)
- s->mb_y = s->mb_height;
-
return 0;
}