Go to the documentation of this file.
53 tab->table_mv_index =
av_malloc(
sizeof(uint16_t) * 4096);
54 if (!
tab->table_mv_index)
59 tab->table_mv_index[
i] =
tab->n;
61 for(
i=0;i<tab->
n;
i++) {
62 x =
tab->table_mvx[
i];
63 y =
tab->table_mvy[
i];
64 tab->table_mv_index[(x << 6) | y] =
i;
83 int run_diff= intra ? 0 : 1;
123 static int init_done=0;
127 if(
s->msmpeg4_version>=4){
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;
178 const int last_size=
size + chroma_size;
179 for(last=0; last<2; last++){
180 int inter_count =
s->ac_stats[0][0][
level][
run][last] +
s->ac_stats[0][1][
level][
run][last];
181 int intra_luma_count =
s->ac_stats[1][0][
level][
run][last];
182 int intra_chroma_count=
s->ac_stats[1][1][
level][
run][last];
193 if(last_size ==
size+chroma_size)
break;
200 if(chroma_size<best_chroma_size){
201 best_chroma_size= chroma_size;
210 s->rl_table_index = best;
211 s->rl_chroma_table_index= chroma_best;
213 if(
s->pict_type !=
s->last_non_b_pict_type){
214 s->rl_table_index= 2;
216 s->rl_chroma_table_index= 1;
218 s->rl_chroma_table_index= 2;
232 if(
s->msmpeg4_version<=2){
233 s->rl_table_index = 2;
234 s->rl_chroma_table_index = 2;
237 s->dc_table_index = 1;
238 s->mv_table_index = 1;
239 s->use_skip_mb_code = 1;
240 s->per_mb_rl_table = 0;
241 if(
s->msmpeg4_version==4)
243 ff_dlog(
s,
"%d %"PRId64
" %d %d %d\n",
s->pict_type,
s->bit_rate,
244 s->inter_intra_pred,
s->width,
s->height);
247 s->slice_height=
s->mb_height/1;
248 put_bits(&
s->pb, 5, 0x16 +
s->mb_height/
s->slice_height);
250 if(
s->msmpeg4_version==4){
256 if(
s->msmpeg4_version>2){
257 if(!
s->per_mb_rl_table){
270 if(
s->msmpeg4_version>2){
271 if(!
s->per_mb_rl_table)
280 s->esc3_level_length= 0;
281 s->esc3_run_length= 0;
286 unsigned fps =
s->avctx->time_base.den /
s->avctx->time_base.num /
FFMAX(
s->avctx->ticks_per_frame, 1);
291 if(
s->msmpeg4_version>=3)
319 code =
mv->table_mv_index[(mx << 6) | my];
332 if (
s->slice_height && (
s->mb_y %
s->slice_height) == 0) {
333 if(
s->msmpeg4_version < 4){
336 s->first_slice_line = 1;
338 s->first_slice_line = 0;
345 int range, bit_size, sign,
code,
bits;
352 bit_size =
s->f_code - 1;
353 range = 1 << bit_size;
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++) {
390 if (
s->block_last_index[
i] >= 0)
393 if (
s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
402 if (
s->use_skip_mb_code)
405 if(
s->msmpeg4_version<=2){
409 if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
436 for (
i = 0;
i < 6;
i++) {
444 for (
i = 0;
i < 6;
i++) {
446 val = (
s->block_last_index[
i] >= 1);
447 cbp |=
val << (5 -
i);
454 coded_cbp |=
val << (5 -
i);
457 if(
s->msmpeg4_version<=2){
462 if (
s->use_skip_mb_code)
477 if (
s->use_skip_mb_code)
484 if(
s->inter_intra_pred){
491 for (
i = 0;
i < 6;
i++) {
510 *dc_val =
level *
s->y_dc_scale;
512 *dc_val =
level *
s->c_dc_scale;
518 if(
s->msmpeg4_version<=2){
537 else if(
s->msmpeg4_version>=6 ) {
538 if(
s->qscale == 1 ) {
539 extquant = (
level + 3) & 0x3;
541 }
else if(
s->qscale == 2 ) {
542 extquant = (
level + 1) & 0x1;
547 if (
s->dc_table_index == 0) {
561 if(
s->msmpeg4_version>=6 &&
s->qscale<=2)
562 extrabits = 3 -
s->qscale;
566 else if(extrabits > 0)
580 int last_non_zero, sign, slevel;
581 int code, run_diff, dc_pred_dir;
593 run_diff =
s->msmpeg4_version>=4;
594 scantable=
s->intra_scantable.permutated;
598 if(
s->msmpeg4_version<=2)
602 scantable=
s->inter_scantable.permutated;
606 if(
s->msmpeg4_version>=4 &&
s->msmpeg4_version<6 &&
s->block_last_index[
n]>0){
607 for(last_index=63; last_index>=0; last_index--){
608 if(
block[scantable[last_index]])
break;
610 s->block_last_index[
n]= last_index;
612 last_index =
s->block_last_index[
n];
614 last_non_zero =
i - 1;
615 for (;
i <= last_index;
i++) {
619 run =
i - last_non_zero - 1;
620 last = (
i == last_index);
632 s->ac_stats[
s->mb_intra][
n > 3][40][63][0]++;
652 if (
s->msmpeg4_version == 4 &&
code == rl->
n)
660 if(
s->msmpeg4_version>=4){
661 if(
s->esc3_level_length==0){
662 s->esc3_level_length=8;
663 s->esc3_run_length= 6;
666 put_bits(&
s->pb, 6 + (
s->msmpeg4_version>=6), 3);
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_msmpeg4_handle_slices(MpegEncContext *s)
av_cold int ff_msmpeg4_encode_init(MpegEncContext *s)
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)
static const struct twinvq_data tab
int n
number of entries of table_vlc minus 1
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 avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
void ff_mpeg4_clean_buffers(MpegEncContext *s)
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]
static int get_size_of_code(MpegEncContext *s, RLTable *rl, int last, int run, int level, int intra)
const char const char void * val
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
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]
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]
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]
uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 *MAX_RUN+MAX_LEVEL+3]
static void msmpeg4v2_encode_motion(MpegEncContext *s, int val)
@ AV_PICTURE_TYPE_P
Predicted.
static void find_best_tables(MpegEncContext *s)
static av_cold int init_mv_table(MVTable *tab)
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)