You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/mpeg12enc, speedhqenc: Optimize writing escape codes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -628,12 +628,11 @@ next_coef:
|
|||||||
put_bits(&s->pb, table_vlc[code][1] + 1,
|
put_bits(&s->pb, table_vlc[code][1] + 1,
|
||||||
(table_vlc[code][0] << 1) + sign);
|
(table_vlc[code][0] << 1) + sign);
|
||||||
} else {
|
} else {
|
||||||
/* Escape seems to be pretty rare <5% so I do not optimize it;
|
/* Escape seems to be pretty rare <5% so I do not optimize it.
|
||||||
* the following value is the common escape value for both
|
* The following encodes run together with the common escape
|
||||||
* possible tables (i.e. table_vlc[111]). */
|
* value of both tables 000001b. */
|
||||||
put_bits(&s->pb, 6, 0x01);
|
put_bits(&s->pb, 6 + 6, 0x01 << 6 | run);
|
||||||
/* escape: only clip in this case */
|
/* escape: only clip in this case */
|
||||||
put_bits(&s->pb, 6, run);
|
|
||||||
if (s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
if (s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
||||||
if (alevel < 128) {
|
if (alevel < 128) {
|
||||||
put_sbits(&s->pb, 8, level);
|
put_sbits(&s->pb, 8, level);
|
||||||
|
@ -194,11 +194,10 @@ static void encode_block(MPVEncContext *const s, const int16_t block[], int n)
|
|||||||
ff_speedhq_vlc_table[code][0] | (sign << ff_speedhq_vlc_table[code][1]));
|
ff_speedhq_vlc_table[code][0] | (sign << ff_speedhq_vlc_table[code][1]));
|
||||||
} else {
|
} else {
|
||||||
/* escape seems to be pretty rare <5% so I do not optimize it;
|
/* escape seems to be pretty rare <5% so I do not optimize it;
|
||||||
* the values correspond to ff_speedhq_vlc_table[121] */
|
* The following encodes the escape value 100000b together with
|
||||||
put_bits_le(&s->pb, 6, 32);
|
* run and level. */
|
||||||
/* escape: only clip in this case */
|
put_bits_le(&s->pb, 6 + 6 + 12, 0x20 | run << 6 |
|
||||||
put_bits_le(&s->pb, 6, run);
|
(level + 2048) << 12);
|
||||||
put_bits_le(&s->pb, 12, level + 2048);
|
|
||||||
}
|
}
|
||||||
last_non_zero = i;
|
last_non_zero = i;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user