* [FFmpeg-devel] [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16
@ 2025-05-18 22:06 Andreas Rheinhardt
2025-05-20 4:18 ` Peter Ross
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-05-18 22:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 27 bytes --]
Patch attached.
- Andreas
[-- Attachment #2: 0001-avcodec-rv60dec-Avoid-branch-when-decoding-cbp16.patch --]
[-- Type: text/x-patch, Size: 2069 bytes --]
From 02724d5792348bea618c049034dc0febf24a46ac Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 18 May 2025 23:12:03 +0200
Subject: [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/rv60dec.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/libavcodec/rv60dec.c b/libavcodec/rv60dec.c
index d704ae512c..2bbcb1d620 100644
--- a/libavcodec/rv60dec.c
+++ b/libavcodec/rv60dec.c
@@ -82,7 +82,7 @@ enum {
};
static const VLCElem * cbp8_vlc[7][4];
-static const VLCElem * cbp16_vlc[7][3][4];
+static const VLCElem * cbp16_vlc[7][4][4];
typedef struct {
const VLCElem * l0[2];
@@ -137,12 +137,12 @@ static av_cold void rv60_init_static_data(void)
for (int i = 0; i < 7; i++)
for (int j = 0; j < 4; j++)
- cbp8_vlc[i][j] = gen_vlc(rv60_cbp8_lens[i][j], 64, &state);
+ cbp16_vlc[i][0][j] = cbp8_vlc[i][j] = gen_vlc(rv60_cbp8_lens[i][j], 64, &state);
for (int i = 0; i < 7; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 4; k++)
- cbp16_vlc[i][j][k] = gen_vlc(rv60_cbp16_lens[i][j][k], 64, &state);
+ cbp16_vlc[i][j + 1][k] = gen_vlc(rv60_cbp16_lens[i][j][k], 64, &state);
build_coeff_vlc(rv60_intra_lens, intra_coeff_vlc, 5, &state);
build_coeff_vlc(rv60_inter_lens, inter_coeff_vlc, 7, &state);
@@ -1650,10 +1650,7 @@ static int decode_super_cbp(GetBitContext * gb, const VLCElem * vlc[4])
static int decode_cbp16(GetBitContext * gb, int subset, int qp)
{
int cb_set = rv60_qp_to_idx[qp];
- if (!subset)
- return decode_super_cbp(gb, cbp8_vlc[cb_set]);
- else
- return decode_super_cbp(gb, cbp16_vlc[cb_set][subset - 1]);
+ return decode_super_cbp(gb, cbp16_vlc[cb_set][subset]);
}
static int decode_cu_r(RV60Context * s, AVFrame * frame, ThreadContext * thread, GetBitContext * gb, int xpos, int ypos, int log_size, int qp, int sel_qp)
--
2.45.2
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16
2025-05-18 22:06 [FFmpeg-devel] [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16 Andreas Rheinhardt
@ 2025-05-20 4:18 ` Peter Ross
2025-05-20 12:36 ` Andreas Rheinhardt
0 siblings, 1 reply; 3+ messages in thread
From: Peter Ross @ 2025-05-20 4:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2475 bytes --]
On Mon, May 19, 2025 at 12:06:02AM +0200, Andreas Rheinhardt wrote:
> Patch attached.
>
> - Andreas
> From 02724d5792348bea618c049034dc0febf24a46ac Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Date: Sun, 18 May 2025 23:12:03 +0200
> Subject: [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/rv60dec.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/rv60dec.c b/libavcodec/rv60dec.c
> index d704ae512c..2bbcb1d620 100644
> --- a/libavcodec/rv60dec.c
> +++ b/libavcodec/rv60dec.c
> @@ -82,7 +82,7 @@ enum {
> };
>
> static const VLCElem * cbp8_vlc[7][4];
> -static const VLCElem * cbp16_vlc[7][3][4];
> +static const VLCElem * cbp16_vlc[7][4][4];
>
> typedef struct {
> const VLCElem * l0[2];
> @@ -137,12 +137,12 @@ static av_cold void rv60_init_static_data(void)
>
> for (int i = 0; i < 7; i++)
> for (int j = 0; j < 4; j++)
> - cbp8_vlc[i][j] = gen_vlc(rv60_cbp8_lens[i][j], 64, &state);
> + cbp16_vlc[i][0][j] = cbp8_vlc[i][j] = gen_vlc(rv60_cbp8_lens[i][j], 64, &state);
>
> for (int i = 0; i < 7; i++)
> for (int j = 0; j < 3; j++)
> for (int k = 0; k < 4; k++)
> - cbp16_vlc[i][j][k] = gen_vlc(rv60_cbp16_lens[i][j][k], 64, &state);
> + cbp16_vlc[i][j + 1][k] = gen_vlc(rv60_cbp16_lens[i][j][k], 64, &state);
>
> build_coeff_vlc(rv60_intra_lens, intra_coeff_vlc, 5, &state);
> build_coeff_vlc(rv60_inter_lens, inter_coeff_vlc, 7, &state);
> @@ -1650,10 +1650,7 @@ static int decode_super_cbp(GetBitContext * gb, const VLCElem * vlc[4])
> static int decode_cbp16(GetBitContext * gb, int subset, int qp)
> {
> int cb_set = rv60_qp_to_idx[qp];
> - if (!subset)
> - return decode_super_cbp(gb, cbp8_vlc[cb_set]);
> - else
> - return decode_super_cbp(gb, cbp16_vlc[cb_set][subset - 1]);
> + return decode_super_cbp(gb, cbp16_vlc[cb_set][subset]);
> }
>
> static int decode_cu_r(RV60Context * s, AVFrame * frame, ThreadContext * thread, GetBitContext * gb, int xpos, int ypos, int log_size, int qp, int sel_qp)
> --
> 2.45.2
Looks okay. What was the motivation for this change. Speed up; any numbers?
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16
2025-05-20 4:18 ` Peter Ross
@ 2025-05-20 12:36 ` Andreas Rheinhardt
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-05-20 12:36 UTC (permalink / raw)
To: ffmpeg-devel
Peter Ross:
> On Mon, May 19, 2025 at 12:06:02AM +0200, Andreas Rheinhardt wrote:
>> Patch attached.
>>
>> - Andreas
>
>> From 02724d5792348bea618c049034dc0febf24a46ac Mon Sep 17 00:00:00 2001
>> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> Date: Sun, 18 May 2025 23:12:03 +0200
>> Subject: [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> libavcodec/rv60dec.c | 11 ++++-------
>> 1 file changed, 4 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavcodec/rv60dec.c b/libavcodec/rv60dec.c
>> index d704ae512c..2bbcb1d620 100644
>> --- a/libavcodec/rv60dec.c
>> +++ b/libavcodec/rv60dec.c
>> @@ -82,7 +82,7 @@ enum {
>> };
>>
>> static const VLCElem * cbp8_vlc[7][4];
>> -static const VLCElem * cbp16_vlc[7][3][4];
>> +static const VLCElem * cbp16_vlc[7][4][4];
>>
>> typedef struct {
>> const VLCElem * l0[2];
>> @@ -137,12 +137,12 @@ static av_cold void rv60_init_static_data(void)
>>
>> for (int i = 0; i < 7; i++)
>> for (int j = 0; j < 4; j++)
>> - cbp8_vlc[i][j] = gen_vlc(rv60_cbp8_lens[i][j], 64, &state);
>> + cbp16_vlc[i][0][j] = cbp8_vlc[i][j] = gen_vlc(rv60_cbp8_lens[i][j], 64, &state);
>>
>> for (int i = 0; i < 7; i++)
>> for (int j = 0; j < 3; j++)
>> for (int k = 0; k < 4; k++)
>> - cbp16_vlc[i][j][k] = gen_vlc(rv60_cbp16_lens[i][j][k], 64, &state);
>> + cbp16_vlc[i][j + 1][k] = gen_vlc(rv60_cbp16_lens[i][j][k], 64, &state);
>>
>> build_coeff_vlc(rv60_intra_lens, intra_coeff_vlc, 5, &state);
>> build_coeff_vlc(rv60_inter_lens, inter_coeff_vlc, 7, &state);
>> @@ -1650,10 +1650,7 @@ static int decode_super_cbp(GetBitContext * gb, const VLCElem * vlc[4])
>> static int decode_cbp16(GetBitContext * gb, int subset, int qp)
>> {
>> int cb_set = rv60_qp_to_idx[qp];
>> - if (!subset)
>> - return decode_super_cbp(gb, cbp8_vlc[cb_set]);
>> - else
>> - return decode_super_cbp(gb, cbp16_vlc[cb_set][subset - 1]);
>> + return decode_super_cbp(gb, cbp16_vlc[cb_set][subset]);
>> }
>>
>> static int decode_cu_r(RV60Context * s, AVFrame * frame, ThreadContext * thread, GetBitContext * gb, int xpos, int ypos, int log_size, int qp, int sel_qp)
>> --
>> 2.45.2
>
> Looks okay. What was the motivation for this change. Speed up; any numbers?
>
I saw a branch that could be avoided. I don't think that this leads to
any measurable speedup.
- Andreas
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2025-05-20 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-18 22:06 [FFmpeg-devel] [PATCH] avcodec/rv60dec: Avoid branch when decoding cbp16 Andreas Rheinhardt
2025-05-20 4:18 ` Peter Ross
2025-05-20 12:36 ` Andreas Rheinhardt
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