46 const uint8_t *rpu,
size_t rpu_size,
92 ff_cbs_delete_unit(au, au->
nb_units - 1);
102 if (!rpu || rpu_size <= 0)
107 memcpy(
nal->data + 3, rpu, rpu_size);
109 nal->data_size = rpu_size + 3;
117 memcpy(
ref->data,
nal->data, 3);
118 memcpy(
ref->data + 3, rpu, rpu_size);
122 nal->data_size = rpu_size + 3;
124 nal->data_bit_padding = 0;
134 int provider_code, provider_oriented_code, rpu_size, ret;
150 provider_oriented_code != 0x800)
154 ff_cbs_delete_unit(frag,
i);
163 if (!rpu || rpu_size <= 1) {
186 .fragment_name =
"access unit",
187 .unit_name =
"NAL unit",
193 .fragment_name =
"temporal unit",
202 s->dec.logctx =
s->enc.logctx = bsf;
226 cfg->dv_md_compression =
s->compression;
227 if (
s->compression &&
s->dec.cfg.dv_profile < 8) {
229 "Dolby Vision profile %d.\n",
s->compression,
s->dec.cfg.dv_profile);
236 "found? Generating one, but results may be invalid.\n");
242 s->dec.cfg =
s->enc.cfg;
265#define OFFSET(x) offsetof(DoviRpuContext, x)
266#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
270 {
"none",
"Don't compress metadata", 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, .flags =
FLAGS, .unit =
"compression" },
277 .class_name =
"dovi_rpu_bsf",
288 .p.name =
"dovi_rpu",
static av_cold void close(AVCodecParserContext *s)
const FFBitStreamFilter ff_dovi_rpu_bsf
static int dovi_rpu_update_fragment_hevc(AVBSFContext *bsf, AVPacket *pkt, CodedBitstreamFragment *au)
static const CBSBSFType dovi_rpu_hevc_type
static int dovi_rpu_update_fragment_av1(AVBSFContext *bsf, AVPacket *pkt, CodedBitstreamFragment *frag)
static void dovi_rpu_close(AVBSFContext *bsf)
static int dovi_rpu_init(AVBSFContext *bsf)
static int update_rpu(AVBSFContext *bsf, const AVPacket *pkt, int flags, const uint8_t *rpu, size_t rpu_size, uint8_t **out_rpu, int *out_size)
static const AVOption dovi_rpu_options[]
static enum AVCodecID dovi_rpu_codec_ids[]
static const AVClass dovi_rpu_class
static const CBSBSFType dovi_rpu_av1_type
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt)
Filter operation for CBS BSF.
av_cold void ff_cbs_bsf_generic_close(AVBSFContext *bsf)
Close a generic CBS BSF instance.
av_cold int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type)
Initialise generic CBS BSF setup.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
common internal and external API header
#define FF_COMPLIANCE_NORMAL
av_cold void ff_dovi_ctx_flush(DOVIContext *s)
Partially reset the internal state.
void ff_dovi_ctx_unref(DOVIContext *s)
Completely reset a DOVIContext, preserving only logctx.
int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition)
Parse the contents of a Dolby Vision RPU and update the parsed values in the DOVIContext struct.
int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, int flags, uint8_t **out_rpu, int *out_size)
Synthesize a Dolby Vision RPU reflecting the current state.
@ FF_DOVI_WRAP_T35
wrap inside T.35+EMDF
@ FF_DOVI_COMPRESS_RPU
enable compression for this RPU
int ff_dovi_configure_from_codedpar(DOVIContext *s, AVCodecParameters *codecpar, const AVDOVIMetadata *metadata, enum AVDOVICompression compression, int strict_std_compliance)
Configure the encoder for Dolby Vision encoding.
int ff_dovi_get_metadata(DOVIContext *s, AVDOVIMetadata **out_metadata)
Get the decoded AVDOVIMetadata.
int(* init)(AVBSFContext *ctx)
static CheckasmConfig cfg
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
AVCodecID
Identify the syntax and semantics of the bitstream.
void av_packet_side_data_remove(AVPacketSideData *sd, int *pnb_sd, enum AVPacketSideDataType type)
Remove side data of the given type from a side data array.
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_buffer_is_writable(const AVBufferRef *buf)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
#define ITU_T_T35_PROVIDER_CODE_DOLBY
#define ITU_T_T35_COUNTRY_CODE_US
@ AV1_METADATA_TYPE_ITUT_T35
Memory handling functions.
union AV1RawOBU::@016362317061177152367125047142162076164261250366 obu
The bitstream filter state.
void * priv_data
Opaque filter-specific private data.
AVCodecParameters * par_in
Parameters of the input stream.
AVCodecParameters * par_out
Parameters of the output stream.
A reference to a data buffer.
Describe the class of an AVClass context structure.
int nb_coded_side_data
Amount of entries in coded_side_data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
This structure stores compressed data.
Coded bitstream fragment structure, combining one or more units.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
int nb_units
Number of units in this fragment.
Coded bitstream unit structure.
void * content
Pointer to the decomposed form of this unit.
CodedBitstreamUnitType type
Codec-specific type of this unit.
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static int ref[MAX_W *MAX_W]