You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/mpeg4videoenc: Remove no-output code
While it offers modest speedups compared to the ordinary code,
removing it completely offers even bigger speedups; and given
that these speedups also exist in the ordinary mode, they are
even more important. The no-output code has a 7.8% performance
improvement (based on benchmarking mpeg4_encode_mb()), yet
removing the no-output code resulted in a 9.4% improvement.
Furthermore, the no-output code was broken for the majority of
its existence (until 9207dc3b0d
)
and no one complained, so it is likely not used at all.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -292,14 +292,6 @@ static inline void mpeg4_encode_dc(PutBitContext *s, int level, int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int mpeg4_get_dc_length(int level, int n)
|
|
||||||
{
|
|
||||||
if (n < 4)
|
|
||||||
return uni_DCtab_lum_len[level + 256];
|
|
||||||
else
|
|
||||||
return uni_DCtab_chrom_len[level + 256];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode an 8x8 block.
|
* Encode an 8x8 block.
|
||||||
* @param n block index (0-3 are luma, 4-5 are chroma)
|
* @param n block index (0-3 are luma, 4-5 are chroma)
|
||||||
@ -365,60 +357,6 @@ static inline void mpeg4_encode_block(const MPVEncContext *const s,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mpeg4_get_block_length(MPVEncContext *const s,
|
|
||||||
const int16_t *block, int n,
|
|
||||||
int intra_dc, const uint8_t *scan_table)
|
|
||||||
{
|
|
||||||
int i, last_non_zero;
|
|
||||||
const uint8_t *len_tab;
|
|
||||||
const int last_index = s->c.block_last_index[n];
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (s->c.mb_intra) { // Note gcc (3.2.1 at least) will optimize this away
|
|
||||||
/* MPEG-4 based DC predictor */
|
|
||||||
len += mpeg4_get_dc_length(intra_dc, n);
|
|
||||||
if (last_index < 1)
|
|
||||||
return len;
|
|
||||||
i = 1;
|
|
||||||
len_tab = uni_mpeg4_intra_rl_len;
|
|
||||||
} else {
|
|
||||||
if (last_index < 0)
|
|
||||||
return 0;
|
|
||||||
i = 0;
|
|
||||||
len_tab = uni_mpeg4_inter_rl_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* AC coefs */
|
|
||||||
last_non_zero = i - 1;
|
|
||||||
for (; i < last_index; i++) {
|
|
||||||
int level = block[scan_table[i]];
|
|
||||||
if (level) {
|
|
||||||
int run = i - last_non_zero - 1;
|
|
||||||
level += 64;
|
|
||||||
if ((level & (~127)) == 0) {
|
|
||||||
const int index = UNI_MPEG4_ENC_INDEX(0, run, level);
|
|
||||||
len += len_tab[index];
|
|
||||||
} else { // ESC3
|
|
||||||
len += 7 + 2 + 1 + 6 + 1 + 12 + 1;
|
|
||||||
}
|
|
||||||
last_non_zero = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* if (i <= last_index) */ {
|
|
||||||
int level = block[scan_table[i]];
|
|
||||||
int run = i - last_non_zero - 1;
|
|
||||||
level += 64;
|
|
||||||
if ((level & (~127)) == 0) {
|
|
||||||
const int index = UNI_MPEG4_ENC_INDEX(1, run, level);
|
|
||||||
len += len_tab[index];
|
|
||||||
} else { // ESC3
|
|
||||||
len += 7 + 2 + 1 + 6 + 1 + 12 + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void mpeg4_encode_blocks(MPVEncContext *const s,
|
static inline void mpeg4_encode_blocks(MPVEncContext *const s,
|
||||||
const int16_t block[6][64],
|
const int16_t block[6][64],
|
||||||
const int intra_dc[6],
|
const int intra_dc[6],
|
||||||
@ -429,30 +367,16 @@ static inline void mpeg4_encode_blocks(MPVEncContext *const s,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (scan_table) {
|
if (scan_table) {
|
||||||
if (s->c.avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) {
|
|
||||||
for (i = 0; i < 6; i++)
|
|
||||||
skip_put_bits(&s->pb,
|
|
||||||
mpeg4_get_block_length(s, block[i], i,
|
|
||||||
intra_dc[i], scan_table[i]));
|
|
||||||
} else {
|
|
||||||
/* encode each block */
|
/* encode each block */
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
mpeg4_encode_block(s, block[i], i,
|
mpeg4_encode_block(s, block[i], i,
|
||||||
intra_dc[i], scan_table[i], dc_pb, ac_pb);
|
intra_dc[i], scan_table[i], dc_pb, ac_pb);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (s->c.avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) {
|
|
||||||
for (i = 0; i < 6; i++)
|
|
||||||
skip_put_bits(&s->pb,
|
|
||||||
mpeg4_get_block_length(s, block[i], i, 0,
|
|
||||||
s->c.intra_scantable.permutated));
|
|
||||||
} else {
|
} else {
|
||||||
/* encode each block */
|
/* encode each block */
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
mpeg4_encode_block(s, block[i], i, 0,
|
mpeg4_encode_block(s, block[i], i, 0,
|
||||||
s->c.intra_scantable.permutated, dc_pb, ac_pb);
|
s->c.intra_scantable.permutated, dc_pb, ac_pb);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_b_cbp(MPVEncContext *const s, int16_t block[6][64],
|
static inline int get_b_cbp(MPVEncContext *const s, int16_t block[6][64],
|
||||||
|
Reference in New Issue
Block a user