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.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -1975,9 +1975,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, · 1974 unmodified lines | ||
| 1975 | 1975 | ret = av_buffer_realloc(&s1->a53_buf_ref, new_size); |
| 1976 | 1976 | if (ret >= 0) { |
| 1977 | 1977 | 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; | |
| 1979 | 1979 | |
| 1980 | − memset(s1->a53_buf_ref->data + old_size, 0, cc_count * 3); | |
| 1980 | + memset(cap, 0, cc_count * 3); | |
| 1981 | 1981 | for (i = 0; i < cc_count && get_bits_left(&gb) >= 26; i++) { |
| 1982 | 1982 | skip_bits(&gb, 2); // priority |
| 1983 | 1983 | field = get_bits(&gb, 2); |
| @@ -2047,7 +2047,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, · 63 unmodified lines | ||
| 2047 | 2047 | ret = av_buffer_realloc(&s1->a53_buf_ref, new_size); |
| 2048 | 2048 | if (ret >= 0) { |
| 2049 | 2049 | 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; | |
| 2051 | 2051 | p += 5; |
| 2052 | 2052 | for (i = 0; i < cc_count; i++) { |
| 2053 | 2053 | cap[0] = (p[0] == 0xff && field1) ? 0xfc : 0xfd; |
| @@ -2113,13 +2113,14 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, · 59 unmodified lines | ||
| 2113 | 2113 | |
| 2114 | 2114 | ret = av_buffer_realloc(&s1->a53_buf_ref, new_size); |
| 2115 | 2115 | 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]; | |
| 2119 | 2120 | 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]; | |
| 2123 | 2124 | } |
| 2124 | 2125 | } |
| 2125 | 2126 | |