History

Move avutil tables only used in libavcodec to libavcodec.

Diego Biurrun committed 14 years ago

Commit 9734b8b1 parent 0a75d1d14 files · +70 −85Browse files

Unified · Split

14 files
  1. libavcodec/Makefile +1 −6
  2. libavcodec/arm/mathops.h +24 −0
  3. libavcodec/inverse.c +0 −1
  4. libavcodec/mathops.h +29 −0
  5. libavcodec/mathtables.c +11 −3
  6. libavcodec/motion_est.c +1 −1
  7. libavcodec/mpegvideo.c +1 −1
  8. libavcodec/mpegvideo_enc.c +1 −0
  9. libavcodec/ra144.c +1 −1
  10. libavcodec/roqaudioenc.c +1 −1
  11. libavutil/Makefile +0 −1
  12. libavutil/arm/intmath.h +0 −24
  13. libavutil/intmath.h +0 −35
  14. libavutil/mathematics.c +0 −11
libavcodec/Makefile+1−6
@@ -22,6 +22,7 @@ OBJS = allcodecs.o \ · 21 unmodified lines
2222 fmtconvert.o \
2323 imgconvert.o \
2424 jrevdct.o \
25+ mathtables.o \
2526 options.o \
2627 parser.o \
2728 raw.o \
@@ -655,12 +656,6 @@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o · 627 unmodified lines
655656 OBJS-$(HAVE_PTHREADS) += pthread.o
656657 OBJS-$(HAVE_W32THREADS) += pthread.o
657658
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−
664659 SKIPHEADERS += %_tablegen.h \
665660 %_tables.h \
666661 aac_tablegen_decl.h \
libavcodec/arm/mathops.h+24−0
@@ -36,6 +36,30 @@ static inline av_const int MULH(int a, int b) · 35 unmodified lines
3636 __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
3737 return r;
3838 }
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+}
3963 #endif
4064
4165 #define MLS64(d, a, b) MAC64(d, -(a), b)
libavcodec/inverse.c+0−1
@@ -1 +0,0 @@
1−#include "libavutil/inverse.c"
libavcodec/mathops.h+29−0
@@ -22,9 +22,14 @@ · 21 unmodified lines
2222 #ifndef AVCODEC_MATHOPS_H
2323 #define AVCODEC_MATHOPS_H
2424
25+#include <stdint.h>
26+
2527 #include "libavutil/common.h"
2628 #include "config.h"
2729
30+extern const uint32_t ff_inverse[257];
31+extern const uint8_t ff_sqrt_tab[256];
32+
2833 #if ARCH_ARM
2934 # include "arm/mathops.h"
3035 #elif ARCH_AVR32
@@ -185,4 +190,28 @@ if ((y) < (x)) {\ · 154 unmodified lines
185190 # define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff)
186191 #endif
187192
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+
188217 #endif /* AVCODEC_MATHOPS_H */
libavcodec/mathtables.crenamed from libavutil/inverse.c+11−3
@@ -1,7 +1,4 @@
11 /*
2− * Inverse table
3− * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4− *
52 * This file is part of Libav.
63 *
74 * Libav is free software; you can redistribute it and/or
@@ -58,3 +55,14 @@ const uint32_t ff_inverse[257]={ · 50 unmodified lines
5855 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
5956 16777216
6057 };
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+};
libavcodec/motion_est.c+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include <stdlib.h>
3131 #include <stdio.h>
3232 #include <limits.h>
33−#include "libavutil/intmath.h"
33+
3434 #include "avcodec.h"
3535 #include "dsputil.h"
3636 #include "mathops.h"
libavcodec/mpegvideo.c+1−1
@@ -27,11 +27,11 @@ · 26 unmodified lines
2727 * The simplest mpeg encoder (well, it was the simplest!).
2828 */
2929
30−#include "libavutil/intmath.h"
3130 #include "libavutil/imgutils.h"
3231 #include "avcodec.h"
3332 #include "dsputil.h"
3433 #include "internal.h"
34+#include "mathops.h"
3535 #include "mpegvideo.h"
3636 #include "mjpegenc.h"
3737 #include "msmpeg4.h"
libavcodec/mpegvideo_enc.c+1−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "dsputil.h"
3535 #include "mpegvideo.h"
3636 #include "h263.h"
37+#include "mathops.h"
3738 #include "mjpegenc.h"
3839 #include "msmpeg4.h"
3940 #include "faandct.h"
libavcodec/ra144.c+1−1
@@ -22,8 +22,8 @@ · 21 unmodified lines
2222 #include <stdint.h>
2323 #include "avcodec.h"
2424 #include "celp_filters.h"
25+#include "mathops.h"
2526 #include "ra144.h"
26−#include "libavutil/common.h"
2727
2828 const int16_t ff_gain_val_tab[256][3] = {
2929 { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668},
libavcodec/roqaudioenc.c+1−1
@@ -21,10 +21,10 @@ · 20 unmodified lines
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2222 */
2323
24−#include "libavutil/intmath.h"
2524 #include "avcodec.h"
2625 #include "bytestream.h"
2726 #include "internal.h"
27+#include "mathops.h"
2828
2929 #define ROQ_FRAME_SIZE 735
3030 #define ROQ_HEADER_SIZE 8
libavutil/Makefile+0−1
@@ -66,7 +66,6 @@ OBJS = adler32.o \ · 65 unmodified lines
6666 float_dsp.o \
6767 imgutils.o \
6868 intfloat_readwrite.o \
69− inverse.o \
7069 lfg.o \
7170 lls.o \
7271 log.o \
libavutil/arm/intmath.h+0−24
@@ -30,19 +30,6 @@ · 29 unmodified lines
3030
3131 #if HAVE_ARMV6
3232
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−
4633 #define av_clip_uint8 av_clip_uint8_arm
4734 static av_always_inline av_const unsigned av_clip_uint8_arm(int a)
4835 {
@@ -99,17 +86,6 @@ static av_always_inline int av_sat_dadd32_arm(int a, int b) · 50 unmodified lines
9986 return r;
10087 }
10188
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−
11389 #endif /* HAVE_ARMV6 */
11490
11591 #if HAVE_ASM_MOD_Q
libavutil/intmath.h+0−35
@@ -21,7 +21,6 @@ · 20 unmodified lines
2121 #ifndef AVUTIL_INTMATH_H
2222 #define AVUTIL_INTMATH_H
2323
24−#include <stdint.h>
2524 #include "config.h"
2625 #include "attributes.h"
2726
@@ -30,12 +29,6 @@ · 2 unmodified lines
3029 * @{
3130 */
3231
33−extern const uint32_t ff_inverse[257];
34−
35−#if ARCH_ARM
36−# include "arm/intmath.h"
37−#endif
38−
3932 #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
4033
4134 #ifndef av_log2
@@ -47,34 +40,6 @@ extern const uint32_t ff_inverse[257]; · 5 unmodified lines
4740
4841 #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
4942
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−
7843 /**
7944 * @}
8045 */
libavutil/mathematics.c+0−11
@@ -28,17 +28,6 @@ · 27 unmodified lines
2828 #include <limits.h>
2929 #include "mathematics.h"
3030
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−
4231 const uint8_t ff_log2_tab[256]={
4332 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,
4433 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,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t