You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/dvbsubdec: convert dvbsub_read_8bit_string to bytestream reader
No change in functionality. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@ -612,15 +612,16 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx,
|
|||||||
const uint8_t **srcbuf, int buf_size,
|
const uint8_t **srcbuf, int buf_size,
|
||||||
int non_mod, uint8_t *map_table, int x_pos)
|
int non_mod, uint8_t *map_table, int x_pos)
|
||||||
{
|
{
|
||||||
const uint8_t *sbuf_end = (*srcbuf) + buf_size;
|
|
||||||
int bits;
|
int bits;
|
||||||
int run_length;
|
int run_length;
|
||||||
int pixels_read = x_pos;
|
int pixels_read = x_pos;
|
||||||
|
GetByteContext gb0, *const gb = &gb0;
|
||||||
|
|
||||||
|
bytestream2_init(gb, *srcbuf, buf_size);
|
||||||
destbuf += x_pos;
|
destbuf += x_pos;
|
||||||
|
|
||||||
while (*srcbuf < sbuf_end && pixels_read < dbuf_len) {
|
while (bytestream2_get_bytes_left(gb) && pixels_read < dbuf_len) {
|
||||||
bits = *(*srcbuf)++;
|
bits = bytestream2_get_byteu(gb);
|
||||||
|
|
||||||
if (bits) {
|
if (bits) {
|
||||||
if (non_mod != 1 || bits != 1) {
|
if (non_mod != 1 || bits != 1) {
|
||||||
@ -631,16 +632,17 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
pixels_read++;
|
pixels_read++;
|
||||||
} else {
|
} else {
|
||||||
bits = *(*srcbuf)++;
|
bits = bytestream2_get_byte(gb);
|
||||||
run_length = bits & 0x7f;
|
run_length = bits & 0x7f;
|
||||||
if ((bits & 0x80) == 0) {
|
if ((bits & 0x80) == 0) {
|
||||||
if (run_length == 0) {
|
if (run_length == 0) {
|
||||||
|
*srcbuf += bytestream2_tell(gb);
|
||||||
return pixels_read;
|
return pixels_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
bits = 0;
|
bits = 0;
|
||||||
} else {
|
} else {
|
||||||
bits = *(*srcbuf)++;
|
bits = bytestream2_get_byte(gb);
|
||||||
}
|
}
|
||||||
if (non_mod == 1 && bits == 1)
|
if (non_mod == 1 && bits == 1)
|
||||||
pixels_read += run_length;
|
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");
|
av_log(avctx, AV_LOG_ERROR, "line overflow\n");
|
||||||
|
|
||||||
|
*srcbuf += bytestream2_tell(gb);
|
||||||
return pixels_read;
|
return pixels_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user