From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 2C01445118 for ; Sat, 18 Jan 2025 23:01:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 58AD768B1A1; Sun, 19 Jan 2025 01:01:18 +0200 (EET) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0B50468A9BD for ; Sun, 19 Jan 2025 01:01:11 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6487F40003 for ; Sat, 18 Jan 2025 23:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1737241271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=7/e1aLPkf+EJxJVq7J/35ogSIK7s/2LehpQbl3FQiPU=; b=MmAi6t6LxudSaYuW3MDo65K0qTef04qOxLo6xYxGTLD6YqrnmdMgBDTON3R+qDfjHSU4s1 MFSKpK1kL5VN5qFalS6wpz2tA42K+7o57eszWj6h8RjaFhHPI2TYP2qxBc5q5StSu5Df7D HbIvxKj47pLkvNu+UGS52UFbjMZa43Pp5ap7NO69n48Hi6+ZZ1m1NvV8abNS0C8NJJ9Ycz ec05Wo3lZGsaVEYMPFq2kVTlCqnGSKtRe/DuDjVvbZvr6p3BBQQI7DXnfVfuv3EjHz44EI yM3IwypxIuUHpwpPdyjXb9+wvOrPIBHlZcu3+sGBnH95cplWxwoQnxrvhm2yRA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 19 Jan 2025 00:01:10 +0100 Message-ID: <20250118230110.2936048-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH] avcodec/ffv1: NOT FOR GIT experiment seperately coding sign bits of float16 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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".