FFmpeg
Macros | Functions | Variables
mpeg4videodec.c File Reference
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/thread.h"
#include "error_resilience.h"
#include "hwconfig.h"
#include "idctdsp.h"
#include "internal.h"
#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodata.h"
#include "mpeg4video.h"
#include "h263.h"
#include "profiles.h"
#include "thread.h"
#include "xvididct.h"
#include "unary.h"

Go to the source code of this file.

Macros

#define UNCHECKED_BITSTREAM_READER   1
 
#define SPRITE_TRAJ_VLC_BITS   6
 
#define DC_VLC_BITS   9
 
#define MB_TYPE_B_VLC_BITS   4
 
#define STUDIO_INTRA_BITS   9
 
#define SET_QPEL_FUNC(postfix1, postfix2)
 
#define OFFSET(x)   offsetof(MpegEncContext, x)
 
#define FLAGS   AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY
 

Functions

void ff_mpeg4_pred_ac (MpegEncContext *s, int16_t *block, int n, int dir)
 Predict the ac. More...
 
static int mpeg4_is_resync (Mpeg4DecContext *ctx)
 check if the next stuff is a resync marker or the end. More...
 
static int mpeg4_decode_sprite_trajectory (Mpeg4DecContext *ctx, GetBitContext *gb)
 
static int decode_new_pred (Mpeg4DecContext *ctx, GetBitContext *gb)
 
int ff_mpeg4_decode_video_packet_header (Mpeg4DecContext *ctx)
 Decode the next video packet. More...
 
static void reset_studio_dc_predictors (MpegEncContext *s)
 
int ff_mpeg4_decode_studio_slice_header (Mpeg4DecContext *ctx)
 Decode the next video packet. More...
 
static int get_amv (Mpeg4DecContext *ctx, int n)
 Get the average motion vector for a GMC MB. More...
 
static int mpeg4_decode_dc (MpegEncContext *s, int n, int *dir_ptr)
 Decode the dc value. More...
 
static int mpeg4_decode_partition_a (Mpeg4DecContext *ctx)
 Decode first partition. More...
 
static int mpeg4_decode_partition_b (MpegEncContext *s, int mb_count)
 decode second partition. More...
 
int ff_mpeg4_decode_partitions (Mpeg4DecContext *ctx)
 Decode the first and second partition. More...
 
static int mpeg4_decode_block (Mpeg4DecContext *ctx, int16_t *block, int n, int coded, int intra, int rvlc)
 Decode a block. More...
 
static int mpeg4_decode_partitioned_mb (MpegEncContext *s, int16_t block[6][64])
 decode partition C of one MB. More...
 
static int mpeg4_decode_mb (MpegEncContext *s, int16_t block[6][64])
 
static void next_start_code_studio (GetBitContext *gb)
 
static int mpeg4_decode_studio_block (MpegEncContext *s, int32_t block[64], int n)
 
static int mpeg4_decode_dpcm_macroblock (MpegEncContext *s, int16_t macroblock[256], int n)
 
static int mpeg4_decode_studio_mb (MpegEncContext *s, int16_t block_[12][64])
 
static int mpeg4_decode_gop_header (MpegEncContext *s, GetBitContext *gb)
 
static int mpeg4_decode_profile_level (MpegEncContext *s, GetBitContext *gb, int *profile, int *level)
 
static int mpeg4_decode_visual_object (MpegEncContext *s, GetBitContext *gb)
 
static void mpeg4_load_default_matrices (MpegEncContext *s)
 
static int read_quant_matrix_ext (MpegEncContext *s, GetBitContext *gb)
 
static void extension_and_user_data (MpegEncContext *s, GetBitContext *gb, int id)
 
static int decode_studio_vol_header (Mpeg4DecContext *ctx, GetBitContext *gb)
 
static int decode_vol_header (Mpeg4DecContext *ctx, GetBitContext *gb)
 
static int decode_user_data (Mpeg4DecContext *ctx, GetBitContext *gb)
 Decode the user data stuff in the header. More...
 
int ff_mpeg4_workaround_bugs (AVCodecContext *avctx)
 
static int decode_vop_header (Mpeg4DecContext *ctx, GetBitContext *gb)
 
static void decode_smpte_tc (Mpeg4DecContext *ctx, GetBitContext *gb)
 
static int decode_studio_vop_header (Mpeg4DecContext *ctx, GetBitContext *gb)
 Decode the next studio vop header. More...
 
static int decode_studiovisualobject (Mpeg4DecContext *ctx, GetBitContext *gb)
 
int ff_mpeg4_decode_picture_header (Mpeg4DecContext *ctx, GetBitContext *gb, int header)
 Decode MPEG-4 headers. More...
 
av_cold void ff_mpeg4videodec_static_init (void)
 
int ff_mpeg4_frame_end (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 
static av_cold void mpeg4_init_static (void)
 
static av_cold int decode_init (AVCodecContext *avctx)
 

Variables

static VLC dc_lum
 
static VLC dc_chrom
 
static VLC sprite_trajectory
 
static VLC mb_type_b_vlc
 
static VLC studio_intra_tab [12]
 
static VLC studio_luma_dc
 
static VLC studio_chroma_dc
 
static const int mb_type_b_map [4]
 
static const uint8_t ac_state_tab [22][2]
 
static const AVOption mpeg4_options []
 
static const AVClass mpeg4_class
 
const AVCodec ff_mpeg4_decoder
 

Macro Definition Documentation

◆ UNCHECKED_BITSTREAM_READER

#define UNCHECKED_BITSTREAM_READER   1

Definition at line 23 of file mpeg4videodec.c.

◆ SPRITE_TRAJ_VLC_BITS

#define SPRITE_TRAJ_VLC_BITS   6

Definition at line 47 of file mpeg4videodec.c.

◆ DC_VLC_BITS

#define DC_VLC_BITS   9

Definition at line 48 of file mpeg4videodec.c.

◆ MB_TYPE_B_VLC_BITS

#define MB_TYPE_B_VLC_BITS   4

Definition at line 49 of file mpeg4videodec.c.

◆ STUDIO_INTRA_BITS

#define STUDIO_INTRA_BITS   9

Definition at line 50 of file mpeg4videodec.c.

◆ SET_QPEL_FUNC

#define SET_QPEL_FUNC (   postfix1,
  postfix2 
)
Value:
s->qdsp.put_ ## postfix1 = ff_put_ ## postfix2; \
s->qdsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2; \
s->qdsp.avg_ ## postfix1 = ff_avg_ ## postfix2;

◆ OFFSET

#define OFFSET (   x)    offsetof(MpegEncContext, x)

Definition at line 3568 of file mpeg4videodec.c.

◆ FLAGS

Definition at line 3569 of file mpeg4videodec.c.

Function Documentation

◆ ff_mpeg4_pred_ac()

void ff_mpeg4_pred_ac ( MpegEncContext s,
int16_t *  block,
int  n,
int  dir 
)

Predict the ac.

Parameters
nblock index (0-3 are luma, 4-5 are chroma)
dirthe ac prediction direction

Definition at line 71 of file mpeg4videodec.c.

Referenced by ff_msmpeg4_decode_block(), and mpeg4_decode_block().

◆ mpeg4_is_resync()

static int mpeg4_is_resync ( Mpeg4DecContext ctx)
inlinestatic

check if the next stuff is a resync marker or the end.

Returns
0 if not

Definition at line 126 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb(), and mpeg4_decode_partitioned_mb().

◆ mpeg4_decode_sprite_trajectory()

static int mpeg4_decode_sprite_trajectory ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 176 of file mpeg4videodec.c.

Referenced by decode_vop_header(), and ff_mpeg4_decode_video_packet_header().

◆ decode_new_pred()

static int decode_new_pred ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 429 of file mpeg4videodec.c.

Referenced by decode_vop_header(), and ff_mpeg4_decode_video_packet_header().

◆ ff_mpeg4_decode_video_packet_header()

int ff_mpeg4_decode_video_packet_header ( Mpeg4DecContext ctx)

Decode the next video packet.

Returns
<0 if something went wrong

Definition at line 445 of file mpeg4videodec.c.

Referenced by ff_h263_resync().

◆ reset_studio_dc_predictors()

static void reset_studio_dc_predictors ( MpegEncContext s)
static

◆ ff_mpeg4_decode_studio_slice_header()

int ff_mpeg4_decode_studio_slice_header ( Mpeg4DecContext ctx)

Decode the next video packet.

Returns
<0 if something went wrong

Definition at line 546 of file mpeg4videodec.c.

Referenced by decode_slice().

◆ get_amv()

static int get_amv ( Mpeg4DecContext ctx,
int  n 
)
inlinestatic

Get the average motion vector for a GMC MB.

Parameters
neither 0 for the x component or 1 for y
Returns
the average MV for a GMC MB

Definition at line 588 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb(), and mpeg4_decode_partition_a().

◆ mpeg4_decode_dc()

static int mpeg4_decode_dc ( MpegEncContext s,
int  n,
int dir_ptr 
)
inlinestatic

Decode the dc value.

Parameters
nblock index (0-3 are luma, 4-5 are chroma)
dir_ptrthe prediction direction will be stored here
Returns
the quantized dc

Definition at line 641 of file mpeg4videodec.c.

Referenced by mpeg4_decode_block(), mpeg4_decode_partition_a(), and mpeg4_decode_partition_b().

◆ mpeg4_decode_partition_a()

static int mpeg4_decode_partition_a ( Mpeg4DecContext ctx)
static

Decode first partition.

Returns
number of MBs decoded or <0 if an error occurred

Definition at line 688 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_partitions().

◆ mpeg4_decode_partition_b()

static int mpeg4_decode_partition_b ( MpegEncContext s,
int  mb_count 
)
static

decode second partition.

Returns
<0 if an error occurred

Definition at line 882 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_partitions().

◆ ff_mpeg4_decode_partitions()

int ff_mpeg4_decode_partitions ( Mpeg4DecContext ctx)

Decode the first and second partition.

Returns
<0 if error (and sets error type in the error_status_table)

Definition at line 975 of file mpeg4videodec.c.

Referenced by decode_slice().

◆ mpeg4_decode_block()

static int mpeg4_decode_block ( Mpeg4DecContext ctx,
int16_t *  block,
int  n,
int  coded,
int  intra,
int  rvlc 
)
inlinestatic

Decode a block.

Returns
<0 if an error occurred

Definition at line 1040 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb(), and mpeg4_decode_partitioned_mb().

◆ mpeg4_decode_partitioned_mb()

static int mpeg4_decode_partitioned_mb ( MpegEncContext s,
int16_t  block[6][64] 
)
static

decode partition C of one MB.

Returns
<0 if an error occurred

Definition at line 1311 of file mpeg4videodec.c.

Referenced by decode_vop_header().

◆ mpeg4_decode_mb()

static int mpeg4_decode_mb ( MpegEncContext s,
int16_t  block[6][64] 
)
static

Definition at line 1398 of file mpeg4videodec.c.

Referenced by decode_init(), and decode_vop_header().

◆ next_start_code_studio()

static void next_start_code_studio ( GetBitContext gb)
static

◆ mpeg4_decode_studio_block()

static int mpeg4_decode_studio_block ( MpegEncContext s,
int32_t  block[64],
int  n 
)
static

Definition at line 1815 of file mpeg4videodec.c.

Referenced by mpeg4_decode_studio_mb().

◆ mpeg4_decode_dpcm_macroblock()

static int mpeg4_decode_dpcm_macroblock ( MpegEncContext s,
int16_t  macroblock[256],
int  n 
)
static

Definition at line 1930 of file mpeg4videodec.c.

Referenced by mpeg4_decode_studio_mb().

◆ mpeg4_decode_studio_mb()

static int mpeg4_decode_studio_mb ( MpegEncContext s,
int16_t  block_[12][64] 
)
static

Definition at line 2013 of file mpeg4videodec.c.

Referenced by decode_studio_vop_header().

◆ mpeg4_decode_gop_header()

static int mpeg4_decode_gop_header ( MpegEncContext s,
GetBitContext gb 
)
static

Definition at line 2060 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ mpeg4_decode_profile_level()

static int mpeg4_decode_profile_level ( MpegEncContext s,
GetBitContext gb,
int profile,
int level 
)
static

Definition at line 2082 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ mpeg4_decode_visual_object()

static int mpeg4_decode_visual_object ( MpegEncContext s,
GetBitContext gb 
)
static

Definition at line 2096 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ mpeg4_load_default_matrices()

static void mpeg4_load_default_matrices ( MpegEncContext s)
static

Definition at line 2128 of file mpeg4videodec.c.

Referenced by decode_studio_vop_header(), and decode_vol_header().

◆ read_quant_matrix_ext()

static int read_quant_matrix_ext ( MpegEncContext s,
GetBitContext gb 
)
static

Definition at line 2145 of file mpeg4videodec.c.

Referenced by extension_and_user_data().

◆ extension_and_user_data()

static void extension_and_user_data ( MpegEncContext s,
GetBitContext gb,
int  id 
)
static

◆ decode_studio_vol_header()

static int decode_studio_vol_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 2211 of file mpeg4videodec.c.

Referenced by decode_vol_header().

◆ decode_vol_header()

static int decode_vol_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 2297 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ decode_user_data()

static int decode_user_data ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Decode the user data stuff in the header.

Also initializes divx/xvid/lavc_version/build.

Definition at line 2672 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ ff_mpeg4_workaround_bugs()

int ff_mpeg4_workaround_bugs ( AVCodecContext avctx)

Definition at line 2729 of file mpeg4videodec.c.

Referenced by ff_h263_decode_frame().

◆ decode_vop_header()

static int decode_vop_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 2847 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ decode_smpte_tc()

static void decode_smpte_tc ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 3121 of file mpeg4videodec.c.

Referenced by decode_studio_vop_header().

◆ decode_studio_vop_header()

static int decode_studio_vop_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Decode the next studio vop header.

Returns
<0 if something went wrong

Definition at line 3140 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ decode_studiovisualobject()

static int decode_studiovisualobject ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 3195 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

◆ ff_mpeg4_decode_picture_header()

int ff_mpeg4_decode_picture_header ( Mpeg4DecContext ctx,
GetBitContext gb,
int  header 
)

Decode MPEG-4 headers.

Parameters
headerIf set the absence of a VOP is not treated as error; otherwise, it is treated as such.
Returns
<0 if an error occurred FRAME_SKIPPED if a not coded VOP is found 0 else

Definition at line 3221 of file mpeg4videodec.c.

Referenced by ff_h263_decode_frame(), and mpeg4_decode_header().

◆ ff_mpeg4videodec_static_init()

av_cold void ff_mpeg4videodec_static_init ( void  )

Definition at line 3377 of file mpeg4videodec.c.

Referenced by mpeg4_init_static(), and mpeg4video_parse_init().

◆ ff_mpeg4_frame_end()

int ff_mpeg4_frame_end ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size 
)

Definition at line 3405 of file mpeg4videodec.c.

Referenced by ff_h263_decode_frame().

◆ mpeg4_init_static()

static av_cold void mpeg4_init_static ( void  )
static

Definition at line 3514 of file mpeg4videodec.c.

Referenced by decode_init().

◆ decode_init()

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 3541 of file mpeg4videodec.c.

Variable Documentation

◆ dc_lum

VLC dc_lum
static

Definition at line 52 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_dc().

◆ dc_chrom

VLC dc_chrom
static

Definition at line 52 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_dc().

◆ sprite_trajectory

VLC sprite_trajectory
static

Definition at line 53 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_sprite_trajectory().

◆ mb_type_b_vlc

VLC mb_type_b_vlc
static

Definition at line 54 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_mb().

◆ studio_intra_tab

VLC studio_intra_tab[12]
static

Definition at line 55 of file mpeg4videodec.c.

Referenced by mpeg4_decode_studio_block(), and mpeg4_init_static().

◆ studio_luma_dc

VLC studio_luma_dc
static

Definition at line 56 of file mpeg4videodec.c.

Referenced by mpeg4_decode_studio_block(), and mpeg4_init_static().

◆ studio_chroma_dc

VLC studio_chroma_dc
static

Definition at line 57 of file mpeg4videodec.c.

Referenced by mpeg4_decode_studio_block(), and mpeg4_init_static().

◆ mb_type_b_map

const int mb_type_b_map[4]
static

◆ ac_state_tab

const uint8_t ac_state_tab[22][2]
static
Initial value:
=
{
{0, 0},
{0, 1},
{1, 1},
{2, 1},
{3, 1},
{4, 1},
{5, 1},
{1, 2},
{2, 2},
{3, 2},
{4, 2},
{5, 2},
{6, 2},
{1, 3},
{2, 4},
{3, 5},
{4, 6},
{5, 7},
{6, 8},
{7, 9},
{8, 10},
{0, 11}
}

Definition at line 1789 of file mpeg4videodec.c.

Referenced by mpeg4_decode_studio_block().

◆ mpeg4_options

const AVOption mpeg4_options[]
static
Initial value:
= {
{"quarter_sample", "1/4 subpel MC", OFFSET(quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
{"divx_packed", "divx style packed b frames", OFFSET(divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
{NULL}
}

Definition at line 3570 of file mpeg4videodec.c.

◆ mpeg4_class

const AVClass mpeg4_class
static
Initial value:
= {
.class_name = "MPEG4 Video Decoder",
.item_name = av_default_item_name,
.option = mpeg4_options,
}

Definition at line 3576 of file mpeg4videodec.c.

◆ ff_mpeg4_decoder

const AVCodec ff_mpeg4_decoder

Definition at line 3583 of file mpeg4videodec.c.

MB_TYPE_L0
#define MB_TYPE_L0
Definition: mpegutils.h:67
OFFSET
#define OFFSET(x)
Definition: mpeg4videodec.c:3568
MB_TYPE_16x16
#define MB_TYPE_16x16
Definition: mpegutils.h:54
MB_TYPE_L1
#define MB_TYPE_L1
Definition: mpegutils.h:68
s
#define s(width, name)
Definition: cbs_vp9.c:257
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
MB_TYPE_L0L1
#define MB_TYPE_L0L1
Definition: mpegutils.h:69
FLAGS
#define FLAGS
Definition: mpeg4videodec.c:3569
mpeg4_options
static const AVOption mpeg4_options[]
Definition: mpeg4videodec.c:3570
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
MB_TYPE_DIRECT2
#define MB_TYPE_DIRECT2
Definition: mpegutils.h:59