* [FFmpeg-devel] [PATCH 2/6] avcodec/svq1enc: Move initializing DSP out of svq1enc.c
2024-02-28 16:16 [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
@ 2024-02-28 16:18 ` Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 3/6] avcodec/vvc/vvc_intra: Move utils " Andreas Rheinhardt
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-02-28 16:18 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Otherwise svq1enc.o gets pulled in by the svq1encdsp checkasm
test and it in turn pulls the rest of lavc in.
Besides being bad size-wise this also has the downside that
it pulls in avpriv_(cga|vga16)_font from libavutil which are
marked as being imported from another library when building
libavcodec as a DLL and this breaks checkasm because it links
both lavc and lavu statically.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/svq1enc.c | 23 -----------------------
libavcodec/svq1encdsp.h | 26 +++++++++++++++++++++++++-
2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 5675ae5218..77dbf07275 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -137,16 +137,6 @@ static void svq1_write_header(SVQ1EncContext *s, PutBitContext *pb, int frame_ty
#define QUALITY_THRESHOLD 100
#define THRESHOLD_MULTIPLIER 0.6
-static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
- intptr_t size)
-{
- int score = 0, i;
-
- for (i = 0; i < size; i++)
- score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
- return score;
-}
-
static int encode_block(SVQ1EncContext *s, uint8_t *src, uint8_t *ref,
uint8_t *decoded, int stride, unsigned level,
int threshold, int lambda, int intra)
@@ -760,16 +750,3 @@ const FFCodec ff_svq1_encoder = {
AV_PIX_FMT_NONE },
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
-
-void ff_svq1enc_init(SVQ1EncDSPContext *c)
-{
- c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
-
-#if ARCH_PPC
- ff_svq1enc_init_ppc(c);
-#elif ARCH_RISCV
- ff_svq1enc_init_riscv(c);
-#elif ARCH_X86
- ff_svq1enc_init_x86(c);
-#endif
-}
diff --git a/libavcodec/svq1encdsp.h b/libavcodec/svq1encdsp.h
index 5dfa35cc62..751b5eed86 100644
--- a/libavcodec/svq1encdsp.h
+++ b/libavcodec/svq1encdsp.h
@@ -23,14 +23,38 @@
#include <stdint.h>
+#include "config.h"
+
typedef struct SVQ1EncDSPContext {
int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
intptr_t size);
} SVQ1EncDSPContext;
-void ff_svq1enc_init(SVQ1EncDSPContext *c);
void ff_svq1enc_init_ppc(SVQ1EncDSPContext *c);
void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c);
void ff_svq1enc_init_x86(SVQ1EncDSPContext *c);
+static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
+ intptr_t size)
+{
+ int score = 0;
+
+ for (intptr_t i = 0; i < size; i++)
+ score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
+ return score;
+}
+
+static inline void ff_svq1enc_init(SVQ1EncDSPContext *c)
+{
+ c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
+
+#if ARCH_PPC
+ ff_svq1enc_init_ppc(c);
+#elif ARCH_RISCV
+ ff_svq1enc_init_riscv(c);
+#elif ARCH_X86
+ ff_svq1enc_init_x86(c);
+#endif
+}
+
#endif /* AVCODEC_SVQ1ENCDSP_H */
--
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] 8+ messages in thread
* [FFmpeg-devel] [PATCH 3/6] avcodec/vvc/vvc_intra: Move utils out of svq1enc.c
2024-02-28 16:16 [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 2/6] avcodec/svq1enc: Move initializing DSP out of svq1enc.c Andreas Rheinhardt
@ 2024-02-28 16:18 ` Andreas Rheinhardt
2024-02-28 16:33 ` Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 4/6] avcodec/vvc/vvc_mvs: Add proper header include Andreas Rheinhardt
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-02-28 16:18 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Otherwise vvc_intra.o gets pulled in by the vvc_mc checkasm
test and it in turn pulls vvc_ctu.o and then the rest of vvcdec
and lavc in. Besides being bad size-wise this also has the downside
that it pulls in avpriv_(cga|vga16)_font from libavutil which are
marked as being imported from another library when building
libavcodec as a DLL and this breaks checkasm because it links
both lavc and lavu statically.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/vvc/Makefile | 1 +
libavcodec/vvc/vvc_intra.c | 187 --------------------------
libavcodec/vvc/vvc_intra_utils.c | 218 +++++++++++++++++++++++++++++++
3 files changed, 219 insertions(+), 187 deletions(-)
create mode 100644 libavcodec/vvc/vvc_intra_utils.c
diff --git a/libavcodec/vvc/Makefile b/libavcodec/vvc/Makefile
index dc484e5fb9..2a0055d494 100644
--- a/libavcodec/vvc/Makefile
+++ b/libavcodec/vvc/Makefile
@@ -9,6 +9,7 @@ OBJS-$(CONFIG_VVC_DECODER) += vvc/vvcdec.o \
vvc/vvc_filter.o \
vvc/vvc_inter.o \
vvc/vvc_intra.o \
+ vvc/vvc_intra_utils.o \
vvc/vvc_itx_1d.o \
vvc/vvc_mvs.o \
vvc/vvc_ps.o \
diff --git a/libavcodec/vvc/vvc_intra.c b/libavcodec/vvc/vvc_intra.c
index 58dd492478..6d976320f8 100644
--- a/libavcodec/vvc/vvc_intra.c
+++ b/libavcodec/vvc/vvc_intra.c
@@ -26,7 +26,6 @@
#include "vvc_inter.h"
#include "vvc_intra.h"
#include "vvc_itx_1d.h"
-#include "vvc_mvs.h"
static int is_cclm(enum IntraPredMode mode)
{
@@ -694,189 +693,3 @@ int ff_vvc_reconstruct(VVCLocalContext *lc, const int rs, const int rx, const in
return ret;
}
-int ff_vvc_get_mip_size_id(const int w, const int h)
-{
- if (w == 4 && h == 4)
- return 0;
- if ((w == 4 || h == 4) || (w == 8 && h == 8))
- return 1;
- return 2;
-}
-
-int ff_vvc_nscale_derive(const int w, const int h, const int mode)
-{
- int side_size, nscale;
- av_assert0(mode < INTRA_LT_CCLM && !(mode > INTRA_HORZ && mode < INTRA_VERT));
- if (mode == INTRA_PLANAR || mode == INTRA_DC ||
- mode == INTRA_HORZ || mode == INTRA_VERT) {
- nscale = (av_log2(w) + av_log2(h) - 2) >> 2;
- } else {
- const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
- const int inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
- if (mode >= INTRA_VERT)
- side_size = h;
- if (mode <= INTRA_HORZ)
- side_size = w;
- nscale = FFMIN(2, av_log2(side_size) - av_log2(3 * inv_angle - 2) + 8);
- }
- return nscale;
-}
-
-int ff_vvc_need_pdpc(const int w, const int h, const uint8_t bdpcm_flag, const int mode, const int ref_idx)
-{
- av_assert0(mode < INTRA_LT_CCLM);
- if ((w >= 4 && h >= 4) && !ref_idx && !bdpcm_flag) {
- int nscale;
- if (mode == INTRA_PLANAR || mode == INTRA_DC ||
- mode == INTRA_HORZ || mode == INTRA_VERT)
- return 1;
- if (mode > INTRA_HORZ && mode < INTRA_VERT)
- return 0;
- nscale = ff_vvc_nscale_derive(w, h, mode);
- return nscale >= 0;
-
- }
- return 0;
-}
-
-static const ReconstructedArea* get_reconstructed_area(const VVCLocalContext *lc, const int x, const int y, const int c_idx)
-{
- const int ch_type = c_idx > 0;
- for (int i = lc->num_ras[ch_type] - 1; i >= 0; i--) {
- const ReconstructedArea* a = &lc->ras[ch_type][i];
- const int r = (a->x + a->w);
- const int b = (a->y + a->h);
- if (a->x <= x && x < r && a->y <= y && y < b)
- return a;
-
- //it's too far away, no need check it;
- if (x >= r && y >= b)
- break;
- }
- return NULL;
-}
-
-int ff_vvc_get_top_available(const VVCLocalContext *lc, const int x, const int y, int target_size, const int c_idx)
-{
- const VVCFrameContext *fc = lc->fc;
- const VVCSPS *sps = fc->ps.sps;
- const int hs = sps->hshift[c_idx];
- const int vs = sps->vshift[c_idx];
- const int log2_ctb_size_v = sps->ctb_log2_size_y - vs;
- const int end_of_ctb_x = ((lc->cu->x0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y;
- const int y0b = av_mod_uintp2(y, log2_ctb_size_v);
- const int max_x = FFMIN(fc->ps.pps->width, end_of_ctb_x) >> hs;
- const ReconstructedArea *a;
- int px = x;
-
- if (!y0b) {
- if (!lc->ctb_up_flag)
- return 0;
- target_size = FFMIN(target_size, (lc->end_of_tiles_x >> hs) - x);
- if (sps->r->sps_entropy_coding_sync_enabled_flag)
- target_size = FFMIN(target_size, (end_of_ctb_x >> hs) - x);
- return target_size;
- }
-
- target_size = FFMAX(0, FFMIN(target_size, max_x - x));
- while (target_size > 0 && (a = get_reconstructed_area(lc, px, y - 1, c_idx))) {
- const int sz = FFMIN(target_size, a->x + a->w - px);
- px += sz;
- target_size -= sz;
- }
- return px - x;
-}
-
-int ff_vvc_get_left_available(const VVCLocalContext *lc, const int x, const int y, int target_size, const int c_idx)
-{
- const VVCFrameContext *fc = lc->fc;
- const VVCSPS *sps = fc->ps.sps;
- const int hs = sps->hshift[c_idx];
- const int vs = sps->vshift[c_idx];
- const int log2_ctb_size_h = sps->ctb_log2_size_y - hs;
- const int x0b = av_mod_uintp2(x, log2_ctb_size_h);
- const int end_of_ctb_y = ((lc->cu->y0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y;
- const int max_y = FFMIN(fc->ps.pps->height, end_of_ctb_y) >> vs;
- const ReconstructedArea *a;
- int py = y;
-
- if (!x0b && !lc->ctb_left_flag)
- return 0;
-
- target_size = FFMAX(0, FFMIN(target_size, max_y - y));
- if (!x0b)
- return target_size;
-
- while (target_size > 0 && (a = get_reconstructed_area(lc, x - 1, py, c_idx))) {
- const int sz = FFMIN(target_size, a->y + a->h - py);
- py += sz;
- target_size -= sz;
- }
- return py - y;
-}
-
-static int less(const void *a, const void *b)
-{
- return *(const int*)a - *(const int*)b;
-}
-
-int ff_vvc_ref_filter_flag_derive(const int mode)
-{
- static const int modes[] = { -14, -12, -10, -6, INTRA_PLANAR, 2, 34, 66, 72, 76, 78, 80};
- return bsearch(&mode, modes, FF_ARRAY_ELEMS(modes), sizeof(int), less) != NULL;
-}
-
-int ff_vvc_intra_pred_angle_derive(const int pred_mode)
-{
- static const int angles[] = {
- 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 23, 26, 29,
- 32, 35, 39, 45, 51, 57, 64, 73, 86, 102, 128, 171, 256, 341, 512
- };
- int sign = 1, idx, intra_pred_angle;
- if (pred_mode > INTRA_DIAG) {
- idx = pred_mode - INTRA_VERT;
- } else if (pred_mode > 0) {
- idx = INTRA_HORZ - pred_mode;
- } else {
- idx = INTRA_HORZ - 2 - pred_mode;
- }
- if (idx < 0) {
- idx = -idx;
- sign = -1;
- }
- intra_pred_angle = sign * angles[idx];
- return intra_pred_angle;
-}
-
-#define ROUND(f) (int)(f < 0 ? -(-f + 0.5) : (f + 0.5))
-int ff_vvc_intra_inv_angle_derive(const int intra_pred_angle)
-{
- float inv_angle;
- av_assert0(intra_pred_angle);
- inv_angle = 32 * 512.0 / intra_pred_angle;
- return ROUND(inv_angle);
-}
-
-//8.4.5.2.7 Wide angle intra prediction mode mapping proces
-int ff_vvc_wide_angle_mode_mapping(const CodingUnit *cu,
- const int tb_width, const int tb_height, const int c_idx, int pred_mode_intra)
-{
- int nw, nh, wh_ratio, min, max;
-
- if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
- nw = tb_width;
- nh = tb_height;
- } else {
- nw = cu->cb_width;
- nh = cu->cb_height;
- }
- wh_ratio = FFABS(ff_log2(nw) - ff_log2(nh));
- max = (wh_ratio > 1) ? (8 + 2 * wh_ratio) : 8;
- min = (wh_ratio > 1) ? (60 - 2 * wh_ratio) : 60;
-
- if (nw > nh && pred_mode_intra >=2 && pred_mode_intra < max)
- pred_mode_intra += 65;
- else if (nh > nw && pred_mode_intra <= 66 && pred_mode_intra > min)
- pred_mode_intra -= 67;
- return pred_mode_intra;
-}
diff --git a/libavcodec/vvc/vvc_intra_utils.c b/libavcodec/vvc/vvc_intra_utils.c
new file mode 100644
index 0000000000..7d34cff023
--- /dev/null
+++ b/libavcodec/vvc/vvc_intra_utils.c
@@ -0,0 +1,218 @@
+/*
+ * VVC intra prediction utils
+ *
+ * Copyright (C) 2021 Nuo Mi
+ *
+ * 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
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include "libavutil/avassert.h"
+#include "libavutil/macros.h"
+#include "libavutil/common.h"
+#include "vvc_ctu.h"
+#include "vvc_intra.h"
+#include "vvc_ps.h"
+#include "vvcdec.h"
+
+int ff_vvc_get_mip_size_id(const int w, const int h)
+{
+ if (w == 4 && h == 4)
+ return 0;
+ if ((w == 4 || h == 4) || (w == 8 && h == 8))
+ return 1;
+ return 2;
+}
+
+int ff_vvc_nscale_derive(const int w, const int h, const int mode)
+{
+ int side_size, nscale;
+ av_assert0(mode < INTRA_LT_CCLM && !(mode > INTRA_HORZ && mode < INTRA_VERT));
+ if (mode == INTRA_PLANAR || mode == INTRA_DC ||
+ mode == INTRA_HORZ || mode == INTRA_VERT) {
+ nscale = (av_log2(w) + av_log2(h) - 2) >> 2;
+ } else {
+ const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
+ const int inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
+ if (mode >= INTRA_VERT)
+ side_size = h;
+ if (mode <= INTRA_HORZ)
+ side_size = w;
+ nscale = FFMIN(2, av_log2(side_size) - av_log2(3 * inv_angle - 2) + 8);
+ }
+ return nscale;
+}
+
+int ff_vvc_need_pdpc(const int w, const int h, const uint8_t bdpcm_flag, const int mode, const int ref_idx)
+{
+ av_assert0(mode < INTRA_LT_CCLM);
+ if ((w >= 4 && h >= 4) && !ref_idx && !bdpcm_flag) {
+ int nscale;
+ if (mode == INTRA_PLANAR || mode == INTRA_DC ||
+ mode == INTRA_HORZ || mode == INTRA_VERT)
+ return 1;
+ if (mode > INTRA_HORZ && mode < INTRA_VERT)
+ return 0;
+ nscale = ff_vvc_nscale_derive(w, h, mode);
+ return nscale >= 0;
+
+ }
+ return 0;
+}
+
+static const ReconstructedArea* get_reconstructed_area(const VVCLocalContext *lc, const int x, const int y, const int c_idx)
+{
+ const int ch_type = c_idx > 0;
+ for (int i = lc->num_ras[ch_type] - 1; i >= 0; i--) {
+ const ReconstructedArea* a = &lc->ras[ch_type][i];
+ const int r = (a->x + a->w);
+ const int b = (a->y + a->h);
+ if (a->x <= x && x < r && a->y <= y && y < b)
+ return a;
+
+ //it's too far away, no need check it;
+ if (x >= r && y >= b)
+ break;
+ }
+ return NULL;
+}
+
+int ff_vvc_get_top_available(const VVCLocalContext *lc, const int x, const int y, int target_size, const int c_idx)
+{
+ const VVCFrameContext *fc = lc->fc;
+ const VVCSPS *sps = fc->ps.sps;
+ const int hs = sps->hshift[c_idx];
+ const int vs = sps->vshift[c_idx];
+ const int log2_ctb_size_v = sps->ctb_log2_size_y - vs;
+ const int end_of_ctb_x = ((lc->cu->x0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y;
+ const int y0b = av_mod_uintp2(y, log2_ctb_size_v);
+ const int max_x = FFMIN(fc->ps.pps->width, end_of_ctb_x) >> hs;
+ const ReconstructedArea *a;
+ int px = x;
+
+ if (!y0b) {
+ if (!lc->ctb_up_flag)
+ return 0;
+ target_size = FFMIN(target_size, (lc->end_of_tiles_x >> hs) - x);
+ if (sps->r->sps_entropy_coding_sync_enabled_flag)
+ target_size = FFMIN(target_size, (end_of_ctb_x >> hs) - x);
+ return target_size;
+ }
+
+ target_size = FFMAX(0, FFMIN(target_size, max_x - x));
+ while (target_size > 0 && (a = get_reconstructed_area(lc, px, y - 1, c_idx))) {
+ const int sz = FFMIN(target_size, a->x + a->w - px);
+ px += sz;
+ target_size -= sz;
+ }
+ return px - x;
+}
+
+int ff_vvc_get_left_available(const VVCLocalContext *lc, const int x, const int y, int target_size, const int c_idx)
+{
+ const VVCFrameContext *fc = lc->fc;
+ const VVCSPS *sps = fc->ps.sps;
+ const int hs = sps->hshift[c_idx];
+ const int vs = sps->vshift[c_idx];
+ const int log2_ctb_size_h = sps->ctb_log2_size_y - hs;
+ const int x0b = av_mod_uintp2(x, log2_ctb_size_h);
+ const int end_of_ctb_y = ((lc->cu->y0 >> sps->ctb_log2_size_y) + 1) << sps->ctb_log2_size_y;
+ const int max_y = FFMIN(fc->ps.pps->height, end_of_ctb_y) >> vs;
+ const ReconstructedArea *a;
+ int py = y;
+
+ if (!x0b && !lc->ctb_left_flag)
+ return 0;
+
+ target_size = FFMAX(0, FFMIN(target_size, max_y - y));
+ if (!x0b)
+ return target_size;
+
+ while (target_size > 0 && (a = get_reconstructed_area(lc, x - 1, py, c_idx))) {
+ const int sz = FFMIN(target_size, a->y + a->h - py);
+ py += sz;
+ target_size -= sz;
+ }
+ return py - y;
+}
+
+static int less(const void *a, const void *b)
+{
+ return *(const int*)a - *(const int*)b;
+}
+
+int ff_vvc_ref_filter_flag_derive(const int mode)
+{
+ static const int modes[] = { -14, -12, -10, -6, INTRA_PLANAR, 2, 34, 66, 72, 76, 78, 80};
+ return bsearch(&mode, modes, FF_ARRAY_ELEMS(modes), sizeof(int), less) != NULL;
+}
+
+int ff_vvc_intra_pred_angle_derive(const int pred_mode)
+{
+ static const int angles[] = {
+ 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 23, 26, 29,
+ 32, 35, 39, 45, 51, 57, 64, 73, 86, 102, 128, 171, 256, 341, 512
+ };
+ int sign = 1, idx, intra_pred_angle;
+ if (pred_mode > INTRA_DIAG) {
+ idx = pred_mode - INTRA_VERT;
+ } else if (pred_mode > 0) {
+ idx = INTRA_HORZ - pred_mode;
+ } else {
+ idx = INTRA_HORZ - 2 - pred_mode;
+ }
+ if (idx < 0) {
+ idx = -idx;
+ sign = -1;
+ }
+ intra_pred_angle = sign * angles[idx];
+ return intra_pred_angle;
+}
+
+#define ROUND(f) (int)(f < 0 ? -(-f + 0.5) : (f + 0.5))
+int ff_vvc_intra_inv_angle_derive(const int intra_pred_angle)
+{
+ float inv_angle;
+ av_assert0(intra_pred_angle);
+ inv_angle = 32 * 512.0 / intra_pred_angle;
+ return ROUND(inv_angle);
+}
+
+//8.4.5.2.7 Wide angle intra prediction mode mapping proces
+int ff_vvc_wide_angle_mode_mapping(const CodingUnit *cu,
+ const int tb_width, const int tb_height, const int c_idx, int pred_mode_intra)
+{
+ int nw, nh, wh_ratio, min, max;
+
+ if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
+ nw = tb_width;
+ nh = tb_height;
+ } else {
+ nw = cu->cb_width;
+ nh = cu->cb_height;
+ }
+ wh_ratio = FFABS(ff_log2(nw) - ff_log2(nh));
+ max = (wh_ratio > 1) ? (8 + 2 * wh_ratio) : 8;
+ min = (wh_ratio > 1) ? (60 - 2 * wh_ratio) : 60;
+
+ if (nw > nh && pred_mode_intra >=2 && pred_mode_intra < max)
+ pred_mode_intra += 65;
+ else if (nh > nw && pred_mode_intra <= 66 && pred_mode_intra > min)
+ pred_mode_intra -= 67;
+ return pred_mode_intra;
+}
--
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] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/6] avcodec/vvc/vvc_intra: Move utils out of svq1enc.c
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 3/6] avcodec/vvc/vvc_intra: Move utils " Andreas Rheinhardt
@ 2024-02-28 16:33 ` Andreas Rheinhardt
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-02-28 16:33 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Otherwise vvc_intra.o gets pulled in by the vvc_mc checkasm
> test and it in turn pulls vvc_ctu.o and then the rest of vvcdec
> and lavc in. Besides being bad size-wise this also has the downside
> that it pulls in avpriv_(cga|vga16)_font from libavutil which are
> marked as being imported from another library when building
> libavcodec as a DLL and this breaks checkasm because it links
> both lavc and lavu statically.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
Fixed the commit title locally.
- 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] 8+ messages in thread
* [FFmpeg-devel] [PATCH 4/6] avcodec/vvc/vvc_mvs: Add proper header include
2024-02-28 16:16 [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 2/6] avcodec/svq1enc: Move initializing DSP out of svq1enc.c Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 3/6] avcodec/vvc/vvc_intra: Move utils " Andreas Rheinhardt
@ 2024-02-28 16:18 ` Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 5/6] checkasm/vvc_mc: Don't use declare_func_emms Andreas Rheinhardt
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-02-28 16:18 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
TODO: Make checkheader also test subfolders.
libavcodec/vvc/vvc_mvs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/vvc/vvc_mvs.h b/libavcodec/vvc/vvc_mvs.h
index a546a324c2..78ad17c303 100644
--- a/libavcodec/vvc/vvc_mvs.h
+++ b/libavcodec/vvc/vvc_mvs.h
@@ -23,7 +23,7 @@
#ifndef AVCODEC_VVC_VVC_MVS_H
#define AVCODEC_VVC_VVC_MVS_H
-#include "vvcdec.h"
+#include "vvc_ctu.h"
void ff_vvc_round_mv(Mv *mv, int lshift, int rshift);
void ff_vvc_clip_mv(Mv *mv);
--
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] 8+ messages in thread
* [FFmpeg-devel] [PATCH 5/6] checkasm/vvc_mc: Don't use declare_func_emms
2024-02-28 16:16 [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
` (2 preceding siblings ...)
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 4/6] avcodec/vvc/vvc_mvs: Add proper header include Andreas Rheinhardt
@ 2024-02-28 16:18 ` Andreas Rheinhardt
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 6/6] tests/checkasm: Improve included headers Andreas Rheinhardt
2024-03-01 11:35 ` [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
5 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-02-28 16:18 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
There is no MMX DSP code for VVC, so one can use the stricter
declare_func which also tests that we are not in MMX mode
at the end of this function.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
tests/checkasm/vvc_mc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index 8adb00573f..ce34965b7d 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -74,7 +74,7 @@ static void check_put_vvc_luma(void)
LOCAL_ALIGNED_32(uint8_t, src1, [SRC_BUF_SIZE]);
VVCDSPContext c;
- declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, int16_t *dst, const uint8_t *src, const ptrdiff_t src_stride,
+ declare_func(void, int16_t *dst, const uint8_t *src, const ptrdiff_t src_stride,
const int height, const int8_t *hf, const int8_t *vf, const int width);
for (int bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
@@ -122,7 +122,7 @@ static void check_put_vvc_luma_uni(void)
LOCAL_ALIGNED_32(uint8_t, src1, [SRC_BUF_SIZE]);
VVCDSPContext c;
- declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride,
+ declare_func(void, uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, ptrdiff_t srcstride, int height, const int8_t *hf, const int8_t *vf, int width);
for (int bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
@@ -172,7 +172,7 @@ static void check_put_vvc_chroma(void)
LOCAL_ALIGNED_32(uint8_t, src1, [SRC_BUF_SIZE]);
VVCDSPContext c;
- declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, int16_t *dst, const uint8_t *src, const ptrdiff_t src_stride,
+ declare_func(void, int16_t *dst, const uint8_t *src, const ptrdiff_t src_stride,
const int height, const int8_t *hf, const int8_t *vf, const int width);
for (int bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
@@ -220,7 +220,7 @@ static void check_put_vvc_chroma_uni(void)
LOCAL_ALIGNED_32(uint8_t, src1, [SRC_BUF_SIZE]);
VVCDSPContext c;
- declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dststride,
+ declare_func(void, uint8_t *dst, ptrdiff_t dststride,
uint8_t *src, ptrdiff_t srcstride, int height, const int8_t *hf, const int8_t *vf, int width);
for (int bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
@@ -282,7 +282,7 @@ static void check_avg(void)
for (int h = 2; h <= MAX_CTU_SIZE; h *= 2) {
for (int w = 2; w <= MAX_CTU_SIZE; w *= 2) {
{
- declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dst_stride,
+ declare_func(void, uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *src0, const int16_t *src1, int width, int height);
if (check_func(c.inter.avg, "avg_%d_%dx%d", bit_depth, w, h)) {
memset(dst0, 0, AVG_DST_BUF_SIZE);
@@ -296,7 +296,7 @@ static void check_avg(void)
}
}
{
- declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, ptrdiff_t dst_stride,
+ declare_func(void, uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *src0, const int16_t *src1, int width, int height,
int denom, int w0, int w1, int o0, int o1);
{
--
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] 8+ messages in thread
* [FFmpeg-devel] [PATCH 6/6] tests/checkasm: Improve included headers
2024-02-28 16:16 [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
` (3 preceding siblings ...)
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 5/6] checkasm/vvc_mc: Don't use declare_func_emms Andreas Rheinhardt
@ 2024-02-28 16:18 ` Andreas Rheinhardt
2024-03-01 11:35 ` [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
5 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-02-28 16:18 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
tests/checkasm/exrdsp.c | 2 +-
tests/checkasm/h264dsp.c | 2 --
tests/checkasm/h264pred.c | 2 +-
tests/checkasm/hevc_sao.c | 2 --
tests/checkasm/utvideodsp.c | 1 -
tests/checkasm/vp8dsp.c | 1 -
tests/checkasm/vvc_mc.c | 4 +---
7 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/tests/checkasm/exrdsp.c b/tests/checkasm/exrdsp.c
index 2a5febb9d3..8af2f13109 100644
--- a/tests/checkasm/exrdsp.c
+++ b/tests/checkasm/exrdsp.c
@@ -21,7 +21,7 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/avcodec.h"
+#include "libavcodec/defs.h"
#include "libavcodec/exrdsp.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index 3c95f9d74d..0f484e3f43 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -20,12 +20,10 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/avcodec.h"
#include "libavcodec/h264dsp.h"
#include "libavcodec/h264data.h"
#include "libavcodec/h264_parse.h"
#include "libavutil/common.h"
-#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
diff --git a/tests/checkasm/h264pred.c b/tests/checkasm/h264pred.c
index a3077f6946..53e1cdb219 100644
--- a/tests/checkasm/h264pred.c
+++ b/tests/checkasm/h264pred.c
@@ -20,7 +20,7 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/avcodec.h"
+#include "libavcodec/codec_id.h"
#include "libavcodec/h264pred.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
diff --git a/tests/checkasm/hevc_sao.c b/tests/checkasm/hevc_sao.c
index da3f710537..d05af9ac72 100644
--- a/tests/checkasm/hevc_sao.c
+++ b/tests/checkasm/hevc_sao.c
@@ -23,8 +23,6 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
-#include "libavcodec/avcodec.h"
-
#include "libavcodec/hevcdsp.h"
#include "checkasm.h"
diff --git a/tests/checkasm/utvideodsp.c b/tests/checkasm/utvideodsp.c
index bdede6107b..2463c96603 100644
--- a/tests/checkasm/utvideodsp.c
+++ b/tests/checkasm/utvideodsp.c
@@ -21,7 +21,6 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/avcodec.h"
#include "libavcodec/utvideodsp.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
diff --git a/tests/checkasm/vp8dsp.c b/tests/checkasm/vp8dsp.c
index 87b03d71d5..4cd0f8ac4f 100644
--- a/tests/checkasm/vp8dsp.c
+++ b/tests/checkasm/vp8dsp.c
@@ -20,7 +20,6 @@
#include <string.h>
-#include "libavcodec/avcodec.h"
#include "libavcodec/vp8dsp.h"
#include "libavutil/common.h"
diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index ce34965b7d..d102e2ac9a 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -22,13 +22,11 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/avcodec.h"
#include "libavcodec/vvc/vvc_ctu.h"
#include "libavcodec/vvc/vvc_data.h"
+#include "libavcodec/vvc/vvcdsp.h"
#include "libavutil/common.h"
-#include "libavutil/internal.h"
-#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
--
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] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c
2024-02-28 16:16 [FFmpeg-devel] [PATCH 1/6] avcodec/aacenc: Move initializing DSP out of aacenc.c Andreas Rheinhardt
` (4 preceding siblings ...)
2024-02-28 16:18 ` [FFmpeg-devel] [PATCH 6/6] tests/checkasm: Improve included headers Andreas Rheinhardt
@ 2024-03-01 11:35 ` Andreas Rheinhardt
5 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2024-03-01 11:35 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Otherwise aacenc.o gets pulled in by the aacencdsp checkasm
> test and it in turn pulls the rest of lavc in.
> Besides being bad size-wise this also has the downside that
> it pulls in avpriv_(cga|vga16)_font from libavutil which are
> marked as being imported from another library when building
> libavcodec as a DLL and this breaks checkasm because it links
> both lavc and lavu statically.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/aaccoder.c | 26 +++++------
> libavcodec/aaccoder_trellis.h | 2 +-
> libavcodec/aaccoder_twoloop.h | 2 +-
> libavcodec/aacenc.c | 21 +++------
> libavcodec/aacenc.h | 9 +---
> libavcodec/aacenc_is.c | 6 +--
> libavcodec/aacenc_ltp.c | 4 +-
> libavcodec/aacenc_pred.c | 6 +--
> libavcodec/aacenc_utils.h | 24 -----------
> libavcodec/aacencdsp.h | 72 +++++++++++++++++++++++++++++++
> libavcodec/mips/aaccoder_mips.c | 1 +
> libavcodec/riscv/aacencdsp_init.c | 5 +--
> libavcodec/x86/aacencdsp_init.c | 5 +--
> tests/checkasm/aacencdsp.c | 10 ++---
> 14 files changed, 112 insertions(+), 81 deletions(-)
> create mode 100644 libavcodec/aacencdsp.h
>
> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
> index 6291c16123..4ce54ca886 100644
> --- a/libavcodec/aaccoder.c
> +++ b/libavcodec/aaccoder.c
> @@ -108,10 +108,10 @@ static av_always_inline float quantize_and_encode_band_cost_template(
> return cost * lambda;
> }
> if (!scaled) {
> - s->abs_pow34(s->scoefs, in, size);
> + s->aacdsp.abs_pow34(s->scoefs, in, size);
> scaled = s->scoefs;
> }
> - s->quant_bands(s->qcoefs, in, scaled, size, !BT_UNSIGNED, aac_cb_maxval[cb], Q34, ROUNDING);
> + s->aacdsp.quant_bands(s->qcoefs, in, scaled, size, !BT_UNSIGNED, aac_cb_maxval[cb], Q34, ROUNDING);
> if (BT_UNSIGNED) {
> off = 0;
> } else {
> @@ -311,7 +311,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
> float next_minrd = INFINITY;
> int next_mincb = 0;
>
> - s->abs_pow34(s->scoefs, sce->coeffs, 1024);
> + s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
> start = win*128;
> for (cb = 0; cb < CB_TOT_ALL; cb++) {
> path[0][cb].cost = 0.0f;
> @@ -522,7 +522,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
> }
> }
> idx = 1;
> - s->abs_pow34(s->scoefs, sce->coeffs, 1024);
> + s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
> for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
> start = w*128;
> for (g = 0; g < sce->ics.num_swb; g++) {
> @@ -668,7 +668,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
>
> if (!allz)
> return;
> - s->abs_pow34(s->scoefs, sce->coeffs, 1024);
> + s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
> ff_quantize_band_cost_cache_init(s);
>
> for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
> @@ -874,8 +874,8 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
> s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]);
> pns_senergy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
> pns_energy += pns_senergy;
> - s->abs_pow34(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]);
> - s->abs_pow34(PNS34, PNS, sce->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(PNS34, PNS, sce->ics.swb_sizes[g]);
> dist1 += quantize_band_cost(s, &sce->coeffs[start_c],
> NOR34,
> sce->ics.swb_sizes[g],
> @@ -1012,8 +1012,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
> S[i] = M[i]
> - sce1->coeffs[start+(w+w2)*128+i];
> }
> - s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
> - s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
> for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
> Mmax = FFMAX(Mmax, M34[i]);
> Smax = FFMAX(Smax, S34[i]);
> @@ -1056,10 +1056,10 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
> - sce1->coeffs[start+(w+w2)*128+i];
> }
>
> - s->abs_pow34(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
> - s->abs_pow34(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
> - s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
> - s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
> dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
> L34,
> sce0->ics.swb_sizes[g],
> diff --git a/libavcodec/aaccoder_trellis.h b/libavcodec/aaccoder_trellis.h
> index 4810ff3208..245aa1c11b 100644
> --- a/libavcodec/aaccoder_trellis.h
> +++ b/libavcodec/aaccoder_trellis.h
> @@ -70,7 +70,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
> float next_minbits = INFINITY;
> int next_mincb = 0;
>
> - s->abs_pow34(s->scoefs, sce->coeffs, 1024);
> + s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
> start = win*128;
> for (cb = 0; cb < CB_TOT_ALL; cb++) {
> path[0][cb].cost = run_bits+4;
> diff --git a/libavcodec/aaccoder_twoloop.h b/libavcodec/aaccoder_twoloop.h
> index 0504a916ad..92dc2911a3 100644
> --- a/libavcodec/aaccoder_twoloop.h
> +++ b/libavcodec/aaccoder_twoloop.h
> @@ -291,7 +291,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
>
> if (!allz)
> return;
> - s->abs_pow34(s->scoefs, sce->coeffs, 1024);
> + s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
> ff_quantize_band_cost_cache_init(s);
>
> for (i = 0; i < sizeof(minsf) / sizeof(minsf[0]); ++i)
> diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
> index bce4e039dc..3f99188be4 100644
> --- a/libavcodec/aacenc.c
> +++ b/libavcodec/aacenc.c
> @@ -1381,7 +1381,11 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
> ff_lpc_init(&s->lpc, 2*avctx->frame_size, TNS_MAX_ORDER, FF_LPC_TYPE_LEVINSON);
> s->random_state = 0x1f2e3d4c;
>
> - ff_aac_dsp_init(s);
> + ff_aacenc_dsp_init(&s->aacdsp);
> +
> +#if HAVE_MIPSDSP
> + ff_aac_coder_init_mips(s);
> +#endif
>
> ff_af_queue_init(avctx, &s->afq);
>
> @@ -1435,18 +1439,3 @@ const FFCodec ff_aac_encoder = {
> AV_SAMPLE_FMT_NONE },
> .p.priv_class = &aacenc_class,
> };
> -
> -void ff_aac_dsp_init(AACEncContext *s){
> - s->abs_pow34 = abs_pow34_v;
> - s->quant_bands = quantize_bands;
> -
> -#if ARCH_RISCV
> - ff_aac_dsp_init_riscv(s);
> -#elif ARCH_X86
> - ff_aac_dsp_init_x86(s);
> -#endif
> -
> -#if HAVE_MIPSDSP
> - ff_aac_coder_init_mips(s);
> -#endif
> -}
> diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
> index 752f1c26b2..c18e828905 100644
> --- a/libavcodec/aacenc.h
> +++ b/libavcodec/aacenc.h
> @@ -33,6 +33,7 @@
> #include "put_bits.h"
>
> #include "aac.h"
> +#include "aacencdsp.h"
> #include "audio_frame_queue.h"
> #include "psymodel.h"
>
> @@ -233,19 +234,13 @@ typedef struct AACEncContext {
> uint16_t quantize_band_cost_cache_generation;
> AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]; ///< memoization area for quantize_band_cost
>
> - void (*abs_pow34)(float *out, const float *in, const int size);
> - void (*quant_bands)(int *out, const float *in, const float *scaled,
> - int size, int is_signed, int maxval, const float Q34,
> - const float rounding);
> + AACEncDSPContext aacdsp;
>
> struct {
> float *samples;
> } buffer;
> } AACEncContext;
>
> -void ff_aac_dsp_init(AACEncContext *s);
> -void ff_aac_dsp_init_riscv(AACEncContext *s);
> -void ff_aac_dsp_init_x86(AACEncContext *s);
> void ff_aac_coder_init_mips(AACEncContext *c);
> void ff_quantize_band_cost_cache_init(struct AACEncContext *s);
>
> diff --git a/libavcodec/aacenc_is.c b/libavcodec/aacenc_is.c
> index 1810790d88..4943b6450c 100644
> --- a/libavcodec/aacenc_is.c
> +++ b/libavcodec/aacenc_is.c
> @@ -59,9 +59,9 @@ struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe,
> float minthr = FFMIN(band0->threshold, band1->threshold);
> for (i = 0; i < sce0->ics.swb_sizes[g]; i++)
> IS[i] = (L[start+(w+w2)*128+i] + phase*R[start+(w+w2)*128+i])*sqrt(ener0/ener01);
> - s->abs_pow34(L34, &L[start+(w+w2)*128], sce0->ics.swb_sizes[g]);
> - s->abs_pow34(R34, &R[start+(w+w2)*128], sce0->ics.swb_sizes[g]);
> - s->abs_pow34(I34, IS, sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(L34, &L[start+(w+w2)*128], sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(R34, &R[start+(w+w2)*128], sce0->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(I34, IS, sce0->ics.swb_sizes[g]);
> maxval = find_max_val(1, sce0->ics.swb_sizes[g], I34);
> is_band_type = find_min_book(maxval, is_sf_idx);
> dist1 += quantize_band_cost(s, &L[start + (w+w2)*128], L34,
> diff --git a/libavcodec/aacenc_ltp.c b/libavcodec/aacenc_ltp.c
> index f3075f0e71..591ff6aedf 100644
> --- a/libavcodec/aacenc_ltp.c
> +++ b/libavcodec/aacenc_ltp.c
> @@ -190,8 +190,8 @@ void ff_aac_search_for_ltp(AACEncContext *s, SingleChannelElement *sce,
> FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
> for (i = 0; i < sce->ics.swb_sizes[g]; i++)
> PCD[i] = sce->coeffs[start+(w+w2)*128+i] - sce->lcoeffs[start+(w+w2)*128+i];
> - s->abs_pow34(C34, &sce->coeffs[start+(w+w2)*128], sce->ics.swb_sizes[g]);
> - s->abs_pow34(PCD34, PCD, sce->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(C34, &sce->coeffs[start+(w+w2)*128], sce->ics.swb_sizes[g]);
> + s->aacdsp.abs_pow34(PCD34, PCD, sce->ics.swb_sizes[g]);
> dist1 += quantize_band_cost(s, &sce->coeffs[start+(w+w2)*128], C34, sce->ics.swb_sizes[g],
> sce->sf_idx[(w+w2)*16+g], sce->band_type[(w+w2)*16+g],
> s->lambda/band->threshold, INFINITY, &bits_tmp1, NULL);
> diff --git a/libavcodec/aacenc_pred.c b/libavcodec/aacenc_pred.c
> index f87fcd5a00..a486c44d42 100644
> --- a/libavcodec/aacenc_pred.c
> +++ b/libavcodec/aacenc_pred.c
> @@ -270,7 +270,7 @@ void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce)
> continue;
>
> /* Normal coefficients */
> - s->abs_pow34(O34, &sce->coeffs[start_coef], num_coeffs);
> + s->aacdsp.abs_pow34(O34, &sce->coeffs[start_coef], num_coeffs);
> dist1 = ff_quantize_and_encode_band_cost(s, NULL, &sce->coeffs[start_coef], NULL,
> O34, num_coeffs, sce->sf_idx[sfb],
> cb_n, s->lambda / band->threshold, INFINITY, &cost1, NULL);
> @@ -279,7 +279,7 @@ void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce)
> /* Encoded coefficients - needed for #bits, band type and quant. error */
> for (i = 0; i < num_coeffs; i++)
> SENT[i] = sce->coeffs[start_coef + i] - sce->prcoeffs[start_coef + i];
> - s->abs_pow34(S34, SENT, num_coeffs);
> + s->aacdsp.abs_pow34(S34, SENT, num_coeffs);
> if (cb_n < RESERVED_BT)
> cb_p = av_clip(find_min_book(find_max_val(1, num_coeffs, S34), sce->sf_idx[sfb]), cb_min, cb_max);
> else
> @@ -291,7 +291,7 @@ void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce)
> /* Reconstructed coefficients - needed for distortion measurements */
> for (i = 0; i < num_coeffs; i++)
> sce->prcoeffs[start_coef + i] += QERR[i] != 0.0f ? (sce->prcoeffs[start_coef + i] - QERR[i]) : 0.0f;
> - s->abs_pow34(P34, &sce->prcoeffs[start_coef], num_coeffs);
> + s->aacdsp.abs_pow34(P34, &sce->prcoeffs[start_coef], num_coeffs);
> if (cb_n < RESERVED_BT)
> cb_p = av_clip(find_min_book(find_max_val(1, num_coeffs, P34), sce->sf_idx[sfb]), cb_min, cb_max);
> else
> diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
> index ef2218e036..cc747c3ea6 100644
> --- a/libavcodec/aacenc_utils.h
> +++ b/libavcodec/aacenc_utils.h
> @@ -37,15 +37,6 @@
> #define ROUND_TO_ZERO 0.1054f
> #define C_QUANT 0.4054f
>
> -static inline void abs_pow34_v(float *out, const float *in, const int size)
> -{
> - int i;
> - for (i = 0; i < size; i++) {
> - float a = fabsf(in[i]);
> - out[i] = sqrtf(a * sqrtf(a));
> - }
> -}
> -
> static inline float pos_pow34(float a)
> {
> return sqrtf(a * sqrtf(a));
> @@ -62,21 +53,6 @@ static inline int quant(float coef, const float Q, const float rounding)
> return sqrtf(a * sqrtf(a)) + rounding;
> }
>
> -static inline void quantize_bands(int *out, const float *in, const float *scaled,
> - int size, int is_signed, int maxval, const float Q34,
> - const float rounding)
> -{
> - int i;
> - for (i = 0; i < size; i++) {
> - float qc = scaled[i] * Q34;
> - int tmp = (int)FFMIN(qc + rounding, (float)maxval);
> - if (is_signed && in[i] < 0.0f) {
> - tmp = -tmp;
> - }
> - out[i] = tmp;
> - }
> -}
> -
> static inline float find_max_val(int group_len, int swb_size, const float *scaled)
> {
> float maxval = 0.0f;
> diff --git a/libavcodec/aacencdsp.h b/libavcodec/aacencdsp.h
> new file mode 100644
> index 0000000000..67836d8cf7
> --- /dev/null
> +++ b/libavcodec/aacencdsp.h
> @@ -0,0 +1,72 @@
> +/*
> + * 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_AACENCDSP_H
> +#define AVCODEC_AACENCDSP_H
> +
> +#include <math.h>
> +
> +#include "config.h"
> +
> +#include "libavutil/macros.h"
> +
> +typedef struct AACEncDSPContext {
> + void (*abs_pow34)(float *out, const float *in, const int size);
> + void (*quant_bands)(int *out, const float *in, const float *scaled,
> + int size, int is_signed, int maxval, const float Q34,
> + const float rounding);
> +} AACEncDSPContext;
> +
> +void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s);
> +void ff_aacenc_dsp_init_x86(AACEncDSPContext *s);
> +
> +static inline void abs_pow34_v(float *out, const float *in, const int size)
> +{
> + for (int i = 0; i < size; i++) {
> + float a = fabsf(in[i]);
> + out[i] = sqrtf(a * sqrtf(a));
> + }
> +}
> +
> +static inline void quantize_bands(int *out, const float *in, const float *scaled,
> + int size, int is_signed, int maxval, const float Q34,
> + const float rounding)
> +{
> + for (int i = 0; i < size; i++) {
> + float qc = scaled[i] * Q34;
> + int tmp = (int)FFMIN(qc + rounding, (float)maxval);
> + if (is_signed && in[i] < 0.0f) {
> + tmp = -tmp;
> + }
> + out[i] = tmp;
> + }
> +}
> +
> +static inline void ff_aacenc_dsp_init(AACEncDSPContext *s)
> +{
> + s->abs_pow34 = abs_pow34_v;
> + s->quant_bands = quantize_bands;
> +
> +#if ARCH_RISCV
> + ff_aacenc_dsp_init_riscv(s);
> +#elif ARCH_X86
> + ff_aacenc_dsp_init_x86(s);
> +#endif
> +}
> +
> +#endif
> diff --git a/libavcodec/mips/aaccoder_mips.c b/libavcodec/mips/aaccoder_mips.c
> index bf27a2a5da..dd9661fbdd 100644
> --- a/libavcodec/mips/aaccoder_mips.c
> +++ b/libavcodec/mips/aaccoder_mips.c
> @@ -61,6 +61,7 @@
> #include "libavcodec/put_bits.h"
> #include "libavcodec/aac.h"
> #include "libavcodec/aacenc.h"
> +#include "libavcodec/aacencdsp.h"
> #include "libavcodec/aactab.h"
> #include "libavcodec/aacenctab.h"
> #include "libavcodec/aacenc_utils.h"
> diff --git a/libavcodec/riscv/aacencdsp_init.c b/libavcodec/riscv/aacencdsp_init.c
> index 83ae16f46b..b27af9d973 100644
> --- a/libavcodec/riscv/aacencdsp_init.c
> +++ b/libavcodec/riscv/aacencdsp_init.c
> @@ -22,13 +22,12 @@
> #include "config.h"
>
> #include "libavutil/attributes.h"
> -#include "libavutil/float_dsp.h"
> #include "libavutil/cpu.h"
> -#include "libavcodec/aacenc.h"
> +#include "libavcodec/aacencdsp.h"
>
> void ff_abs_pow34_rvv(float *out, const float *in, const int size);
>
> -av_cold void ff_aac_dsp_init_riscv(AACEncContext *s)
> +av_cold void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s)
> {
> #if HAVE_RVV
> int flags = av_get_cpu_flags();
> diff --git a/libavcodec/x86/aacencdsp_init.c b/libavcodec/x86/aacencdsp_init.c
> index 049a2417d9..e0d8dec4f8 100644
> --- a/libavcodec/x86/aacencdsp_init.c
> +++ b/libavcodec/x86/aacencdsp_init.c
> @@ -22,9 +22,8 @@
> #include "config.h"
>
> #include "libavutil/attributes.h"
> -#include "libavutil/float_dsp.h"
> #include "libavutil/x86/cpu.h"
> -#include "libavcodec/aacenc.h"
> +#include "libavcodec/aacencdsp.h"
>
> void ff_abs_pow34_sse(float *out, const float *in, const int size);
>
> @@ -32,7 +31,7 @@ void ff_aac_quantize_bands_sse2(int *out, const float *in, const float *scaled,
> int size, int is_signed, int maxval, const float Q34,
> const float rounding);
>
> -av_cold void ff_aac_dsp_init_x86(AACEncContext *s)
> +av_cold void ff_aacenc_dsp_init_x86(AACEncDSPContext *s)
> {
> int cpu_flags = av_get_cpu_flags();
>
> diff --git a/tests/checkasm/aacencdsp.c b/tests/checkasm/aacencdsp.c
> index 6fc22047c3..1756c4ecd5 100644
> --- a/tests/checkasm/aacencdsp.c
> +++ b/tests/checkasm/aacencdsp.c
> @@ -20,10 +20,9 @@
>
> #include <string.h>
>
> -#include "libavutil/mem.h"
> #include "libavutil/mem_internal.h"
>
> -#include "libavcodec/aacenc.h"
> +#include "libavcodec/aacencdsp.h"
>
> #include "checkasm.h"
>
> @@ -36,7 +35,8 @@
> } \
> } while (0)
>
> -static void test_abs_pow34(AACEncContext *s) {
> +static void test_abs_pow34(AACEncDSPContext *s)
> +{
> #define BUF_SIZE 1024
> LOCAL_ALIGNED_32(float, in, [BUF_SIZE]);
>
> @@ -63,8 +63,8 @@ static void test_abs_pow34(AACEncContext *s) {
>
> void checkasm_check_aacencdsp(void)
> {
> - AACEncContext s = { 0 };
> - ff_aac_dsp_init(&s);
> + AACEncDSPContext s = { 0 };
> + ff_aacenc_dsp_init(&s);
>
> test_abs_pow34(&s);
> }
Will apply this patchset 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] 8+ messages in thread