* [FFmpeg-devel] [PATCH] avcodec/ffv1: NOT FOR GIT experiment seperately coding sign bits of float16
@ 2025-01-18 23:01 Michael Niedermayer
0 siblings, 0 replies; only message in thread
From: Michael Niedermayer @ 2025-01-18 23:01 UTC (permalink / raw)
To: FFmpeg development discussions and patches
The float sign bits seem to take about 1% of space in the compressed
bitstream. Storing it separately in a RC symbol each is worse
---
libavcodec/ffv1.c | 1 +
libavcodec/ffv1.h | 1 +
libavcodec/ffv1enc_template.c | 24 ++++++++++++++++--------
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index f303ed769f0..a9fa2959087 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -105,6 +105,7 @@ av_cold int ff_ffv1_init_slice_state(const FFV1Context *f,
sc->c.zero_state[256 - j] = 256 - sc->c.one_state[j];
}
}
+ memset(sc->newstate, 128, sizeof(sc->newstate));
return 0;
}
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 2c2df154037..f2cc5a63d5e 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -104,6 +104,7 @@ typedef struct FFV1SliceContext {
uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
};
};
+ uint8_t newstate[65536];
} FFV1SliceContext;
typedef struct FFV1Context {
diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c
index bc14926ab95..c6535373024 100644
--- a/libavcodec/ffv1enc_template.c
+++ b/libavcodec/ffv1enc_template.c
@@ -62,9 +62,17 @@ RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc,
for (x = 0; x < w; x++) {
int diff, context;
+ int signstate = (1&(sample[0][x-1]>>15)) + 2*(sample[1][x]>>15) + 4*(sample[1][x-1]>>15) + 8*(sample[1][x+1]>>15);
+ put_rac(c, sc->newstate+signstate, 1&(sample[0][x]>>15));
+
context = RENAME(get_context)(f->quant_tables[p->quant_table_index],
sample[0] + x, sample[1] + x, sample[2] + x);
- diff = sample[0][x] - RENAME(predict)(sample[0] + x, sample[1] + x);
+ int64_t L = (sample[0][x-1]) & 0x7FFF;
+ int64_t T = (sample[1][x]) & 0x7FFF;
+ int64_t LT = (sample[1][x-1]) & 0x7FFF;
+
+ diff = (sample[0][x] & 0x7FFF) - mid_pred((L), (L + T - LT), (T));
+// diff = sample[0][x] - RENAME(predict)(sample[0] + x, sample[1] + x);
if (context < 0) {
context = -context;
@@ -180,13 +188,13 @@ static int RENAME(encode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc,
r = *((const uint16_t *)(src[2] + x*2 + stride[2]*y));
}
- if (sc->slice_coding_mode != 1) {
- b -= g;
- r -= g;
- g += (b * sc->slice_rct_by_coef + r * sc->slice_rct_ry_coef) >> 2;
- b += offset;
- r += offset;
- }
+// if (sc->slice_coding_mode != 1) {
+// b -= g;
+// r -= g;
+// g += (b * sc->slice_rct_by_coef + r * sc->slice_rct_ry_coef) >> 2;
+// b += offset;
+// r += offset;
+// }
sample[0][0][x] = g;
sample[1][0][x] = b;
--
2.48.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-18 23:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-18 23:01 [FFmpeg-devel] [PATCH] avcodec/ffv1: NOT FOR GIT experiment seperately coding sign bits of float16 Michael Niedermayer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git