FFmpeg
Loading...
Searching...
No Matches
apv_metadata.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "libavutil/common.h"
20#include "libavutil/opt.h"
21
22#include "libavcodec/bsf.h"
24#include "libavcodec/cbs.h"
25#include "libavcodec/cbs_bsf.h"
26#include "libavcodec/cbs_apv.h"
27
36
37
40{
42
43 if (ctx->color_primaries >= 0 ||
44 ctx->transfer_characteristics >= 0 ||
45 ctx->matrix_coefficients >= 0 ||
46 ctx->full_range_flag >= 0) {
48
49 if (ctx->color_primaries >= 0)
50 hdr->color_primaries = ctx->color_primaries;
51 if (ctx->transfer_characteristics >= 0)
52 hdr->transfer_characteristics = ctx->transfer_characteristics;
53 if (ctx->matrix_coefficients >= 0)
54 hdr->matrix_coefficients = ctx->matrix_coefficients;
55 if (ctx->full_range_flag >= 0)
56 hdr->full_range_flag = ctx->full_range_flag;
57 }
58
59 return 0;
60}
61
64{
65 int err, i;
66
67 for (i = 0; i < frag->nb_units; i++) {
68 if (frag->units[i].type == APV_PBU_PRIMARY_FRAME) {
69 APVRawFrame *pbu = frag->units[i].content;
71 if (err < 0)
72 return err;
73 }
74 }
75
76 return 0;
77}
78
80 .codec_id = AV_CODEC_ID_APV,
81 .fragment_name = "access unit",
82 .unit_name = "PBU",
83 .update_fragment = &apv_metadata_update_fragment,
84};
85
90
91#define OFFSET(x) offsetof(APVMetadataContext, x)
92#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
94 { "color_primaries", "Set color primaries (section 5.3.5)",
96 { .i64 = -1 }, -1, 255, FLAGS },
97 { "transfer_characteristics", "Set transfer characteristics (section 5.3.5)",
99 { .i64 = -1 }, -1, 255, FLAGS },
100 { "matrix_coefficients", "Set matrix coefficients (section 5.3.5)",
101 OFFSET(matrix_coefficients), AV_OPT_TYPE_INT,
102 { .i64 = -1 }, -1, 255, FLAGS },
103
104 { "full_range_flag", "Set full range flag flag (section 5.3.5)",
105 OFFSET(full_range_flag), AV_OPT_TYPE_INT,
106 { .i64 = -1 }, -1, 1, FLAGS, .unit = "cr" },
107 { "tv", "TV (limited) range", 0, AV_OPT_TYPE_CONST,
108 { .i64 = 0 }, .flags = FLAGS, .unit = "cr" },
109 { "pc", "PC (full) range", 0, AV_OPT_TYPE_CONST,
110 { .i64 = 1 }, .flags = FLAGS, .unit = "cr" },
111
112 { NULL }
113};
114
116 .class_name = "apv_metadata_bsf",
117 .item_name = av_default_item_name,
118 .option = apv_metadata_options,
119 .version = LIBAVUTIL_VERSION_INT,
120};
121
125
127 .p.name = "apv_metadata",
128 .p.codec_ids = apv_metadata_codec_ids,
129 .p.priv_class = &apv_metadata_class,
130 .priv_data_size = sizeof(APVMetadataContext),
134};
static AVFormatContext * ctx
static const CBSBSFType apv_metadata_type
static int apv_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, CodedBitstreamFragment *frag)
static int apv_metadata_init(AVBSFContext *bsf)
static const AVClass apv_metadata_class
static const AVOption apv_metadata_options[]
#define OFFSET(x)
static int apv_metadata_update_frame_header(AVBSFContext *bsf, APVRawFrameHeader *hdr)
static enum AVCodecID apv_metadata_codec_ids[]
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
const FFBitStreamFilter ff_apv_metadata_bsf
int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt)
Filter operation for CBS BSF.
Definition cbs_bsf.c:97
av_cold void ff_cbs_bsf_generic_close(AVBSFContext *bsf)
Close a generic CBS BSF instance.
Definition cbs_bsf.c:191
av_cold int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type)
Initialise generic CBS BSF setup.
Definition cbs_bsf.c:146
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define FLAGS
Definition cmdutils.c:598
common internal and external API header
#define NULL
Definition coverity.c:32
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition csp.c:76
static AVPacket * pkt
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_APV
Definition codec_id.h:323
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
@ APV_PBU_PRIMARY_FRAME
Definition apv.h:27
static const struct TransferCharacteristics transfer_characteristics[]
AVOptions.
CBSBSFContext common
uint8_t color_primaries
Definition cbs_apv.h:72
uint8_t color_description_present_flag
Definition cbs_apv.h:71
uint8_t full_range_flag
Definition cbs_apv.h:75
uint8_t matrix_coefficients
Definition cbs_apv.h:74
uint8_t transfer_characteristics
Definition cbs_apv.h:73
APVRawFrameHeader frame_header
Definition cbs_apv.h:103
The bitstream filter state.
Definition bsf.h:68
void * priv_data
Opaque filter-specific private data.
Definition bsf.h:83
Describe the class of an AVClass context structure.
Definition log.h:76
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
Coded bitstream fragment structure, combining one or more units.
Definition cbs.h:129
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
Definition cbs.h:175
int nb_units
Number of units in this fragment.
Definition cbs.h:160
void * content
Pointer to the decomposed form of this unit.
Definition cbs.h:114
CodedBitstreamUnitType type
Codec-specific type of this unit.
Definition cbs.h:81
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29