diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2009-12-02 00:10:37 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2009-12-02 00:10:37 +0300 |
commit | e7e578b73c453ad22c553b8be5535aa3b861cd83 (patch) | |
tree | 3f3301c5051ae319e0a53834f681cebec08168f5 /libavcodec/rv10.c | |
parent | 66765b59339f82422630477e052991507bbd6dc4 (diff) |
Make rv1/2 decoder use the next slice if needed.
Fixes issue782.
Originally committed as revision 20690 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/rv10.c')
-rw-r--r-- | libavcodec/rv10.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 004c02d194..64d506fe7a 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -520,7 +520,7 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx) } static int rv10_decode_packet(AVCodecContext *avctx, - const uint8_t *buf, int buf_size) + const uint8_t *buf, int buf_size, int buf_size2) { MpegEncContext *s = avctx->priv_data; int mb_count, mb_pos, left, start_mb_x; @@ -603,6 +603,12 @@ static int rv10_decode_packet(AVCodecContext *avctx, s->mv_type = MV_TYPE_16X16; ret=ff_h263_decode_mb(s, s->block); + if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){ + av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2); + s->gb.size_in_bits= 8*buf_size2; + ret= SLICE_OK; + } + if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); return -1; @@ -625,7 +631,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END); - return buf_size; + return s->gb.size_in_bits; } static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) @@ -662,14 +668,20 @@ static int rv10_decode_frame(AVCodecContext *avctx, for(i=0; i<slice_count; i++){ int offset= get_slice_offset(avctx, slices_hdr, i); - int size; + int size, size2; if(i+1 == slice_count) size= buf_size - offset; else size= get_slice_offset(avctx, slices_hdr, i+1) - offset; - rv10_decode_packet(avctx, buf+offset, size); + if(i+2 >= slice_count) + size2= buf_size - offset; + else + size2= get_slice_offset(avctx, slices_hdr, i+2) - offset; + + if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size) + i++; } if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){ |