FFmpeg
Loading...
Searching...
No Matches
cbs_bsf.h
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#ifndef AVCODEC_CBS_BSF_H
20#define AVCODEC_CBS_BSF_H
21
22#include "libavutil/log.h"
23#include "libavutil/opt.h"
24
25#include "bsf.h"
26#include "codec_id.h"
27#include "cbs.h"
28#include "packet.h"
29
30
31typedef struct CBSBSFType {
33
34 // Name of a frame fragment in this codec (e.g. "access unit",
35 // "temporal unit").
36 const char *fragment_name;
37
38 // Name of a unit for this BSF, for use in error messages (e.g.
39 // "NAL unit", "OBU").
40 const char *unit_name;
41
42 // Update the content of a fragment with whatever metadata changes
43 // are desired. The associated AVPacket is provided so that any side
44 // data associated with the fragment can be inspected or edited. If
45 // pkt is NULL, then an extradata header fragment is being updated.
49
50// Common structure for all generic CBS BSF users. An instance of this
51// structure must be the first member of the BSF private context (to be
52// pointed to by AVBSFContext.priv_data).
61
62/**
63 * Table of all supported codec IDs.
64 *
65 * Terminated by AV_CODEC_ID_NONE.
66 */
67extern const enum AVCodecID ff_cbs_all_codec_ids[];
68
69/**
70 * Initialise generic CBS BSF setup.
71 *
72 * Creates the input and output CBS instances, and applies the filter to
73 * the extradata on the input codecpar if any is present.
74 *
75 * Since it calls the update_fragment() function immediately to deal with
76 * extradata, this should be called after any codec-specific setup is done
77 * (probably at the end of the FFBitStreamFilter.init function).
78 */
80
81/**
82 * Close a generic CBS BSF instance.
83 *
84 * If no other deinitialisation is required then this function can be used
85 * directly as FFBitStreamFilter.close.
86 */
88
89/**
90 * Filter operation for CBS BSF.
91 *
92 * Reads the input packet into a CBS fragment, calls update_fragment() on
93 * it, then writes the result to an output packet. If the input packet
94 * has AV_PKT_DATA_NEW_EXTRADATA side-data associated with it then it does
95 * the same thing to that new extradata to form the output side-data first.
96 *
97 * If the BSF does not do anything else then this function can be used
98 * directly as FFBitStreamFilter.filter.
99 */
101
102
103// Options for element manipulation.
104enum {
105 // Pass this element through unchanged.
107 // Insert this element, replacing any existing instances of it.
108 // Associated values may be provided explicitly (as additional options)
109 // or implicitly (either as side data or deduced from other parts of
110 // the stream).
112 // Remove this element if it appears in the stream.
114 // Extract this element to side data, so that further manipulation
115 // can happen elsewhere.
117};
118
119#define BSF_ELEMENT_OPTIONS_PIR(name, help, field, opt_flags) \
120 { name, help, OFFSET(field), AV_OPT_TYPE_INT, \
121 { .i64 = BSF_ELEMENT_PASS }, \
122 BSF_ELEMENT_PASS, BSF_ELEMENT_REMOVE, opt_flags, .unit = name }, \
123 { "pass", NULL, 0, AV_OPT_TYPE_CONST, \
124 { .i64 = BSF_ELEMENT_PASS }, .flags = opt_flags, .unit = name }, \
125 { "insert", NULL, 0, AV_OPT_TYPE_CONST, \
126 { .i64 = BSF_ELEMENT_INSERT }, .flags = opt_flags, .unit = name }, \
127 { "remove", NULL, 0, AV_OPT_TYPE_CONST, \
128 { .i64 = BSF_ELEMENT_REMOVE }, .flags = opt_flags, .unit = name }
129
130#define BSF_ELEMENT_OPTIONS_PIRE(name, help, field, opt_flags) \
131 { name, help, OFFSET(field), AV_OPT_TYPE_INT, \
132 { .i64 = BSF_ELEMENT_PASS }, \
133 BSF_ELEMENT_PASS, BSF_ELEMENT_EXTRACT, opt_flags, .unit = name }, \
134 { "pass", NULL, 0, AV_OPT_TYPE_CONST, \
135 { .i64 = BSF_ELEMENT_PASS }, .flags = opt_flags, .unit = name }, \
136 { "insert", NULL, 0, AV_OPT_TYPE_CONST, \
137 { .i64 = BSF_ELEMENT_INSERT }, .flags = opt_flags, .unit = name }, \
138 { "remove", NULL, 0, AV_OPT_TYPE_CONST, \
139 { .i64 = BSF_ELEMENT_REMOVE }, .flags = opt_flags, .unit = name }, \
140 { "extract", NULL, 0, AV_OPT_TYPE_CONST, \
141 { .i64 = BSF_ELEMENT_EXTRACT }, .flags = opt_flags, .unit = name } \
142
143
144#endif /* AVCODEC_CBS_BSF_H */
enum AVCodecID ff_cbs_all_codec_ids[]
Table of all supported codec IDs.
Definition cbs_bsf.c:25
int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt)
Filter operation for CBS BSF.
Definition cbs_bsf.c:97
int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type)
Initialise generic CBS BSF setup.
Definition cbs_bsf.c:146
void ff_cbs_bsf_generic_close(AVBSFContext *bsf)
Close a generic CBS BSF instance.
Definition cbs_bsf.c:191
@ BSF_ELEMENT_REMOVE
Definition cbs_bsf.h:113
@ BSF_ELEMENT_INSERT
Definition cbs_bsf.h:111
@ BSF_ELEMENT_PASS
Definition cbs_bsf.h:106
@ BSF_ELEMENT_EXTRACT
Definition cbs_bsf.h:116
static AVPacket * pkt
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
cl_device_type type
AVOptions.
The bitstream filter state.
Definition bsf.h:68
Describe the class of an AVClass context structure.
Definition log.h:76
This structure stores compressed data.
Definition packet.h:580
CodedBitstreamContext * input
Definition cbs_bsf.h:57
CodedBitstreamFragment fragment
Definition cbs_bsf.h:59
const CBSBSFType * type
Definition cbs_bsf.h:55
CodedBitstreamContext * output
Definition cbs_bsf.h:58
enum AVCodecID codec_id
Definition cbs_bsf.h:32
const char * unit_name
Definition cbs_bsf.h:40
const char * fragment_name
Definition cbs_bsf.h:36
int(* update_fragment)(AVBSFContext *bsf, AVPacket *pkt, CodedBitstreamFragment *frag)
Definition cbs_bsf.h:46
Context structure for coded bitstream operations.
Definition cbs.h:226
Coded bitstream fragment structure, combining one or more units.
Definition cbs.h:129