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
22 fmtconvert.o \22 fmtconvert.o \
23 imgconvert.o \23 imgconvert.o \
24 jrevdct.o \24 jrevdct.o \
25 mathtables.o \
25 options.o \26 options.o \
26 parser.o \27 parser.o \
27 raw.o \28 raw.o \
@@ -655,12 +656,6 @@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o · 627 unmodified lines
655OBJS-$(HAVE_PTHREADS) += pthread.o656OBJS-$(HAVE_PTHREADS) += pthread.o
656OBJS-$(HAVE_W32THREADS) += pthread.o657OBJS-$(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.
662OBJS-$(!CONFIG_SMALL) += inverse.o
663
664SKIPHEADERS += %_tablegen.h \659SKIPHEADERS += %_tablegen.h \
665 %_tables.h \660 %_tables.h \
666 aac_tablegen_decl.h \661 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
36 __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));36 __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
37 return r;37 return r;
38}38}
39
40#define FASTDIV FASTDIV
41static 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
56static 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#endif63#endif
40 64
41#define MLS64(d, a, b) MAC64(d, -(a), b)65#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
22#ifndef AVCODEC_MATHOPS_H22#ifndef AVCODEC_MATHOPS_H
23#define AVCODEC_MATHOPS_H23#define AVCODEC_MATHOPS_H
24 24
25#include <stdint.h>
26
25#include "libavutil/common.h"27#include "libavutil/common.h"
26#include "config.h"28#include "config.h"
27 29
30extern const uint32_t ff_inverse[257];
31extern const uint8_t ff_sqrt_tab[256];
32
28#if ARCH_ARM33#if ARCH_ARM
29# include "arm/mathops.h"34# include "arm/mathops.h"
30#elif ARCH_AVR3235#elif ARCH_AVR32
@@ -185,4 +190,28 @@ if ((y) < (x)) {\ · 154 unmodified lines
185# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff)190# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff)
186#endif191#endif
187 192
193#ifndef FASTDIV
194# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
195#endif /* FASTDIV */
196
197static 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#endif /* AVCODEC_MATHOPS_H */217#endif /* AVCODEC_MATHOPS_H */
libavcodec/mathtables.crenamed from libavutil/inverse.c+11−3
@@ -1,7 +1,4 @@
1/*1/*
2 * Inverse table
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * This file is part of Libav.2 * This file is part of Libav.
6 *3 *
7 * Libav is free software; you can redistribute it and/or4 * Libav is free software; you can redistribute it and/or
@@ -58,3 +55,14 @@ const uint32_t ff_inverse[257]={ · 50 unmodified lines
58 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,55 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
59 1677721656 16777216
60};57};
58
59const 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,
62128,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,
63157,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,
64182,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,
65203,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,
66222,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,
67240,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
30#include <stdlib.h>30#include <stdlib.h>
31#include <stdio.h>31#include <stdio.h>
32#include <limits.h>32#include <limits.h>
33#include "libavutil/intmath.h"33
34#include "avcodec.h"34#include "avcodec.h"
35#include "dsputil.h"35#include "dsputil.h"
36#include "mathops.h"36#include "mathops.h"
libavcodec/mpegvideo.c+1−1
@@ -27,11 +27,11 @@ · 26 unmodified lines
27 * The simplest mpeg encoder (well, it was the simplest!).27 * The simplest mpeg encoder (well, it was the simplest!).
28 */28 */
29 29
30#include "libavutil/intmath.h"
31#include "libavutil/imgutils.h"30#include "libavutil/imgutils.h"
32#include "avcodec.h"31#include "avcodec.h"
33#include "dsputil.h"32#include "dsputil.h"
34#include "internal.h"33#include "internal.h"
34#include "mathops.h"
35#include "mpegvideo.h"35#include "mpegvideo.h"
36#include "mjpegenc.h"36#include "mjpegenc.h"
37#include "msmpeg4.h"37#include "msmpeg4.h"
libavcodec/mpegvideo_enc.c+1−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
34#include "dsputil.h"34#include "dsputil.h"
35#include "mpegvideo.h"35#include "mpegvideo.h"
36#include "h263.h"36#include "h263.h"
37#include "mathops.h"
37#include "mjpegenc.h"38#include "mjpegenc.h"
38#include "msmpeg4.h"39#include "msmpeg4.h"
39#include "faandct.h"40#include "faandct.h"
libavcodec/ra144.c+1−1
@@ -22,8 +22,8 @@ · 21 unmodified lines
22#include <stdint.h>22#include <stdint.h>
23#include "avcodec.h"23#include "avcodec.h"
24#include "celp_filters.h"24#include "celp_filters.h"
25#include "mathops.h"
25#include "ra144.h"26#include "ra144.h"
26#include "libavutil/common.h"
27 27
28const int16_t ff_gain_val_tab[256][3] = {28const int16_t ff_gain_val_tab[256][3] = {
29 { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668},29 { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668},
libavcodec/roqaudioenc.c+1−1
@@ -21,10 +21,10 @@ · 20 unmodified lines
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */22 */
23 23
24#include "libavutil/intmath.h"
25#include "avcodec.h"24#include "avcodec.h"
26#include "bytestream.h"25#include "bytestream.h"
27#include "internal.h"26#include "internal.h"
27#include "mathops.h"
28 28
29#define ROQ_FRAME_SIZE 73529#define ROQ_FRAME_SIZE 735
30#define ROQ_HEADER_SIZE 830#define ROQ_HEADER_SIZE 8
libavutil/Makefile+0−1
@@ -66,7 +66,6 @@ OBJS = adler32.o \ · 65 unmodified lines
66 float_dsp.o \66 float_dsp.o \
67 imgutils.o \67 imgutils.o \
68 intfloat_readwrite.o \68 intfloat_readwrite.o \
69 inverse.o \
70 lfg.o \69 lfg.o \
71 lls.o \70 lls.o \
72 log.o \71 log.o \
libavutil/arm/intmath.h+0−24
@@ -30,19 +30,6 @@ · 29 unmodified lines
30 30
31#if HAVE_ARMV631#if HAVE_ARMV6
32 32
33#define FASTDIV FASTDIV
34static 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#define av_clip_uint8 av_clip_uint8_arm33#define av_clip_uint8 av_clip_uint8_arm
47static av_always_inline av_const unsigned av_clip_uint8_arm(int a)34static 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 return r;86 return r;
100}87}
101 88
102#else /* HAVE_ARMV6 */
103
104#define FASTDIV FASTDIV
105static 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#endif /* HAVE_ARMV6 */89#endif /* HAVE_ARMV6 */
114 90
115#if HAVE_ASM_MOD_Q91#if HAVE_ASM_MOD_Q
libavutil/intmath.h+0−35
@@ -21,7 +21,6 @@ · 20 unmodified lines
21#ifndef AVUTIL_INTMATH_H21#ifndef AVUTIL_INTMATH_H
22#define AVUTIL_INTMATH_H22#define AVUTIL_INTMATH_H
23 23
24#include <stdint.h>
25#include "config.h"24#include "config.h"
26#include "attributes.h"25#include "attributes.h"
27 26
@@ -30,12 +29,6 @@ · 2 unmodified lines
30 * @{29 * @{
31 */30 */
32 31
33extern const uint32_t ff_inverse[257];
34
35#if ARCH_ARM
36# include "arm/intmath.h"
37#endif
38
39#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)32#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
40 33
41#ifndef av_log234#ifndef av_log2
@@ -47,34 +40,6 @@ extern const uint32_t ff_inverse[257]; · 5 unmodified lines
47 40
48#endif /* AV_GCC_VERSION_AT_LEAST(3,4) */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
56extern const uint8_t ff_sqrt_tab[256];
57
58static 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 */
libavutil/mathematics.c+0−11
@@ -28,17 +28,6 @@ · 27 unmodified lines
28#include <limits.h>28#include <limits.h>
29#include "mathematics.h"29#include "mathematics.h"
30 30
31const 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,
34128,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,
35157,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,
36182,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,
37203,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,
38222,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,
39240,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
42const uint8_t ff_log2_tab[256]={31const uint8_t ff_log2_tab[256]={
43 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,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 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,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,

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