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
612612 const uint8_t **srcbuf, int buf_size,
613613 int non_mod, uint8_t *map_table, int x_pos)
614614 {
615− const uint8_t *sbuf_end = (*srcbuf) + buf_size;
616615 int bits;
617616 int run_length;
618617 int pixels_read = x_pos;
618+ GetByteContext gb0, *const gb = &gb0;
619619
620+ bytestream2_init(gb, *srcbuf, buf_size);
620621 destbuf += x_pos;
621622
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);
624625
625626 if (bits) {
626627 if (non_mod != 1 || bits != 1) {
@@ -631,16 +632,17 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 4 unmodified lines
631632 }
632633 pixels_read++;
633634 } else {
634− bits = *(*srcbuf)++;
635+ bits = bytestream2_get_byte(gb);
635636 run_length = bits & 0x7f;
636637 if ((bits & 0x80) == 0) {
637638 if (run_length == 0) {
639+ *srcbuf += bytestream2_tell(gb);
638640 return pixels_read;
639641 }
640642
641643 bits = 0;
642644 } else {
643− bits = *(*srcbuf)++;
645+ bits = bytestream2_get_byte(gb);
644646 }
645647 if (non_mod == 1 && bits == 1)
646648 pixels_read += run_length;
@@ -655,9 +657,10 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 8 unmodified lines
655657 }
656658 }
657659
658− if (*(*srcbuf)++)
660+ if (bytestream2_get_byte(gb))
659661 av_log(avctx, AV_LOG_ERROR, "line overflow\n");
660662
663+ *srcbuf += bytestream2_tell(gb);
661664 return pixels_read;
662665 }
663666

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