diff options
author | James Almer <jamrial@gmail.com> | 2020-08-09 14:01:16 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-08-15 13:01:25 -0300 |
commit | 0de01da1d2d912d3cebf528b188dc5b89d6b7d69 (patch) | |
tree | e502384dcb0634959eef0d7b790f81d1e1870399 /libavcodec/atsc_a53.c | |
parent | 1ab3ae6fd5b1866aa42cfc0c5d79700adb7281d8 (diff) | |
download | ffmpeg-0de01da1d2d912d3cebf528b188dc5b89d6b7d69.tar.gz |
avcodec: move ff_alloc_a53_sei() to atsc_53
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/atsc_a53.c')
-rw-r--r-- | libavcodec/atsc_a53.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libavcodec/atsc_a53.c b/libavcodec/atsc_a53.c index b2d1490c0c..2d89ef50b9 100644 --- a/libavcodec/atsc_a53.c +++ b/libavcodec/atsc_a53.c @@ -22,6 +22,49 @@ #include "atsc_a53.h" #include "get_bits.h" +int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, + void **data, size_t *sei_size) +{ + AVFrameSideData *side_data = NULL; + uint8_t *sei_data; + + if (frame) + side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC); + + if (!side_data) { + *data = NULL; + return 0; + } + + *sei_size = side_data->size + 11; + *data = av_mallocz(*sei_size + prefix_len); + if (!*data) + return AVERROR(ENOMEM); + sei_data = (uint8_t*)*data + prefix_len; + + // country code + sei_data[0] = 181; + sei_data[1] = 0; + sei_data[2] = 49; + + /** + * 'GA94' is standard in North America for ATSC, but hard coding + * this style may not be the right thing to do -- other formats + * do exist. This information is not available in the side_data + * so we are going with this right now. + */ + AV_WL32(sei_data + 3, MKTAG('G', 'A', '9', '4')); + sei_data[7] = 3; + sei_data[8] = ((side_data->size/3) & 0x1f) | 0x40; + sei_data[9] = 0; + + memcpy(sei_data + 10, side_data->data, side_data->size); + + sei_data[side_data->size+10] = 255; + + return 0; +} + int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size) { AVBufferRef *buf = *pbuf; |