[FFmpeg-devel] [PATCH 27/28] avcodec/mpegvideoencdsp: Pass bitexact flag directly

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue May 7 00:52:26 EEST 2024


Don't pass an AVCodecContext*. This avoids inclusions of avcodec.h
and makes it clearer which parameter affect the returned function
pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/arm/mpegvideoencdsp_init_arm.c   |  3 +--
 libavcodec/dnxhdenc.c                       |  2 +-
 libavcodec/mips/mpegvideoencdsp_init_mips.c |  2 +-
 libavcodec/mpegvideo_enc.c                  |  2 +-
 libavcodec/mpegvideoencdsp.c                | 11 +++++------
 libavcodec/mpegvideoencdsp.h                | 17 +++++------------
 libavcodec/ppc/mpegvideoencdsp.c            |  2 +-
 libavcodec/svq1enc.c                        |  2 +-
 libavcodec/x86/mpegvideoencdsp_init.c       | 13 ++++---------
 9 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/libavcodec/arm/mpegvideoencdsp_init_arm.c b/libavcodec/arm/mpegvideoencdsp_init_arm.c
index a95b5bebe9..842079267b 100644
--- a/libavcodec/arm/mpegvideoencdsp_init_arm.c
+++ b/libavcodec/arm/mpegvideoencdsp_init_arm.c
@@ -21,14 +21,13 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/arm/cpu.h"
-#include "libavcodec/avcodec.h"
 #include "libavcodec/mpegvideoencdsp.h"
 
 int ff_pix_norm1_armv6(const uint8_t *pix, int line_size);
 int ff_pix_sum_armv6(const uint8_t *pix, int line_size);
 
 av_cold void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c,
-                                         AVCodecContext *avctx)
+                                         int bitexact)
 {
     int cpu_flags = av_get_cpu_flags();
 
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 0cb25d7714..6417dc48b9 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -423,7 +423,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
     ff_blockdsp_init(&ctx->bdsp);
     ff_fdctdsp_init(&ctx->m.fdsp, avctx);
     ff_mpv_idct_init(&ctx->m);
-    ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx);
+    ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
     ff_pixblockdsp_init(&ctx->m.pdsp, avctx);
     ff_dct_encode_init(&ctx->m);
 
diff --git a/libavcodec/mips/mpegvideoencdsp_init_mips.c b/libavcodec/mips/mpegvideoencdsp_init_mips.c
index 3efbeec34a..4a279e9942 100644
--- a/libavcodec/mips/mpegvideoencdsp_init_mips.c
+++ b/libavcodec/mips/mpegvideoencdsp_init_mips.c
@@ -24,7 +24,7 @@
 #include "h263dsp_mips.h"
 
 av_cold void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c,
-                                          AVCodecContext *avctx)
+                                          int bitexact)
 {
     int cpu_flags = av_get_cpu_flags();
 
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ab14538b33..cfdd8fa3c4 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -809,7 +809,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
     ff_fdctdsp_init(&s->fdsp, avctx);
     ff_me_cmp_init(&s->mecc, avctx);
-    ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
+    ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
     ff_drawedgesdsp_init(&s->drawedges);
     ff_pixblockdsp_init(&s->pdsp, avctx);
 
diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c
index a6de93456d..b8f740630a 100644
--- a/libavcodec/mpegvideoencdsp.c
+++ b/libavcodec/mpegvideoencdsp.c
@@ -22,7 +22,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/attributes.h"
 #include "libavutil/imgutils.h"
-#include "avcodec.h"
 #include "me_cmp.h"
 #include "mpegvideoencdsp.h"
 
@@ -200,7 +199,7 @@ static void shrink88(uint8_t *dst, int dst_wrap,
 }
 
 av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
-                                     AVCodecContext *avctx)
+                                     int bitexact)
 {
     c->try_8x8basis = try_8x8basis_c;
     c->add_8x8basis = add_8x8basis_c;
@@ -214,12 +213,12 @@ av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
     c->pix_norm1 = pix_norm1_c;
 
 #if ARCH_ARM
-    ff_mpegvideoencdsp_init_arm(c, avctx);
+    ff_mpegvideoencdsp_init_arm(c, bitexact);
 #elif ARCH_PPC
-    ff_mpegvideoencdsp_init_ppc(c, avctx);
+    ff_mpegvideoencdsp_init_ppc(c, bitexact);
 #elif ARCH_X86
-    ff_mpegvideoencdsp_init_x86(c, avctx);
+    ff_mpegvideoencdsp_init_x86(c, bitexact);
 #elif ARCH_MIPS
-    ff_mpegvideoencdsp_init_mips(c, avctx);
+    ff_mpegvideoencdsp_init_mips(c, bitexact);
 #endif
 }
diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h
index 46b40cf30e..08dd758494 100644
--- a/libavcodec/mpegvideoencdsp.h
+++ b/libavcodec/mpegvideoencdsp.h
@@ -21,8 +21,6 @@
 
 #include <stdint.h>
 
-#include "avcodec.h"
-
 #define BASIS_SHIFT 16
 #define RECON_SHIFT 6
 
@@ -38,15 +36,10 @@ typedef struct MpegvideoEncDSPContext {
                       int src_wrap, int width, int height);
 } MpegvideoEncDSPContext;
 
-void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
-                             AVCodecContext *avctx);
-void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c,
-                                 AVCodecContext *avctx);
-void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c,
-                                 AVCodecContext *avctx);
-void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
-                                 AVCodecContext *avctx);
-void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c,
-                                  AVCodecContext *avctx);
+void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, int bitexact);
+void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c, int bitexact);
+void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, int bitexact);
+void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, int bitexact);
+void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c, int bitexact);
 
 #endif /* AVCODEC_MPEGVIDEOENCDSP_H */
diff --git a/libavcodec/ppc/mpegvideoencdsp.c b/libavcodec/ppc/mpegvideoencdsp.c
index 07d3e76ee0..1ec35196f1 100644
--- a/libavcodec/ppc/mpegvideoencdsp.c
+++ b/libavcodec/ppc/mpegvideoencdsp.c
@@ -149,7 +149,7 @@ static int pix_sum_altivec(const uint8_t *pix, int line_size)
 #endif /* HAVE_ALTIVEC */
 
 av_cold void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c,
-                                         AVCodecContext *avctx)
+                                         int bitexact)
 {
 #if HAVE_ALTIVEC
     if (!PPC_ALTIVEC(av_get_cpu_flags()))
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index d71ad07b86..3232803dae 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -591,7 +591,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
 
     ff_hpeldsp_init(&s->hdsp, avctx->flags);
     ff_me_cmp_init(&s->mecc, avctx);
-    ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx);
+    ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
 
     s->current_picture = av_frame_alloc();
     s->last_picture    = av_frame_alloc();
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c
index c816ca2ee7..5b4be0e7bc 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -19,7 +19,6 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/x86/cpu.h"
-#include "libavcodec/avcodec.h"
 #include "libavcodec/mpegvideoencdsp.h"
 
 int ff_pix_sum16_sse2(const uint8_t *pix, int line_size);
@@ -95,8 +94,7 @@ int ff_pix_norm1_sse2(const uint8_t *pix, int line_size);
 #endif /* HAVE_SSSE3_INLINE */
 #endif /* HAVE_INLINE_ASM */
 
-av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
-                                         AVCodecContext *avctx)
+av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, int bitexact)
 {
     int cpu_flags = av_get_cpu_flags();
 
@@ -112,24 +110,21 @@ av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
 #if HAVE_INLINE_ASM
 
     if (INLINE_MMX(cpu_flags)) {
-        if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
+        if (!bitexact)
             c->try_8x8basis = try_8x8basis_mmx;
-        }
         c->add_8x8basis = add_8x8basis_mmx;
     }
 
     if (INLINE_AMD3DNOW(cpu_flags)) {
-        if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
+        if (!bitexact)
             c->try_8x8basis = try_8x8basis_3dnow;
-        }
         c->add_8x8basis = add_8x8basis_3dnow;
     }
 
 #if HAVE_SSSE3_INLINE
     if (INLINE_SSSE3(cpu_flags)) {
-        if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
+        if (!bitexact)
             c->try_8x8basis = try_8x8basis_ssse3;
-        }
         c->add_8x8basis = add_8x8basis_ssse3;
     }
 #endif /* HAVE_SSSE3_INLINE */
-- 
2.40.1



More information about the ffmpeg-devel mailing list