summaryrefslogtreecommitdiff
path: root/libavcodec/libdav1d.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-08-07 16:05:13 -0300
committerJames Almer <jamrial@gmail.com>2020-08-15 13:01:08 -0300
commit6c1bf7c02e8ec5f3c0a432774373ba0e8448e499 (patch)
treefddfdc63a950d2a5ba200aad0148f156e45f757a /libavcodec/libdav1d.c
parent184192127701243de18111e37120a37637321f64 (diff)
avcodec/libdav1d: add support for A53 Closed Captions
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libdav1d.c')
-rw-r--r--libavcodec/libdav1d.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 132d344296..fd801c6fd5 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -26,7 +26,9 @@
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
+#include "atsc_a53.h"
#include "avcodec.h"
+#include "bytestream.h"
#include "decode.h"
#include "internal.h"
@@ -364,6 +366,34 @@ FF_ENABLE_DEPRECATION_WARNINGS
light->MaxCLL = p->content_light->max_content_light_level;
light->MaxFALL = p->content_light->max_frame_average_light_level;
}
+ if (p->itut_t35) {
+ GetByteContext gb;
+ unsigned int user_identifier;
+
+ bytestream2_init(&gb, p->itut_t35->payload, p->itut_t35->payload_size);
+ bytestream2_skip(&gb, 1); // terminal provider code
+ bytestream2_skip(&gb, 1); // terminal provider oriented code
+ user_identifier = bytestream2_get_be32(&gb);
+ switch (user_identifier) {
+ case MKBETAG('G', 'A', '9', '4'): { // closed captions
+ AVBufferRef *buf = NULL;
+
+ res = ff_parse_a53_cc(&buf, gb.buffer, bytestream2_get_bytes_left(&gb));
+ if (res < 0)
+ goto fail;
+ if (!res)
+ break;
+
+ if (!av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, buf))
+ av_buffer_unref(&buf);
+
+ c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+ break;
+ }
+ default: // ignore unsupported identifiers
+ break;
+ }
+ }
res = 0;
fail: