History

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 a705bcd763e344fac191e157ffeddc285388b7fa 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.

Scott Theisen committed 1 year ago

Commit 8ad2d191 parent 9305a1e1 file · +10 −9Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/mpeg12dec.c+10−9
@@ -1975,9 +1975,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, · 1974 unmodified lines
19751975 ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
19761976 if (ret >= 0) {
19771977 uint8_t field, cc1, cc2;
1978− uint8_t *cap = s1->a53_buf_ref->data;
1978+ uint8_t *cap = s1->a53_buf_ref->data + old_size;
19791979
1980− memset(s1->a53_buf_ref->data + old_size, 0, cc_count * 3);
1980+ memset(cap, 0, cc_count * 3);
19811981 for (i = 0; i < cc_count && get_bits_left(&gb) >= 26; i++) {
19821982 skip_bits(&gb, 2); // priority
19831983 field = get_bits(&gb, 2);
@@ -2047,7 +2047,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, · 63 unmodified lines
20472047 ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
20482048 if (ret >= 0) {
20492049 uint8_t field1 = !!(p[4] & 0x80);
2050− uint8_t *cap = s1->a53_buf_ref->data;
2050+ uint8_t *cap = s1->a53_buf_ref->data + old_size;
20512051 p += 5;
20522052 for (i = 0; i < cc_count; i++) {
20532053 cap[0] = (p[0] == 0xff && field1) ? 0xfc : 0xfd;
@@ -2113,13 +2113,14 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, · 59 unmodified lines
21132113
21142114 ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
21152115 if (ret >= 0) {
2116− s1->a53_buf_ref->data[0] = cc_header;
2117− s1->a53_buf_ref->data[1] = cc_data[0];
2118− s1->a53_buf_ref->data[2] = cc_data[1];
2116+ uint8_t *cap = s1->a53_buf_ref->data + old_size;
2117+ cap[0] = cc_header;
2118+ cap[1] = cc_data[0];
2119+ cap[2] = cc_data[1];
21192120 if (cc_count == 2) {
2120− s1->a53_buf_ref->data[3] = cc_header;
2121− s1->a53_buf_ref->data[4] = cc_data[2];
2122− s1->a53_buf_ref->data[5] = cc_data[3];
2121+ cap[3] = cc_header;
2122+ cap[4] = cc_data[2];
2123+ cap[5] = cc_data[3];
21232124 }
21242125 }
21252126

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