libavcodec/mpeg4videoenc.c File Reference

#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "mpegvideo.h"
#include "h263.h"
#include "mpeg4video.h"

Go to the source code of this file.

Defines

#define UNI_MPEG4_ENC_INDEX(last, run, level)   ((last)*128*64 + (run)*128 + (level))
#define OFFSET(x)   offsetof(MpegEncContext, x)
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM

Functions

static int get_block_rate (MpegEncContext *s, DCTELEM block[64], int block_last_index, uint8_t scantable[64])
 Return the number of bits that encoding the 8x8 block in block would need.
static void restore_ac_coeffs (MpegEncContext *s, DCTELEM block[6][64], const int dir[6], uint8_t *st[6], const int zigzag_last_index[6])
 Restore the ac coefficients in block that have been changed by decide_ac_pred().
static int decide_ac_pred (MpegEncContext *s, DCTELEM block[6][64], const int dir[6], uint8_t *st[6], int zigzag_last_index[6])
 Return the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4.
void ff_clean_mpeg4_qscales (MpegEncContext *s)
 modify mb_type & qscale so that encoding is acually possible in mpeg4
static void mpeg4_encode_dc (PutBitContext *s, int level, int n)
 encodes the dc value.
static int mpeg4_get_dc_length (int level, int n)
static void mpeg4_encode_block (MpegEncContext *s, DCTELEM *block, int n, int intra_dc, uint8_t *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
 encodes a 8x8 block
static int mpeg4_get_block_length (MpegEncContext *s, DCTELEM *block, int n, int intra_dc, uint8_t *scan_table)
static void mpeg4_encode_blocks (MpegEncContext *s, DCTELEM block[6][64], int intra_dc[6], uint8_t **scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
static int get_b_cbp (MpegEncContext *s, DCTELEM block[6][64], int motion_x, int motion_y, int mb_type)
void mpeg4_encode_mb (MpegEncContext *s, DCTELEM block[6][64], int motion_x, int motion_y)
void ff_mpeg4_stuffing (PutBitContext *pbc)
 add mpeg4 stuffing bits (01.
void ff_set_mpeg4_time (MpegEncContext *s)
static void mpeg4_encode_gop_header (MpegEncContext *s)
static void mpeg4_encode_visual_object_header (MpegEncContext *s)
static void mpeg4_encode_vol_header (MpegEncContext *s, int vo_number, int vol_number)
void mpeg4_encode_picture_header (MpegEncContext *s, int picture_number)
static void init_uni_dc_tab (void)
static void init_uni_mpeg4_rl_tab (RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab)
static av_cold int encode_init (AVCodecContext *avctx)
void ff_mpeg4_init_partitions (MpegEncContext *s)
void ff_mpeg4_merge_partitions (MpegEncContext *s)
void ff_mpeg4_encode_video_packet_header (MpegEncContext *s)

Variables

static uint8_t uni_DCtab_lum_len [512]
static uint8_t uni_DCtab_chrom_len [512]
static uint16_t uni_DCtab_lum_bits [512]
static uint16_t uni_DCtab_chrom_bits [512]
static uint32_t uni_mpeg4_intra_rl_bits [64 *64 *2 *2]
static uint8_t uni_mpeg4_intra_rl_len [64 *64 *2 *2]
static uint32_t uni_mpeg4_inter_rl_bits [64 *64 *2 *2]
static uint8_t uni_mpeg4_inter_rl_len [64 *64 *2 *2]
static const int dquant_code [5] = {1,0,9,2,3}
static const AVOption options []
static const AVClass mpeg4enc_class
AVCodec ff_mpeg4_encoder


Define Documentation

#define OFFSET (  )     offsetof(MpegEncContext, x)

Definition at line 1328 of file mpeg4videoenc.c.

#define UNI_MPEG4_ENC_INDEX ( last,
run,
level   )     ((last)*128*64 + (run)*128 + (level))

Definition at line 45 of file mpeg4videoenc.c.

#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM

Definition at line 1329 of file mpeg4videoenc.c.


Function Documentation

static int decide_ac_pred ( MpegEncContext s,
DCTELEM  block[6][64],
const int  dir[6],
uint8_t *  st[6],
int  zigzag_last_index[6] 
) [inline, static]

Return the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4.

This function will also update s->block_last_index and s->ac_val.

Parameters:
[in,out] block MB coefficients, these will be updated if 1 is returned
[in] dir ac prediction direction for each 8x8 block
[out] st scantable for each 8x8 block
[out] zigzag_last_index index refering to the last non zero coefficient in zigzag order

Definition at line 125 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_mb().

static av_cold int encode_init ( AVCodecContext avctx  )  [static]

Definition at line 1229 of file mpeg4videoenc.c.

void ff_clean_mpeg4_qscales ( MpegEncContext s  ) 

modify mb_type & qscale so that encoding is acually possible in mpeg4

Definition at line 204 of file mpeg4videoenc.c.

Referenced by estimate_qp().

void ff_mpeg4_encode_video_packet_header ( MpegEncContext s  ) 

Definition at line 1316 of file mpeg4videoenc.c.

Referenced by encode_thread().

void ff_mpeg4_init_partitions ( MpegEncContext s  ) 

Definition at line 1276 of file mpeg4videoenc.c.

Referenced by encode_thread().

void ff_mpeg4_merge_partitions ( MpegEncContext s  ) 

Definition at line 1289 of file mpeg4videoenc.c.

Referenced by write_slice_end().

void ff_mpeg4_stuffing ( PutBitContext pbc  ) 

add mpeg4 stuffing bits (01.

..1)

Definition at line 847 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_gop_header(), mpeg4_encode_visual_object_header(), mpeg4_encode_vol_header(), and write_slice_end().

void ff_set_mpeg4_time ( MpegEncContext s  ) 

Definition at line 856 of file mpeg4videoenc.c.

Referenced by encode_picture().

static int get_b_cbp ( MpegEncContext s,
DCTELEM  block[6][64],
int  motion_x,
int  motion_y,
int  mb_type 
) [inline, static]

Definition at line 428 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_mb().

static int get_block_rate ( MpegEncContext s,
DCTELEM  block[64],
int  block_last_index,
uint8_t  scantable[64] 
) [inline, static]

Return the number of bits that encoding the 8x8 block in block would need.

Parameters:
[in] block_last_index last index in scantable order that refers to a non zero element in block.

Definition at line 62 of file mpeg4videoenc.c.

Referenced by decide_ac_pred().

static void init_uni_dc_tab ( void   )  [static]

Definition at line 1096 of file mpeg4videoenc.c.

Referenced by encode_init().

static void init_uni_mpeg4_rl_tab ( RLTable rl,
uint32_t *  bits_tab,
uint8_t *  len_tab 
) [static]

Definition at line 1148 of file mpeg4videoenc.c.

Referenced by encode_init().

static void mpeg4_encode_block ( MpegEncContext s,
DCTELEM block,
int  n,
int  intra_dc,
uint8_t *  scan_table,
PutBitContext dc_pb,
PutBitContext ac_pb 
) [inline, static]

encodes a 8x8 block

Parameters:
n block index (0-3 are luma, 4-5 are chroma)

Definition at line 297 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_blocks().

static void mpeg4_encode_blocks ( MpegEncContext s,
DCTELEM  block[6][64],
int  intra_dc[6],
uint8_t **  scan_table,
PutBitContext dc_pb,
PutBitContext ac_pb 
) [inline, static]

Definition at line 399 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_mb().

static void mpeg4_encode_dc ( PutBitContext s,
int  level,
int  n 
) [inline, static]

encodes the dc value.

Parameters:
n block index (0-3 are luma, 4-5 are chroma)

Definition at line 244 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_block().

static void mpeg4_encode_gop_header ( MpegEncContext s  )  [static]

Definition at line 865 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_picture_header().

void mpeg4_encode_mb ( MpegEncContext s,
DCTELEM  block[6][64],
int  motion_x,
int  motion_y 
)

Definition at line 471 of file mpeg4videoenc.c.

Referenced by encode_mb_internal().

void mpeg4_encode_picture_header ( MpegEncContext s,
int  picture_number 
)

Definition at line 1041 of file mpeg4videoenc.c.

Referenced by encode_picture().

static void mpeg4_encode_visual_object_header ( MpegEncContext s  )  [static]

Definition at line 894 of file mpeg4videoenc.c.

Referenced by encode_init(), and mpeg4_encode_picture_header().

static void mpeg4_encode_vol_header ( MpegEncContext s,
int  vo_number,
int  vol_number 
) [static]

Definition at line 939 of file mpeg4videoenc.c.

Referenced by encode_init(), and mpeg4_encode_picture_header().

static int mpeg4_get_block_length ( MpegEncContext s,
DCTELEM block,
int  n,
int  intra_dc,
uint8_t *  scan_table 
) [static]

Definition at line 348 of file mpeg4videoenc.c.

Referenced by mpeg4_encode_blocks().

static int mpeg4_get_dc_length ( int  level,
int  n 
) [inline, static]

Definition at line 285 of file mpeg4videoenc.c.

Referenced by mpeg4_get_block_length().

static void restore_ac_coeffs ( MpegEncContext s,
DCTELEM  block[6][64],
const int  dir[6],
uint8_t *  st[6],
const int  zigzag_last_index[6] 
) [inline, static]

Restore the ac coefficients in block that have been changed by decide_ac_pred().

This function also restores s->block_last_index.

Parameters:
[in,out] block MB coefficients, these will be restored
[in] dir ac prediction direction for each 8x8 block
[out] st scantable for each 8x8 block
[in] zigzag_last_index index refering to the last non zero coefficient in zigzag order

Definition at line 94 of file mpeg4videoenc.c.

Referenced by decide_ac_pred(), and mpeg4_encode_mb().


Variable Documentation

const int dquant_code[5] = {1,0,9,2,3} [static]

Definition at line 469 of file mpeg4videoenc.c.

Initial value:

 {
    .name           = "mpeg4",
    .type           = AVMEDIA_TYPE_VIDEO,
    .id             = CODEC_ID_MPEG4,
    .priv_data_size = sizeof(MpegEncContext),
    .init           = encode_init,
    .encode         = MPV_encode_picture,
    .close          = MPV_encode_end,
    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
    .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
    .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
    .priv_class     = &mpeg4enc_class,
}

Definition at line 1343 of file mpeg4videoenc.c.

const AVClass mpeg4enc_class [static]

Initial value:

 {
    .class_name = "MPEG4 encoder",
    .item_name  = av_default_item_name,
    .option     = options,
    .version    = LIBAVUTIL_VERSION_INT,
}

Definition at line 1336 of file mpeg4videoenc.c.

const AVOption options[] [static]

Initial value:

 {
    { "data_partitioning",       "Use data partitioning.",      OFFSET(data_partitioning), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
    { "alternate_scan",          "Enable alternate scantable.", OFFSET(alternate_scan),    AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
    { NULL },
}

Definition at line 1330 of file mpeg4videoenc.c.

uint16_t uni_DCtab_chrom_bits[512] [static]

Definition at line 35 of file mpeg4videoenc.c.

Referenced by init_uni_dc_tab(), and mpeg4_encode_dc().

uint8_t uni_DCtab_chrom_len[512] [static]

Definition at line 33 of file mpeg4videoenc.c.

Referenced by init_uni_dc_tab(), mpeg4_encode_dc(), and mpeg4_get_dc_length().

uint16_t uni_DCtab_lum_bits[512] [static]

Definition at line 34 of file mpeg4videoenc.c.

Referenced by init_uni_dc_tab(), and mpeg4_encode_dc().

uint8_t uni_DCtab_lum_len[512] [static]

Definition at line 32 of file mpeg4videoenc.c.

Referenced by encode_init(), init_uni_dc_tab(), mpeg4_encode_dc(), and mpeg4_get_dc_length().

uint32_t uni_mpeg4_inter_rl_bits[64 *64 *2 *2] [static]

Definition at line 41 of file mpeg4videoenc.c.

Referenced by encode_init(), and mpeg4_encode_block().

uint8_t uni_mpeg4_inter_rl_len[64 *64 *2 *2] [static]

Definition at line 42 of file mpeg4videoenc.c.

Referenced by encode_init(), mpeg4_encode_block(), and mpeg4_get_block_length().

uint32_t uni_mpeg4_intra_rl_bits[64 *64 *2 *2] [static]

Definition at line 39 of file mpeg4videoenc.c.

Referenced by encode_init(), and mpeg4_encode_block().

uint8_t uni_mpeg4_intra_rl_len[64 *64 *2 *2] [static]

Definition at line 40 of file mpeg4videoenc.c.

Referenced by encode_init(), mpeg4_encode_block(), and mpeg4_get_block_length().


Generated on Fri Oct 26 02:43:48 2012 for FFmpeg by  doxygen 1.5.8