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 ESMTP id 27B8F46DDE for ; Mon, 11 Dec 2023 01:45:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F0CF168D199; Mon, 11 Dec 2023 03:44:57 +0200 (EET) Received: from ssq0.pkh.me (laubervilliers-656-1-228-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 77DB268D15C for ; Mon, 11 Dec 2023 03:44:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pkh.me; s=selector1; t=1702259076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TcnUQHN3vojWettb5naG2TJJg8kyEbR0v4LfwT3DHeg=; b=rCp2LyvAkoktS+2Bi+4p/+QHNt32w/ymCs9RQXaQz+G0qnAiFjqLxOcihZfth8whIoFtyr PPMxrf0SNnXB2P7vbB9dB67kOLZy/8IxntOslDU1B2Gn5pPEiHUdYwsELqKy4cpF2TCrrC cdYjd6gDXr/dBkU1c+i7qTohgVZh3Cw= Received: from localhost (ssq0.pkh.me [local]) by ssq0.pkh.me (OpenSMTPD) with ESMTPA id df03006b; Mon, 11 Dec 2023 01:44:36 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Dec 2023 02:35:09 +0100 Message-ID: <20231211014429.1841681-9-u@pkh.me> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211014429.1841681-1-u@pkh.me> References: <20231211014429.1841681-1-u@pkh.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/35] avcodec/proresenc_kostya: save a few operations in DC encoding 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 Cc: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 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: This matches the logic from proresenc_anatoliy. --- libavcodec/proresenc_kostya.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index f883ab550b..2d45f9a685 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -135,13 +135,6 @@ static const uint8_t prores_quant_matrices[][64] = { }, }; -static const uint8_t prores_dc_codebook[4] = { - 0x04, // rice_order = 0, exp_golomb_order = 1, switch_bits = 0 - 0x28, // rice_order = 1, exp_golomb_order = 2, switch_bits = 0 - 0x4D, // rice_order = 2, exp_golomb_order = 3, switch_bits = 1 - 0x70 // rice_order = 3, exp_golomb_order = 4, switch_bits = 0 -}; - #define NUM_MB_LIMITS 4 static const int prores_mb_limits[NUM_MB_LIMITS] = { 1620, // up to 720x576 @@ -416,7 +409,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks, int blocks_per_slice, int scale) { int i; - int codebook = 3, code, dc, prev_dc, delta, sign, new_sign; + int codebook = 5, code, dc, prev_dc, delta, sign, new_sign; prev_dc = (blocks[0] - 0x4000) / scale; encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc)); @@ -429,9 +422,8 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks, new_sign = GET_SIGN(delta); delta = (delta ^ sign) - sign; code = MAKE_CODE(delta); - encode_vlc_codeword(pb, prores_dc_codebook[codebook], code); - codebook = (code + (code & 1)) >> 1; - codebook = FFMIN(codebook, 3); + encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code); + codebook = FFMIN(code, 6); sign = new_sign; prev_dc = dc; } @@ -650,7 +642,7 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice, int scale) { int i; - int codebook = 3, code, dc, prev_dc, delta, sign, new_sign; + int codebook = 5, code, dc, prev_dc, delta, sign, new_sign; int bits; prev_dc = (blocks[0] - 0x4000) / scale; @@ -666,9 +658,8 @@ static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice, new_sign = GET_SIGN(delta); delta = (delta ^ sign) - sign; code = MAKE_CODE(delta); - bits += estimate_vlc(prores_dc_codebook[codebook], code); - codebook = (code + (code & 1)) >> 1; - codebook = FFMIN(codebook, 3); + bits += estimate_vlc(ff_prores_dc_codebook[codebook], code); + codebook = FFMIN(code, 6); sign = new_sign; prev_dc = dc; } -- 2.43.0 _______________________________________________ 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".