FFmpeg  4.3
Macros | Functions | Variables
cbs_mpeg2.c File Reference
#include "libavutil/avassert.h"
#include "cbs.h"
#include "cbs_internal.h"
#include "cbs_mpeg2.h"
#include "internal.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)   cbs_ ## codec ## _ ## rw ## _ ## name
 
#define FUNC_MPEG2(rw, name)   FUNC_NAME(rw, mpeg2, name)
 
#define FUNC(name)   FUNC_MPEG2(READWRITE, name)
 
#define SUBSCRIPTS(subs, ...)   (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
 
#define ui(width, name)   xui(width, name, current->name, 0, MAX_UINT_BITS(width), 0, )
 
#define uir(width, name)   xui(width, name, current->name, 1, MAX_UINT_BITS(width), 0, )
 
#define uis(width, name, subs, ...)   xui(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__)
 
#define uirs(width, name, subs, ...)   xui(width, name, current->name, 1, MAX_UINT_BITS(width), subs, __VA_ARGS__)
 
#define xui(width, name, var, range_min, range_max, subs, ...)   xuia(width, #name, var, range_min, range_max, subs, __VA_ARGS__)
 
#define sis(width, name, subs, ...)   xsi(width, name, current->name, subs, __VA_ARGS__)
 
#define marker_bit()   bit("marker_bit", 1)
 
#define bit(string, value)
 
#define READ
 
#define READWRITE   read
 
#define RWContext   GetBitContext
 
#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 xuia(width, string, var, range_min, range_max, subs, ...)
 
#define xsi(width, name, var, subs, ...)
 
#define nextbits(width, compare, var)   (var)
 
#define infer(name, value)
 
#define START(start_code, type, read_func, free_func)
 
#define START(start_code, type, func)
 

Functions

static void cbs_mpeg2_free_picture_header (void *opaque, uint8_t *content)
 
static void cbs_mpeg2_free_user_data (void *opaque, uint8_t *content)
 
static void cbs_mpeg2_free_slice (void *opaque, uint8_t *content)
 
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

const CodedBitstreamType ff_cbs_type_mpeg2
 

Macro Definition Documentation

◆ HEADER

#define HEADER (   name)
Value:
do { \
ff_cbs_trace_header(ctx, name); \
} while (0)

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 
)    cbs_ ## codec ## _ ## rw ## _ ## name

Definition at line 37 of file cbs_mpeg2.c.

◆ FUNC_MPEG2

#define FUNC_MPEG2 (   rw,
  name 
)    FUNC_NAME(rw, mpeg2, name)

Definition at line 38 of file cbs_mpeg2.c.

◆ FUNC

#define FUNC (   name)    FUNC_MPEG2(READWRITE, name)

Definition at line 39 of file cbs_mpeg2.c.

◆ SUBSCRIPTS

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

Definition at line 41 of file cbs_mpeg2.c.

◆ ui

#define ui (   width,
  name 
)    xui(width, name, current->name, 0, MAX_UINT_BITS(width), 0, )

Definition at line 43 of file cbs_mpeg2.c.

◆ uir

#define uir (   width,
  name 
)    xui(width, name, current->name, 1, MAX_UINT_BITS(width), 0, )

Definition at line 45 of file cbs_mpeg2.c.

◆ uis

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

Definition at line 47 of file cbs_mpeg2.c.

◆ uirs

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

Definition at line 49 of file cbs_mpeg2.c.

◆ xui

#define xui (   width,
  name,
  var,
  range_min,
  range_max,
  subs,
  ... 
)    xuia(width, #name, var, range_min, range_max, subs, __VA_ARGS__)

Definition at line 51 of file cbs_mpeg2.c.

◆ sis

#define sis (   width,
  name,
  subs,
  ... 
)    xsi(width, name, current->name, subs, __VA_ARGS__)

Definition at line 53 of file cbs_mpeg2.c.

◆ marker_bit

#define marker_bit ( )    bit("marker_bit", 1)

Definition at line 56 of file cbs_mpeg2.c.

◆ bit

#define bit (   string,
  value 
)
Value:
do { \
av_unused uint32_t bit = value; \
xuia(1, string, bit, value, value, 0, ); \
} while (0)

Definition at line 58 of file cbs_mpeg2.c.

◆ READ

#define READ

Definition at line 64 of file cbs_mpeg2.c.

◆ READWRITE [1/2]

#define READWRITE   read

Definition at line 105 of file cbs_mpeg2.c.

◆ RWContext [1/2]

#define RWContext   GetBitContext

Definition at line 106 of file cbs_mpeg2.c.

◆ 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)

Definition at line 108 of file cbs_mpeg2.c.

◆ xsi [1/2]

#define xsi (   width,
  name,
  var,
  subs,
  ... 
)
Value:
do { \
int32_t value; \
SUBSCRIPTS(subs, __VA_ARGS__), &value, \
var = value; \
} while (0)

Definition at line 114 of file cbs_mpeg2.c.

◆ nextbits [1/2]

#define nextbits (   width,
  compare,
  var 
)
Value:
(var = show_bits(rw, width)) == (compare))

Definition at line 121 of file cbs_mpeg2.c.

◆ infer [1/2]

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

Definition at line 123 of file cbs_mpeg2.c.

◆ WRITE

#define WRITE

Definition at line 104 of file cbs_mpeg2.c.

◆ READWRITE [2/2]

#define READWRITE   write

Definition at line 105 of file cbs_mpeg2.c.

◆ RWContext [2/2]

#define RWContext   PutBitContext

Definition at line 106 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 108 of file cbs_mpeg2.c.

◆ xsi [2/2]

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

Definition at line 114 of file cbs_mpeg2.c.

◆ nextbits [2/2]

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

Definition at line 121 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)

Definition at line 123 of file cbs_mpeg2.c.

◆ START [1/2]

#define START (   start_code,
  type,
  read_func,
  free_func 
)
Value:
case start_code: \
{ \
type *header; \
sizeof(*header), free_func); \
if (err < 0) \
return err; \
header = unit->content; \
err = cbs_mpeg2_read_ ## read_func(ctx, &gbc, header); \
if (err < 0) \
return err; \
} \
break;

◆ START [2/2]

#define START (   start_code,
  type,
  func 
)
Value:
case start_code: \
err = cbs_mpeg2_write_ ## func(ctx, pbc, unit->content); \
break;

Function Documentation

◆ cbs_mpeg2_free_picture_header()

static void cbs_mpeg2_free_picture_header ( void opaque,
uint8_t content 
)
static

Definition at line 143 of file cbs_mpeg2.c.

Referenced by cbs_mpeg2_read_unit().

◆ cbs_mpeg2_free_user_data()

static void cbs_mpeg2_free_user_data ( void opaque,
uint8_t content 
)
static

Definition at line 150 of file cbs_mpeg2.c.

Referenced by cbs_mpeg2_read_unit().

◆ cbs_mpeg2_free_slice()

static void cbs_mpeg2_free_slice ( void opaque,
uint8_t content 
)
static

Definition at line 157 of file cbs_mpeg2.c.

Referenced by cbs_mpeg2_read_unit().

◆ cbs_mpeg2_split_fragment()

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

Definition at line 165 of file cbs_mpeg2.c.

◆ cbs_mpeg2_read_unit()

static int cbs_mpeg2_read_unit ( CodedBitstreamContext ctx,
CodedBitstreamUnit unit 
)
static

Definition at line 224 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 299 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 327 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 376 of file cbs_mpeg2.c.

◆ cbs_mpeg2_assemble_fragment()

static int cbs_mpeg2_assemble_fragment ( CodedBitstreamContext ctx,
CodedBitstreamFragment frag 
)
static

Definition at line 386 of file cbs_mpeg2.c.

Variable Documentation

◆ ff_cbs_type_mpeg2

const CodedBitstreamType ff_cbs_type_mpeg2
Initial value:
= {
.priv_data_size = sizeof(CodedBitstreamMPEG2Context),
.split_fragment = &cbs_mpeg2_split_fragment,
.read_unit = &cbs_mpeg2_read_unit,
.write_unit = &cbs_mpeg2_write_unit,
.assemble_fragment = &cbs_mpeg2_assemble_fragment,
}

Definition at line 423 of file cbs_mpeg2.c.

func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
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
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:849
rw
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug rw
Definition: fate.txt:150
start_code
static const uint8_t start_code[]
Definition: videotoolboxenc.c:178
MAX_INT_BITS
#define MAX_INT_BITS(length)
Definition: cbs_internal.h:102
SUBSCRIPTS
#define SUBSCRIPTS(subs,...)
Definition: cbs_mpeg2.c:41
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:58
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
width
#define width
ctx
AVFormatContext * ctx
Definition: movenc.c:48
cbs_mpeg2_write_unit
static int cbs_mpeg2_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
Definition: cbs_mpeg2.c:376
cbs_mpeg2_split_fragment
static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
Definition: cbs_mpeg2.c:165
header
static const uint8_t header[24]
Definition: sdr2.c:67
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
cbs_mpeg2_assemble_fragment
static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Definition: cbs_mpeg2.c:386
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
show_bits
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:446
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
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
CodedBitstreamMPEG2Context
Definition: cbs_mpeg2.h:220
compare
static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, int offy)
Definition: vf_find_rect.c:104
cbs_mpeg2_read_unit
static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Definition: cbs_mpeg2.c:224
ff_cbs_alloc_unit_content
int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, size_t size, void(*free)(void *opaque, uint8_t *data))
Definition: cbs.c:644
MIN_INT_BITS
#define MIN_INT_BITS(length)
Definition: cbs_internal.h:106
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:51