PR #24853 opened by AJ Granowski (AJGranowski) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24853 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24853.patch
Consolidate luma/chroma scale and weight-matrix selection after determining the component index. # Summary of changes This is a behavior-preserving change. Here's a truth table of the existing code prior to this change: | `is_444` | `n & 2` | `component` | `scale` | `weight_matrix` | |:--------:|:-------:|:-------------------------|:----------------------------|:----------------------------| | 0 | 0 | `0` | `luma` | `luma` | | 0 | 1 | `1 + (n & 1)` (non-zero) | `chroma` | `chroma` | | 1 | 0 | `(n >> 1) % 3` | `component ? chroma : luma` | `component ? chroma : luma` | | 1 | 1 | `(n >> 1) % 3` | `component ? chroma : luma` | `component ? chroma : luma` | Note that the value of `scale` and `weight_matrix` can be determined solely from `component` being zero or non-zero. This change makes that relationship clear by extracting the luma/chroma scale and weight-matrix selection from component selection. >From b2b59fe6f461136d5a6b7e92f63d49d56a60c7bf Mon Sep 17 00:00:00 2001 From: AJ Granowski <[email protected]> Date: Fri, 2 Oct 2026 14:17:29 -0500 Subject: [PATCH] avcodec/dnxhddec: De-duplicate chroma/luma selection Consolidate luma/chroma scale and weight-matrix selection after determining the component index. --- libavcodec/dnxhddec.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 7ba01351d9..86c72fcbe3 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -379,23 +379,20 @@ static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx, if (!ctx->is_444) { if (n & 2) { - component = 1 + (n & 1); - scale = row->chroma_scale; - weight_matrix = ctx->cid_table->chroma_weight; + component = 1 + (n & 1); } else { - component = 0; - scale = row->luma_scale; - weight_matrix = ctx->cid_table->luma_weight; + component = 0; } } else { component = (n >> 1) % 3; - if (component) { - scale = row->chroma_scale; - weight_matrix = ctx->cid_table->chroma_weight; - } else { - scale = row->luma_scale; - weight_matrix = ctx->cid_table->luma_weight; - } + } + + if (component) { + scale = row->chroma_scale; + weight_matrix = ctx->cid_table->chroma_weight; + } else { + scale = row->luma_scale; + weight_matrix = ctx->cid_table->luma_weight; } UPDATE_CACHE(bs, &row->gb); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
