Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it
@ 2022-10-20  8:31 Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 02/22] avcodec/eamad: Don't use IDCTDSP-API unnecessarily Andreas Rheinhardt
                   ` (22 more replies)
  0 siblings, 23 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Currently masked by faan.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 configure | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 431fa5bf7a..bb61e9a0b8 100755
--- a/configure
+++ b/configure
@@ -2773,6 +2773,7 @@ ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
 acelp_kelvin_decoder_select="audiodsp"
 adpcm_g722_decoder_select="g722dsp"
 adpcm_g722_encoder_select="g722dsp"
+agm_decoder_select="idctdsp"
 aic_decoder_select="golomb idctdsp"
 alac_encoder_select="lpc"
 als_decoder_select="bswapdsp mpeg4audio"
@@ -2820,7 +2821,7 @@ dxv_decoder_select="lzf texturedsp"
 eac3_decoder_select="ac3_decoder"
 eac3_encoder_select="ac3_encoder"
 eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
-eatgq_decoder_select="aandcttables"
+eatgq_decoder_select="aandcttables idctdsp"
 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
 exr_decoder_deps="zlib"
 exr_encoder_deps="zlib"
@@ -2859,7 +2860,7 @@ huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp"
 hymt_decoder_select="huffyuv_decoder"
 iac_decoder_select="imc_decoder"
 imc_decoder_select="bswapdsp fft mdct sinewin"
-imm4_decoder_select="bswapdsp"
+imm4_decoder_select="bswapdsp idctdsp"
 imm5_decoder_select="h264_decoder hevc_decoder"
 indeo3_decoder_select="hpeldsp"
 indeo4_decoder_select="ividsp"
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 02/22] avcodec/eamad: Don't use IDCTDSP-API unnecessarily
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 03/22] avcodec/eatgq: " Andreas Rheinhardt
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The eamad decoder uses a custom IDCT and actually does not
use the IDCTDSP API at all. Somehow it was nevertheless
used to simply apply the identity permutation on ff_zigzag_direct.
This commit stops doing so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 configure          | 2 +-
 libavcodec/eamad.c | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index bb61e9a0b8..16b2084945 100755
--- a/configure
+++ b/configure
@@ -2820,7 +2820,7 @@ dxa_decoder_deps="zlib"
 dxv_decoder_select="lzf texturedsp"
 eac3_decoder_select="ac3_decoder"
 eac3_encoder_select="ac3_encoder"
-eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
+eamad_decoder_select="aandcttables blockdsp bswapdsp"
 eatgq_decoder_select="aandcttables idctdsp"
 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
 exr_decoder_deps="zlib"
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index 2a5aac912d..de8f488f65 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -39,7 +39,6 @@
 #include "get_bits.h"
 #include "aandcttab.h"
 #include "eaidct.h"
-#include "idctdsp.h"
 #include "mpeg12data.h"
 #include "mpeg12vlc.h"
 
@@ -52,13 +51,11 @@ typedef struct MadContext {
     AVCodecContext *avctx;
     BlockDSPContext bdsp;
     BswapDSPContext bbdsp;
-    IDCTDSPContext idsp;
     AVFrame *last_frame;
     GetBitContext gb;
     void *bitstream_buf;
     unsigned int bitstream_buf_size;
     DECLARE_ALIGNED(32, int16_t, block)[64];
-    ScanTable scantable;
     uint16_t quant_matrix[64];
     int mb_x;
     int mb_y;
@@ -71,9 +68,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
     ff_blockdsp_init(&s->bdsp);
     ff_bswapdsp_init(&s->bbdsp);
-    ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);
-    ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct);
     ff_mpeg12_init_vlcs();
 
     s->last_frame = av_frame_alloc();
@@ -135,7 +129,7 @@ static inline int decode_block_intra(MadContext *s, int16_t * block)
 {
     int level, i, j, run;
     RLTable *rl = &ff_rl_mpeg1;
-    const uint8_t *scantable = s->scantable.permutated;
+    const uint8_t *scantable = ff_zigzag_direct;
     int16_t *quant_matrix = s->quant_matrix;
 
     block[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 03/22] avcodec/eatgq: Don't use IDCTDSP-API unnecessarily
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 02/22] avcodec/eamad: Don't use IDCTDSP-API unnecessarily Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 04/22] avcodec/eatqi: " Andreas Rheinhardt
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The eatgq decoder uses a custom IDCT and actually does not
use the IDCTDSP API at all. Somehow it was nevertheless
used to simply apply the identity permutation on ff_zigzag_direct.
This commit stops doing so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 configure          | 2 +-
 libavcodec/eatgq.c | 7 +------
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 16b2084945..84d7be8bfe 100755
--- a/configure
+++ b/configure
@@ -2821,7 +2821,7 @@ dxv_decoder_select="lzf texturedsp"
 eac3_decoder_select="ac3_decoder"
 eac3_encoder_select="ac3_encoder"
 eamad_decoder_select="aandcttables blockdsp bswapdsp"
-eatgq_decoder_select="aandcttables idctdsp"
+eatgq_decoder_select="aandcttables"
 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
 exr_decoder_deps="zlib"
 exr_encoder_deps="zlib"
diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index a6c3e72f85..e8d66418b9 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -39,12 +39,10 @@
 #include "decode.h"
 #include "eaidct.h"
 #include "get_bits.h"
-#include "idctdsp.h"
 
 typedef struct TgqContext {
     AVCodecContext *avctx;
     int width, height;
-    ScanTable scantable;
     int qtable[64];
     DECLARE_ALIGNED(16, int16_t, block)[6][64];
     GetByteContext gb;
@@ -53,10 +51,7 @@ typedef struct TgqContext {
 static av_cold int tgq_decode_init(AVCodecContext *avctx)
 {
     TgqContext *s = avctx->priv_data;
-    uint8_t idct_permutation[64];
     s->avctx = avctx;
-    ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE);
-    ff_init_scantable(idct_permutation, &s->scantable, ff_zigzag_direct);
     avctx->framerate = (AVRational){ 15, 1 };
     avctx->pix_fmt   = AV_PIX_FMT_YUV420P;
     return 0;
@@ -64,7 +59,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx)
 
 static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb)
 {
-    uint8_t *perm = s->scantable.permutated;
+    const uint8_t *perm = ff_zigzag_direct;
     int i, j, value;
     block[0] = get_sbits(gb, 8) * s->qtable[0];
     for (i = 1; i < 64;) {
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 04/22] avcodec/eatqi: Don't use IDCTDSP-API unnecessarily
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 02/22] avcodec/eamad: Don't use IDCTDSP-API unnecessarily Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 03/22] avcodec/eatgq: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 05/22] avcodec/aic: Remove useless ScanTable Andreas Rheinhardt
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The eatqi decoder uses a custom IDCT and actually does not
use the IDCTDSP API at all. Somehow it was nevertheless
used to simply apply the identity permutation on ff_zigzag_direct.
This commit stops doing so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 configure          | 2 +-
 libavcodec/eatqi.c | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 84d7be8bfe..baaf61271f 100755
--- a/configure
+++ b/configure
@@ -2822,7 +2822,7 @@ eac3_decoder_select="ac3_decoder"
 eac3_encoder_select="ac3_encoder"
 eamad_decoder_select="aandcttables blockdsp bswapdsp"
 eatgq_decoder_select="aandcttables"
-eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
+eatqi_decoder_select="aandcttables blockdsp bswapdsp"
 exr_decoder_deps="zlib"
 exr_encoder_deps="zlib"
 ffv1_decoder_select="rangecoder"
diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c
index 324e6f1ced..e4f12b3db2 100644
--- a/libavcodec/eatqi.c
+++ b/libavcodec/eatqi.c
@@ -36,7 +36,6 @@
 #include "get_bits.h"
 #include "aandcttab.h"
 #include "eaidct.h"
-#include "idctdsp.h"
 #include "mpeg12data.h"
 #include "mpeg12dec.h"
 
@@ -45,8 +44,6 @@ typedef struct TqiContext {
     GetBitContext gb;
     BlockDSPContext bdsp;
     BswapDSPContext bsdsp;
-    IDCTDSPContext idsp;
-    ScanTable intra_scantable;
 
     void *bitstream_buf;
     unsigned int bitstream_buf_size;
@@ -64,9 +61,6 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx)
 
     ff_blockdsp_init(&t->bdsp);
     ff_bswapdsp_init(&t->bsdsp);
-    ff_idctdsp_init(&t->idsp, avctx);
-    ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE);
-    ff_init_scantable(t->idsp.idct_permutation, &t->intra_scantable, ff_zigzag_direct);
 
     avctx->framerate = (AVRational){ 15, 1 };
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@@ -82,7 +76,7 @@ static int tqi_decode_mb(TqiContext *t, int16_t (*block)[64])
     for (n = 0; n < 6; n++) {
         int ret = ff_mpeg1_decode_block_intra(&t->gb,
                                               t->intra_matrix,
-                                              t->intra_scantable.permutated,
+                                              ff_zigzag_direct,
                                               t->last_dc, block[n], n, 1);
         if (ret < 0) {
             av_log(t->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 05/22] avcodec/aic: Remove useless ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 04/22] avcodec/eatqi: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 06/22] avcodec/imm4: " Andreas Rheinhardt
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aic.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aic.c b/libavcodec/aic.c
index 49d08f0556..7ba1c02fdd 100644
--- a/libavcodec/aic.c
+++ b/libavcodec/aic.c
@@ -143,7 +143,6 @@ typedef struct AICContext {
     AVCodecContext *avctx;
     AVFrame        *frame;
     IDCTDSPContext idsp;
-    ScanTable      scantable;
 
     int            num_x_slices;
     int            slice_width;
@@ -348,10 +347,10 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
     for (mb = 0; mb < slice_width; mb++) {
         for (blk = 0; blk < 4; blk++) {
             if (!ctx->interlaced)
-                recombine_block(ctx->block, ctx->scantable.permutated,
+                recombine_block(ctx->block, ctx->idsp.idct_permutation,
                                 &base_y, &ext_y);
             else
-                recombine_block_il(ctx->block, ctx->scantable.permutated,
+                recombine_block_il(ctx->block, ctx->idsp.idct_permutation,
                                    &base_y, &ext_y, blk);
             unquant_block(ctx->block, ctx->quant, ctx->quant_matrix);
             ctx->idsp.idct(ctx->block);
@@ -368,7 +367,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
         Y += 16;
 
         for (blk = 0; blk < 2; blk++) {
-            recombine_block(ctx->block, ctx->scantable.permutated,
+            recombine_block(ctx->block, ctx->idsp.idct_permutation,
                             &base_c, &ext_c);
             unquant_block(ctx->block, ctx->quant, ctx->quant_matrix);
             ctx->idsp.idct(ctx->block);
@@ -444,7 +443,6 @@ static av_cold int aic_decode_init(AVCodecContext *avctx)
 {
     AICContext *ctx = avctx->priv_data;
     int i;
-    uint8_t scan[64];
 
     ctx->avctx = avctx;
 
@@ -452,9 +450,6 @@ static av_cold int aic_decode_init(AVCodecContext *avctx)
 
     ff_idctdsp_init(&ctx->idsp, avctx);
 
-    for (i = 0; i < 64; i++)
-        scan[i] = i;
-    ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, scan);
     for (i = 0; i < 64; i++)
         ctx->quant_matrix[ctx->idsp.idct_permutation[i]] = aic_quant_matrix[i];
 
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 06/22] avcodec/imm4: Remove useless ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 05/22] avcodec/aic: Remove useless ScanTable Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 07/22] avcodec/idctdsp: Add function to apply permutation to array Andreas Rheinhardt
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/imm4.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index e2aa20813a..f342e6d313 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -51,9 +51,8 @@ typedef struct IMM4Context {
     unsigned lo;
     unsigned hi;
 
-    ScanTable intra_scantable;
-    DECLARE_ALIGNED(32, int16_t, block)[6][64];
     IDCTDSPContext idsp;
+    DECLARE_ALIGNED(32, int16_t, block)[6][64];
 } IMM4Context;
 
 static const uint8_t intra_cb[] = {
@@ -129,7 +128,7 @@ static int decode_block(AVCodecContext *avctx, GetBitContext *gb,
                         int block, int factor, int flag, int offset, int flag2)
 {
     IMM4Context *s = avctx->priv_data;
-    const uint8_t *scantable = s->intra_scantable.permutated;
+    const uint8_t *scantable = s->idsp.idct_permutation;
     int i, last, len, factor2;
 
     for (i = !flag; i < 64; i++) {
@@ -172,7 +171,7 @@ static int decode_blocks(AVCodecContext *avctx, GetBitContext *gb,
                          unsigned cbp, int flag, int offset, unsigned flag2)
 {
     IMM4Context *s = avctx->priv_data;
-    const uint8_t *scantable = s->intra_scantable.permutated;
+    const uint8_t *scantable = s->idsp.idct_permutation;
     int ret, i;
 
     memset(s->block, 0, sizeof(s->block));
@@ -495,14 +494,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
 {
     static AVOnce init_static_once = AV_ONCE_INIT;
     IMM4Context *s = avctx->priv_data;
-    uint8_t table[64];
-
-    for (int i = 0; i < 64; i++)
-        table[i] = i;
 
     ff_bswapdsp_init(&s->bdsp);
     ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, table);
 
     s->prev_frame = av_frame_alloc();
     if (!s->prev_frame)
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 07/22] avcodec/idctdsp: Add function to apply permutation to array
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 06/22] avcodec/imm4: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 08/22] avcodec/agm: Only keep what is used from ScanTable Andreas Rheinhardt
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is the part of ff_init_scantable() that is used
by all users of said function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/idctdsp.c | 9 +++++++++
 libavcodec/idctdsp.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c
index 4ee9c3aa74..50156930ed 100644
--- a/libavcodec/idctdsp.c
+++ b/libavcodec/idctdsp.c
@@ -27,6 +27,15 @@
 #include "simple_idct.h"
 #include "xvididct.h"
 
+av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64],
+                                  const uint8_t permutation[64])
+{
+    for (int i = 0; i < 64; i++) {
+        int j = src[i];
+        dst[i] = permutation[j];
+    }
+}
+
 av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
                                const uint8_t *src_scantable)
 {
diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h
index 2bd9820f72..b286bc231c 100644
--- a/libavcodec/idctdsp.h
+++ b/libavcodec/idctdsp.h
@@ -43,6 +43,8 @@ enum idct_permutation_type {
     FF_IDCT_PERM_SSE2,
 };
 
+void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64],
+                          const uint8_t permutation[64]);
 void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
                        const uint8_t *src_scantable);
 void ff_init_scantable_permutation(uint8_t *idct_permutation,
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 08/22] avcodec/agm: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (5 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 07/22] avcodec/idctdsp: Add function to apply permutation to array Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 09/22] avcodec/asvdec: " Andreas Rheinhardt
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/agm.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index 017aa0e1fa..c365ed7e9a 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -88,7 +88,7 @@ typedef struct AGMContext {
     int luma_quant_matrix[64];
     int chroma_quant_matrix[64];
 
-    ScanTable scantable;
+    uint8_t scantable[64];
     DECLARE_ALIGNED(32, int16_t, block)[64];
 
     int16_t *wblocks;
@@ -195,7 +195,7 @@ static int read_code(GetBitContext *gb, int *oskip, int *level, int *map, int mo
 static int decode_intra_blocks(AGMContext *s, GetBitContext *gb,
                                const int *quant_matrix, int *skip, int *dc_level)
 {
-    const uint8_t *scantable = s->scantable.permutated;
+    const uint8_t *scantable = s->scantable;
     int level, ret, map = 0;
 
     memset(s->wblocks, 0, s->wblocks_size);
@@ -237,7 +237,7 @@ static int decode_inter_blocks(AGMContext *s, GetBitContext *gb,
                                const int *quant_matrix, int *skip,
                                int *map)
 {
-    const uint8_t *scantable = s->scantable.permutated;
+    const uint8_t *scantable = s->scantable;
     int level, ret;
 
     memset(s->wblocks, 0, s->wblocks_size);
@@ -272,7 +272,7 @@ static int decode_inter_blocks(AGMContext *s, GetBitContext *gb,
 static int decode_intra_block(AGMContext *s, GetBitContext *gb,
                               const int *quant_matrix, int *skip, int *dc_level)
 {
-    const uint8_t *scantable = s->scantable.permutated;
+    const uint8_t *scantable = s->scantable;
     const int offset = s->plus ? 0 : 1024;
     int16_t *block = s->block;
     int level, ret, map = 0;
@@ -362,7 +362,7 @@ static int decode_inter_block(AGMContext *s, GetBitContext *gb,
                               const int *quant_matrix, int *skip,
                               int *map)
 {
-    const uint8_t *scantable = s->scantable.permutated;
+    const uint8_t *scantable = s->scantable;
     int16_t *block = s->block;
     int level, ret;
 
@@ -1249,7 +1249,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     avctx->idct_algo = FF_IDCT_SIMPLE;
     ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct);
+    ff_permute_scantable(s->scantable, ff_zigzag_direct,
+                         s->idsp.idct_permutation);
 
     s->prev_frame = av_frame_alloc();
     if (!s->prev_frame)
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 09/22] avcodec/asvdec: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (6 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 08/22] avcodec/agm: Only keep what is used from ScanTable Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 10/22] avcodec/dnxhddec: " Andreas Rheinhardt
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/asvdec.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
index be89544732..11cf105d08 100644
--- a/libavcodec/asvdec.c
+++ b/libavcodec/asvdec.c
@@ -58,7 +58,7 @@ typedef struct ASVDecContext {
 
     BlockDSPContext bdsp;
     IDCTDSPContext idsp;
-    ScanTable scantable;
+    uint8_t scantable[64];
     DECLARE_ALIGNED(32, int16_t, block)[6][64];
     uint16_t intra_matrix[64];
     uint8_t *bitstream_buffer;
@@ -141,13 +141,13 @@ static inline int asv1_decode_block(ASVDecContext *a, int16_t block[64])
             }
 
             if (ccp & 8)
-                block[a->scantable.permutated[4 * i + 0]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 0]) >> 4;
+                block[a->scantable[4 * i + 0]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 0]) >> 4;
             if (ccp & 4)
-                block[a->scantable.permutated[4 * i + 1]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 1]) >> 4;
+                block[a->scantable[4 * i + 1]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 1]) >> 4;
             if (ccp & 2)
-                block[a->scantable.permutated[4 * i + 2]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 2]) >> 4;
+                block[a->scantable[4 * i + 2]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 2]) >> 4;
             if (ccp & 1)
-                block[a->scantable.permutated[4 * i + 3]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 3]) >> 4;
+                block[a->scantable[4 * i + 3]] = (asv1_get_level(&a->gb) * a->intra_matrix[4 * i + 3]) >> 4;
         }
     }
 
@@ -165,11 +165,11 @@ static inline int asv2_decode_block(ASVDecContext *a, int16_t block[64])
     ccp = asv2_get_vlc2(&a->gb, dc_ccp_vlc.table, DC_CCP_VLC_BITS);
     if (ccp) {
         if (ccp & 4)
-            block[a->scantable.permutated[1]] = (asv2_get_level(&a->gb) * a->intra_matrix[1]) >> 4;
+            block[a->scantable[1]] = (asv2_get_level(&a->gb) * a->intra_matrix[1]) >> 4;
         if (ccp & 2)
-            block[a->scantable.permutated[2]] = (asv2_get_level(&a->gb) * a->intra_matrix[2]) >> 4;
+            block[a->scantable[2]] = (asv2_get_level(&a->gb) * a->intra_matrix[2]) >> 4;
         if (ccp & 1)
-            block[a->scantable.permutated[3]] = (asv2_get_level(&a->gb) * a->intra_matrix[3]) >> 4;
+            block[a->scantable[3]] = (asv2_get_level(&a->gb) * a->intra_matrix[3]) >> 4;
     }
 
     for (i = 1; i < count + 1; i++) {
@@ -177,13 +177,13 @@ static inline int asv2_decode_block(ASVDecContext *a, int16_t block[64])
 
         if (ccp) {
             if (ccp & 8)
-                block[a->scantable.permutated[4 * i + 0]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 0]) >> 4;
+                block[a->scantable[4 * i + 0]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 0]) >> 4;
             if (ccp & 4)
-                block[a->scantable.permutated[4 * i + 1]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 1]) >> 4;
+                block[a->scantable[4 * i + 1]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 1]) >> 4;
             if (ccp & 2)
-                block[a->scantable.permutated[4 * i + 2]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 2]) >> 4;
+                block[a->scantable[4 * i + 2]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 2]) >> 4;
             if (ccp & 1)
-                block[a->scantable.permutated[4 * i + 3]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 3]) >> 4;
+                block[a->scantable[4 * i + 3]] = (asv2_get_level(&a->gb) * a->intra_matrix[4 * i + 3]) >> 4;
         }
     }
 
@@ -311,7 +311,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
     ff_asv_common_init(avctx);
     ff_blockdsp_init(&a->bdsp);
     ff_idctdsp_init(&a->idsp, avctx);
-    ff_init_scantable(a->idsp.idct_permutation, &a->scantable, ff_asv_scantab);
+    ff_permute_scantable(a->scantable, ff_asv_scantab,
+                         a->idsp.idct_permutation);
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
     if (avctx->extradata_size < 1 || (inv_qscale = avctx->extradata[0]) == 0) {
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 10/22] avcodec/dnxhddec: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (7 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 09/22] avcodec/asvdec: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 11/22] avcodec/cavs: Only keep what is needed from IDCTDSP-API Andreas Rheinhardt
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dnxhddec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index a44f95f044..ce738f3991 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -65,7 +65,7 @@ typedef struct DNXHDContext {
     int cur_field;                      ///< current interlaced field
     VLC ac_vlc, dc_vlc, run_vlc;
     IDCTDSPContext idsp;
-    ScanTable scantable;
+    uint8_t scantable[64];
     const CIDEntry *cid_table;
     int bit_depth; // 8, 10, 12 or 0 if not initialized at all.
     int is_444;
@@ -275,8 +275,8 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
     if (ctx->bit_depth != old_bit_depth) {
         ff_blockdsp_init(&ctx->bdsp);
         ff_idctdsp_init(&ctx->idsp, ctx->avctx);
-        ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable,
-                          ff_zigzag_direct);
+        ff_permute_scantable(ctx->scantable, ff_zigzag_direct,
+                             ctx->idsp.idct_permutation);
     }
 
     // make sure profile size constraints are respected
@@ -436,7 +436,7 @@ static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx,
             break;
         }
 
-        j     = ctx->scantable.permutated[i];
+        j      = ctx->scantable[i];
         level *= scale[i];
         level += scale[i] >> 1;
         if (level_bias < 32 || weight_matrix[i] != level_bias)
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 11/22] avcodec/cavs: Only keep what is needed from IDCTDSP-API
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (8 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 10/22] avcodec/dnxhddec: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 12/22] avcodec/g2meet: Only keep what is used from ScanTable Andreas Rheinhardt
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated. The rest of the IDCTDSP-API
is unused as cavs has its own idct.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/cavs.c    | 7 +++----
 libavcodec/cavs.h    | 9 ++++++---
 libavcodec/cavsdec.c | 2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 6d54e8eae5..9658e691d7 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -792,15 +792,14 @@ int ff_cavs_init_top_lines(AVSContext *h)
 av_cold int ff_cavs_init(AVCodecContext *avctx)
 {
     AVSContext *h = avctx->priv_data;
+    uint8_t permutation[64];
 
     ff_blockdsp_init(&h->bdsp);
     ff_h264chroma_init(&h->h264chroma, 8);
-    ff_idctdsp_init(&h->idsp, avctx);
     ff_videodsp_init(&h->vdsp, 8);
     ff_cavsdsp_init(&h->cdsp);
-    ff_init_scantable_permutation(h->idsp.idct_permutation,
-                                  h->cdsp.idct_perm);
-    ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct);
+    ff_init_scantable_permutation(permutation, h->cdsp.idct_perm);
+    ff_permute_scantable(h->scantable, ff_zigzag_direct, permutation);
 
     h->avctx       = avctx;
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index cbc163fb4d..0852096b66 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -22,12 +22,16 @@
 #ifndef AVCODEC_CAVS_H
 #define AVCODEC_CAVS_H
 
+#include <stddef.h>
+#include <stdint.h>
+
+#include "libavutil/frame.h"
 #include "libavutil/mem_internal.h"
 
+#include "avcodec.h"
 #include "cavsdsp.h"
 #include "blockdsp.h"
 #include "h264chroma.h"
-#include "idctdsp.h"
 #include "get_bits.h"
 #include "videodsp.h"
 
@@ -166,7 +170,6 @@ typedef struct AVSContext {
     AVCodecContext *avctx;
     BlockDSPContext bdsp;
     H264ChromaContext h264chroma;
-    IDCTDSPContext idsp;
     VideoDSPContext vdsp;
     CAVSDSPContext  cdsp;
     GetBitContext gb;
@@ -220,7 +223,7 @@ typedef struct AVSContext {
     int qp_fixed;
     int pic_qp_fixed;
     int cbp;
-    ScanTable scantable;
+    uint8_t scantable[64];
 
     /** intra prediction is done with un-deblocked samples
      they are saved here before deblocking the MB  */
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 3e8be65968..11197455e6 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -521,7 +521,7 @@ static inline int dequant(AVSContext *h, int16_t *level_buf, uint8_t *run_buf,
 {
     int round = 1 << (shift - 1);
     int pos = -1;
-    const uint8_t *scantab = h->scantable.permutated;
+    const uint8_t *scantab = h->scantable;
 
     /* inverse scan and dequantization */
     while (--coeff_num >= 0) {
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 12/22] avcodec/g2meet: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (9 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 11/22] avcodec/cavs: Only keep what is needed from IDCTDSP-API Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 13/22] avcodec/g2meet: Pre-permute quantization tables Andreas Rheinhardt
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/g2meet.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 4367af3dc0..7c1f8325c4 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -120,7 +120,7 @@ typedef struct ePICContext {
 typedef struct JPGContext {
     BlockDSPContext bdsp;
     IDCTDSPContext idsp;
-    ScanTable  scantable;
+    uint8_t    scantable[64];
 
     VLC        dc_vlc[2], ac_vlc[2];
     int        prev_dc[3];
@@ -182,8 +182,8 @@ static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)
 
     ff_blockdsp_init(&c->bdsp);
     ff_idctdsp_init(&c->idsp, avctx);
-    ff_init_scantable(c->idsp.idct_permutation, &c->scantable,
-                      ff_zigzag_direct);
+    ff_permute_scantable(c->scantable, ff_zigzag_direct,
+                         c->idsp.idct_permutation);
 
     return 0;
 }
@@ -251,7 +251,7 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
 
             val                                 = get_xbits(gb, nbits);
             val                                *= qmat[ff_zigzag_direct[pos]];
-            block[c->scantable.permutated[pos]] = val;
+            block[c->scantable[pos]] = val;
         }
     }
     return 0;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 13/22] avcodec/g2meet: Pre-permute quantization tables
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (10 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 12/22] avcodec/g2meet: Only keep what is used from ScanTable Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 14/22] avcodec/intrax8: Only keep what is used from ScanTable Andreas Rheinhardt
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Allows to avoid a permutation lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/g2meet.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 7c1f8325c4..db427322cd 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -59,22 +59,23 @@ enum Compression {
     COMPR_KEMPF_J_B,
 };
 
+/* These tables are already permuted according to ff_zigzag_direct */
 static const uint8_t luma_quant[64] = {
-     8,  6,  5,  8, 12, 20, 26, 31,
-     6,  6,  7, 10, 13, 29, 30, 28,
-     7,  7,  8, 12, 20, 29, 35, 28,
-     7,  9, 11, 15, 26, 44, 40, 31,
-     9, 11, 19, 28, 34, 55, 52, 39,
-    12, 18, 28, 32, 41, 52, 57, 46,
-    25, 32, 39, 44, 52, 61, 60, 51,
-    36, 46, 48, 49, 56, 50, 52, 50
+     8,  6,  6,  7,  6,  5,  8,  7,
+     7,  7,  9,  9,  8, 10, 12, 20,
+    13, 12, 11, 11, 12, 25, 18, 19,
+    15, 20, 29, 26, 31, 30, 29, 26,
+    28, 28, 32, 36, 46, 39, 32, 34,
+    44, 35, 28, 28, 40, 55, 41, 44,
+    48, 49, 52, 52, 52, 31, 39, 57,
+    61, 56, 50, 60, 46, 51, 52, 50,
 };
 
 static const uint8_t chroma_quant[64] = {
-     9,  9, 12, 24, 50, 50, 50, 50,
-     9, 11, 13, 33, 50, 50, 50, 50,
-    12, 13, 28, 50, 50, 50, 50, 50,
-    24, 33, 50, 50, 50, 50, 50, 50,
+     9,  9,  9, 12, 11, 12, 24, 13,
+    13, 24, 50, 33, 28, 33, 50, 50,
+    50, 50, 50, 50, 50, 50, 50, 50,
+    50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50,
@@ -250,7 +251,7 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
             int nbits = val;
 
             val                                 = get_xbits(gb, nbits);
-            val                                *= qmat[ff_zigzag_direct[pos]];
+            val                                *= qmat[pos];
             block[c->scantable[pos]] = val;
         }
     }
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 14/22] avcodec/intrax8: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (11 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 13/22] avcodec/g2meet: Pre-permute quantization tables Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 15/22] avcodec/mdec: " Andreas Rheinhardt
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/intrax8.c | 15 ++++++++-------
 libavcodec/intrax8.h |  3 +--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index f88baf8daf..e8e48ac1bd 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -25,6 +25,7 @@
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "get_bits.h"
+#include "idctdsp.h"
 #include "msmpeg4data.h"
 #include "intrax8huf.h"
 #include "intrax8.h"
@@ -576,7 +577,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma)
         x8_select_ac_table(w, ac_mode);
         /* scantable_selector[12] = { 0, 2, 0, 1, 1, 1, 0, 2, 2, 0, 1, 2 }; <-
          * -> 10'01' 00'10' 10'00' 01'01' 01'00' 10'00 => 0x928548 */
-        scantable = w->scantable[(0x928548 >> (2 * w->orient)) & 3].permutated;
+        scantable = w->scantable[(0x928548 >> (2 * w->orient)) & 3];
         pos       = 0;
         do {
             n++;
@@ -714,12 +715,12 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
     ff_init_scantable_permutation(w->idct_permutation,
                                   w->wdsp.idct_perm);
 
-    ff_init_scantable(w->idct_permutation, &w->scantable[0],
-                      ff_wmv1_scantable[0]);
-    ff_init_scantable(w->idct_permutation, &w->scantable[1],
-                      ff_wmv1_scantable[2]);
-    ff_init_scantable(w->idct_permutation, &w->scantable[2],
-                      ff_wmv1_scantable[3]);
+    ff_permute_scantable(w->scantable[0], ff_wmv1_scantable[0],
+                         w->idct_permutation);
+    ff_permute_scantable(w->scantable[1], ff_wmv1_scantable[2],
+                         w->idct_permutation);
+    ff_permute_scantable(w->scantable[2], ff_wmv1_scantable[3],
+                         w->idct_permutation);
 
     ff_intrax8dsp_init(&w->dsp);
     ff_blockdsp_init(&w->bdsp);
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 9ef2fc3dd3..217ef75e04 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -21,7 +21,6 @@
 
 #include "blockdsp.h"
 #include "get_bits.h"
-#include "idctdsp.h"
 #include "intrax8dsp.h"
 #include "wmv2dsp.h"
 #include "mpegpicture.h"
@@ -35,7 +34,7 @@ typedef struct IntraX8Context {
 
     // set by ff_intrax8_common_init
     uint8_t *prediction_table; // 2 * (mb_w * 2)
-    ScanTable scantable[3];
+    uint8_t scantable[3][64];
     WMV2DSPContext wdsp;
     uint8_t idct_permutation[64];
     AVCodecContext *avctx;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 15/22] avcodec/mdec: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (12 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 14/22] avcodec/intrax8: Only keep what is used from ScanTable Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 16/22] avcodec/mimic: " Andreas Rheinhardt
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mdec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index f27cf84122..f3f1387d59 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -44,7 +44,7 @@ typedef struct MDECContext {
     BswapDSPContext bbdsp;
     IDCTDSPContext idsp;
     GetBitContext gb;
-    ScanTable scantable;
+    uint8_t scantable[64];
     int version;
     int qscale;
     int last_dc[3];
@@ -64,7 +64,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
     int level, diff, i, j, run;
     int component;
     RLTable *rl = &ff_rl_mpeg1;
-    uint8_t * const scantable = a->scantable.permutated;
+    const uint8_t * const scantable = a->scantable;
     const uint16_t *quant_matrix = a->quant_matrix;
     const int qscale = a->qscale;
 
@@ -223,8 +223,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
     ff_bswapdsp_init(&a->bbdsp);
     ff_idctdsp_init(&a->idsp, avctx);
     ff_mpeg12_init_vlcs();
-    ff_init_scantable(a->idsp.idct_permutation, &a->scantable,
-                      ff_zigzag_direct);
+    ff_permute_scantable(a->scantable, ff_zigzag_direct,
+                         a->idsp.idct_permutation);
 
     avctx->pix_fmt  = AV_PIX_FMT_YUVJ420P;
     avctx->color_range = AVCOL_RANGE_JPEG;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 16/22] avcodec/mimic: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (13 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 15/22] avcodec/mdec: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 17/22] avcodec/mjpegdec: " Andreas Rheinhardt
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mimic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index 74eaa7d043..153bd061f5 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -56,7 +56,7 @@ typedef struct MimicContext {
     DECLARE_ALIGNED(32, int16_t, dct_block)[64];
 
     GetBitContext   gb;
-    ScanTable       scantable;
+    uint8_t         scantable[64];
     BlockDSPContext bdsp;
     BswapDSPContext bbdsp;
     HpelDSPContext  hdsp;
@@ -137,7 +137,7 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx)
     ff_bswapdsp_init(&ctx->bbdsp);
     ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
     ff_idctdsp_init(&ctx->idsp, avctx);
-    ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, col_zag);
+    ff_permute_scantable(ctx->scantable, col_zag, ctx->idsp.idct_permutation);
 
     for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
         ctx->frames[i].f = av_frame_alloc();
@@ -250,7 +250,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
         else /* TODO Use >> 10 instead of / 1001 */
             coeff = (coeff * qscale) / 1001;
 
-        block[ctx->scantable.permutated[pos]] = coeff;
+        block[ctx->scantable[pos]] = coeff;
     }
 
     return 0;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 17/22] avcodec/mjpegdec: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (14 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 16/22] avcodec/mimic: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 18/22] avcodec/mjpegenc_common: Only pass " Andreas Rheinhardt
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mjpegdec.c | 16 ++++++++--------
 libavcodec/mjpegdec.h |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 3374ae71bd..d9df138ab5 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -115,8 +115,8 @@ static void init_idct(AVCodecContext *avctx)
     MJpegDecodeContext *s = avctx->priv_data;
 
     ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
-                      ff_zigzag_direct);
+    ff_permute_scantable(s->scantable, ff_zigzag_direct,
+                         s->idsp.idct_permutation);
 }
 
 av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
@@ -846,7 +846,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t *block, int component,
                 av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
                 return AVERROR_INVALIDDATA;
             }
-            j        = s->scantable.permutated[i];
+            j        = s->scantable[i];
             block[j] = level * quant_matrix[i];
         }
     } while (i < 63);
@@ -909,14 +909,14 @@ static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
 
                 if (i >= se) {
                     if (i == se) {
-                        j = s->scantable.permutated[se];
+                        j = s->scantable[se];
                         block[j] = level * (quant_matrix[se] << Al);
                         break;
                     }
                     av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
                     return AVERROR_INVALIDDATA;
                 }
-                j = s->scantable.permutated[i];
+                j = s->scantable[i];
                 block[j] = level * (quant_matrix[i] << Al);
             } else {
                 if (run == 0xF) {// ZRL - skip 15 coefficients
@@ -964,7 +964,7 @@ for (; ; i++) {                                                     \
         }                                                           \
         break;                                                      \
     }                                                               \
-    j = s->scantable.permutated[i];                                 \
+    j = s->scantable[i];                                            \
     if (block[j])                                                   \
         REFINE_BIT(j)                                               \
     else if (run-- == 0)                                            \
@@ -994,7 +994,7 @@ static int decode_block_refinement(MJpegDecodeContext *s, int16_t *block,
                 val = SHOW_UBITS(re, &s->gb, 1);
                 LAST_SKIP_BITS(re, &s->gb, 1);
                 ZERO_RUN;
-                j = s->scantable.permutated[i];
+                j = s->scantable[i];
                 val--;
                 block[j] = ((quant_matrix[i] << Al) ^ val) - val;
                 if (i == se) {
@@ -1026,7 +1026,7 @@ static int decode_block_refinement(MJpegDecodeContext *s, int16_t *block,
     }
 
     for (; i <= last; i++) {
-        j = s->scantable.permutated[i];
+        j = s->scantable[i];
         if (block[j])
             REFINE_BIT(j)
     }
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h
index 648dd714e1..621f329f9f 100644
--- a/libavcodec/mjpegdec.h
+++ b/libavcodec/mjpegdec.h
@@ -118,7 +118,7 @@ typedef struct MJpegDecodeContext {
     uint64_t coefs_finished[MAX_COMPONENTS]; ///< bitmask of which coefs have been completely decoded (progressive mode)
     int palette_index;
     int force_pal8;
-    ScanTable scantable;
+    uint8_t scantable[64];
     BlockDSPContext bdsp;
     HpelDSPContext hdsp;
     IDCTDSPContext idsp;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 18/22] avcodec/mjpegenc_common: Only pass what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (15 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 17/22] avcodec/mjpegdec: " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 19/22] avcodec/speedhq: Only keep " Andreas Rheinhardt
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mjpegenc.c        | 2 +-
 libavcodec/mjpegenc_common.c | 8 ++++----
 libavcodec/mjpegenc_common.h | 3 +--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index e56a466b36..eafe7130e2 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -81,7 +81,7 @@ static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256],
 static void mjpeg_encode_picture_header(MpegEncContext *s)
 {
     ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->picture->f, s->mjpeg_ctx,
-                                   &s->intra_scantable, 0,
+                                   s->intra_scantable.permutated, 0,
                                    s->intra_matrix, s->chroma_intra_matrix,
                                    s->slice_context_count > 1);
 
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index c37c964931..d1b0ee7e3d 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -58,7 +58,7 @@ static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
 
 static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
                               MJpegContext *m,
-                              ScanTable *intra_scantable,
+                              const uint8_t intra_scantable[64],
                               uint16_t luma_intra_matrix[64],
                               uint16_t chroma_intra_matrix[64],
                               int hsample[3], int use_slices, int matrices_differ)
@@ -76,7 +76,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
         put_bits(p, 4, 0); /* 8 bit precision */
         put_bits(p, 4, 0); /* table 0 */
         for (int i = 0; i < 64; i++) {
-            uint8_t j = intra_scantable->permutated[i];
+            uint8_t j = intra_scantable[i];
             put_bits(p, 8, luma_intra_matrix[j]);
         }
 
@@ -84,7 +84,7 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
             put_bits(p, 4, 0); /* 8 bit precision */
             put_bits(p, 4, 1); /* table 1 */
             for(i=0;i<64;i++) {
-                j = intra_scantable->permutated[i];
+                j = intra_scantable[i];
                 put_bits(p, 8, chroma_intra_matrix[j]);
             }
         }
@@ -275,7 +275,7 @@ void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4
 
 void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
                                     const AVFrame *frame, struct MJpegContext *m,
-                                    ScanTable *intra_scantable, int pred,
+                                    const uint8_t intra_scantable[64], int pred,
                                     uint16_t luma_intra_matrix[64],
                                     uint16_t chroma_intra_matrix[64],
                                     int use_slices)
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index 5b13faae23..3501ce6bfb 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -24,7 +24,6 @@
 #include <stdint.h>
 
 #include "avcodec.h"
-#include "idctdsp.h"
 #include "put_bits.h"
 
 struct MJpegContext;
@@ -33,7 +32,7 @@ int ff_mjpeg_add_icc_profile_size(AVCodecContext *avctx, const AVFrame *frame,
                                   size_t *max_pkt_size);
 void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
                                     const AVFrame *frame, struct MJpegContext *m,
-                                    ScanTable *intra_scantable, int pred,
+                                    const uint8_t intra_scantable[64], int pred,
                                     uint16_t luma_intra_matrix[64],
                                     uint16_t chroma_intra_matrix[64],
                                     int use_slices);
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 19/22] avcodec/speedhq: Only keep what is used from ScanTable
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (16 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 18/22] avcodec/mjpegenc_common: Only pass " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 20/22] avcodec/wmv2dec: Remove unnecessary ScanTables Andreas Rheinhardt
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Namely ScanTable.permutated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/speedhq.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index 6dbba02776..c9bb2e8418 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -54,7 +54,7 @@ typedef struct SHQContext {
     AVCodecContext *avctx;
     BlockDSPContext bdsp;
     IDCTDSPContext idsp;
-    ScanTable intra_scantable;
+    uint8_t intra_scantable[64];
     int quant_matrix[64];
     enum { SHQ_SUBSAMPLING_420, SHQ_SUBSAMPLING_422, SHQ_SUBSAMPLING_444 }
         subsampling;
@@ -223,7 +223,7 @@ static inline int decode_alpha_block(const SHQContext *s, GetBitContext *gb, uin
 static inline int decode_dct_block(const SHQContext *s, GetBitContext *gb, int last_dc[4], int component, uint8_t *dest, int linesize)
 {
     const int *quant_matrix = s->quant_matrix;
-    const uint8_t *scantable = s->intra_scantable.permutated;
+    const uint8_t *scantable = s->intra_scantable;
     LOCAL_ALIGNED_32(int16_t, block, [64]);
     int dc_offset;
 
@@ -667,7 +667,8 @@ static av_cold int speedhq_decode_init(AVCodecContext *avctx)
 
     ff_blockdsp_init(&s->bdsp);
     ff_idctdsp_init(&s->idsp, avctx);
-    ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
+    ff_permute_scantable(s->intra_scantable, ff_zigzag_direct,
+                         s->idsp.idct_permutation);
 
     switch (avctx->codec_tag) {
     case MKTAG('S', 'H', 'Q', '0'):
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 20/22] avcodec/wmv2dec: Remove unnecessary ScanTables
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (17 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 19/22] avcodec/speedhq: Only keep " Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 21/22] avcodec/idctdsp: Move ScanTable to mpegvideo Andreas Rheinhardt
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Only ScanTable.scantable is used for the abt_scantables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/wmv2dec.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index f638b31cec..a70913134c 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -52,7 +52,6 @@ typedef struct WMV2DecContext {
     int per_mb_rl_bit;
     int skip_type;
 
-    ScanTable abt_scantable[2];
     DECLARE_ALIGNED(32, int16_t, abt_block2)[6][64];
 } WMV2DecContext;
 
@@ -425,9 +424,7 @@ static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block,
     w->abt_type_table[n] = w->abt_type;
 
     if (w->abt_type) {
-//        const uint8_t *scantable = w->abt_scantable[w->abt_type - 1].permutated;
-        const uint8_t *scantable = w->abt_scantable[w->abt_type - 1].scantable;
-//        const uint8_t *scantable = w->abt_type - 1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable;
+        const uint8_t *scantable = w->abt_type == 1 ? ff_wmv2_scantableA : ff_wmv2_scantableB;
 
         sub_cbp = sub_cbp_table[decode012(&s->gb)];
 
@@ -577,10 +574,6 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
         return ret;
 
     ff_wmv2_common_init(s);
-    ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0],
-                      ff_wmv2_scantableA);
-    ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1],
-                      ff_wmv2_scantableB);
 
     return ff_intrax8_common_init(avctx, &w->x8,
                                   w->s.block, w->s.block_last_index,
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 21/22] avcodec/idctdsp: Move ScanTable to mpegvideo
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (18 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 20/22] avcodec/wmv2dec: Remove unnecessary ScanTables Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 22/22] avcodec/eatgq: Move transient GetByteContext from context to stack Andreas Rheinhardt
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/idctdsp.c   | 21 ---------------------
 libavcodec/idctdsp.h   | 11 -----------
 libavcodec/mpegvideo.c | 21 +++++++++++++++++++++
 libavcodec/mpegvideo.h | 11 +++++++++++
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c
index 50156930ed..7216afb094 100644
--- a/libavcodec/idctdsp.c
+++ b/libavcodec/idctdsp.c
@@ -36,27 +36,6 @@ av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64],
     }
 }
 
-av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
-                               const uint8_t *src_scantable)
-{
-    int i, end;
-
-    st->scantable = src_scantable;
-
-    for (i = 0; i < 64; i++) {
-        int j = src_scantable[i];
-        st->permutated[i] = permutation[j];
-    }
-
-    end = -1;
-    for (i = 0; i < 64; i++) {
-        int j = st->permutated[i];
-        if (j > end)
-            end = j;
-        st->raster_end[i] = end;
-    }
-}
-
 av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
                                            enum idct_permutation_type perm_type)
 {
diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h
index b286bc231c..7224463349 100644
--- a/libavcodec/idctdsp.h
+++ b/libavcodec/idctdsp.h
@@ -25,15 +25,6 @@
 
 #include "avcodec.h"
 
-/**
- * Scantable.
- */
-typedef struct ScanTable {
-    const uint8_t *scantable;
-    uint8_t permutated[64];
-    uint8_t raster_end[64];
-} ScanTable;
-
 enum idct_permutation_type {
     FF_IDCT_PERM_NONE,
     FF_IDCT_PERM_LIBMPEG2,
@@ -45,8 +36,6 @@ enum idct_permutation_type {
 
 void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64],
                           const uint8_t permutation[64]);
-void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
-                       const uint8_t *src_scantable);
 void ff_init_scantable_permutation(uint8_t *idct_permutation,
                                    enum idct_permutation_type perm_type);
 int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index fbe9884b4c..4326f7f9a5 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -320,6 +320,27 @@ static av_cold int dct_init(MpegEncContext *s)
     return 0;
 }
 
+av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
+                               const uint8_t *src_scantable)
+{
+    int end;
+
+    st->scantable = src_scantable;
+
+    for (int i = 0; i < 64; i++) {
+        int j = src_scantable[i];
+        st->permutated[i] = permutation[j];
+    }
+
+    end = -1;
+    for (int i = 0; i < 64; i++) {
+        int j = st->permutated[i];
+        if (j > end)
+            end = j;
+        st->raster_end[i] = end;
+    }
+}
+
 av_cold void ff_mpv_idct_init(MpegEncContext *s)
 {
     if (s->codec_id == AV_CODEC_ID_MPEG4)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 237adf2388..60d2ec751e 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -55,6 +55,15 @@
 
 #define MAX_B_FRAMES 16
 
+/**
+ * Scantable.
+ */
+typedef struct ScanTable {
+    const uint8_t *scantable;
+    uint8_t permutated[64];
+    uint8_t raster_end[64];
+} ScanTable;
+
 /**
  * MpegEncContext.
  */
@@ -576,6 +585,8 @@ int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src);
 void ff_set_qscale(MpegEncContext * s, int qscale);
 
 void ff_mpv_idct_init(MpegEncContext *s);
+void ff_init_scantable(const uint8_t *permutation, ScanTable *st,
+                       const uint8_t *src_scantable);
 void ff_init_block_index(MpegEncContext *s);
 
 void ff_mpv_motion(MpegEncContext *s,
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 22/22] avcodec/eatgq: Move transient GetByteContext from context to stack
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (19 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 21/22] avcodec/idctdsp: Move ScanTable to mpegvideo Andreas Rheinhardt
@ 2022-10-20  8:45 ` Andreas Rheinhardt
  2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 23/24] avcodec/mpegvideo: Move ASM-offset warning to its proper place Andreas Rheinhardt
  2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary Andreas Rheinhardt
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20  8:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/eatgq.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index e8d66418b9..85bd5ee3b8 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -45,7 +45,6 @@ typedef struct TgqContext {
     int width, height;
     int qtable[64];
     DECLARE_ALIGNED(16, int16_t, block)[6][64];
-    GetByteContext gb;
 } TgqContext;
 
 static av_cold int tgq_decode_init(AVCodecContext *avctx)
@@ -147,34 +146,35 @@ static void tgq_idct_put_mb_dconly(TgqContext *s, AVFrame *frame,
     }
 }
 
-static int tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
+static int tgq_decode_mb(TgqContext *s, GetByteContext *gbyte,
+                         AVFrame *frame, int mb_y, int mb_x)
 {
     int mode;
     int i;
     int8_t dc[6];
 
-    mode = bytestream2_get_byte(&s->gb);
+    mode = bytestream2_get_byte(gbyte);
     if (mode > 12) {
         GetBitContext gb;
-        int ret = init_get_bits8(&gb, s->gb.buffer, FFMIN(bytestream2_get_bytes_left(&s->gb), mode));
+        int ret = init_get_bits8(&gb, gbyte->buffer, FFMIN(bytestream2_get_bytes_left(gbyte), mode));
         if (ret < 0)
             return ret;
 
         for (i = 0; i < 6; i++)
             tgq_decode_block(s, s->block[i], &gb);
         tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
-        bytestream2_skip(&s->gb, mode);
+        bytestream2_skip(gbyte, mode);
     } else {
         if (mode == 3) {
-            memset(dc, bytestream2_get_byte(&s->gb), 4);
-            dc[4] = bytestream2_get_byte(&s->gb);
-            dc[5] = bytestream2_get_byte(&s->gb);
+            memset(dc, bytestream2_get_byte(gbyte), 4);
+            dc[4] = bytestream2_get_byte(gbyte);
+            dc[5] = bytestream2_get_byte(gbyte);
         } else if (mode == 6) {
-            bytestream2_get_buffer(&s->gb, dc, 6);
+            bytestream2_get_buffer(gbyte, dc, 6);
         } else if (mode == 12) {
             for (i = 0; i < 6; i++) {
-                dc[i] = bytestream2_get_byte(&s->gb);
-                bytestream2_skip(&s->gb, 1);
+                dc[i] = bytestream2_get_byte(gbyte);
+                bytestream2_skip(gbyte, 1);
             }
         } else {
             av_log(s->avctx, AV_LOG_ERROR, "unsupported mb mode %i\n", mode);
@@ -202,6 +202,7 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     const uint8_t *buf = avpkt->data;
     int buf_size       = avpkt->size;
     TgqContext *s      = avctx->priv_data;
+    GetByteContext gbyte;
     int x, y, ret;
     int big_endian;
 
@@ -210,21 +211,21 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         return AVERROR_INVALIDDATA;
     }
     big_endian = AV_RL32(&buf[4]) > 0x000FFFFF;
-    bytestream2_init(&s->gb, buf + 8, buf_size - 8);
+    bytestream2_init(&gbyte, buf + 8, buf_size - 8);
     if (big_endian) {
-        s->width  = bytestream2_get_be16u(&s->gb);
-        s->height = bytestream2_get_be16u(&s->gb);
+        s->width  = bytestream2_get_be16u(&gbyte);
+        s->height = bytestream2_get_be16u(&gbyte);
     } else {
-        s->width  = bytestream2_get_le16u(&s->gb);
-        s->height = bytestream2_get_le16u(&s->gb);
+        s->width  = bytestream2_get_le16u(&gbyte);
+        s->height = bytestream2_get_le16u(&gbyte);
     }
 
     ret = ff_set_dimensions(s->avctx, s->width, s->height);
     if (ret < 0)
         return ret;
 
-    tgq_calculate_qtable(s, bytestream2_get_byteu(&s->gb));
-    bytestream2_skip(&s->gb, 3);
+    tgq_calculate_qtable(s, bytestream2_get_byteu(&gbyte));
+    bytestream2_skipu(&gbyte, 3);
 
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
@@ -233,7 +234,7 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     for (y = 0; y < FFALIGN(avctx->height, 16) >> 4; y++)
         for (x = 0; x < FFALIGN(avctx->width, 16) >> 4; x++)
-            if (tgq_decode_mb(s, frame, y, x) < 0)
+            if (tgq_decode_mb(s, &gbyte, frame, y, x) < 0)
                 return AVERROR_INVALIDDATA;
 
     *got_frame = 1;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 23/24] avcodec/mpegvideo: Move ASM-offset warning to its proper place
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (20 preceding siblings ...)
  2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 22/22] avcodec/eatgq: Move transient GetByteContext from context to stack Andreas Rheinhardt
@ 2022-10-20 17:24 ` Andreas Rheinhardt
  2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary Andreas Rheinhardt
  22 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20 17:24 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 60d2ec751e..6adf724dac 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -77,13 +77,14 @@ typedef struct MpegEncContext {
 
     /* scantables */
     ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce the cache usage
-    ScanTable intra_scantable;
-    ScanTable intra_h_scantable;
-    ScanTable intra_v_scantable;
 
     /* WARNING: changes above this line require updates to hardcoded
      *          offsets used in ASM. */
 
+    ScanTable intra_scantable;
+    ScanTable intra_h_scantable;
+    ScanTable intra_v_scantable;
+
     struct AVCodecContext *avctx;
     /* The following pointer is intended for codecs sharing code
      * between decoder and encoder and in need of a common context to do so. */
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary
  2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
                   ` (21 preceding siblings ...)
  2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 23/24] avcodec/mpegvideo: Move ASM-offset warning to its proper place Andreas Rheinhardt
@ 2022-10-20 17:24 ` Andreas Rheinhardt
  2022-10-21 18:46   ` Michael Niedermayer
  22 siblings, 1 reply; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-20 17:24 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

For the intra_[hv]_scantables, only ScanTable.permutated
is used, so one only needs to keep that.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ituh263dec.c    |  4 ++--
 libavcodec/mpeg4videodec.c | 28 ++++++++++++++++++----------
 libavcodec/mpeg4videoenc.c |  4 ++--
 libavcodec/mpegvideo.c     |  6 ++++--
 libavcodec/mpegvideo.h     |  4 ++--
 libavcodec/msmpeg4.c       |  6 ++++--
 libavcodec/msmpeg4dec.c    |  4 ++--
 libavcodec/wmv2.c          |  8 ++++----
 8 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 200de8527e..2655d026cd 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -544,9 +544,9 @@ static int h263_decode_block(MpegEncContext * s, int16_t * block,
         i = 0;
         if (s->ac_pred) {
             if (s->h263_aic_dir)
-                scan_table = s->intra_v_scantable.permutated; /* left */
+                scan_table = s->intra_v_scantable; /* left */
             else
-                scan_table = s->intra_h_scantable.permutated; /* top */
+                scan_table = s->intra_h_scantable; /* top */
         }
     } else if (s->mb_intra) {
         /* DC coef */
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c4f268c534..6fbf4e4220 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1327,9 +1327,9 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
         }
         if (s->ac_pred) {
             if (dc_pred_dir == 0)
-                scan_table = s->intra_v_scantable.permutated;  /* left */
+                scan_table = s->intra_v_scantable;  /* left */
             else
-                scan_table = s->intra_h_scantable.permutated;  /* top */
+                scan_table = s->intra_h_scantable;  /* top */
         } else {
             scan_table = s->intra_scantable.permutated;
         }
@@ -3258,13 +3258,17 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
     if (s->alternate_scan) {
         ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   ff_alternate_vertical_scan);
         ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   ff_alternate_vertical_scan);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+        ff_permute_scantable(s->intra_h_scantable, ff_alternate_vertical_scan,
+                             s->idsp.idct_permutation);
+        ff_permute_scantable(s->intra_v_scantable, ff_alternate_vertical_scan,
+                             s->idsp.idct_permutation);
     } else {
         ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   ff_zigzag_direct);
         ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   ff_zigzag_direct);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+        ff_permute_scantable(s->intra_h_scantable, ff_alternate_horizontal_scan,
+                             s->idsp.idct_permutation);
+        ff_permute_scantable(s->intra_v_scantable, ff_alternate_vertical_scan,
+                             s->idsp.idct_permutation);
     }
 
     /* Skip at this point when only parsing since the remaining
@@ -3432,13 +3436,17 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
     if (s->alternate_scan) {
         ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   ff_alternate_vertical_scan);
         ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   ff_alternate_vertical_scan);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+        ff_permute_scantable(s->intra_h_scantable, ff_alternate_vertical_scan,
+                             s->idsp.idct_permutation);
+        ff_permute_scantable(s->intra_v_scantable, ff_alternate_vertical_scan,
+                             s->idsp.idct_permutation);
     } else {
         ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   ff_zigzag_direct);
         ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   ff_zigzag_direct);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+        ff_permute_scantable(s->intra_h_scantable, ff_alternate_horizontal_scan,
+                             s->idsp.idct_permutation);
+        ff_permute_scantable(s->intra_v_scantable, ff_alternate_vertical_scan,
+                             s->idsp.idct_permutation);
     }
 
     mpeg4_load_default_matrices(s);
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 8e6e35b927..bf499a2206 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -175,7 +175,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
                     ac_val1[i + 8] = level;
                 }
             }
-            st[n] = s->intra_h_scantable.permutated;
+            st[n] = s->intra_h_scantable;
         } else {
             const int xy = s->mb_x - 1 + s->mb_y * s->mb_stride;
             /* left prediction */
@@ -197,7 +197,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
                     ac_val1[i + 8] = block[n][s->idsp.idct_permutation[i]];
                 }
             }
-            st[n] = s->intra_v_scantable.permutated;
+            st[n] = s->intra_v_scantable;
         }
 
         for (i = 63; i > 0; i--)  // FIXME optimize
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 4326f7f9a5..cdcf06fe85 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -357,8 +357,10 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s)
         ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);
         ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
     }
-    ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
-    ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
+    ff_permute_scantable(s->intra_h_scantable, ff_alternate_horizontal_scan,
+                         s->idsp.idct_permutation);
+    ff_permute_scantable(s->intra_v_scantable, ff_alternate_vertical_scan,
+                         s->idsp.idct_permutation);
 }
 
 static int init_duplicate_context(MpegEncContext *s)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 6adf724dac..7ba9af3923 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -82,8 +82,8 @@ typedef struct MpegEncContext {
      *          offsets used in ASM. */
 
     ScanTable intra_scantable;
-    ScanTable intra_h_scantable;
-    ScanTable intra_v_scantable;
+    uint8_t intra_h_scantable[64];
+    uint8_t intra_v_scantable[64];
 
     struct AVCodecContext *avctx;
     /* The following pointer is intended for codecs sharing code
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 455436e9c4..a0725c44fa 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -150,9 +150,11 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
 
     if(s->msmpeg4_version>=4){
         ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,   ff_wmv1_scantable[1]);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_wmv1_scantable[2]);
-        ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_wmv1_scantable[3]);
         ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,   ff_wmv1_scantable[0]);
+        ff_permute_scantable(s->intra_h_scantable, ff_wmv1_scantable[2],
+                             s->idsp.idct_permutation);
+        ff_permute_scantable(s->intra_v_scantable, ff_wmv1_scantable[3],
+                             s->idsp.idct_permutation);
     }
     //Note the default tables are set in common_init in mpegvideo.c
 
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 05a7ed4db6..098fc55d2b 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -687,9 +687,9 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
         }
         if (s->ac_pred) {
             if (dc_pred_dir == 0)
-                scan_table = s->intra_v_scantable.permutated; /* left */
+                scan_table = s->intra_v_scantable; /* left */
             else
-                scan_table = s->intra_h_scantable.permutated; /* top */
+                scan_table = s->intra_h_scantable; /* top */
         } else {
             scan_table = s->intra_scantable.permutated;
         }
diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c
index 07a5d14f90..9772035b5b 100644
--- a/libavcodec/wmv2.c
+++ b/libavcodec/wmv2.c
@@ -36,12 +36,12 @@ av_cold void ff_wmv2_common_init(MpegEncContext *s)
                                   w->wdsp.idct_perm);
     ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,
                       ff_wmv1_scantable[1]);
-    ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable,
-                      ff_wmv1_scantable[2]);
-    ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable,
-                      ff_wmv1_scantable[3]);
     ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,
                       ff_wmv1_scantable[0]);
+    ff_permute_scantable(s->intra_h_scantable, ff_wmv1_scantable[2],
+                         s->idsp.idct_permutation);
+    ff_permute_scantable(s->intra_v_scantable, ff_wmv1_scantable[3],
+                         s->idsp.idct_permutation);
     s->idsp.idct_put = w->wdsp.idct_put;
     s->idsp.idct_add = w->wdsp.idct_add;
     s->idsp.idct     = NULL;
-- 
2.34.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".

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary
  2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary Andreas Rheinhardt
@ 2022-10-21 18:46   ` Michael Niedermayer
  2022-10-21 19:00     ` Andreas Rheinhardt
  0 siblings, 1 reply; 26+ messages in thread
From: Michael Niedermayer @ 2022-10-21 18:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1865 bytes --]

On Thu, Oct 20, 2022 at 07:24:36PM +0200, Andreas Rheinhardt wrote:
> For the intra_[hv]_scantables, only ScanTable.permutated
> is used, so one only needs to keep that.
[...]
> diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
> index 8e6e35b927..bf499a2206 100644
> --- a/libavcodec/mpeg4videoenc.c
> +++ b/libavcodec/mpeg4videoenc.c
> @@ -175,7 +175,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
>                      ac_val1[i + 8] = level;
>                  }
>              }
> -            st[n] = s->intra_h_scantable.permutated;
> +            st[n] = s->intra_h_scantable;
>          } else {
>              const int xy = s->mb_x - 1 + s->mb_y * s->mb_stride;
>              /* left prediction */
> @@ -197,7 +197,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
>                      ac_val1[i + 8] = block[n][s->idsp.idct_permutation[i]];
>                  }
>              }
> -            st[n] = s->intra_v_scantable.permutated;
> +            st[n] = s->intra_v_scantable;

Iam thinking that replacing 
s->intra_v_scantable.permutated
by
intra_v_scantable
is semantically feeling inferrior to calling it
permutated_intra_v_scantable
or something like that

The same probably applies to te other patches too
iam not happy about the long name but having consistent
naming between scantables (as in the spec) and scantables permutated
for idct optimizations could improve readability of the code

thx
[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier

[-- 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] 26+ messages in thread

* Re: [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary
  2022-10-21 18:46   ` Michael Niedermayer
@ 2022-10-21 19:00     ` Andreas Rheinhardt
  0 siblings, 0 replies; 26+ messages in thread
From: Andreas Rheinhardt @ 2022-10-21 19:00 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> On Thu, Oct 20, 2022 at 07:24:36PM +0200, Andreas Rheinhardt wrote:
>> For the intra_[hv]_scantables, only ScanTable.permutated
>> is used, so one only needs to keep that.
> [...]
>> diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
>> index 8e6e35b927..bf499a2206 100644
>> --- a/libavcodec/mpeg4videoenc.c
>> +++ b/libavcodec/mpeg4videoenc.c
>> @@ -175,7 +175,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
>>                      ac_val1[i + 8] = level;
>>                  }
>>              }
>> -            st[n] = s->intra_h_scantable.permutated;
>> +            st[n] = s->intra_h_scantable;
>>          } else {
>>              const int xy = s->mb_x - 1 + s->mb_y * s->mb_stride;
>>              /* left prediction */
>> @@ -197,7 +197,7 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
>>                      ac_val1[i + 8] = block[n][s->idsp.idct_permutation[i]];
>>                  }
>>              }
>> -            st[n] = s->intra_v_scantable.permutated;
>> +            st[n] = s->intra_v_scantable;
> 
> Iam thinking that replacing 
> s->intra_v_scantable.permutated
> by
> intra_v_scantable
> is semantically feeling inferrior to calling it
> permutated_intra_v_scantable
> or something like that
> 
> The same probably applies to te other patches too
> iam not happy about the long name but having consistent
> naming between scantables (as in the spec) and scantables permutated
> for idct optimizations could improve readability of the code
> 

Ok, will send a v2 with this changed.

- 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] 26+ messages in thread

end of thread, other threads:[~2022-10-21 19:00 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20  8:31 [FFmpeg-devel] [PATCH 01/22] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 02/22] avcodec/eamad: Don't use IDCTDSP-API unnecessarily Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 03/22] avcodec/eatgq: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 04/22] avcodec/eatqi: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 05/22] avcodec/aic: Remove useless ScanTable Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 06/22] avcodec/imm4: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 07/22] avcodec/idctdsp: Add function to apply permutation to array Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 08/22] avcodec/agm: Only keep what is used from ScanTable Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 09/22] avcodec/asvdec: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 10/22] avcodec/dnxhddec: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 11/22] avcodec/cavs: Only keep what is needed from IDCTDSP-API Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 12/22] avcodec/g2meet: Only keep what is used from ScanTable Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 13/22] avcodec/g2meet: Pre-permute quantization tables Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 14/22] avcodec/intrax8: Only keep what is used from ScanTable Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 15/22] avcodec/mdec: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 16/22] avcodec/mimic: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 17/22] avcodec/mjpegdec: " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 18/22] avcodec/mjpegenc_common: Only pass " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 19/22] avcodec/speedhq: Only keep " Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 20/22] avcodec/wmv2dec: Remove unnecessary ScanTables Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 21/22] avcodec/idctdsp: Move ScanTable to mpegvideo Andreas Rheinhardt
2022-10-20  8:45 ` [FFmpeg-devel] [PATCH 22/22] avcodec/eatgq: Move transient GetByteContext from context to stack Andreas Rheinhardt
2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 23/24] avcodec/mpegvideo: Move ASM-offset warning to its proper place Andreas Rheinhardt
2022-10-20 17:24 ` [FFmpeg-devel] [PATCH 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary Andreas Rheinhardt
2022-10-21 18:46   ` Michael Niedermayer
2022-10-21 19:00     ` 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