61 for(i=0;i<tab->
n;i++) {
83 int run_diff= intra ? 0 : 1;
123 static int init_done=0;
144 for (level = 1; level <=
MAX_LEVEL; level++) {
146 for(run=0; run<=
MAX_RUN; run++){
148 for(last=0; last<2; last++){
162 int best = 0, best_size = INT_MAX;
163 int chroma_best = 0, best_chroma_size = INT_MAX;
176 for(run=0; run<=
MAX_RUN; run++){
178 const int last_size= size + chroma_size;
179 for(last=0; last<2; last++){
186 chroma_size+= intra_chroma_count*rl_length[i+3][
level][
run][last];
193 if(last_size == size+chroma_size)
break;
200 if(chroma_size<best_chroma_size){
201 best_chroma_size= chroma_size;
345 int range, bit_size, sign, code,
bits;
353 range = 1 << bit_size;
366 code = (val >> bit_size) + 1;
367 bits = val & (range - 1);
377 int16_t
block[6][64],
378 int motion_x,
int motion_y)
380 int cbp, coded_cbp, i;
389 for (i = 0; i < 6; i++) {
409 if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
436 for (i = 0; i < 6; i++) {
444 for (i = 0; i < 6; i++) {
447 cbp |= val << (5 - i);
454 coded_cbp |= val << (5 - i);
491 for (i = 0; i < 6; i++) {
539 extquant = (level + 3) & 0x3;
540 code = ((level+3)>>2);
541 }
else if( s->
qscale == 2 ) {
542 extquant = (level + 1) & 0x1;
543 code = ((level+1)>>1);
562 extrabits = 3 - s->
qscale;
566 else if(extrabits > 0)
579 int level,
run, last, i, j, last_index;
580 int last_non_zero, sign, slevel;
581 int code, run_diff, dc_pred_dir;
607 for(last_index=63; last_index>=0; last_index--){
608 if(block[scantable[last_index]])
break;
614 last_non_zero = i - 1;
615 for (; i <= last_index; i++) {
619 run = i - last_non_zero - 1;
620 last = (i == last_index);
const char const char void * val
uint32_t ff_v2_dc_lum_table[512][2]
const uint32_t ff_table_mb_non_intra[128][2]
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
const uint32_t ff_table0_dc_lum[120][2]
Memory handling functions.
uint32_t ff_v2_dc_chroma_table[512][2]
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
Convenience header that includes libavutil's core.
int min_qcoeff
minimum encodable coefficient
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2]
av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
Macro definitions for various function/variable attributes.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void ff_mpeg4_clean_buffers(MpegEncContext *s)
void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int8_t * max_run[2]
encoding & decoding
static av_cold int init_mv_table(MVTable *tab)
const uint8_t ff_v2_intra_cbpc[4][2]
uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 *MAX_RUN+MAX_LEVEL+3]
int misc_bits
cbp, mb_type
int8_t * max_level[2]
encoding & decoding
const uint32_t ff_table0_dc_chroma[120][2]
int mb_height
number of MBs horizontally & vertically
int max_qcoeff
maximum encodable coefficient
static void msmpeg4_encode_dc(MpegEncContext *s, int level, int n, int *dir_ptr)
static void find_best_tables(MpegEncContext *s)
static int get_bits_diff(MpegEncContext *s)
int last_non_b_pict_type
used for MPEG-4 gmc B-frames & ratecontrol
const uint16_t ff_msmp4_mb_i_table[64][2]
void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
int rl_chroma_table_index
int n
number of entries of table_vlc minus 1
const uint8_t ff_v2_mb_type[8][2]
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
const uint8_t * table_mvx
const uint16_t(* table_vlc)[2]
const uint8_t * table_mv_bits
int(* ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2]
[mb_intra][isChroma][level][run][last]
av_cold int ff_msmpeg4_encode_init(MpegEncContext *s)
int block_last_index[12]
last non zero coefficient in block
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
const uint32_t ff_table1_dc_chroma[120][2]
uint16_t * table_mv_index
static const float pred[4]
static const int8_t mv[256][2]
int first_slice_line
used in MPEG-4 too to handle resync markers
void ff_msmpeg4_encode_block(MpegEncContext *s, int16_t *block, int n)
ScanTable intra_scantable
int height
picture size. must be a multiple of 16
void ff_msmpeg4_encode_ext_header(MpegEncContext *s)
const uint16_t * table_mv_code
av_cold int ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
const uint32_t ff_table1_dc_lum[120][2]
static void msmpeg4v2_encode_motion(MpegEncContext *s, int val)
int slice_height
in macroblocks
int f_code
forward MV resolution
const uint8_t ff_h263_cbpy_tab[16][2]
void ff_msmpeg4_code012(PutBitContext *pb, int n)
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
RLTable ff_rl_table[NB_RL_TABLES]
struct AVCodecContext * avctx
PutBitContext pb
bit output
void ff_msmpeg4_handle_slices(MpegEncContext *s)
void ff_msmpeg4_encode_motion(MpegEncContext *s, int mx, int my)
common internal api header.
static int get_rl_index(const RLTable *rl, int last, int run, int level)
int last_bits
temp var used for calculating the above vars
int64_t bit_rate
wanted bit rate
static const struct twinvq_data tab
const uint8_t * table_mvy
ScanTable inter_scantable
if inter == intra then intra should be used to reduce the cache usage
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
static int get_size_of_code(MpegEncContext *s, RLTable *rl, int last, int run, int level, int intra)
int h263_aic_dir
AIC direction: 0 = left, 1 = top.
const uint8_t ff_table_inter_intra[4][2]
const uint8_t ff_mvtab[33][2]