diff options
author | Marton Balint <cus@passwd.hu> | 2025-08-03 01:01:31 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2025-08-03 21:33:29 +0200 |
commit | aeb6ea51f5079d1456546ac28edc6549d45de1f2 (patch) | |
tree | 7d6c8932e2ecd0de8a79e97988e8974036ae23b5 | |
parent | 74f470c05c3ea76091b6d85d8fbf54ea3db1805b (diff) | |
download | ffmpeg-aeb6ea51f5079d1456546ac28edc6549d45de1f2.tar.gz |
avcodec/dvbsubdec: convert dvbsub_read_8bit_string to bytestream reader
No change in functionality.
Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r-- | libavcodec/dvbsubdec.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index cbb16e501a..4af3feeb09 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -612,15 +612,16 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, const uint8_t **srcbuf, int buf_size, int non_mod, uint8_t *map_table, int x_pos) { - const uint8_t *sbuf_end = (*srcbuf) + buf_size; int bits; int run_length; int pixels_read = x_pos; + GetByteContext gb0, *const gb = &gb0; + bytestream2_init(gb, *srcbuf, buf_size); destbuf += x_pos; - while (*srcbuf < sbuf_end && pixels_read < dbuf_len) { - bits = *(*srcbuf)++; + while (bytestream2_get_bytes_left(gb) && pixels_read < dbuf_len) { + bits = bytestream2_get_byteu(gb); if (bits) { if (non_mod != 1 || bits != 1) { @@ -631,16 +632,17 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, } pixels_read++; } else { - bits = *(*srcbuf)++; + bits = bytestream2_get_byte(gb); run_length = bits & 0x7f; if ((bits & 0x80) == 0) { if (run_length == 0) { + *srcbuf += bytestream2_tell(gb); return pixels_read; } bits = 0; } else { - bits = *(*srcbuf)++; + bits = bytestream2_get_byte(gb); } if (non_mod == 1 && bits == 1) pixels_read += run_length; @@ -655,9 +657,10 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, } } - if (*(*srcbuf)++) + if (bytestream2_get_byte(gb)) av_log(avctx, AV_LOG_ERROR, "line overflow\n"); + *srcbuf += bytestream2_tell(gb); return pixels_read; } |