Go to the documentation of this file.
53 tab->table_mv_index = table_mv_index;
60 x =
tab->table_mvx[
i];
61 y =
tab->table_mvy[
i];
62 tab->table_mv_index[(x << 6) | y] =
i;
81 int run_diff= intra ? 0 : 1;
121 static uint16_t mv_index_tables[2][4096];
128 for (
int last = 0; last < 2; last++) {
141 if (
s->msmpeg4_version >= 4) {
142 s->min_qcoeff = -255;
153 int best = 0, best_size = INT_MAX;
154 int chroma_best = 0, best_chroma_size = INT_MAX;
169 const int last_size=
size + chroma_size;
170 for(last=0; last<2; last++){
171 int inter_count =
s->ac_stats[0][0][
level][
run][last] +
s->ac_stats[0][1][
level][
run][last];
172 int intra_luma_count =
s->ac_stats[1][0][
level][
run][last];
173 int intra_chroma_count=
s->ac_stats[1][1][
level][
run][last];
184 if(last_size ==
size+chroma_size)
break;
191 if(chroma_size<best_chroma_size){
192 best_chroma_size= chroma_size;
201 s->rl_table_index = best;
202 s->rl_chroma_table_index= chroma_best;
204 if(
s->pict_type !=
s->last_non_b_pict_type){
205 s->rl_table_index= 2;
207 s->rl_chroma_table_index= 1;
209 s->rl_chroma_table_index= 2;
223 if(
s->msmpeg4_version<=2){
224 s->rl_table_index = 2;
225 s->rl_chroma_table_index = 2;
228 s->dc_table_index = 1;
229 s->mv_table_index = 1;
230 s->use_skip_mb_code = 1;
231 s->per_mb_rl_table = 0;
232 if(
s->msmpeg4_version==4)
234 ff_dlog(
s,
"%d %"PRId64
" %d %d %d\n",
s->pict_type,
s->bit_rate,
235 s->inter_intra_pred,
s->width,
s->height);
238 s->slice_height=
s->mb_height/1;
239 put_bits(&
s->pb, 5, 0x16 +
s->mb_height/
s->slice_height);
241 if(
s->msmpeg4_version==4){
247 if(
s->msmpeg4_version>2){
248 if(!
s->per_mb_rl_table){
261 if(
s->msmpeg4_version>2){
262 if(!
s->per_mb_rl_table)
271 s->esc3_level_length= 0;
272 s->esc3_run_length= 0;
277 unsigned fps =
s->avctx->time_base.den /
s->avctx->time_base.num /
FFMAX(
s->avctx->ticks_per_frame, 1);
282 if(
s->msmpeg4_version>=3)
310 code =
mv->table_mv_index[(mx << 6) | my];
323 if (
s->slice_height && (
s->mb_y %
s->slice_height) == 0) {
324 if(
s->msmpeg4_version < 4){
327 s->first_slice_line = 1;
329 s->first_slice_line = 0;
336 int range, bit_size, sign,
code,
bits;
343 bit_size =
s->f_code - 1;
344 range = 1 << bit_size;
368 int16_t
block[6][64],
369 int motion_x,
int motion_y)
371 int cbp, coded_cbp,
i;
373 uint8_t *coded_block;
380 for (
i = 0;
i < 6;
i++) {
381 if (
s->block_last_index[
i] >= 0)
384 if (
s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
393 if (
s->use_skip_mb_code)
396 if(
s->msmpeg4_version<=2){
400 if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
427 for (
i = 0;
i < 6;
i++) {
435 for (
i = 0;
i < 6;
i++) {
437 val = (
s->block_last_index[
i] >= 1);
438 cbp |=
val << (5 -
i);
445 coded_cbp |=
val << (5 -
i);
448 if(
s->msmpeg4_version<=2){
453 if (
s->use_skip_mb_code)
468 if (
s->use_skip_mb_code)
475 if(
s->inter_intra_pred){
482 for (
i = 0;
i < 6;
i++) {
500 *dc_val =
level *
s->y_dc_scale;
502 *dc_val =
level *
s->c_dc_scale;
508 if(
s->msmpeg4_version<=2){
528 if (
s->dc_table_index == 0) {
556 int last_non_zero, sign, slevel;
557 int code, run_diff, dc_pred_dir;
559 const uint8_t *scantable;
569 run_diff =
s->msmpeg4_version>=4;
570 scantable=
s->intra_scantable.permutated;
574 if(
s->msmpeg4_version<=2)
578 scantable=
s->inter_scantable.permutated;
582 if (
s->msmpeg4_version >= 4 &&
s->block_last_index[n] > 0) {
583 for(last_index=63; last_index>=0; last_index--){
584 if(
block[scantable[last_index]])
break;
586 s->block_last_index[n]= last_index;
588 last_index =
s->block_last_index[n];
590 last_non_zero =
i - 1;
591 for (;
i <= last_index;
i++) {
595 run =
i - last_non_zero - 1;
596 last = (
i == last_index);
605 s->ac_stats[
s->mb_intra][n>3][
level][
run][last]++;
608 s->ac_stats[
s->mb_intra][n > 3][40][63][0]++;
628 if (
s->msmpeg4_version == 4 &&
code == rl->
n)
636 if(
s->msmpeg4_version>=4){
637 if(
s->esc3_level_length==0){
638 s->esc3_level_length=8;
639 s->esc3_run_length= 6;
void ff_msmpeg4_handle_slices(MpegEncContext *s)
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
static const int8_t mv[256][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
av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
RLTable ff_rl_table[NB_RL_TABLES]
const uint16_t ff_msmp4_mb_i_table[64][2]
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
static const struct twinvq_data tab
static double val(void *priv, double ch)
int n
number of entries of table_vlc minus 1
static int ff_thread_once(char *control, void(*routine)(void))
int8_t * max_level[2]
encoding & decoding
const uint32_t ff_table0_dc_chroma[120][2]
static int get_rl_index(const RLTable *rl, int last, int run, int level)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_msmpeg4_encode_motion(MpegEncContext *s, int mx, int my)
const uint32_t ff_table1_dc_chroma[120][2]
const uint16_t(* table_vlc)[2]
const uint32_t ff_table_mb_non_intra[128][2]
const uint8_t ff_v2_mb_type[8][2]
uint32_t ff_v2_dc_lum_table[512][2]
@ AV_PICTURE_TYPE_I
Intra.
const uint32_t ff_table0_dc_lum[120][2]
uint32_t ff_v2_dc_chroma_table[512][2]
void ff_mpeg4_clean_buffers(MpegEncContext *s)
static av_cold void init_mv_table(MVTable *tab, uint16_t table_mv_index[4096])
const uint8_t ff_h263_cbpy_tab[16][2]
void ff_msmpeg4_encode_ext_header(MpegEncContext *s)
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2]
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
const uint8_t ff_v2_intra_cbpc[4][2]
static void msmpeg4_encode_dc(MpegEncContext *s, int level, int n, int *dir_ptr)
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int get_size_of_code(const RLTable *rl, int last, int run, int level, int intra)
int8_t * max_run[2]
encoding & decoding
void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
static int get_bits_diff(MpegEncContext *s)
static const float pred[4]
const uint8_t ff_mvtab[33][2]
static av_cold void msmpeg4_encode_init_static(void)
void ff_msmpeg4_encode_block(MpegEncContext *s, int16_t *block, int n)
void ff_msmpeg4_code012(PutBitContext *pb, int n)
const uint8_t ff_table_inter_intra[4][2]
const uint32_t ff_table1_dc_lum[120][2]
static void msmpeg4v2_encode_motion(MpegEncContext *s, int val)
@ AV_PICTURE_TYPE_P
Predicted.
static void find_best_tables(MpegEncContext *s)
#define MSMPEG4_MV_TABLES_NB_ELEMS
The exact code depends on how similar the blocks are and how related they are to the block
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)