[FFmpeg-cvslog] libavcodec/mpeg12dec: append CC data to a53_buf_ref
Scott Theisen
git at videolan.org
Wed Jan 8 08:27:54 EET 2025
ffmpeg | branch: master | Scott Theisen <scott.the.elm at gmail.com> | Sat Dec 14 16:49:16 2024 -0500| [8ad2d1919fdf8a33f72761799367293bbb379b55] | committer: Marth64
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.
Reviewed-by: Marth64 <marth64 at proxyid.net>
Signed-off-by: Marth64 <marth64 at proxyid.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ad2d1919fdf8a33f72761799367293bbb379b55
---
libavcodec/mpeg12dec.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 8f4deeb10d..9bb995b5be 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -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];
}
}
More information about the ffmpeg-cvslog
mailing list