aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-08-09 14:01:16 -0300
committerJames Almer <jamrial@gmail.com>2020-08-15 13:01:25 -0300
commit0de01da1d2d912d3cebf528b188dc5b89d6b7d69 (patch)
treee502384dcb0634959eef0d7b790f81d1e1870399 /libavcodec
parent1ab3ae6fd5b1866aa42cfc0c5d79700adb7281d8 (diff)
downloadffmpeg-0de01da1d2d912d3cebf528b188dc5b89d6b7d69.tar.gz
avcodec: move ff_alloc_a53_sei() to atsc_53
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/atsc_a53.c43
-rw-r--r--libavcodec/atsc_a53.h17
-rw-r--r--libavcodec/internal.h15
-rw-r--r--libavcodec/libx264.c1
-rw-r--r--libavcodec/nvenc.c1
-rw-r--r--libavcodec/utils.c43
-rw-r--r--libavcodec/videotoolboxenc.c1
7 files changed, 63 insertions, 58 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;
diff --git a/libavcodec/atsc_a53.h b/libavcodec/atsc_a53.h
index a419d801b9..0622a55549 100644
--- a/libavcodec/atsc_a53.h
+++ b/libavcodec/atsc_a53.h
@@ -19,9 +19,26 @@
#ifndef AVCODEC_ATSC_A53_H
#define AVCODEC_ATSC_A53_H
+#include <stddef.h>
#include <stdint.h>
#include "libavutil/buffer.h"
+#include "libavutil/frame.h"
+
+/**
+ * Check AVFrame for A53 side data and allocate and fill SEI message with A53 info
+ *
+ * @param frame Raw frame to get A53 side data from
+ * @param prefix_len Number of bytes to allocate before SEI message
+ * @param data Pointer to a variable to store allocated memory
+ * Upon return the variable will hold NULL on error or if frame has no A53 info.
+ * Otherwise it will point to prefix_len uninitialized bytes followed by
+ * *sei_size SEI message
+ * @param sei_size Pointer to a variable to store generated SEI message length
+ * @return Zero on success, negative error code on failure
+ */
+int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
+ void **data, size_t *sei_size);
/**
* Parse a data array for ATSC A53 Part 4 Closed Captions and store them in an AVBufferRef.
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 0a1c0a17ec..21486ae987 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -364,21 +364,6 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame);
AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx);
/**
- * Check AVFrame for A53 side data and allocate and fill SEI message with A53 info
- *
- * @param frame Raw frame to get A53 side data from
- * @param prefix_len Number of bytes to allocate before SEI message
- * @param data Pointer to a variable to store allocated memory
- * Upon return the variable will hold NULL on error or if frame has no A53 info.
- * Otherwise it will point to prefix_len uninitialized bytes followed by
- * *sei_size SEI message
- * @param sei_size Pointer to a variable to store generated SEI message length
- * @return Zero on success, negative error code on failure
- */
-int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
- void **data, size_t *sei_size);
-
-/**
* Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode info
*
* @param frame Raw frame to get S12M timecode side data from
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 347d29df27..ca7cc3a540 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -30,6 +30,7 @@
#include "avcodec.h"
#include "internal.h"
#include "packet_internal.h"
+#include "atsc_a53.h"
#if defined(_MSC_VER)
#define X264_API_IMPORTS 1
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 8f5036b699..ee8ba3cb39 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -31,6 +31,7 @@
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
+#include "atsc_a53.h"
#include "encode.h"
#include "internal.h"
#include "packet_internal.h"
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5a2a90b030..1814b417fc 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2204,49 +2204,6 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
return 0;
}
-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;
-}
-
static unsigned bcd2uint(uint8_t bcd)
{
unsigned low = bcd & 0xf;
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index cc08cf6a50..e89cfaeed8 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -31,6 +31,7 @@
#include "libavutil/pixdesc.h"
#include "internal.h"
#include <pthread.h>
+#include "atsc_a53.h"
#include "h264.h"
#include "h264_sei.h"
#include <dlfcn.h>