No change in functionality.
Unified · Split
| @@ -612,15 +612,16 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 611 unmodified lines | ||
| 612 | 612 | const uint8_t **srcbuf, int buf_size, |
| 613 | 613 | int non_mod, uint8_t *map_table, int x_pos) |
| 614 | 614 | { |
| 615 | − const uint8_t *sbuf_end = (*srcbuf) + buf_size; | |
| 616 | 615 | int bits; |
| 617 | 616 | int run_length; |
| 618 | 617 | int pixels_read = x_pos; |
| 618 | + GetByteContext gb0, *const gb = &gb0; | |
| 619 | 619 | |
| 620 | + bytestream2_init(gb, *srcbuf, buf_size); | |
| 620 | 621 | destbuf += x_pos; |
| 621 | 622 | |
| 622 | − while (*srcbuf < sbuf_end && pixels_read < dbuf_len) { | |
| 623 | − bits = *(*srcbuf)++; | |
| 623 | + while (bytestream2_get_bytes_left(gb) && pixels_read < dbuf_len) { | |
| 624 | + bits = bytestream2_get_byteu(gb); | |
| 624 | 625 | |
| 625 | 626 | if (bits) { |
| 626 | 627 | if (non_mod != 1 || bits != 1) { |
| @@ -631,16 +632,17 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 4 unmodified lines | ||
| 631 | 632 | } |
| 632 | 633 | pixels_read++; |
| 633 | 634 | } else { |
| 634 | − bits = *(*srcbuf)++; | |
| 635 | + bits = bytestream2_get_byte(gb); | |
| 635 | 636 | run_length = bits & 0x7f; |
| 636 | 637 | if ((bits & 0x80) == 0) { |
| 637 | 638 | if (run_length == 0) { |
| 639 | + *srcbuf += bytestream2_tell(gb); | |
| 638 | 640 | return pixels_read; |
| 639 | 641 | } |
| 640 | 642 | |
| 641 | 643 | bits = 0; |
| 642 | 644 | } else { |
| 643 | − bits = *(*srcbuf)++; | |
| 645 | + bits = bytestream2_get_byte(gb); | |
| 644 | 646 | } |
| 645 | 647 | if (non_mod == 1 && bits == 1) |
| 646 | 648 | pixels_read += run_length; |
| @@ -655,9 +657,10 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 8 unmodified lines | ||
| 655 | 657 | } |
| 656 | 658 | } |
| 657 | 659 | |
| 658 | − if (*(*srcbuf)++) | |
| 660 | + if (bytestream2_get_byte(gb)) | |
| 659 | 661 | av_log(avctx, AV_LOG_ERROR, "line overflow\n"); |
| 660 | 662 | |
| 663 | + *srcbuf += bytestream2_tell(gb); | |
| 661 | 664 | return pixels_read; |
| 662 | 665 | } |
| 663 | 666 | |