Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Timo Rothenpieler via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Timo Rothenpieler <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avcodec/prores_raw: use av_popcount instead of limited lookup table (PR #21505)
Date: Sun, 18 Jan 2026 17:55:01 -0000
Message-ID: <176875890239.25.7496494912959696703@4457048688e7> (raw)

PR #21505 opened by Timo Rothenpieler (BtbN)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21505
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21505.patch

The calculation can yield bigger values than the lookup table provides.
So just use actual popcount instead.

Fixes #21503


>From 7379539685ec900b372d87ad25a23e82b8b45f17 Mon Sep 17 00:00:00 2001
From: Timo Rothenpieler <timo@rothenpieler.org>
Date: Sun, 18 Jan 2026 18:52:52 +0100
Subject: [PATCH] avcodec/prores_raw: use av_popcount instead of limited lookup
 table

The calculation can yield bigger values than the lookup table provides.
So just use actual popcount instead.

Fixes #21503
---
 libavcodec/prores_raw.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/prores_raw.c b/libavcodec/prores_raw.c
index 8be566ed36..eb1a9af14f 100644
--- a/libavcodec/prores_raw.c
+++ b/libavcodec/prores_raw.c
@@ -93,10 +93,6 @@ static uint16_t get_value(GetBitContext *gb, int16_t codebook)
 
 #define TODCCODEBOOK(x) ((x + 1) >> 1)
 
-static const uint8_t align_tile_w[16] = {
-    0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
-};
-
 #define DC_CB_MAX 12
 const uint8_t ff_prores_raw_dc_cb[DC_CB_MAX + 1] = {
     0x010, 0x021, 0x032, 0x033, 0x033, 0x033, 0x044, 0x044, 0x044, 0x044, 0x044, 0x044, 0x076,
@@ -432,7 +428,7 @@ static int decode_frame(AVCodecContext *avctx,
 
     s->nb_tw = (w + 15) >> 4;
     s->nb_th = (h + 15) >> 4;
-    s->nb_tw = (s->nb_tw >> align) + align_tile_w[~(-1 * (1 << align)) & s->nb_tw];
+    s->nb_tw = (s->nb_tw >> align) + av_popcount(~(-1 * (1 << align)) & s->nb_tw);
     s->nb_tiles = s->nb_tw * s->nb_th;
     av_log(avctx, AV_LOG_DEBUG, "%dx%d | nb_tiles: %d\n", s->nb_tw, s->nb_th, s->nb_tiles);
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2026-01-18 17:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176875890239.25.7496494912959696703@4457048688e7 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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