FFmpeg
Loading...
Searching...
No Matches
cbs_mpeg2.c File Reference
#include "libavutil/avassert.h"
#include "cbs.h"
#include "cbs_internal.h"
#include "cbs_mpeg2.h"
#include "startcode.h"
#include "cbs_mpeg2_syntax_template.c"

Go to the source code of this file.

Macros

#define HEADER(name)
 
#define CHECK(call)
 
#define FUNC_NAME(rw, codec, name)
 
#define FUNC_MPEG2(rw, name)
 
#define FUNC(name)
 
#define SUBSCRIPTS(subs, ...)
 
#define uir(width, name)
 
#define uis(width, name, subs, ...)
 
#define uirs(width, name, subs, ...)
 
#define xui(width, name, var, range_min, range_max, subs, ...)
 
#define sis(width, name, subs, ...)
 
#define marker_bit()
 
#define bit(string, value)
 
#define READ
 
#define READWRITE   read
 
#define RWContext   GetBitContext
 
#define ui(width, name)
 
#define xuia(width, string, var, range_min, range_max, subs, ...)
 
#define xsi(width, name, var, subs, ...)
 
#define nextbits(width, compare, var)
 
#define infer(name, value)
 
#define WRITE
 
#define READWRITE   write
 
#define RWContext   PutBitContext
 
#define ui(width, name)
 
#define xuia(width, string, var, range_min, range_max, subs, ...)
 
#define xsi(width, name, var, subs, ...)
 
#define nextbits(width, compare, var)
 
#define infer(name, value)
 
#define START(start_code, type, read_func, free_func)
 
#define START(start_code, type, func)
 

Functions

static int cbs_mpeg2_split_fragment (CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
 
static int cbs_mpeg2_read_unit (CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
 
static int cbs_mpeg2_write_header (CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
 
static int cbs_mpeg2_write_slice (CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
 
static int cbs_mpeg2_write_unit (CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
 
static int cbs_mpeg2_assemble_fragment (CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
 

Variables

static CodedBitstreamUnitTypeDescriptor cbs_mpeg2_unit_types []
 
const CodedBitstreamType ff_cbs_type_mpeg2
 

Macro Definition Documentation

◆ HEADER

#define HEADER ( name)
Value:
do { \
ff_cbs_trace_header(ctx, name); \
} while (0)
const char * name
Definition qsvenc.c:142
static AVFormatContext * ctx
Definition movenc.c:49

Definition at line 27 of file cbs_mpeg2.c.

◆ CHECK

#define CHECK ( call)
Value:
do { \
err = (call); \
if (err < 0) \
return err; \
} while (0)

Definition at line 31 of file cbs_mpeg2.c.

◆ FUNC_NAME

#define FUNC_NAME ( rw,
codec,
name )
Value:
cbs_ ## codec ## _ ## rw ## _ ## name
#define _

Definition at line 37 of file cbs_mpeg2.c.

◆ FUNC_MPEG2

#define FUNC_MPEG2 ( rw,
name )
Value:
FUNC_NAME(rw, mpeg2, name)
#define FUNC_NAME(rw, codec, name)
Definition cbs_av1.c:487

Definition at line 38 of file cbs_mpeg2.c.

◆ FUNC

#define FUNC ( name)
Value:
#define READWRITE
Definition cbs_h264.c:92
#define FUNC_MPEG2(rw, name)
Definition cbs_mpeg2.c:38

Definition at line 39 of file cbs_mpeg2.c.

◆ SUBSCRIPTS

#define SUBSCRIPTS ( subs,
... )
Value:
(subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
#define NULL
Definition coverity.c:32

Definition at line 41 of file cbs_mpeg2.c.

◆ uir

#define uir ( width,
name )
Value:
xui(width, name, current->name, 1, MAX_UINT_BITS(width), 0, )
#define MAX_UINT_BITS(length)
#define xui(width, name, var, range_min, range_max, subs,...)
Definition cbs_mpeg2.c:49
static struct @111144215057303131116103221376075045141373005341 current
#define width
Definition dsp.h:89

Definition at line 43 of file cbs_mpeg2.c.

Referenced by picture_coding_extension(), picture_header(), sequence_display_extension(), sequence_header(), and slice_header().

◆ uis

#define uis ( width,
name,
subs,
... )
Value:
xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)

Definition at line 45 of file cbs_mpeg2.c.

Referenced by user_data().

◆ uirs

#define uirs ( width,
name,
subs,
... )
Value:
xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__)

Definition at line 47 of file cbs_mpeg2.c.

Referenced by quant_matrix_extension(), and sequence_header().

◆ xui

#define xui ( width,
name,
var,
range_min,
range_max,
subs,
... )
Value:
xuia(width, #name, var, range_min, range_max, subs, __VA_ARGS__)
#define xuia(width, string, var, range_min, range_max, subs,...)
Definition cbs_mpeg2.c:72

Definition at line 49 of file cbs_mpeg2.c.

◆ sis

#define sis ( width,
name,
subs,
... )
Value:
xsi(width, name, current->name, subs, __VA_ARGS__)
#define xsi(width, name, var, subs,...)
Definition cbs_mpeg2.c:80

Definition at line 51 of file cbs_mpeg2.c.

Referenced by picture_display_extension().

◆ marker_bit

#define marker_bit ( )
Value:
bit("marker_bit", 1)
#define bit(string, value)
Definition cbs_mpeg2.c:56

Definition at line 54 of file cbs_mpeg2.c.

Referenced by picture_display_extension(), sequence_display_extension(), sequence_extension(), and sequence_header().

◆ bit

◆ READ

#define READ

Definition at line 62 of file cbs_mpeg2.c.

◆ READWRITE [1/2]

#define READWRITE   read

Definition at line 63 of file cbs_mpeg2.c.

◆ RWContext [1/2]

#define RWContext   GetBitContext

Definition at line 64 of file cbs_mpeg2.c.

◆ ui [1/2]

◆ xuia [1/2]

#define xuia ( width,
string,
var,
range_min,
range_max,
subs,
... )
Value:
do { \
uint32_t value; \
CHECK(ff_cbs_read_unsigned(ctx, rw, width, string, \
SUBSCRIPTS(subs, __VA_ARGS__), \
&value, range_min, range_max)); \
var = value; \
} while (0)
#define SUBSCRIPTS(subs,...)
Definition cbs_apv.c:65

Definition at line 72 of file cbs_mpeg2.c.

Referenced by extra_information().

◆ xsi [1/2]

#define xsi ( width,
name,
var,
subs,
... )
Value:
do { \
CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), &value, \
var = value; \
} while (0)
int32_t
#define MAX_INT_BITS(length)
#define MIN_INT_BITS(length)

Definition at line 80 of file cbs_mpeg2.c.

◆ nextbits [1/2]

#define nextbits ( width,
compare,
var )
Value:
(get_bits_left(rw) >= width && \
(var = show_bits(rw, width)) == (compare))
static int get_bits_left(GetBitContext *gb)
Definition get_bits.h:688
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition get_bits.h:373
static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, int offy)

Definition at line 89 of file cbs_mpeg2.c.

Referenced by extra_information(), and slice_header().

◆ infer [1/2]

#define infer ( name,
value )
Value:
do { \
current->name = value; \
} while (0)

Definition at line 93 of file cbs_mpeg2.c.

◆ WRITE

#define WRITE

Definition at line 109 of file cbs_mpeg2.c.

◆ READWRITE [2/2]

#define READWRITE   write

Definition at line 63 of file cbs_mpeg2.c.

◆ RWContext [2/2]

#define RWContext   PutBitContext

Definition at line 64 of file cbs_mpeg2.c.

◆ ui [2/2]

#define ui ( width,
name )
Value:
do { \
CHECK(ff_cbs_write_simple_unsigned(ctx, rw, width, #name, \
current->name)); \
} while (0)

Definition at line 66 of file cbs_mpeg2.c.

◆ xuia [2/2]

#define xuia ( width,
string,
var,
range_min,
range_max,
subs,
... )
Value:
do { \
CHECK(ff_cbs_write_unsigned(ctx, rw, width, string, \
SUBSCRIPTS(subs, __VA_ARGS__), \
var, range_min, range_max)); \
} while (0)

Definition at line 72 of file cbs_mpeg2.c.

◆ xsi [2/2]

#define xsi ( width,
name,
var,
subs,
... )
Value:
do { \
CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \
SUBSCRIPTS(subs, __VA_ARGS__), var, \
} while (0)

Definition at line 80 of file cbs_mpeg2.c.

◆ nextbits [2/2]

#define nextbits ( width,
compare,
var )
Value:
(var)

Definition at line 89 of file cbs_mpeg2.c.

◆ infer [2/2]

#define infer ( name,
value )
Value:
do { \
if (current->name != (value)) { \
av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \
"%s does not match inferred value: " \
"%"PRId64", but should be %"PRId64".\n", \
#name, (int64_t)current->name, (int64_t)(value)); \
} \
} while (0)
long long int64_t
Definition coverity.c:34
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216

Definition at line 93 of file cbs_mpeg2.c.

◆ START [1/2]

#define START ( start_code,
type,
read_func,
free_func )
Value:
case start_code: \
{ \
type *header = unit->content; \
err = cbs_mpeg2_read_ ## read_func(ctx, &gbc, header); \
if (err < 0) \
return err; \
} \
break;
cl_device_type type
static const uint8_t header[24]
Definition sdr2.c:68
static const uint8_t start_code[]

Referenced by cbs_mpeg2_read_unit(), and cbs_mpeg2_write_header().

◆ START [2/2]

#define START ( start_code,
type,
func )
Value:
case start_code: \
err = cbs_mpeg2_write_ ## func(ctx, pbc, unit->content); \
break;
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition jacosubdec.c:66

Function Documentation

◆ cbs_mpeg2_split_fragment()

static int cbs_mpeg2_split_fragment ( CodedBitstreamContext * ctx,
CodedBitstreamFragment * frag,
int header )
static

Definition at line 154 of file cbs_mpeg2.c.

◆ cbs_mpeg2_read_unit()

static int cbs_mpeg2_read_unit ( CodedBitstreamContext * ctx,
CodedBitstreamUnit * unit )
static

Definition at line 208 of file cbs_mpeg2.c.

◆ cbs_mpeg2_write_header()

static int cbs_mpeg2_write_header ( CodedBitstreamContext * ctx,
CodedBitstreamUnit * unit,
PutBitContext * pbc )
static

Definition at line 276 of file cbs_mpeg2.c.

Referenced by cbs_mpeg2_write_unit().

◆ cbs_mpeg2_write_slice()

static int cbs_mpeg2_write_slice ( CodedBitstreamContext * ctx,
CodedBitstreamUnit * unit,
PutBitContext * pbc )
static

Definition at line 304 of file cbs_mpeg2.c.

Referenced by cbs_mpeg2_write_unit().

◆ cbs_mpeg2_write_unit()

static int cbs_mpeg2_write_unit ( CodedBitstreamContext * ctx,
CodedBitstreamUnit * unit,
PutBitContext * pbc )
static

Definition at line 353 of file cbs_mpeg2.c.

◆ cbs_mpeg2_assemble_fragment()

static int cbs_mpeg2_assemble_fragment ( CodedBitstreamContext * ctx,
CodedBitstreamFragment * frag )
static

Definition at line 363 of file cbs_mpeg2.c.

Variable Documentation

◆ cbs_mpeg2_unit_types

CodedBitstreamUnitTypeDescriptor cbs_mpeg2_unit_types[]
static
Initial value:
= {
extra_information_picture.extra_information),
{
.nb_unit_types = CBS_UNIT_TYPE_RANGE,
.unit_type.range.start = 0x01,
.unit_type.range.end = 0xaf,
.content_size = sizeof(MPEG2RawSlice),
.type.ref = { .nb_offsets = 2,
.offsets = { 0x42 ,
0x42 } },
},
CBS_UNIT_TYPE_POD(MPEG2_START_EXTENSION, MPEG2RawExtensionData),
CBS_UNIT_TYPE_POD(MPEG2_START_GROUP, MPEG2RawGroupOfPicturesHeader),
}
#define CBS_UNIT_TYPE_POD(type_, structure)
@ CBS_UNIT_TYPE_RANGE
#define CBS_UNIT_TYPE_END_OF_LIST
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
@ MPEG2_START_PICTURE
Definition cbs_mpeg2.h:29
@ MPEG2_START_SEQUENCE_HEADER
Definition cbs_mpeg2.h:33
@ MPEG2_START_SEQUENCE_END
Definition cbs_mpeg2.h:36
@ MPEG2_START_EXTENSION
Definition cbs_mpeg2.h:35
@ MPEG2_START_GROUP
Definition cbs_mpeg2.h:37
@ MPEG2_START_USER_DATA
Definition cbs_mpeg2.h:32
static int FUNC user_data(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawUserData *current)

Definition at line 400 of file cbs_mpeg2.c.

◆ ff_cbs_type_mpeg2

const CodedBitstreamType ff_cbs_type_mpeg2
Initial value:
= {
.priv_data_size = sizeof(CodedBitstreamMPEG2Context),
.unit_types = cbs_mpeg2_unit_types,
.split_fragment = &cbs_mpeg2_split_fragment,
.read_unit = &cbs_mpeg2_read_unit,
.write_unit = &cbs_mpeg2_write_unit,
.assemble_fragment = &cbs_mpeg2_assemble_fragment,
}
static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition cbs_mpeg2.c:363
static int cbs_mpeg2_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition cbs_mpeg2.c:353
static CodedBitstreamUnitTypeDescriptor cbs_mpeg2_unit_types[]
Definition cbs_mpeg2.c:400
static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Definition cbs_mpeg2.c:154
static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition cbs_mpeg2.c:208
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition codec_id.h:52

Definition at line 427 of file cbs_mpeg2.c.