Originally committed as revision 20690 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2009/12/02 06:10:37... | ... |
@@ -520,7 +520,7 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx) |
520 | 520 |
} |
521 | 521 |
|
522 | 522 |
static int rv10_decode_packet(AVCodecContext *avctx, |
523 |
- const uint8_t *buf, int buf_size) |
|
523 |
+ const uint8_t *buf, int buf_size, int buf_size2) |
|
524 | 524 |
{ |
525 | 525 |
MpegEncContext *s = avctx->priv_data; |
526 | 526 |
int mb_count, mb_pos, left, start_mb_x; |
... | ... |
@@ -603,6 +603,12 @@ static int rv10_decode_packet(AVCodecContext *avctx, |
603 | 603 |
s->mv_type = MV_TYPE_16X16; |
604 | 604 |
ret=ff_h263_decode_mb(s, s->block); |
605 | 605 |
|
606 |
+ if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){ |
|
607 |
+ av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2); |
|
608 |
+ s->gb.size_in_bits= 8*buf_size2; |
|
609 |
+ ret= SLICE_OK; |
|
610 |
+ } |
|
611 |
+ |
|
606 | 612 |
if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) { |
607 | 613 |
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); |
608 | 614 |
return -1; |
... | ... |
@@ -625,7 +631,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, |
625 | 625 |
|
626 | 626 |
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); |
627 | 627 |
|
628 |
- return buf_size; |
|
628 |
+ return s->gb.size_in_bits; |
|
629 | 629 |
} |
630 | 630 |
|
631 | 631 |
static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) |
... | ... |
@@ -662,14 +668,20 @@ static int rv10_decode_frame(AVCodecContext *avctx, |
662 | 662 |
|
663 | 663 |
for(i=0; i<slice_count; i++){ |
664 | 664 |
int offset= get_slice_offset(avctx, slices_hdr, i); |
665 |
- int size; |
|
665 |
+ int size, size2; |
|
666 | 666 |
|
667 | 667 |
if(i+1 == slice_count) |
668 | 668 |
size= buf_size - offset; |
669 | 669 |
else |
670 | 670 |
size= get_slice_offset(avctx, slices_hdr, i+1) - offset; |
671 | 671 |
|
672 |
- rv10_decode_packet(avctx, buf+offset, size); |
|
672 |
+ if(i+2 >= slice_count) |
|
673 |
+ size2= buf_size - offset; |
|
674 |
+ else |
|
675 |
+ size2= get_slice_offset(avctx, slices_hdr, i+2) - offset; |
|
676 |
+ |
|
677 |
+ if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size) |
|
678 |
+ i++; |
|
673 | 679 |
} |
674 | 680 |
|
675 | 681 |
if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){ |