FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
mpeg4videodec.c File Reference
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "error_resilience.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"

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 SET_QPEL_FUNC(postfix1, postfix2)
 

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 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 int mpeg4_decode_gop_header (MpegEncContext *s, GetBitContext *gb)
 
static int mpeg4_decode_profile_level (MpegEncContext *s, 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)
 
int ff_mpeg4_decode_picture_header (Mpeg4DecContext *ctx, GetBitContext *gb)
 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 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 const int mb_type_b_map [4]
 
static const AVOption mpeg4_options []
 
static const AVClass mpeg4_class
 
AVCodec ff_mpeg4_decoder
 

Macro Definition Documentation

#define UNCHECKED_BITSTREAM_READER   1

Definition at line 23 of file mpeg4videodec.c.

#define SPRITE_TRAJ_VLC_BITS   6

Definition at line 43 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_sprite_trajectory().

#define DC_VLC_BITS   9

Definition at line 44 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_dc().

#define MB_TYPE_B_VLC_BITS   4

Definition at line 45 of file mpeg4videodec.c.

Referenced by ff_mpeg4videodec_static_init(), and mpeg4_decode_mb().

#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;
const char * s
Definition: avisynth_c.h:768

Referenced by ff_mpeg4_workaround_bugs().

Function Documentation

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 63 of file mpeg4videodec.c.

Referenced by ff_msmpeg4_decode_block(), and mpeg4_decode_block().

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 118 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb(), and mpeg4_decode_partitioned_mb().

static int mpeg4_decode_sprite_trajectory ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 168 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_video_packet_header().

static int decode_new_pred ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 383 of file mpeg4videodec.c.

Referenced by 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 399 of file mpeg4videodec.c.

Referenced by ff_h263_resync().

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 493 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb(), and mpeg4_decode_partition_a().

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 546 of file mpeg4videodec.c.

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

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 593 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_partitions().

static int mpeg4_decode_partition_b ( MpegEncContext s,
int  mb_count 
)
static

decode second partition.

Returns
<0 if an error occurred

Definition at line 787 of file mpeg4videodec.c.

Referenced by 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 880 of file mpeg4videodec.c.

Referenced by decode_slice().

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 943 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb(), and 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 1214 of file mpeg4videodec.c.

Referenced by decode_vop_header().

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

Definition at line 1299 of file mpeg4videodec.c.

Referenced by decode_init(), and decode_vop_header().

static int mpeg4_decode_gop_header ( MpegEncContext s,
GetBitContext gb 
)
static

Definition at line 1678 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

static int mpeg4_decode_profile_level ( MpegEncContext s,
GetBitContext gb 
)
static

Definition at line 1700 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

static int decode_vol_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 1714 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

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 2082 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

int ff_mpeg4_workaround_bugs ( AVCodecContext avctx)

Definition at line 2132 of file mpeg4videodec.c.

Referenced by ff_h263_decode_frame().

static int decode_vop_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)
static

Definition at line 2243 of file mpeg4videodec.c.

Referenced by ff_mpeg4_decode_picture_header().

int ff_mpeg4_decode_picture_header ( Mpeg4DecContext ctx,
GetBitContext gb 
)

Decode MPEG-4 headers.

Returns
<0 if no VOP found (or a damaged one) FRAME_SKIPPED if a not coded VOP is found 0 if a VOP is found

Definition at line 2518 of file mpeg4videodec.c.

Referenced by ff_h263_decode_frame(), and mpeg4_decode_header().

av_cold void ff_mpeg4videodec_static_init ( void  )

Definition at line 2635 of file mpeg4videodec.c.

Referenced by decode_init(), and mpeg4video_parse_init().

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

Definition at line 2661 of file mpeg4videodec.c.

Referenced by ff_h263_decode_frame().

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 2732 of file mpeg4videodec.c.

Variable Documentation

VLC dc_lum
static

Definition at line 47 of file mpeg4videodec.c.

VLC dc_chrom
static

Definition at line 47 of file mpeg4videodec.c.

VLC sprite_trajectory
static

Definition at line 48 of file mpeg4videodec.c.

VLC mb_type_b_vlc
static

Definition at line 49 of file mpeg4videodec.c.

const int mb_type_b_map[4]
static
Initial value:
= {
}
#define MB_TYPE_DIRECT2
Definition: avcodec.h:1261
#define MB_TYPE_L0L1
Definition: avcodec.h:1271
#define MB_TYPE_L1
Definition: avcodec.h:1270
#define MB_TYPE_16x16
Definition: avcodec.h:1256
#define MB_TYPE_L0
Definition: avcodec.h:1269

Definition at line 51 of file mpeg4videodec.c.

Referenced by mpeg4_decode_mb().

const AVOption mpeg4_options[]
static
Initial value:
= {
{"quarter_sample", "1/4 subpel MC", 0x42, AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0},
{"divx_packed", "divx style packed b frames", 0x42, AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0},
{NULL}
}
#define NULL
Definition: coverity.c:32

Definition at line 2759 of file mpeg4videodec.c.

const AVClass mpeg4_class
static
Initial value:
= {
"MPEG4 Video Decoder",
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
av_default_item_name
static const AVOption mpeg4_options[]

Definition at line 2765 of file mpeg4videodec.c.

AVCodec ff_mpeg4_decoder
Initial value:
= {
.name = "mpeg4",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
.priv_data_size = sizeof(Mpeg4DecContext),
.max_lowres = 3,
.update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg4_update_thread_context),
.priv_class = &mpeg4_class,
}
static void flush(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int decode_init(AVCodecContext *avctx)
const AVProfile ff_mpeg4_video_profiles[]
Definition: profiles.c:107
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:984
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1022
void ff_mpeg_flush(AVCodecContext *avctx)
Definition: mpegvideo.c:2771
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:215
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: h263dec.c:409
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
Definition: avcodec.h:953
enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]
Definition: h263dec.c:721
static const AVProfile profiles[]
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
#define AV_CODEC_CAP_TRUNCATED
Definition: avcodec.h:960
static const AVClass mpeg4_class
int ff_h263_decode_end(AVCodecContext *avctx)
Definition: h263dec.c:149
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: ffmpeg.c:2035
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:959

Definition at line 2772 of file mpeg4videodec.c.