[FFmpeg-cvslog] avcodec/hq_hqadata: Move data in a header
Andreas Rheinhardt
git at videolan.org
Thu Mar 7 10:22:50 EET 2024
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Mar 4 12:59:07 2024 +0100| [51b2343ef9e3fa2595c7cf55cc585441c27c2182] | committer: Andreas Rheinhardt
avcodec/hq_hqadata: Move data in a header
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=51b2343ef9e3fa2595c7cf55cc585441c27c2182
---
libavcodec/Makefile | 3 +-
libavcodec/hq_hqa.c | 39 +++++++++++++++-----
libavcodec/hq_hqa.h | 60 -------------------------------
libavcodec/{hq_hqadata.c => hq_hqadata.h} | 37 ++++++++++---------
4 files changed, 52 insertions(+), 87 deletions(-)
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..2faf47f003 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,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "hq_hqa.h"
+#ifndef AVCODEC_HQ_HQADATA_H
+#define AVCODEC_HQ_HQADATA_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 +1137,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 +1303,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 +1353,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 +8354,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 },
@@ -8365,13 +8379,4 @@ const HQProfile ff_hq_profile[NUM_HQ_PROFILES] = {
{ 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);
-}
+#endif /* AVCODEC_HQ_HQADATA_H */
More information about the ffmpeg-cvslog
mailing list