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>
This commit is contained in:
Reimar Döffinger 2013-08-21 05:04:46 +02:00
parent 05b7a635dc
commit 2aa8e33d7d
2 changed files with 5 additions and 15 deletions

View File

@ -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){

View File

@ -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;
}