Signed-off-by: James Almer <jamrial@gmail.com>tags/n4.4
@@ -3060,9 +3060,10 @@ h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser" | |||
h264_mf_encoder_deps="mediafoundation" | |||
h264_mmal_decoder_deps="mmal" | |||
h264_nvenc_encoder_deps="nvenc" | |||
h264_nvenc_encoder_select="atsc_a53" | |||
h264_omx_encoder_deps="omx" | |||
h264_qsv_decoder_select="h264_mp4toannexb_bsf qsvdec" | |||
h264_qsv_encoder_select="qsvenc" | |||
h264_qsv_encoder_select="atsc_a53 qsvenc" | |||
h264_rkmpp_decoder_deps="rkmpp" | |||
h264_rkmpp_decoder_select="h264_mp4toannexb_bsf" | |||
h264_vaapi_encoder_select="cbs_h264 vaapi_encode" | |||
@@ -3076,6 +3077,7 @@ hevc_mediacodec_decoder_deps="mediacodec" | |||
hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser" | |||
hevc_mf_encoder_deps="mediafoundation" | |||
hevc_nvenc_encoder_deps="nvenc" | |||
hevc_nvenc_encoder_select="atsc_a53" | |||
hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec" | |||
hevc_qsv_encoder_select="hevcparse qsvenc" | |||
hevc_rkmpp_decoder_deps="rkmpp" | |||
@@ -3200,9 +3202,9 @@ pcm_mulaw_at_encoder_deps="audiotoolbox" | |||
pcm_mulaw_at_encoder_select="audio_frame_queue" | |||
chromaprint_muxer_deps="chromaprint" | |||
h264_videotoolbox_encoder_deps="pthreads" | |||
h264_videotoolbox_encoder_select="videotoolbox_encoder" | |||
h264_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder" | |||
hevc_videotoolbox_encoder_deps="pthreads" | |||
hevc_videotoolbox_encoder_select="videotoolbox_encoder" | |||
hevc_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder" | |||
libaom_av1_decoder_deps="libaom" | |||
libaom_av1_encoder_deps="libaom" | |||
libaom_av1_encoder_select="extract_extradata_bsf" | |||
@@ -3265,6 +3267,7 @@ libwebp_encoder_deps="libwebp" | |||
libwebp_anim_encoder_deps="libwebp" | |||
libx262_encoder_deps="libx262" | |||
libx264_encoder_deps="libx264" | |||
libx264_encoder_select="atsc_a53" | |||
libx264rgb_encoder_deps="libx264 x264_csp_bgr" | |||
libx264rgb_encoder_select="libx264_encoder" | |||
libx265_encoder_deps="libx265" | |||
@@ -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; | |||
@@ -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. | |||
@@ -363,21 +363,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 | |||
* | |||
@@ -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 | |||
@@ -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" | |||
@@ -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; | |||
@@ -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> | |||