From 86c909558ce3e7505d5a63647c27cd0a4314a603 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 17 Mar 2022 12:16:38 +0100 Subject: [PATCH] avcodec/internal: Move FF_SIGNBIT and ff_log2_run to mathops.h It is a more fitting place for them. Also move the definition of ff_log2_run to mathtables.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/aptx.c | 2 +- libavcodec/bitstream.c | 9 --------- libavcodec/cavs.c | 4 ---- libavcodec/cavsdec.c | 1 + libavcodec/dnxhdenc.c | 2 +- libavcodec/ffv1dec.c | 1 - libavcodec/ffv1enc.c | 1 - libavcodec/internal.h | 4 ---- libavcodec/jpeglsdec.c | 2 -- libavcodec/jpeglsenc.c | 1 - libavcodec/mathops.h | 3 +++ libavcodec/mathtables.c | 9 +++++++++ 12 files changed, 15 insertions(+), 24 deletions(-) diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c index b1a78c5f77..f2604be60c 100644 --- a/libavcodec/aptx.c +++ b/libavcodec/aptx.c @@ -21,7 +21,7 @@ */ #include "aptx.h" -#include "internal.h" +#include "mathops.h" static const int32_t quantize_intervals_LF[65] = { diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 36a980646d..3606575055 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -36,15 +36,6 @@ #include "libavutil/intreadwrite.h" #include "put_bits.h" -const uint8_t ff_log2_run[41]={ - 0, 0, 0, 0, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, - 8, 9,10,11,12,13,14,15, -16,17,18,19,20,21,22,23, -24, -}; - void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) { while (*string) { diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index 5367c44248..87bbe26f98 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -25,14 +25,10 @@ * @author Stefan Gehrer */ -#include "libavutil/mem_internal.h" - #include "avcodec.h" -#include "get_bits.h" #include "golomb.h" #include "h264chroma.h" #include "idctdsp.h" -#include "internal.h" #include "mathops.h" #include "qpeldsp.h" #include "cavs.h" diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index ba7ead6f41..760dd792cb 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -32,6 +32,7 @@ #include "cavs.h" #include "codec_internal.h" #include "internal.h" +#include "mathops.h" #include "mpeg12data.h" #include "startcode.h" diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 6d4d7e01c7..1795993efe 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -33,7 +33,7 @@ #include "codec_internal.h" #include "encode.h" #include "fdctdsp.h" -#include "internal.h" +#include "mathops.h" #include "mpegvideo.h" #include "mpegvideoenc.h" #include "pixblockdsp.h" diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index a5aae79c94..d1f69ae6e1 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -32,7 +32,6 @@ #include "libavutil/pixdesc.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" #include "get_bits.h" #include "rangecoder.h" #include "golomb.h" diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index edaa8b4b3d..13af2547a0 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -35,7 +35,6 @@ #include "avcodec.h" #include "encode.h" #include "codec_internal.h" -#include "internal.h" #include "put_bits.h" #include "put_golomb.h" #include "rangecoder.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 854c969395..351c057d01 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -44,8 +44,6 @@ #define FF_SANE_NB_CHANNELS 512U -#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1) - #if HAVE_SIMD_ALIGN_64 # define STRIDE_ALIGN 64 /* AVX-512 */ #elif HAVE_SIMD_ALIGN_32 @@ -159,8 +157,6 @@ typedef struct AVCodecInternal { AVChannelLayout initial_ch_layout; } AVCodecInternal; -extern const uint8_t ff_log2_run[41]; - /** * Return the index into tab at which {a,b} match elements {[0],[1]} of tab. * If there is no such matching pair then size is returned. diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index c3d0a1c9a7..4c747b3919 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -29,9 +29,7 @@ #include "codec_internal.h" #include "get_bits.h" #include "golomb.h" -#include "internal.h" #include "mathops.h" -#include "mjpeg.h" #include "mjpegdec.h" #include "jpegls.h" #include "jpeglsdec.h" diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 42c2d6b038..dbd7941df2 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -34,7 +34,6 @@ #include "get_bits.h" #include "put_bits.h" #include "put_golomb.h" -#include "internal.h" #include "mathops.h" #include "mjpeg.h" #include "jpegls.h" diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 239e0e492f..f81d21f9c4 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -30,6 +30,7 @@ #define MAX_NEG_CROP 1024 extern const uint32_t ff_inverse[257]; +extern const uint8_t ff_log2_run[41]; extern const uint8_t ff_sqrt_tab[256]; extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP]; extern const uint8_t ff_zigzag_direct[64]; @@ -125,6 +126,8 @@ static inline av_const int median4(int a, int b, int c, int d) } #endif +#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1) + #ifndef sign_extend static inline av_const int sign_extend(int val, unsigned bits) { diff --git a/libavcodec/mathtables.c b/libavcodec/mathtables.c index 81eabc7a65..8b0031eb00 100644 --- a/libavcodec/mathtables.c +++ b/libavcodec/mathtables.c @@ -112,3 +112,12 @@ const uint8_t ff_zigzag_scan[16+1] = { 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, }; + +const uint8_t ff_log2_run[41] = { + 0, 0, 0, 0, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, + 8, 9, 10, 11, 12, 13, 14, 15, +16, 17, 18, 19, 20, 21, 22, 23, +24, +};