aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-12-02 21:17:34 +0100
committerPaul B Mahol <onemda@gmail.com>2022-12-02 23:03:52 +0100
commit8d9f7fa79ecc194dc1e7148b824eea6d779ee918 (patch)
tree3b3f6cc19bc6e27f1a3e1996ec4941236de84f80 /libavcodec
parentfb51eebc6cb3df8e6ee232a650fbb4c1a05c4125 (diff)
downloadffmpeg-8d9f7fa79ecc194dc1e7148b824eea6d779ee918.tar.gz
avcodec/smcenc: improve compression ratio a little
Actually reverts previous change.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/smcenc.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c
index 33f9dfcc24..e3ea7e5e9f 100644
--- a/libavcodec/smcenc.c
+++ b/libavcodec/smcenc.c
@@ -127,16 +127,11 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
int color_pair_index = 0;
int color_quad_index = 0;
int color_octet_index = 0;
- int prev_block_inter = 0;
int color_table_index; /* indexes to color pair, quad, or octet tables */
int total_blocks;
int cur_y = 0;
int cur_x = 0;
- memset(s->color_pairs, 0, sizeof(s->color_pairs));
- memset(s->color_quads, 0, sizeof(s->color_quads));
- memset(s->color_octets, 0, sizeof(s->color_octets));
-
/* Number of 4x4 blocks in frame. */
total_blocks = ((width + 3) / 4) * ((height + 3) / 4);
@@ -183,7 +178,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
cur_y = frame_y;
cur_x = frame_x;
- while (block_counter > 0 && prev_block_inter == 0 && block_counter + intra_skip_blocks < total_blocks) {
+ while (block_counter > 0 && block_counter + intra_skip_blocks < total_blocks) {
const int y_size = FFMIN(4, height - cur_y);
const int x_size = FFMIN(4, width - cur_x);
const ptrdiff_t offset = xpixel_ptr - src_pixels;
@@ -249,30 +244,36 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
cur_y = frame_y;
cur_x = frame_x;
- blocks = coded_blocks;
+ blocks = coded_distinct <= 8 ? coded_blocks : 0;
distinct = coded_distinct;
- if (intra_skip_blocks > 0 && intra_skip_blocks >= inter_skip_blocks) {
+ if (intra_skip_blocks >= blocks && intra_skip_blocks >= inter_skip_blocks) {
distinct = 17;
blocks = intra_skip_blocks;
}
- if (intra_skip_blocks > 16 && intra_skip_blocks >= inter_skip_blocks) {
+ if (intra_skip_blocks > 16 && intra_skip_blocks >= inter_skip_blocks &&
+ intra_skip_blocks >= blocks) {
distinct = 18;
blocks = intra_skip_blocks;
}
- if (inter_skip_blocks > 0 && inter_skip_blocks > intra_skip_blocks) {
+ if (inter_skip_blocks >= blocks && inter_skip_blocks > intra_skip_blocks) {
distinct = 19;
blocks = inter_skip_blocks;
}
- if (inter_skip_blocks > 16 && inter_skip_blocks > intra_skip_blocks) {
+ if (inter_skip_blocks > 16 && inter_skip_blocks > intra_skip_blocks &&
+ inter_skip_blocks >= blocks) {
distinct = 20;
blocks = inter_skip_blocks;
}
- prev_block_inter = distinct == 19 || distinct == 20;
+ if (blocks == 0) {
+ blocks = coded_blocks;
+ distinct = coded_distinct;
+ }
+
switch (distinct) {
case 1:
if (blocks <= 16) {