Mercurial > audlegacy
annotate Plugins/Input/shorten/common.h @ 920:999d1af32ab4 trunk
[svn] Extra_stereo effect plugin ported by deitarion. Some last pointer-related touchups by nemo & me.
author | chainsaw |
---|---|
date | Sat, 08 Apr 2006 19:44:43 -0700 |
parents | 5da5c262b1ef |
children |
rev | line source |
---|---|
915
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
1 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
2 * @file common.h |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
3 * common internal api header. |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
4 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
5 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
6 #ifndef COMMON_H |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
7 #define COMMON_H |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
8 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
9 #ifdef HAVE_CONFIG_H |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
10 #include "config.h" |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
11 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
12 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
13 #define TUNECPU generic |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
14 #undef HAVE_MMX |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
15 #define __CPU__ 586 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
16 #define HAVE_BUILTIN_VECTOR 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
17 #define CONFIG_DECODERS 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
18 /*#define CONFIG_HAVE_DLOPEN 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
19 #define CONFIG_HAVE_DLFCN 1*/ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
20 /*#undef CONFIG_AUDIO_OSS*/ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
21 #define SIMPLE_IDCT 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
22 /*#undef CONFIG_FFSERVER*/ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
23 #define CONFIG_RISKY 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
24 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
25 #define ALT_BITSTREAM_READER |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
26 //#define LIBMPEG2_BITSTREAM_READER |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
27 //#define A32_BITSTREAM_READER |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
28 //#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
29 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
30 #ifndef M_PI |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
31 #define M_PI 3.14159265358979323846 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
32 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
33 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
34 #if 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
35 /* only include the following when compiling package */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
36 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
37 #include <stdlib.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
38 #include <stdio.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
39 #include <string.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
40 #include <ctype.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
41 #include <errno.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
42 #include <math.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
43 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
44 # ifndef ENODATA |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
45 # define ENODATA 61 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
46 # endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
47 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
48 #include <stddef.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
49 #ifndef offsetof |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
50 # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
51 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
52 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
53 #define AVOPTION_CODEC_BOOL(name, help, field) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
54 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_BOOL } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
55 #define AVOPTION_CODEC_DOUBLE(name, help, field, minv, maxv, defval) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
56 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_DOUBLE, minv, maxv, defval } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
57 #define AVOPTION_CODEC_FLAG(name, help, field, flag, defval) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
58 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_FLAG, flag, 0, defval } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
59 #define AVOPTION_CODEC_INT(name, help, field, minv, maxv, defval) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
60 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_INT, minv, maxv, defval } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
61 #define AVOPTION_CODEC_STRING(name, help, field, str, val) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
62 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_STRING, .defval = val, .defstr = str } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
63 #define AVOPTION_CODEC_RCOVERRIDE(name, help, field) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
64 { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_RCOVERRIDE, .defval = 0, .defstr = NULL } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
65 #define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
66 #define AVOPTION_END() AVOPTION_SUB(NULL) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
67 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
68 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
69 * AVOption. |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
70 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
71 typedef struct AVOption { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
72 /** options' name */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
73 const char *name; /* if name is NULL, it indicates a link to next */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
74 /** short English text help or const struct AVOption* subpointer */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
75 const char *help; // const struct AVOption* sub; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
76 /** offset to context structure where the parsed value should be stored */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
77 int offset; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
78 /** options' type */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
79 int type; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
80 #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
81 #define FF_OPT_TYPE_DOUBLE 2 ///< double |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
82 #define FF_OPT_TYPE_INT 3 ///< integer |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
83 #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
84 #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
85 //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
86 #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
87 #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
88 /** min value (min == max -> no limits) */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
89 double min; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
90 /** maximum value for double/int */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
91 double max; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
92 /** default boo [0,1]l/double/int value */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
93 double defval; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
94 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
95 * default string value (with optional semicolon delimited extra option-list |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
96 * i.e. option1;option2;option3 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
97 * defval might select other then first argument as default |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
98 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
99 const char *defstr; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
100 #define FF_OPT_MAX_DEPTH 10 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
101 } AVOption; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
102 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
103 #ifdef HAVE_MMX |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
104 extern const struct AVOption avoptions_common[3 + 5]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
105 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
106 extern const struct AVOption avoptions_common[3]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
107 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
108 extern const struct AVOption avoptions_workaround_bug[11]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
109 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
110 #endif /* HAVE_AV_CONFIG_H */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
111 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
112 /* Suppress restrict if it was not defined in config.h. */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
113 #ifndef restrict |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
114 # define restrict |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
115 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
116 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
117 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
118 # define always_inline __attribute__((always_inline)) inline |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
119 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
120 # define always_inline inline |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
121 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
122 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
123 #ifndef EMULATE_INTTYPES |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
124 # include <inttypes.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
125 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
126 typedef signed char int8_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
127 typedef signed short int16_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
128 typedef signed int int32_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
129 typedef unsigned char uint8_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
130 typedef unsigned short uint16_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
131 typedef unsigned int uint32_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
132 typedef signed long long int64_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
133 typedef unsigned long long uint64_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
134 #endif /* HAVE_INTTYPES_H */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
135 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
136 #ifndef INT64_MAX |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
137 #define INT64_MAX 9223372036854775807LL |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
138 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
139 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
140 #ifdef EMULATE_FAST_INT |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
141 /* note that we don't emulate 64bit ints */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
142 typedef signed char int_fast8_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
143 typedef signed int int_fast16_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
144 typedef signed int int_fast32_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
145 typedef unsigned char uint_fast8_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
146 typedef unsigned int uint_fast16_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
147 typedef unsigned int uint_fast32_t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
148 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
149 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
150 #if 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
151 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
152 #include <float.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
153 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
154 #endif /* HAVE_AV_CONFIG_H */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
155 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
156 /* CONFIG_OS2 end */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
157 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
158 /* unix */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
159 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
160 #ifndef int64_t_C |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
161 #define int64_t_C(c) (c ## LL) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
162 #define uint64_t_C(c) (c ## ULL) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
163 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
164 #if 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
165 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
166 # ifdef USE_FASTMEMCPY |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
167 # include "fastmemcpy.h" |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
168 # endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
169 # endif /* HAVE_AV_CONFIG_H */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
170 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
171 #endif /* !CONFIG_WIN32 && !CONFIG_OS2 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
172 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
173 #if 1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
174 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
175 # include "bswap.h" |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
176 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
177 # if defined(__MINGW32__) || defined(__CYGWIN__) || \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
178 defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
179 # define MANGLE(a) "_" #a |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
180 # else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
181 # define MANGLE(a) #a |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
182 # endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
183 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
184 /* debug stuff */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
185 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
186 # ifndef DEBUG |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
187 # define NDEBUG |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
188 # endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
189 # include <assert.h> |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
190 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
191 /* dprintf macros */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
192 # if defined(CONFIG_WIN32) && !defined(__MINGW32__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
193 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
194 inline void dprintf(const char* fmt,...) {} |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
195 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
196 # else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
197 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
198 # ifdef DEBUG |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
199 # define dprintf(fmt,...) printf(fmt, __VA_ARGS__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
200 # else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
201 # define dprintf(fmt,...) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
202 # endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
203 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
204 # endif /* !CONFIG_WIN32 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
205 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
206 # define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
207 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
208 //rounded divison & shift |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
209 #define RSHIFT(a,b) ((a) > 0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
210 /* assume b>0 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
211 #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
212 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
213 #ifndef ABS |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
214 #define ABS(a) ((a) >= 0 ? (a) : (-(a))) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
215 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
216 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
217 #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
218 #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
219 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
220 extern const uint32_t inverse[256]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
221 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
222 #ifdef ARCH_X86 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
223 # define FASTDIV(a,b) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
224 ({\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
225 int ret,dmy;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
226 asm volatile(\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
227 "mull %3"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
228 :"=d"(ret),"=a"(dmy)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
229 :"1"(a),"g"(inverse[b])\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
230 );\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
231 ret;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
232 }) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
233 #elif defined(CONFIG_FASTDIV) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
234 # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*inverse[b])>>32)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
235 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
236 # define FASTDIV(a,b) ((a)/(b)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
237 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
238 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
239 #ifdef ARCH_X86 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
240 // avoid +32 for shift optimization (gcc should do that ...) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
241 static inline int32_t NEG_SSR32( int32_t a, int8_t s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
242 asm ("sarl %1, %0\n\t" |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
243 : "+r" (a) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
244 : "ic" ((uint8_t)(-s)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
245 ); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
246 return a; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
247 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
248 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
249 asm ("shrl %1, %0\n\t" |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
250 : "+r" (a) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
251 : "ic" ((uint8_t)(-s)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
252 ); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
253 return a; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
254 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
255 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
256 # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
257 # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
258 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
259 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
260 /* bit output */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
261 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
262 struct PutBitContext; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
263 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
264 typedef void (*WriteDataFunc)(void *, uint8_t *, int); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
265 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
266 typedef struct PutBitContext { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
267 uint32_t bit_buf; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
268 int bit_left; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
269 uint8_t *buf, *buf_ptr, *buf_end; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
270 } PutBitContext; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
271 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
272 void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
273 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
274 // XXX XXX XXX |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
275 #if 0 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
276 int get_bit_count(PutBitContext *s); /* XXX: change function name */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
277 void align_put_bits(PutBitContext *s); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
278 void flush_put_bits(PutBitContext *s); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
279 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
280 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
281 /* bit input */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
282 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
283 typedef struct GetBitContext { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
284 const uint8_t *buffer, *buffer_end; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
285 int index; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
286 int size_in_bits; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
287 } GetBitContext; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
288 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
289 static inline int get_bits_count(GetBitContext *s); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
290 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
291 #define VLC_TYPE int16_t |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
292 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
293 typedef struct VLC { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
294 int bits; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
295 VLC_TYPE (*table)[2]; ///< code, bits |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
296 int table_size, table_allocated; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
297 } VLC; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
298 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
299 typedef struct RL_VLC_ELEM { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
300 int16_t level; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
301 int8_t len; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
302 uint8_t run; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
303 } RL_VLC_ELEM; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
304 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
305 #ifdef ARCH_SPARC64 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
306 #define UNALIGNED_STORES_ARE_BAD |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
307 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
308 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
309 /* used to avoid missaligned exceptions on some archs (alpha, ...) */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
310 #ifdef ARCH_X86 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
311 # define unaligned32(a) (*(uint32_t*)(a)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
312 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
313 # ifdef __GNUC__ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
314 static inline uint32_t unaligned32(const void *v) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
315 struct Unaligned { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
316 uint32_t i; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
317 } __attribute__((packed)); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
318 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
319 return ((const struct Unaligned *) v)->i; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
320 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
321 # elif defined(__DECC) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
322 static inline uint32_t unaligned32(const void *v) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
323 return *(const __unaligned uint32_t *) v; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
324 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
325 # else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
326 static inline uint32_t unaligned32(const void *v) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
327 return *(const uint32_t *) v; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
328 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
329 # endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
330 #endif //!ARCH_X86 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
331 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
332 static inline void put_bits(PutBitContext *s, int n, unsigned int value) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
333 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
334 unsigned int bit_buf; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
335 int bit_left; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
336 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
337 #ifdef STATS |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
338 st_out_bit_counts[st_current_index] += n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
339 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
340 // printf("put_bits=%d %x\n", n, value); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
341 assert(n == 32 || value < (1U << n)); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
342 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
343 bit_buf = s->bit_buf; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
344 bit_left = s->bit_left; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
345 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
346 // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
347 /* XXX: optimize */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
348 if (n < bit_left) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
349 bit_buf = (bit_buf<<n) | value; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
350 bit_left-=n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
351 } else { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
352 bit_buf<<=bit_left; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
353 bit_buf |= value >> (n - bit_left); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
354 #ifdef UNALIGNED_STORES_ARE_BAD |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
355 if (3 & (int) s->buf_ptr) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
356 s->buf_ptr[0] = bit_buf >> 24; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
357 s->buf_ptr[1] = bit_buf >> 16; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
358 s->buf_ptr[2] = bit_buf >> 8; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
359 s->buf_ptr[3] = bit_buf ; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
360 } else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
361 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
362 *(uint32_t *)s->buf_ptr = be2me_32(bit_buf); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
363 //printf("bitbuf = %08x\n", bit_buf); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
364 s->buf_ptr+=4; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
365 bit_left+=32 - n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
366 bit_buf = value; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
367 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
368 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
369 s->bit_buf = bit_buf; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
370 s->bit_left = bit_left; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
371 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
372 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
373 static inline uint8_t* pbBufPtr(PutBitContext *s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
374 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
375 return s->buf_ptr; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
376 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
377 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
378 /* Bitstream reader API docs: |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
379 name |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
380 abritary name which is used as prefix for the internal variables |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
381 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
382 gb |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
383 getbitcontext |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
384 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
385 OPEN_READER(name, gb) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
386 loads gb into local variables |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
387 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
388 CLOSE_READER(name, gb) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
389 stores local vars in gb |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
390 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
391 UPDATE_CACHE(name, gb) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
392 refills the internal cache from the bitstream |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
393 after this call at least MIN_CACHE_BITS will be available, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
394 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
395 GET_CACHE(name, gb) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
396 will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
397 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
398 SHOW_UBITS(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
399 will return the nest num bits |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
400 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
401 SHOW_SBITS(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
402 will return the nest num bits and do sign extension |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
403 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
404 SKIP_BITS(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
405 will skip over the next num bits |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
406 note, this is equinvalent to SKIP_CACHE; SKIP_COUNTER |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
407 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
408 SKIP_CACHE(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
409 will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
410 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
411 SKIP_COUNTER(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
412 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
413 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
414 LAST_SKIP_CACHE(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
415 will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
416 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
417 LAST_SKIP_BITS(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
418 is equinvalent to SKIP_LAST_CACHE; SKIP_COUNTER |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
419 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
420 for examples see get_bits, show_bits, skip_bits, get_vlc |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
421 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
422 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
423 static inline int unaligned32_be(const void *v) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
424 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
425 #ifdef CONFIG_ALIGN |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
426 const uint8_t *p=v; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
427 return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
428 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
429 return be2me_32( unaligned32(v)); //original |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
430 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
431 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
432 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
433 # define MIN_CACHE_BITS 25 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
434 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
435 # define OPEN_READER(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
436 int name##_index= (gb)->index;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
437 int name##_cache= 0;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
438 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
439 # define CLOSE_READER(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
440 (gb)->index= name##_index;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
441 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
442 # define UPDATE_CACHE(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
443 name##_cache= unaligned32_be( ((uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
444 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
445 # define SKIP_CACHE(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
446 name##_cache <<= (num);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
447 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
448 // FIXME name? |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
449 # define SKIP_COUNTER(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
450 name##_index += (num);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
451 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
452 # define SKIP_BITS(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
453 {\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
454 SKIP_CACHE(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
455 SKIP_COUNTER(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
456 }\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
457 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
458 # define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
459 # define LAST_SKIP_CACHE(name, gb, num) ; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
460 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
461 # define SHOW_UBITS(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
462 NEG_USR32(name##_cache, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
463 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
464 # define SHOW_SBITS(name, gb, num)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
465 NEG_SSR32(name##_cache, num) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
466 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
467 # define GET_CACHE(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
468 ((uint32_t)name##_cache) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
469 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
470 static inline int get_bits_count(GetBitContext *s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
471 return s->index; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
472 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
473 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
474 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
475 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
476 * if MSB not set it is negative |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
477 * @param n length in bits |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
478 * @author BERO |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
479 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
480 static inline int get_xbits(GetBitContext *s, int n){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
481 register int tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
482 register int32_t cache; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
483 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
484 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
485 cache = GET_CACHE(re,s); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
486 if ((int32_t)cache<0) { //MSB=1 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
487 tmp = NEG_USR32(cache,n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
488 } else { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
489 // tmp = (-1<<n) | NEG_USR32(cache,n) + 1; mpeg12.c algo |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
490 // tmp = - (NEG_USR32(cache,n) ^ ((1 << n) - 1)); h263.c algo |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
491 tmp = - NEG_USR32(~cache,n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
492 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
493 LAST_SKIP_BITS(re, s, n) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
494 CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
495 return tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
496 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
497 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
498 static inline int get_sbits(GetBitContext *s, int n){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
499 register int tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
500 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
501 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
502 tmp= SHOW_SBITS(re, s, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
503 LAST_SKIP_BITS(re, s, n) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
504 CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
505 return tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
506 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
507 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
508 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
509 * reads 0-17 bits. |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
510 * Note, the alt bitstream reader can read upto 25 bits, but the libmpeg2 reader cant |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
511 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
512 static inline unsigned int get_bits(GetBitContext *s, int n){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
513 register int tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
514 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
515 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
516 tmp= SHOW_UBITS(re, s, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
517 LAST_SKIP_BITS(re, s, n) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
518 CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
519 return tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
520 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
521 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
522 unsigned int get_bits_long(GetBitContext *s, int n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
523 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
524 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
525 * shows 0-17 bits. |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
526 * Note, the alt bitstream reader can read upto 25 bits, but the libmpeg2 reader cant |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
527 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
528 static inline unsigned int show_bits(GetBitContext *s, int n){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
529 register int tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
530 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
531 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
532 tmp= SHOW_UBITS(re, s, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
533 // CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
534 return tmp; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
535 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
536 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
537 unsigned int show_bits_long(GetBitContext *s, int n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
538 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
539 static inline void skip_bits(GetBitContext *s, int n){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
540 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
541 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
542 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
543 LAST_SKIP_BITS(re, s, n) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
544 CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
545 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
546 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
547 static inline unsigned int get_bits1(GetBitContext *s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
548 #ifdef ALT_BITSTREAM_READER |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
549 int index= s->index; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
550 uint8_t result= s->buffer[ index>>3 ]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
551 result<<= (index&0x07); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
552 result>>= 8 - 1; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
553 index++; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
554 s->index= index; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
555 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
556 return result; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
557 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
558 return get_bits(s, 1); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
559 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
560 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
561 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
562 static inline unsigned int show_bits1(GetBitContext *s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
563 return show_bits(s, 1); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
564 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
565 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
566 static inline void skip_bits1(GetBitContext *s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
567 skip_bits(s, 1); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
568 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
569 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
570 void init_get_bits(GetBitContext *s, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
571 const uint8_t *buffer, int buffer_size); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
572 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
573 int check_marker(GetBitContext *s, const char *msg); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
574 void align_get_bits(GetBitContext *s); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
575 int init_vlc(VLC *vlc, int nb_bits, int nb_codes, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
576 const void *bits, int bits_wrap, int bits_size, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
577 const void *codes, int codes_wrap, int codes_size); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
578 void free_vlc(VLC *vlc); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
579 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
580 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
581 * |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
582 * if the vlc code is invalid and max_depth=1 than no bits will be removed |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
583 * if the vlc code is invalid and max_depth>1 than the number of bits removed |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
584 * is undefined |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
585 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
586 #define GET_VLC(code, name, gb, table, bits, max_depth)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
587 {\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
588 int n, index, nb_bits;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
589 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
590 index= SHOW_UBITS(name, gb, bits);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
591 code = table[index][0];\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
592 n = table[index][1];\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
593 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
594 if(max_depth > 1 && n < 0){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
595 LAST_SKIP_BITS(name, gb, bits)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
596 UPDATE_CACHE(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
597 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
598 nb_bits = -n;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
599 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
600 index= SHOW_UBITS(name, gb, nb_bits) + code;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
601 code = table[index][0];\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
602 n = table[index][1];\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
603 if(max_depth > 2 && n < 0){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
604 LAST_SKIP_BITS(name, gb, nb_bits)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
605 UPDATE_CACHE(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
606 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
607 nb_bits = -n;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
608 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
609 index= SHOW_UBITS(name, gb, nb_bits) + code;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
610 code = table[index][0];\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
611 n = table[index][1];\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
612 }\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
613 }\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
614 SKIP_BITS(name, gb, n)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
615 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
616 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
617 #define GET_RL_VLC(level, run, name, gb, table, bits, max_depth)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
618 {\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
619 int n, index, nb_bits;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
620 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
621 index= SHOW_UBITS(name, gb, bits);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
622 level = table[index].level;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
623 n = table[index].len;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
624 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
625 if(max_depth > 1 && n < 0){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
626 LAST_SKIP_BITS(name, gb, bits)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
627 UPDATE_CACHE(name, gb)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
628 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
629 nb_bits = -n;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
630 \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
631 index= SHOW_UBITS(name, gb, nb_bits) + level;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
632 level = table[index].level;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
633 n = table[index].len;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
634 }\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
635 run= table[index].run;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
636 SKIP_BITS(name, gb, n)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
637 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
638 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
639 // deprecated, dont use get_vlc for new code, use get_vlc2 instead or use GET_VLC directly |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
640 static inline int get_vlc(GetBitContext *s, VLC *vlc) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
641 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
642 int code; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
643 VLC_TYPE (*table)[2]= vlc->table; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
644 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
645 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
646 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
647 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
648 GET_VLC(code, re, s, table, vlc->bits, 3) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
649 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
650 CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
651 return code; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
652 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
653 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
654 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
655 * parses a vlc code, faster then get_vlc() |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
656 * @param bits is the number of bits which will be read at once, must be |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
657 * identical to nb_bits in init_vlc() |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
658 * @param max_depth is the number of times bits bits must be readed to completly |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
659 * read the longest vlc code |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
660 * = (max_vlc_length + bits - 1) / bits |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
661 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
662 static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
663 int bits, int max_depth) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
664 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
665 int code; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
666 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
667 OPEN_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
668 UPDATE_CACHE(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
669 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
670 GET_VLC(code, re, s, table, bits, max_depth) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
671 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
672 CLOSE_READER(re, s) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
673 return code; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
674 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
675 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
676 //#define TRACE |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
677 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
678 #ifdef TRACE |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
679 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
680 static inline void print_bin(int bits, int n){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
681 int i; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
682 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
683 for(i=n-1; i>=0; i--){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
684 printf("%d", (bits>>i)&1); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
685 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
686 for(i=n; i<24; i++) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
687 printf(" "); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
688 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
689 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
690 static inline int get_bits_trace(GetBitContext *s, int n, char *file, char *func, int line){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
691 int r= get_bits(s, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
692 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
693 print_bin(r, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
694 printf("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
695 return r; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
696 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
697 static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, char *func, int line){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
698 int show= show_bits(s, 24); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
699 int pos= get_bits_count(s); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
700 int r= get_vlc2(s, table, bits, max_depth); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
701 int len= get_bits_count(s) - pos; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
702 int bits2= show>>(24-len); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
703 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
704 print_bin(bits2, len); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
705 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
706 printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
707 return r; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
708 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
709 static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *func, int line){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
710 int show= show_bits(s, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
711 int r= get_xbits(s, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
712 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
713 print_bin(show, n); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
714 printf("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
715 return r; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
716 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
717 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
718 #define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
719 #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
720 #define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
721 #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
722 #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
723 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
724 #define tprintf printf |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
725 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
726 #else //TRACE |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
727 #define tprintf(_arg...) {} |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
728 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
729 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
730 /* define it to include statistics code (useful only for optimizing |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
731 codec efficiency */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
732 //#define STATS |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
733 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
734 #ifdef STATS |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
735 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
736 enum { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
737 ST_UNKNOWN, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
738 ST_DC, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
739 ST_INTRA_AC, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
740 ST_INTER_AC, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
741 ST_INTRA_MB, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
742 ST_INTER_MB, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
743 ST_MV, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
744 ST_NB, |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
745 }; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
746 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
747 extern int st_current_index; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
748 extern unsigned int st_bit_counts[ST_NB]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
749 extern unsigned int st_out_bit_counts[ST_NB]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
750 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
751 void print_stats(void); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
752 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
753 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
754 /* misc math functions */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
755 extern const uint8_t ff_log2_tab[256]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
756 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
757 static inline int av_log2(unsigned int v) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
758 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
759 int n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
760 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
761 n = 0; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
762 if (v & 0xffff0000) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
763 v >>= 16; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
764 n += 16; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
765 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
766 if (v & 0xff00) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
767 v >>= 8; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
768 n += 8; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
769 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
770 n += ff_log2_tab[v]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
771 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
772 return n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
773 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
774 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
775 static inline int av_log2_16bit(unsigned int v) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
776 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
777 int n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
778 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
779 n = 0; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
780 if (v & 0xff00) { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
781 v >>= 8; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
782 n += 8; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
783 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
784 n += ff_log2_tab[v]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
785 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
786 return n; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
787 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
788 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
789 /* median of 3 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
790 static inline int mid_pred(int a, int b, int c) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
791 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
792 #if 0 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
793 int t= (a-b)&((a-b)>>31); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
794 a-=t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
795 b+=t; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
796 b-= (b-c)&((b-c)>>31); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
797 b+= (a-b)&((a-b)>>31); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
798 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
799 return b; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
800 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
801 if(a>b){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
802 if(c>b){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
803 if(c>a) b=a; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
804 else b=c; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
805 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
806 }else{ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
807 if(b>c){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
808 if(c>a) b=c; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
809 else b=a; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
810 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
811 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
812 return b; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
813 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
814 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
815 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
816 static inline int clip(int a, int amin, int amax) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
817 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
818 if (a < amin) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
819 return amin; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
820 else if (a > amax) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
821 return amax; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
822 else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
823 return a; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
824 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
825 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
826 /* math */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
827 extern const uint8_t ff_sqrt_tab[128]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
828 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
829 int64_t ff_gcd(int64_t a, int64_t b); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
830 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
831 static inline int ff_sqrt(int a) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
832 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
833 int ret=0; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
834 int s; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
835 int ret_sq=0; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
836 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
837 if(a<128) return ff_sqrt_tab[a]; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
838 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
839 for(s=15; s>=0; s--){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
840 int b= ret_sq + (1<<(s*2)) + (ret<<s)*2; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
841 if(b<=a){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
842 ret_sq=b; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
843 ret+= 1<<s; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
844 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
845 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
846 return ret; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
847 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
848 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
849 /** |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
850 * converts fourcc string to int |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
851 */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
852 static inline int ff_get_fourcc(const char *s){ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
853 assert( strlen(s)==4 ); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
854 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
855 return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
856 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
857 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
858 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
859 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
860 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
861 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
862 #ifdef ARCH_X86 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
863 #define MASK_ABS(mask, level)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
864 asm volatile(\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
865 "cdq \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
866 "xorl %1, %0 \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
867 "subl %1, %0 \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
868 : "+a" (level), "=&d" (mask)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
869 ); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
870 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
871 #define MASK_ABS(mask, level)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
872 mask= level>>31;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
873 level= (level^mask)-mask; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
874 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
875 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
876 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
877 #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
878 #define COPY3_IF_LT(x,y,a,b,c,d)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
879 asm volatile (\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
880 "cmpl %0, %3 \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
881 "cmovl %3, %0 \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
882 "cmovl %4, %1 \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
883 "cmovl %5, %2 \n\t"\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
884 : "+r" (x), "+r" (a), "+r" (c)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
885 : "r" (y), "r" (b), "r" (d)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
886 ); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
887 #else |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
888 #define COPY3_IF_LT(x,y,a,b,c,d)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
889 if((y)<(x)){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
890 (x)=(y);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
891 (a)=(b);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
892 (c)=(d);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
893 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
894 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
895 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
896 #ifdef ARCH_X86 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
897 static inline long long rdtsc() |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
898 { |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
899 long long l; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
900 asm volatile( "rdtsc\n\t" |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
901 : "=A" (l) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
902 ); |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
903 return l; |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
904 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
905 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
906 #define START_TIMER \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
907 static uint64_t tsum=0;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
908 static int tcount=0;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
909 static int tskip_count=0;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
910 uint64_t tend;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
911 uint64_t tstart= rdtsc();\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
912 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
913 #define STOP_TIMER(id) \ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
914 tend= rdtsc();\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
915 if(tcount<2 || tend - tstart < 4*tsum/tcount){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
916 tsum+= tend - tstart;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
917 tcount++;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
918 }else\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
919 tskip_count++;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
920 if(256*256*256*64%(tcount+tskip_count)==0){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
921 fprintf(stderr, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
922 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
923 #endif |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
924 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
925 #define CLAMP_TO_8BIT(d) ((d > 0xff) ? 0xff : (d < 0) ? 0 : d) |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
926 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
927 #define CHECKED_ALLOCZ(p, size)\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
928 {\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
929 p= av_mallocz(size);\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
930 if(p==NULL && (size)!=0){\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
931 perror("malloc");\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
932 goto fail;\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
933 }\ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
934 } |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
935 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
936 #endif /* HAVE_AV_CONFIG_H */ |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
937 |
5da5c262b1ef
[svn] - input proposed shorten input plugin for hacking
nenolod
parents:
diff
changeset
|
938 #endif /* COMMON_H */ |