FFmpeg
cbs_internal.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_INTERNAL_H
20 #define AVCODEC_CBS_INTERNAL_H
21 
22 #include "avcodec.h"
23 #include "cbs.h"
24 #include "get_bits.h"
25 #include "put_bits.h"
26 
27 
28 typedef struct CodedBitstreamType {
30 
32 
33  // Split frag->data into coded bitstream units, creating the
34  // frag->units array. Fill data but not content on each unit.
35  // The header argument should be set if the fragment came from
36  // a header block, which may require different parsing for some
37  // codecs (e.g. the AVCC header in H.264).
40  int header);
41 
42  // Read the unit->data bitstream and decompose it, creating
43  // unit->content.
45  CodedBitstreamUnit *unit);
46 
47  // Write the data bitstream from unit->content into pbc.
48  // Return value AVERROR(ENOSPC) indicates that pbc was too small.
50  CodedBitstreamUnit *unit,
51  PutBitContext *pbc);
52 
53  // Read the data from all of frag->units and assemble it into
54  // a bitstream for the whole fragment.
57 
58  // Free the codec internal state.
61 
62 
63 // Helper functions for trace output.
64 
66  const char *name);
67 
69  const char *name, const int *subscripts,
70  const char *bitstring, int64_t value);
71 
72 
73 // Helper functions for read/write of common bitstream elements, including
74 // generation of trace output.
75 
77  int width, const char *name,
78  const int *subscripts, uint32_t *write_to,
79  uint32_t range_min, uint32_t range_max);
80 
82  int width, const char *name,
83  const int *subscripts, uint32_t value,
84  uint32_t range_min, uint32_t range_max);
85 
87  int width, const char *name,
88  const int *subscripts, int32_t *write_to,
89  int32_t range_min, int32_t range_max);
90 
92  int width, const char *name,
93  const int *subscripts, int32_t value,
94  int32_t range_min, int32_t range_max);
95 
96 // The largest unsigned value representable in N bits, suitable for use as
97 // range_max in the above functions.
98 #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
99 
100 // The largest signed value representable in N bits, suitable for use as
101 // range_max in the above functions.
102 #define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
103 
104 // The smallest signed value representable in N bits, suitable for use as
105 // range_min in the above functions.
106 #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
107 
108 
115 
116 
117 #endif /* AVCODEC_CBS_INTERNAL_H */
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
CodedBitstreamType::close
void(* close)(CodedBitstreamContext *ctx)
Definition: cbs_internal.h:59
ff_cbs_type_vp9
const CodedBitstreamType ff_cbs_type_vp9
Definition: cbs_vp9.c:645
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:168
cbs.h
ff_cbs_read_signed
int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, int32_t *write_to, int32_t range_min, int32_t range_max)
Definition: cbs.c:564
CodedBitstreamUnit
Coded bitstream unit structure.
Definition: cbs.h:64
ff_cbs_write_unsigned
int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max)
Definition: cbs.c:528
GetBitContext
Definition: get_bits.h:61
ff_cbs_trace_syntax_element
void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, const char *name, const int *subscripts, const char *bitstring, int64_t value)
Definition: cbs.c:435
ff_cbs_type_mpeg2
const CodedBitstreamType ff_cbs_type_mpeg2
Definition: cbs_mpeg2.c:423
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:116
width
#define width
ff_cbs_read_unsigned
int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, const char *name, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max)
Definition: cbs.c:485
ctx
AVFormatContext * ctx
Definition: movenc.c:48
get_bits.h
CodedBitstreamType::codec_id
enum AVCodecID codec_id
Definition: cbs_internal.h:29
PutBitContext
Definition: put_bits.h:35
int32_t
int32_t
Definition: audio_convert.c:194
CodedBitstreamType::read_unit
int(* read_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition: cbs_internal.h:44
ff_cbs_trace_header
void ff_cbs_trace_header(CodedBitstreamContext *ctx, const char *name)
Definition: cbs.c:426
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:46
ff_cbs_type_jpeg
const CodedBitstreamType ff_cbs_type_jpeg
Definition: cbs_jpeg.c:461
header
static const uint8_t header[24]
Definition: sdr2.c:67
CodedBitstreamType
Definition: cbs_internal.h:28
ff_cbs_type_av1
const CodedBitstreamType ff_cbs_type_av1
Definition: cbs_av1.c:1265
CodedBitstreamType::priv_data_size
size_t priv_data_size
Definition: cbs_internal.h:31
CodedBitstreamType::write_unit
int(* write_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_internal.h:49
ff_cbs_write_signed
int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, const char *name, const int *subscripts, int32_t value, int32_t range_min, int32_t range_max)
Definition: cbs.c:607
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
avcodec.h
ff_cbs_type_h265
const CodedBitstreamType ff_cbs_type_h265
Definition: cbs_h2645.c:1521
CodedBitstreamType::assemble_fragment
int(* assemble_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_internal.h:55
CodedBitstreamType::split_fragment
int(* split_fragment)(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Definition: cbs_internal.h:38
int
int
Definition: ffmpeg_filter.c:192
put_bits.h
ff_cbs_type_h264
const CodedBitstreamType ff_cbs_type_h264
Definition: cbs_h2645.c:1508