History

avcodec/dvbsubdec: convert dvbsub_read_8bit_string to bytestream reader

No change in functionality.

Marton Balint committed 1 year ago

Commit aeb6ea51 parent 74f470c1 file · +9 −6Browse files

Unified · Split

libavcodec/dvbsubdec.c+9−6
@@ -612,15 +612,16 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 611 unmodified lines
612 const uint8_t **srcbuf, int buf_size,612 const uint8_t **srcbuf, int buf_size,
613 int non_mod, uint8_t *map_table, int x_pos)613 int non_mod, uint8_t *map_table, int x_pos)
614{614{
615 const uint8_t *sbuf_end = (*srcbuf) + buf_size;
616 int bits;615 int bits;
617 int run_length;616 int run_length;
618 int pixels_read = x_pos;617 int pixels_read = x_pos;
618 GetByteContext gb0, *const gb = &gb0;
619 619
620 bytestream2_init(gb, *srcbuf, buf_size);
620 destbuf += x_pos;621 destbuf += x_pos;
621 622
622 while (*srcbuf < sbuf_end && pixels_read < dbuf_len) {623 while (bytestream2_get_bytes_left(gb) && pixels_read < dbuf_len) {
623 bits = *(*srcbuf)++;624 bits = bytestream2_get_byteu(gb);
624 625
625 if (bits) {626 if (bits) {
626 if (non_mod != 1 || bits != 1) {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 pixels_read++;633 pixels_read++;
633 } else {634 } else {
634 bits = *(*srcbuf)++;635 bits = bytestream2_get_byte(gb);
635 run_length = bits & 0x7f;636 run_length = bits & 0x7f;
636 if ((bits & 0x80) == 0) {637 if ((bits & 0x80) == 0) {
637 if (run_length == 0) {638 if (run_length == 0) {
639 *srcbuf += bytestream2_tell(gb);
638 return pixels_read;640 return pixels_read;
639 }641 }
640 642
641 bits = 0;643 bits = 0;
642 } else {644 } else {
643 bits = *(*srcbuf)++;645 bits = bytestream2_get_byte(gb);
644 }646 }
645 if (non_mod == 1 && bits == 1)647 if (non_mod == 1 && bits == 1)
646 pixels_read += run_length;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 av_log(avctx, AV_LOG_ERROR, "line overflow\n");661 av_log(avctx, AV_LOG_ERROR, "line overflow\n");
660 662
663 *srcbuf += bytestream2_tell(gb);
661 return pixels_read;664 return pixels_read;
662}665}
663 666

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t