libavcodec/mpeg12dec: append CC data to a53_buf_ref

In mpeg_decode_a53_cc() only the A/53 part 4 CC data ("GA94") is saved between
frames. The other formats incorrectly created a larger buffer than they use
since a705bcd763 because they did not append to
the previous data.

The a53_buf_ref is added to the frame in mpeg_field_start() which will only be
called in decode_chunks() if not all of the picture data slices are skipped.

For these formats, utilize the data added to the buffer in case frames are skipped
(concatenating the CC data until a frame can be exported), in a similar fashion to
the A/53 part 4 logic.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Marth64 <marth64@proxyid.net>
This commit is contained in:
Scott Theisen 2024-12-14 16:49:16 -05:00 committed by Marth64
parent 9305a1edca
commit 8ad2d1919f

View file

@ -1975,9 +1975,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
if (ret >= 0) {
uint8_t field, cc1, cc2;
uint8_t *cap = s1->a53_buf_ref->data;
uint8_t *cap = s1->a53_buf_ref->data + old_size;
memset(s1->a53_buf_ref->data + old_size, 0, cc_count * 3);
memset(cap, 0, cc_count * 3);
for (i = 0; i < cc_count && get_bits_left(&gb) >= 26; i++) {
skip_bits(&gb, 2); // priority
field = get_bits(&gb, 2);
@ -2047,7 +2047,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
if (ret >= 0) {
uint8_t field1 = !!(p[4] & 0x80);
uint8_t *cap = s1->a53_buf_ref->data;
uint8_t *cap = s1->a53_buf_ref->data + old_size;
p += 5;
for (i = 0; i < cc_count; i++) {
cap[0] = (p[0] == 0xff && field1) ? 0xfc : 0xfd;
@ -2113,13 +2113,14 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
if (ret >= 0) {
s1->a53_buf_ref->data[0] = cc_header;
s1->a53_buf_ref->data[1] = cc_data[0];
s1->a53_buf_ref->data[2] = cc_data[1];
uint8_t *cap = s1->a53_buf_ref->data + old_size;
cap[0] = cc_header;
cap[1] = cc_data[0];
cap[2] = cc_data[1];
if (cc_count == 2) {
s1->a53_buf_ref->data[3] = cc_header;
s1->a53_buf_ref->data[4] = cc_data[2];
s1->a53_buf_ref->data[5] = cc_data[3];
cap[3] = cc_header;
cap[4] = cc_data[2];
cap[5] = cc_data[3];
}
}