* [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header
@ 2024-03-04 12:43 Andreas Rheinhardt
2024-03-04 12:46 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hq_hqa: Make VLC tables static Andreas Rheinhardt
2024-03-06 16:27 ` [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header Andreas Rheinhardt
0 siblings, 2 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-04 12:43 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is only used by hq_hqa.c, so said header can simply
be included there.
Also move the code to initialize the VLCs to hq_hqa.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 3 +-
libavcodec/hq_hqa.c | 39 +++++++++++----
libavcodec/hq_hqa.h | 60 -----------------------
libavcodec/{hq_hqadata.c => hq_hqadata.h} | 34 ++++++-------
4 files changed, 48 insertions(+), 88 deletions(-)
delete mode 100644 libavcodec/hq_hqa.h
rename libavcodec/{hq_hqadata.c => hq_hqadata.h} (99%)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index eadaab5ec4..cf81a55edb 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -451,8 +451,7 @@ OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
-OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
- canopus.o
+OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadsp.o canopus.o
OBJS-$(CONFIG_HQX_DECODER) += hqx.o hqxvlc.o hqxdsp.o canopus.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o
diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
index 0df7995f84..510a66fd91 100644
--- a/libavcodec/hq_hqa.c
+++ b/libavcodec/hq_hqa.c
@@ -21,6 +21,7 @@
#include <stdint.h>
#include "libavutil/attributes.h"
+#include "libavutil/mem_internal.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -28,9 +29,9 @@
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
-
-#include "hq_hqa.h"
+#include "hq_hqadata.h"
#include "hq_hqadsp.h"
+#include "vlc.h"
/* HQ/HQA slices are a set of macroblocks belonging to a frame, and
* they usually form a pseudorandom pattern (probably because it is
@@ -48,6 +49,15 @@
* while lavc simply aligns coded_width and coded_height.
*/
+typedef struct HQContext {
+ AVCodecContext *avctx;
+ HQDSPContext hqhqadsp;
+
+ VLC hq_ac_vlc;
+ VLC hqa_cbp_vlc;
+ DECLARE_ALIGNED(16, int16_t, block)[12][64];
+} HQContext;
+
static inline void put_blocks(HQContext *c, AVFrame *pic,
int plane, int x, int y, int ilace,
int16_t *block0, int16_t *block1)
@@ -70,9 +80,9 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
if (!is_hqa) {
block[0] = get_sbits(gb, 9) * 64;
- q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
+ q = hq_quants[qsel][is_chroma][get_bits(gb, 2)];
} else {
- q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
+ q = hq_quants[qsel][is_chroma][get_bits(gb, 2)];
block[0] = get_sbits(gb, 9) * 64;
}
@@ -81,10 +91,10 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
if (val < 0)
return AVERROR_INVALIDDATA;
- pos += ff_hq_ac_skips[val];
+ pos += hq_ac_skips[val];
if (pos >= 64)
break;
- block[ff_zigzag_direct[pos]] = (int)(ff_hq_ac_syms[val] * (unsigned)q[pos]) >> 12;
+ block[ff_zigzag_direct[pos]] = (int)(hq_ac_syms[val] * (unsigned)q[pos]) >> 12;
pos++;
}
@@ -124,10 +134,10 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc,
int slice, start_off, next_off, i, ret;
if ((unsigned)prof_num >= NUM_HQ_PROFILES) {
- profile = &ff_hq_profile[0];
+ profile = &hq_profile[0];
avpriv_request_sample(ctx->avctx, "HQ Profile %d", prof_num);
} else {
- profile = &ff_hq_profile[prof_num];
+ profile = &hq_profile[prof_num];
av_log(ctx->avctx, AV_LOG_VERBOSE, "HQ Profile %d\n", prof_num);
}
@@ -362,6 +372,17 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic,
return avpkt->size;
}
+static av_cold int hq_init_vlcs(HQContext *c)
+{
+ int ret = vlc_init(&c->hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
+ cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
+ if (ret < 0)
+ return ret;
+
+ return vlc_init(&c->hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES,
+ hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0);
+}
+
static av_cold int hq_hqa_decode_init(AVCodecContext *avctx)
{
HQContext *ctx = avctx->priv_data;
@@ -369,7 +390,7 @@ static av_cold int hq_hqa_decode_init(AVCodecContext *avctx)
ff_hqdsp_init(&ctx->hqhqadsp);
- return ff_hq_init_vlcs(ctx);
+ return hq_init_vlcs(ctx);
}
static av_cold int hq_hqa_decode_close(AVCodecContext *avctx)
diff --git a/libavcodec/hq_hqa.h b/libavcodec/hq_hqa.h
deleted file mode 100644
index 71aa36706c..0000000000
--- a/libavcodec/hq_hqa.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Canopus HQ/HQA decoder
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_HQ_HQA_H
-#define AVCODEC_HQ_HQA_H
-
-#include <stdint.h>
-
-#include "libavutil/mem_internal.h"
-
-#include "avcodec.h"
-#include "hq_hqadsp.h"
-#include "vlc.h"
-
-#define NUM_HQ_AC_ENTRIES 746
-#define NUM_HQ_PROFILES 22
-#define NUM_HQ_QUANTS 16
-
-typedef struct HQContext {
- AVCodecContext *avctx;
- HQDSPContext hqhqadsp;
-
- VLC hq_ac_vlc;
- VLC hqa_cbp_vlc;
- DECLARE_ALIGNED(16, int16_t, block)[12][64];
-} HQContext;
-
-typedef struct HQProfile {
- const uint8_t *perm_tab;
- int width, height;
- int num_slices;
- int tab_w, tab_h;
-} HQProfile;
-
-extern const int32_t * const ff_hq_quants[16][2][4];
-extern const HQProfile ff_hq_profile[NUM_HQ_PROFILES];
-
-extern const uint8_t ff_hq_ac_skips[NUM_HQ_AC_ENTRIES];
-extern const int16_t ff_hq_ac_syms [NUM_HQ_AC_ENTRIES];
-
-int ff_hq_init_vlcs(HQContext *c);
-
-#endif /* AVCODEC_HQ_HQA_H */
diff --git a/libavcodec/hq_hqadata.c b/libavcodec/hq_hqadata.h
similarity index 99%
rename from libavcodec/hq_hqadata.c
rename to libavcodec/hq_hqadata.h
index 438bdf093a..f71d8bd4fa 100644
--- a/libavcodec/hq_hqadata.c
+++ b/libavcodec/hq_hqadata.h
@@ -1,5 +1,5 @@
/*
- * Canopus HQ/HQA decoder
+ * Canopus HQ/HQA data
*
* This file is part of FFmpeg.
*
@@ -18,7 +18,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "hq_hqa.h"
+#include <stdint.h>
+
+#define NUM_HQ_AC_ENTRIES 746
+#define NUM_HQ_PROFILES 22
+#define NUM_HQ_QUANTS 16
+
+typedef struct HQProfile {
+ const uint8_t *perm_tab;
+ int width, height;
+ int num_slices;
+ int tab_w, tab_h;
+} HQProfile;
#define MAT_SIZE 64
@@ -1123,7 +1134,7 @@ static const int32_t qmat4D[MAT_SIZE] = {
0x24CF8B9, 0x384AC0F, 0x709581F, 0x3CDBBA7,
};
-const int32_t *const ff_hq_quants[NUM_HQ_QUANTS][2][4] = {
+static const int32_t *const hq_quants[NUM_HQ_QUANTS][2][4] = {
{ { qmat00, qmat02, qmat06, qmat0E }, { qmat01, qmat03, qmat07, qmat0F } },
{ { qmat02, qmat06, qmat0E, qmat16 }, { qmat03, qmat07, qmat0F, qmat17 } },
{ { qmat04, qmat0A, qmat12, qmat1E }, { qmat05, qmat0B, qmat13, qmat1F } },
@@ -1289,7 +1300,7 @@ static const uint16_t hq_ac_codes[NUM_HQ_AC_ENTRIES] = {
0xFFFE, 0xFFFF,
};
-const uint8_t ff_hq_ac_skips[NUM_HQ_AC_ENTRIES] = {
+static const uint8_t hq_ac_skips[NUM_HQ_AC_ENTRIES] = {
0, 0, 0, 0, 64, 1, 1, 0, 0, 0, 0, 2, 2, 1, 1, 0,
0, 0, 0, 3, 3, 4, 4, 0, 0, 0, 0, 5, 5, 6, 6, 2,
2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 7, 7, 8, 8, 9,
@@ -1339,7 +1350,7 @@ const uint8_t ff_hq_ac_skips[NUM_HQ_AC_ENTRIES] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-const int16_t ff_hq_ac_syms[NUM_HQ_AC_ENTRIES] = {
+static const int16_t hq_ac_syms[NUM_HQ_AC_ENTRIES] = {
1, -1, 2, -2, 0, 1, -1, 3,
-3, 4, -4, 1, -1, 2, -2, 5,
-5, 6, -6, 1, -1, 1, -1, 7,
@@ -8340,7 +8351,7 @@ static const uint8_t hq_tab_21[] = {
};
/* List of profiles, order is important */
-const HQProfile ff_hq_profile[NUM_HQ_PROFILES] = {
+static const HQProfile hq_profile[NUM_HQ_PROFILES] = {
{ hq_tab_11, 160, 120, 8, 10, 8 }, // case 0 (default) = case 11
{ hq_tab_01, 720, 480, 8, 25, 54 },
{ hq_tab_02, 720, 486, 8, 15, 93 },
@@ -8364,14 +8375,3 @@ const HQProfile ff_hq_profile[NUM_HQ_PROFILES] = {
{ hq_tab_20, 704, 480, 8, 20, 66 },
{ hq_tab_21, 704, 576, 8, 24, 66 },
};
-
-av_cold int ff_hq_init_vlcs(HQContext *c)
-{
- int ret = vlc_init(&c->hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
- cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
- if (ret < 0)
- return ret;
-
- return vlc_init(&c->hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES,
- hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0);
-}
--
2.40.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] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/hq_hqa: Make VLC tables static
2024-03-04 12:43 [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header Andreas Rheinhardt
@ 2024-03-04 12:46 ` Andreas Rheinhardt
2024-03-06 16:27 ` [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header Andreas Rheinhardt
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-04 12:46 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/hq_hqa.c | 35 +++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)
diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
index 510a66fd91..096fb65dc7 100644
--- a/libavcodec/hq_hqa.c
+++ b/libavcodec/hq_hqa.c
@@ -22,6 +22,7 @@
#include "libavutil/attributes.h"
#include "libavutil/mem_internal.h"
+#include "libavutil/thread.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -53,11 +54,12 @@ typedef struct HQContext {
AVCodecContext *avctx;
HQDSPContext hqhqadsp;
- VLC hq_ac_vlc;
- VLC hqa_cbp_vlc;
DECLARE_ALIGNED(16, int16_t, block)[12][64];
} HQContext;
+static VLCElem hq_ac_vlc[1184];
+static VLCElem hqa_cbp_vlc[32];
+
static inline void put_blocks(HQContext *c, AVFrame *pic,
int plane, int x, int y, int ilace,
int16_t *block0, int16_t *block1)
@@ -87,7 +89,7 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
}
for (;;) {
- val = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2);
+ val = get_vlc2(gb, hq_ac_vlc, 9, 2);
if (val < 0)
return AVERROR_INVALIDDATA;
@@ -195,7 +197,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
if (get_bits_left(gb) < 1)
return AVERROR_INVALIDDATA;
- cbp = get_vlc2(gb, c->hqa_cbp_vlc.table, 5, 1);
+ cbp = get_vlc2(gb, hqa_cbp_vlc, 5, 1);
for (i = 0; i < 12; i++)
memset(c->block[i], 0, sizeof(*c->block));
@@ -372,33 +374,24 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic,
return avpkt->size;
}
-static av_cold int hq_init_vlcs(HQContext *c)
+static av_cold void hq_init_vlcs(void)
{
- int ret = vlc_init(&c->hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
- cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
- if (ret < 0)
- return ret;
+ VLC_INIT_STATIC_TABLE(hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
+ cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
- return vlc_init(&c->hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES,
- hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0);
+ VLC_INIT_STATIC_TABLE(hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES,
+ hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0);
}
static av_cold int hq_hqa_decode_init(AVCodecContext *avctx)
{
+ static AVOnce init_static_once = AV_ONCE_INIT;
HQContext *ctx = avctx->priv_data;
ctx->avctx = avctx;
ff_hqdsp_init(&ctx->hqhqadsp);
- return hq_init_vlcs(ctx);
-}
-
-static av_cold int hq_hqa_decode_close(AVCodecContext *avctx)
-{
- HQContext *ctx = avctx->priv_data;
-
- ff_vlc_free(&ctx->hq_ac_vlc);
- ff_vlc_free(&ctx->hqa_cbp_vlc);
+ ff_thread_once(&init_static_once, hq_init_vlcs);
return 0;
}
@@ -411,7 +404,5 @@ const FFCodec ff_hq_hqa_decoder = {
.priv_data_size = sizeof(HQContext),
.init = hq_hqa_decode_init,
FF_CODEC_DECODE_CB(hq_hqa_decode_frame),
- .close = hq_hqa_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
--
2.40.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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header
2024-03-04 12:43 [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header Andreas Rheinhardt
2024-03-04 12:46 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hq_hqa: Make VLC tables static Andreas Rheinhardt
@ 2024-03-06 16:27 ` Andreas Rheinhardt
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-06 16:27 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> It is only used by hq_hqa.c, so said header can simply
> be included there.
> Also move the code to initialize the VLCs to hq_hqa.c.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/Makefile | 3 +-
> libavcodec/hq_hqa.c | 39 +++++++++++----
> libavcodec/hq_hqa.h | 60 -----------------------
> libavcodec/{hq_hqadata.c => hq_hqadata.h} | 34 ++++++-------
> 4 files changed, 48 insertions(+), 88 deletions(-)
> delete mode 100644 libavcodec/hq_hqa.h
> rename libavcodec/{hq_hqadata.c => hq_hqadata.h} (99%)
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index eadaab5ec4..cf81a55edb 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -451,8 +451,7 @@ OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
> OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
> OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
> OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
> -OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
> - canopus.o
> +OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadsp.o canopus.o
> OBJS-$(CONFIG_HQX_DECODER) += hqx.o hqxvlc.o hqxdsp.o canopus.o
> OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o
> OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o
> diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
> index 0df7995f84..510a66fd91 100644
> --- a/libavcodec/hq_hqa.c
> +++ b/libavcodec/hq_hqa.c
> @@ -21,6 +21,7 @@
> #include <stdint.h>
>
> #include "libavutil/attributes.h"
> +#include "libavutil/mem_internal.h"
>
> #include "avcodec.h"
> #include "bytestream.h"
> @@ -28,9 +29,9 @@
> #include "codec_internal.h"
> #include "decode.h"
> #include "get_bits.h"
> -
> -#include "hq_hqa.h"
> +#include "hq_hqadata.h"
> #include "hq_hqadsp.h"
> +#include "vlc.h"
>
> /* HQ/HQA slices are a set of macroblocks belonging to a frame, and
> * they usually form a pseudorandom pattern (probably because it is
> @@ -48,6 +49,15 @@
> * while lavc simply aligns coded_width and coded_height.
> */
>
> +typedef struct HQContext {
> + AVCodecContext *avctx;
> + HQDSPContext hqhqadsp;
> +
> + VLC hq_ac_vlc;
> + VLC hqa_cbp_vlc;
> + DECLARE_ALIGNED(16, int16_t, block)[12][64];
> +} HQContext;
> +
> static inline void put_blocks(HQContext *c, AVFrame *pic,
> int plane, int x, int y, int ilace,
> int16_t *block0, int16_t *block1)
> @@ -70,9 +80,9 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
>
> if (!is_hqa) {
> block[0] = get_sbits(gb, 9) * 64;
> - q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
> + q = hq_quants[qsel][is_chroma][get_bits(gb, 2)];
> } else {
> - q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
> + q = hq_quants[qsel][is_chroma][get_bits(gb, 2)];
> block[0] = get_sbits(gb, 9) * 64;
> }
>
> @@ -81,10 +91,10 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
> if (val < 0)
> return AVERROR_INVALIDDATA;
>
> - pos += ff_hq_ac_skips[val];
> + pos += hq_ac_skips[val];
> if (pos >= 64)
> break;
> - block[ff_zigzag_direct[pos]] = (int)(ff_hq_ac_syms[val] * (unsigned)q[pos]) >> 12;
> + block[ff_zigzag_direct[pos]] = (int)(hq_ac_syms[val] * (unsigned)q[pos]) >> 12;
> pos++;
> }
>
> @@ -124,10 +134,10 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc,
> int slice, start_off, next_off, i, ret;
>
> if ((unsigned)prof_num >= NUM_HQ_PROFILES) {
> - profile = &ff_hq_profile[0];
> + profile = &hq_profile[0];
> avpriv_request_sample(ctx->avctx, "HQ Profile %d", prof_num);
> } else {
> - profile = &ff_hq_profile[prof_num];
> + profile = &hq_profile[prof_num];
> av_log(ctx->avctx, AV_LOG_VERBOSE, "HQ Profile %d\n", prof_num);
> }
>
> @@ -362,6 +372,17 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, AVFrame *pic,
> return avpkt->size;
> }
>
> +static av_cold int hq_init_vlcs(HQContext *c)
> +{
> + int ret = vlc_init(&c->hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
> + cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
> + if (ret < 0)
> + return ret;
> +
> + return vlc_init(&c->hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES,
> + hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0);
> +}
> +
> static av_cold int hq_hqa_decode_init(AVCodecContext *avctx)
> {
> HQContext *ctx = avctx->priv_data;
> @@ -369,7 +390,7 @@ static av_cold int hq_hqa_decode_init(AVCodecContext *avctx)
>
> ff_hqdsp_init(&ctx->hqhqadsp);
>
> - return ff_hq_init_vlcs(ctx);
> + return hq_init_vlcs(ctx);
> }
>
> static av_cold int hq_hqa_decode_close(AVCodecContext *avctx)
> diff --git a/libavcodec/hq_hqa.h b/libavcodec/hq_hqa.h
> deleted file mode 100644
> index 71aa36706c..0000000000
> --- a/libavcodec/hq_hqa.h
> +++ /dev/null
> @@ -1,60 +0,0 @@
> -/*
> - * Canopus HQ/HQA decoder
> - *
> - * This file is part of FFmpeg.
> - *
> - * FFmpeg is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2.1 of the License, or (at your option) any later version.
> - *
> - * FFmpeg is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with FFmpeg; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> - */
> -
> -#ifndef AVCODEC_HQ_HQA_H
> -#define AVCODEC_HQ_HQA_H
> -
> -#include <stdint.h>
> -
> -#include "libavutil/mem_internal.h"
> -
> -#include "avcodec.h"
> -#include "hq_hqadsp.h"
> -#include "vlc.h"
> -
> -#define NUM_HQ_AC_ENTRIES 746
> -#define NUM_HQ_PROFILES 22
> -#define NUM_HQ_QUANTS 16
> -
> -typedef struct HQContext {
> - AVCodecContext *avctx;
> - HQDSPContext hqhqadsp;
> -
> - VLC hq_ac_vlc;
> - VLC hqa_cbp_vlc;
> - DECLARE_ALIGNED(16, int16_t, block)[12][64];
> -} HQContext;
> -
> -typedef struct HQProfile {
> - const uint8_t *perm_tab;
> - int width, height;
> - int num_slices;
> - int tab_w, tab_h;
> -} HQProfile;
> -
> -extern const int32_t * const ff_hq_quants[16][2][4];
> -extern const HQProfile ff_hq_profile[NUM_HQ_PROFILES];
> -
> -extern const uint8_t ff_hq_ac_skips[NUM_HQ_AC_ENTRIES];
> -extern const int16_t ff_hq_ac_syms [NUM_HQ_AC_ENTRIES];
> -
> -int ff_hq_init_vlcs(HQContext *c);
> -
> -#endif /* AVCODEC_HQ_HQA_H */
> diff --git a/libavcodec/hq_hqadata.c b/libavcodec/hq_hqadata.h
> similarity index 99%
> rename from libavcodec/hq_hqadata.c
> rename to libavcodec/hq_hqadata.h
> index 438bdf093a..f71d8bd4fa 100644
> --- a/libavcodec/hq_hqadata.c
> +++ b/libavcodec/hq_hqadata.h
> @@ -1,5 +1,5 @@
> /*
> - * Canopus HQ/HQA decoder
> + * Canopus HQ/HQA data
> *
> * This file is part of FFmpeg.
> *
> @@ -18,7 +18,18 @@
> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> */
>
> -#include "hq_hqa.h"
> +#include <stdint.h>
> +
> +#define NUM_HQ_AC_ENTRIES 746
> +#define NUM_HQ_PROFILES 22
> +#define NUM_HQ_QUANTS 16
> +
> +typedef struct HQProfile {
> + const uint8_t *perm_tab;
> + int width, height;
> + int num_slices;
> + int tab_w, tab_h;
> +} HQProfile;
>
> #define MAT_SIZE 64
>
> @@ -1123,7 +1134,7 @@ static const int32_t qmat4D[MAT_SIZE] = {
> 0x24CF8B9, 0x384AC0F, 0x709581F, 0x3CDBBA7,
> };
>
> -const int32_t *const ff_hq_quants[NUM_HQ_QUANTS][2][4] = {
> +static const int32_t *const hq_quants[NUM_HQ_QUANTS][2][4] = {
> { { qmat00, qmat02, qmat06, qmat0E }, { qmat01, qmat03, qmat07, qmat0F } },
> { { qmat02, qmat06, qmat0E, qmat16 }, { qmat03, qmat07, qmat0F, qmat17 } },
> { { qmat04, qmat0A, qmat12, qmat1E }, { qmat05, qmat0B, qmat13, qmat1F } },
> @@ -1289,7 +1300,7 @@ static const uint16_t hq_ac_codes[NUM_HQ_AC_ENTRIES] = {
> 0xFFFE, 0xFFFF,
> };
>
> -const uint8_t ff_hq_ac_skips[NUM_HQ_AC_ENTRIES] = {
> +static const uint8_t hq_ac_skips[NUM_HQ_AC_ENTRIES] = {
> 0, 0, 0, 0, 64, 1, 1, 0, 0, 0, 0, 2, 2, 1, 1, 0,
> 0, 0, 0, 3, 3, 4, 4, 0, 0, 0, 0, 5, 5, 6, 6, 2,
> 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 7, 7, 8, 8, 9,
> @@ -1339,7 +1350,7 @@ const uint8_t ff_hq_ac_skips[NUM_HQ_AC_ENTRIES] = {
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> };
>
> -const int16_t ff_hq_ac_syms[NUM_HQ_AC_ENTRIES] = {
> +static const int16_t hq_ac_syms[NUM_HQ_AC_ENTRIES] = {
> 1, -1, 2, -2, 0, 1, -1, 3,
> -3, 4, -4, 1, -1, 2, -2, 5,
> -5, 6, -6, 1, -1, 1, -1, 7,
> @@ -8340,7 +8351,7 @@ static const uint8_t hq_tab_21[] = {
> };
>
> /* List of profiles, order is important */
> -const HQProfile ff_hq_profile[NUM_HQ_PROFILES] = {
> +static const HQProfile hq_profile[NUM_HQ_PROFILES] = {
> { hq_tab_11, 160, 120, 8, 10, 8 }, // case 0 (default) = case 11
> { hq_tab_01, 720, 480, 8, 25, 54 },
> { hq_tab_02, 720, 486, 8, 15, 93 },
> @@ -8364,14 +8375,3 @@ const HQProfile ff_hq_profile[NUM_HQ_PROFILES] = {
> { hq_tab_20, 704, 480, 8, 20, 66 },
> { hq_tab_21, 704, 576, 8, 24, 66 },
> };
> -
> -av_cold int ff_hq_init_vlcs(HQContext *c)
> -{
> - int ret = vlc_init(&c->hqa_cbp_vlc, 5, FF_ARRAY_ELEMS(cbp_vlc_lens),
> - cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
> - if (ret < 0)
> - return ret;
> -
> - return vlc_init(&c->hq_ac_vlc, 9, NUM_HQ_AC_ENTRIES,
> - hq_ac_bits, 1, 1, hq_ac_codes, 2, 2, 0);
> -}
Will apply this patchset (with the proper inclusion guard in the header)
tomorrow unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-06 16:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 12:43 [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header Andreas Rheinhardt
2024-03-04 12:46 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hq_hqa: Make VLC tables static Andreas Rheinhardt
2024-03-06 16:27 ` [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqadata: Move data in a header 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