Unified · Split
| @@ -22,6 +22,7 @@ OBJS = allcodecs.o \ · 21 unmodified lines | ||
| 22 | 22 | fmtconvert.o \ |
| 23 | 23 | imgconvert.o \ |
| 24 | 24 | jrevdct.o \ |
| 25 | + mathtables.o \ | |
| 25 | 26 | options.o \ |
| 26 | 27 | parser.o \ |
| 27 | 28 | raw.o \ |
| @@ -655,12 +656,6 @@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o · 627 unmodified lines | ||
| 655 | 656 | OBJS-$(HAVE_PTHREADS) += pthread.o |
| 656 | 657 | OBJS-$(HAVE_W32THREADS) += pthread.o |
| 657 | 658 | |
| 658 | −# inverse.o contains the ff_inverse table definition, which is used by | |
| 659 | −# the FASTDIV macro (from libavutil); since referencing the external | |
| 660 | −# table has a negative effect on performance, copy it in libavcodec as | |
| 661 | −# well. | |
| 662 | −OBJS-$(!CONFIG_SMALL) += inverse.o | |
| 663 | − | |
| 664 | 659 | SKIPHEADERS += %_tablegen.h \ |
| 665 | 660 | %_tables.h \ |
| 666 | 661 | aac_tablegen_decl.h \ |
| @@ -36,6 +36,30 @@ static inline av_const int MULH(int a, int b) · 35 unmodified lines | ||
| 36 | 36 | __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b)); |
| 37 | 37 | return r; |
| 38 | 38 | } |
| 39 | + | |
| 40 | +#define FASTDIV FASTDIV | |
| 41 | +static av_always_inline av_const int FASTDIV(int a, int b) | |
| 42 | +{ | |
| 43 | + int r; | |
| 44 | + __asm__ ("cmp %2, #2 \n\t" | |
| 45 | + "ldr %0, [%3, %2, lsl #2] \n\t" | |
| 46 | + "ite le \n\t" | |
| 47 | + "lsrle %0, %1, #1 \n\t" | |
| 48 | + "smmulgt %0, %0, %1 \n\t" | |
| 49 | + : "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc"); | |
| 50 | + return r; | |
| 51 | +} | |
| 52 | + | |
| 53 | +#else /* HAVE_ARMV6 */ | |
| 54 | + | |
| 55 | +#define FASTDIV FASTDIV | |
| 56 | +static av_always_inline av_const int FASTDIV(int a, int b) | |
| 57 | +{ | |
| 58 | + int r, t; | |
| 59 | + __asm__ ("umull %1, %0, %2, %3" | |
| 60 | + : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); | |
| 61 | + return r; | |
| 62 | +} | |
| 39 | 63 | #endif |
| 40 | 64 | |
| 41 | 65 | #define MLS64(d, a, b) MAC64(d, -(a), b) |
| @@ -1 +0,0 @@ | ||
| 1 | −#include "libavutil/inverse.c" | |
| @@ -22,9 +22,14 @@ · 21 unmodified lines | ||
| 22 | 22 | #ifndef AVCODEC_MATHOPS_H |
| 23 | 23 | #define AVCODEC_MATHOPS_H |
| 24 | 24 | |
| 25 | +#include <stdint.h> | |
| 26 | + | |
| 25 | 27 | #include "libavutil/common.h" |
| 26 | 28 | #include "config.h" |
| 27 | 29 | |
| 30 | +extern const uint32_t ff_inverse[257]; | |
| 31 | +extern const uint8_t ff_sqrt_tab[256]; | |
| 32 | + | |
| 28 | 33 | #if ARCH_ARM |
| 29 | 34 | # include "arm/mathops.h" |
| 30 | 35 | #elif ARCH_AVR32 |
| @@ -185,4 +190,28 @@ if ((y) < (x)) {\ · 154 unmodified lines | ||
| 185 | 190 | # define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff) |
| 186 | 191 | #endif |
| 187 | 192 | |
| 193 | +#ifndef FASTDIV | |
| 194 | +# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) | |
| 195 | +#endif /* FASTDIV */ | |
| 196 | + | |
| 197 | +static inline av_const unsigned int ff_sqrt(unsigned int a) | |
| 198 | +{ | |
| 199 | + unsigned int b; | |
| 200 | + | |
| 201 | + if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4; | |
| 202 | + else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2; | |
| 203 | +#if !CONFIG_SMALL | |
| 204 | + else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1; | |
| 205 | + else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ; | |
| 206 | +#endif | |
| 207 | + else { | |
| 208 | + int s = av_log2_16bit(a >> 16) >> 1; | |
| 209 | + unsigned int c = a >> (s + 2); | |
| 210 | + b = ff_sqrt_tab[c >> (s + 8)]; | |
| 211 | + b = FASTDIV(c,b) + (b << s); | |
| 212 | + } | |
| 213 | + | |
| 214 | + return b - (a < b * b); | |
| 215 | +} | |
| 216 | + | |
| 188 | 217 | #endif /* AVCODEC_MATHOPS_H */ |
| @@ -1,7 +1,4 @@ | ||
| 1 | 1 | /* |
| 2 | − * Inverse table | |
| 3 | − * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
| 4 | − * | |
| 5 | 2 | * This file is part of Libav. |
| 6 | 3 | * |
| 7 | 4 | * Libav is free software; you can redistribute it and/or |
| @@ -58,3 +55,14 @@ const uint32_t ff_inverse[257]={ · 50 unmodified lines | ||
| 58 | 55 | 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010, |
| 59 | 56 | 16777216 |
| 60 | 57 | }; |
| 58 | + | |
| 59 | +const uint8_t ff_sqrt_tab[256]={ | |
| 60 | + 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, | |
| 61 | + 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127, | |
| 62 | +128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156, | |
| 63 | +157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181, | |
| 64 | +182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202, | |
| 65 | +203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222, | |
| 66 | +222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239, | |
| 67 | +240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255 | |
| 68 | +}; | |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include <stdlib.h> |
| 31 | 31 | #include <stdio.h> |
| 32 | 32 | #include <limits.h> |
| 33 | −#include "libavutil/intmath.h" | |
| 33 | + | |
| 34 | 34 | #include "avcodec.h" |
| 35 | 35 | #include "dsputil.h" |
| 36 | 36 | #include "mathops.h" |
| @@ -27,11 +27,11 @@ · 26 unmodified lines | ||
| 27 | 27 | * The simplest mpeg encoder (well, it was the simplest!). |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | −#include "libavutil/intmath.h" | |
| 31 | 30 | #include "libavutil/imgutils.h" |
| 32 | 31 | #include "avcodec.h" |
| 33 | 32 | #include "dsputil.h" |
| 34 | 33 | #include "internal.h" |
| 34 | +#include "mathops.h" | |
| 35 | 35 | #include "mpegvideo.h" |
| 36 | 36 | #include "mjpegenc.h" |
| 37 | 37 | #include "msmpeg4.h" |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "dsputil.h" |
| 35 | 35 | #include "mpegvideo.h" |
| 36 | 36 | #include "h263.h" |
| 37 | +#include "mathops.h" | |
| 37 | 38 | #include "mjpegenc.h" |
| 38 | 39 | #include "msmpeg4.h" |
| 39 | 40 | #include "faandct.h" |
| @@ -22,8 +22,8 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <stdint.h> |
| 23 | 23 | #include "avcodec.h" |
| 24 | 24 | #include "celp_filters.h" |
| 25 | +#include "mathops.h" | |
| 25 | 26 | #include "ra144.h" |
| 26 | −#include "libavutil/common.h" | |
| 27 | 27 | |
| 28 | 28 | const int16_t ff_gain_val_tab[256][3] = { |
| 29 | 29 | { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668}, |
| @@ -21,10 +21,10 @@ · 20 unmodified lines | ||
| 21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | −#include "libavutil/intmath.h" | |
| 25 | 24 | #include "avcodec.h" |
| 26 | 25 | #include "bytestream.h" |
| 27 | 26 | #include "internal.h" |
| 27 | +#include "mathops.h" | |
| 28 | 28 | |
| 29 | 29 | #define ROQ_FRAME_SIZE 735 |
| 30 | 30 | #define ROQ_HEADER_SIZE 8 |
| @@ -66,7 +66,6 @@ OBJS = adler32.o \ · 65 unmodified lines | ||
| 66 | 66 | float_dsp.o \ |
| 67 | 67 | imgutils.o \ |
| 68 | 68 | intfloat_readwrite.o \ |
| 69 | − inverse.o \ | |
| 70 | 69 | lfg.o \ |
| 71 | 70 | lls.o \ |
| 72 | 71 | log.o \ |
| @@ -30,19 +30,6 @@ · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | #if HAVE_ARMV6 |
| 32 | 32 | |
| 33 | −#define FASTDIV FASTDIV | |
| 34 | −static av_always_inline av_const int FASTDIV(int a, int b) | |
| 35 | −{ | |
| 36 | − int r; | |
| 37 | − __asm__ ("cmp %2, #2 \n\t" | |
| 38 | − "ldr %0, [%3, %2, lsl #2] \n\t" | |
| 39 | − "ite le \n\t" | |
| 40 | − "lsrle %0, %1, #1 \n\t" | |
| 41 | − "smmulgt %0, %0, %1 \n\t" | |
| 42 | − : "=&r"(r) : "r"(a), "r"(b), "r"(ff_inverse) : "cc"); | |
| 43 | − return r; | |
| 44 | −} | |
| 45 | − | |
| 46 | 33 | #define av_clip_uint8 av_clip_uint8_arm |
| 47 | 34 | static av_always_inline av_const unsigned av_clip_uint8_arm(int a) |
| 48 | 35 | { |
| @@ -99,17 +86,6 @@ static av_always_inline int av_sat_dadd32_arm(int a, int b) · 50 unmodified lines | ||
| 99 | 86 | return r; |
| 100 | 87 | } |
| 101 | 88 | |
| 102 | −#else /* HAVE_ARMV6 */ | |
| 103 | − | |
| 104 | −#define FASTDIV FASTDIV | |
| 105 | −static av_always_inline av_const int FASTDIV(int a, int b) | |
| 106 | −{ | |
| 107 | − int r, t; | |
| 108 | − __asm__ ("umull %1, %0, %2, %3" | |
| 109 | − : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); | |
| 110 | − return r; | |
| 111 | −} | |
| 112 | − | |
| 113 | 89 | #endif /* HAVE_ARMV6 */ |
| 114 | 90 | |
| 115 | 91 | #if HAVE_ASM_MOD_Q |
| @@ -21,7 +21,6 @@ · 20 unmodified lines | ||
| 21 | 21 | #ifndef AVUTIL_INTMATH_H |
| 22 | 22 | #define AVUTIL_INTMATH_H |
| 23 | 23 | |
| 24 | −#include <stdint.h> | |
| 25 | 24 | #include "config.h" |
| 26 | 25 | #include "attributes.h" |
| 27 | 26 | |
| @@ -30,12 +29,6 @@ · 2 unmodified lines | ||
| 30 | 29 | * @{ |
| 31 | 30 | */ |
| 32 | 31 | |
| 33 | −extern const uint32_t ff_inverse[257]; | |
| 34 | − | |
| 35 | −#if ARCH_ARM | |
| 36 | −# include "arm/intmath.h" | |
| 37 | −#endif | |
| 38 | − | |
| 39 | 32 | #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4) |
| 40 | 33 | |
| 41 | 34 | #ifndef av_log2 |
| @@ -47,34 +40,6 @@ extern const uint32_t ff_inverse[257]; · 5 unmodified lines | ||
| 47 | 40 | |
| 48 | 41 | #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */ |
| 49 | 42 | |
| 50 | −#ifndef FASTDIV | |
| 51 | −# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) | |
| 52 | −#endif /* FASTDIV */ | |
| 53 | − | |
| 54 | −#include "common.h" | |
| 55 | − | |
| 56 | −extern const uint8_t ff_sqrt_tab[256]; | |
| 57 | − | |
| 58 | −static inline av_const unsigned int ff_sqrt(unsigned int a) | |
| 59 | −{ | |
| 60 | − unsigned int b; | |
| 61 | − | |
| 62 | − if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4; | |
| 63 | − else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2; | |
| 64 | −#if !CONFIG_SMALL | |
| 65 | − else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1; | |
| 66 | − else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ; | |
| 67 | −#endif | |
| 68 | − else { | |
| 69 | − int s = av_log2_16bit(a >> 16) >> 1; | |
| 70 | − unsigned int c = a >> (s + 2); | |
| 71 | − b = ff_sqrt_tab[c >> (s + 8)]; | |
| 72 | − b = FASTDIV(c,b) + (b << s); | |
| 73 | − } | |
| 74 | − | |
| 75 | − return b - (a < b * b); | |
| 76 | −} | |
| 77 | − | |
| 78 | 43 | /** |
| 79 | 44 | * @} |
| 80 | 45 | */ |
| @@ -28,17 +28,6 @@ · 27 unmodified lines | ||
| 28 | 28 | #include <limits.h> |
| 29 | 29 | #include "mathematics.h" |
| 30 | 30 | |
| 31 | −const uint8_t ff_sqrt_tab[256]={ | |
| 32 | − 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, | |
| 33 | − 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127, | |
| 34 | −128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156, | |
| 35 | −157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181, | |
| 36 | −182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202, | |
| 37 | −203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222, | |
| 38 | −222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239, | |
| 39 | −240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255 | |
| 40 | −}; | |
| 41 | − | |
| 42 | 31 | const uint8_t ff_log2_tab[256]={ |
| 43 | 32 | 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, |
| 44 | 33 | 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, |