Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
rv30: return AVERROR(EINVAL) instead of EINVAL
build: add -L flags before existing LDFLAGS
simple_idct: whitespace cosmetics
simple_idct: make repeated code a macro
dsputil: remove huge #if 0 block
simple_idct: change 10-bit add/put stride from pixels to bytes
dsputil: allow 9/10-bit functions for non-h264 codecs
dnxhd: rename some data tables
dnxhdenc: remove inline from function only called through pointer
dnxhdenc: whitespace cosmetics
swscale: mark YUV422P10(LE,BE) as supported for output
configure: add -xc99 to LDFLAGS for Sun CC
Remove unused and non-compiling vestigial g729 decoder
Remove unused code under G729_BITEXACT #ifdef.
mpegvideo: fix invalid picture unreferencing.
dsputil: Remove extra blank line at end.
dsputil: Replace a LONG_MAX check with HAVE_FAST_64BIT.
simple_idct: add 10-bit version

Conflicts:
Makefile
libavcodec/g729data.h
libavcodec/g729dec.c
libavcodec/rv30.c
tests/ref/lavfi/pixdesc
tests/ref/lavfi/pixfmts_copy
tests/ref/lavfi/pixfmts_null
tests/ref/lavfi/pixfmts_scale
tests/ref/lavfi/pixfmts_vflip

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/07/21 23:27:55
Showing 32 changed files
... ...
@@ -27,8 +27,6 @@ ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
27 27
 ALLPROGS_G  = $(BASENAMES:%=%_g$(EXESUF))
28 28
 ALLMANPAGES = $(BASENAMES:%=%.1)
29 29
 
30
-ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
31
-
32 30
 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
33 31
 FFLIBS-$(CONFIG_AVFILTER) += avfilter
34 32
 FFLIBS-$(CONFIG_AVFORMAT) += avformat
... ...
@@ -20,6 +20,8 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
20 20
 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
21 21
 endif
22 22
 
23
+ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
24
+
23 25
 # NASM requires -I path terminated with /
24 26
 IFLAGS     := -I. -I$(SRC_PATH)/
25 27
 CPPFLAGS   := $(IFLAGS) $(CPPFLAGS)
... ...
@@ -27,7 +29,7 @@ CFLAGS     += $(ECFLAGS)
27 27
 CCFLAGS     = $(CFLAGS)
28 28
 YASMFLAGS  += $(IFLAGS) -Pconfig.asm
29 29
 HOSTCFLAGS += $(IFLAGS)
30
-LDFLAGS    += $(ALLFFLIBS:%=-Llib%)
30
+LDFLAGS    := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS)
31 31
 
32 32
 define COMPILE
33 33
        $($(1)DEP)
... ...
@@ -2049,6 +2049,7 @@ elif $cc -V 2>&1 | grep -q Sun; then
2049 2049
     cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
2050 2050
     DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2051 2051
     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
2052
+    add_ldflags -xc99
2052 2053
     speed_cflags='-O5'
2053 2054
     size_cflags='-O5 -xspace'
2054 2055
     filter_cflags=suncc_flags
... ...
@@ -105,20 +105,9 @@ int16_t ff_acelp_decode_gain_code(
105 105
     for(i=0; i<ma_pred_order; i++)
106 106
         mr_energy += quant_energy[i] * ma_prediction_coeff[i];
107 107
 
108
-#ifdef G729_BITEXACT
109
-    mr_energy += (((-6165LL * ff_log2(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0))) >> 3) & ~0x3ff);
110
-
111
-    mr_energy = (5439 * (mr_energy >> 15)) >> 8;           // (0.15) = (0.15) * (7.23)
112
-
113
-    return bidir_sal(
114
-               ((ff_exp2(mr_energy & 0x7fff) + 16) >> 5) * (gain_corr_factor >> 1),
115
-               (mr_energy >> 15) - 25
116
-           );
117
-#else
118 108
     mr_energy = gain_corr_factor * exp(M_LN10 / (20 << 23) * mr_energy) /
119 109
                 sqrt(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0));
120 110
     return mr_energy >> 12;
121
-#endif
122 111
 }
123 112
 
124 113
 float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
... ...
@@ -48,26 +48,6 @@ const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
48 48
   28, 26,
49 49
 };
50 50
 
51
-const uint8_t ff_fc_2pulses_9bits_track2_gray[32] =
52
-{
53
-  0,  2,
54
-  5,  4,
55
-  12, 10,
56
-  7,  9,
57
-  25, 24,
58
-  20, 22,
59
-  14, 15,
60
-  19, 17,
61
-  36, 31,
62
-  21, 26,
63
-  1,  6,
64
-  16, 11,
65
-  27, 29,
66
-  32, 30,
67
-  39, 37,
68
-  34, 35,
69
-};
70
-
71 51
 const uint8_t ff_fc_4pulses_8bits_tracks_13[16] =
72 52
 {
73 53
   0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
... ...
@@ -82,37 +82,6 @@ extern const uint8_t ff_fc_2pulses_9bits_track1[16];
82 82
 extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16];
83 83
 
84 84
 /**
85
- * Track|Pulse|        Positions
86
- * -----------------------------------------
87
- *  2   | 1   | 0, 7, 14, 20, 27, 34,  1, 21
88
- *      |     | 2, 9, 15, 22, 29, 35,  6, 26
89
- *      |     | 4,10, 17, 24, 30, 37, 11, 31
90
- *      |     | 5,12, 19, 25, 32, 39, 16, 36
91
- * -----------------------------------------
92
- *
93
- * @remark Track in the table should be read top-to-bottom, left-to-right.
94
- *
95
- * @note (EE.1) This table (from the reference code) does not comply with
96
- *              the specification.
97
- *              The specification contains the following table:
98
- *
99
- * Track|Pulse|        Positions
100
- * -----------------------------------------
101
- *  2   | 1   | 0, 5, 10, 15, 20, 25, 30, 35
102
- *      |     | 1, 6, 11, 16, 21, 26, 31, 36
103
- *      |     | 2, 7, 12, 17, 22, 27, 32, 37
104
- *      |     | 4, 9, 14, 19, 24, 29, 34, 39
105
- *
106
- * -----------------------------------------
107
- *
108
- * @note (EE.2) Reference G.729D code also uses gray decoding for each
109
- *              pulse index before looking up the value in the table.
110
- *
111
- * Used in G.729 @@6.4k (with gray coding)
112
- */
113
-extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32];
114
-
115
-/**
116 85
  * b60 hamming windowed sinc function coefficients
117 86
  */
118 87
 extern const float ff_b60_sinc[61];
... ...
@@ -335,7 +335,7 @@ void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
335 335
     put_pixels_clamped_axp_p = c->put_pixels_clamped;
336 336
     add_pixels_clamped_axp_p = c->add_pixels_clamped;
337 337
 
338
-    if (!avctx->lowres &&
338
+    if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
339 339
         (avctx->idct_algo == FF_IDCT_AUTO ||
340 340
          avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) {
341 341
         c->idct_put = ff_simple_idct_put_axp;
... ...
@@ -83,7 +83,7 @@
83 83
 /** Maximum sharpening factor
84 84
  *
85 85
  * The specification says 0.8, which should be 13107, but the reference C code
86
- * uses 13017 instead. (Amusingly the same applies to SHARP_MAX in g729dec.c.)
86
+ * uses 13017 instead. (Amusingly the same applies to SHARP_MAX in bitexact G.729.)
87 87
  */
88 88
 #define SHARP_MAX 0.79449462890625
89 89
 
... ...
@@ -80,7 +80,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
80 80
     ff_put_pixels_clamped = c->put_pixels_clamped;
81 81
     ff_add_pixels_clamped = c->add_pixels_clamped;
82 82
 
83
-    if (!avctx->lowres) {
83
+    if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) {
84 84
         if(avctx->idct_algo == FF_IDCT_AUTO ||
85 85
            avctx->idct_algo == FF_IDCT_ARM){
86 86
             c->idct_put              = j_rev_dct_arm_put;
... ...
@@ -29,8 +29,9 @@ void ff_prefetch_arm(void *mem, int stride, int h);
29 29
 
30 30
 void av_cold ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx)
31 31
 {
32
-    if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
33
-                           avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {
32
+    if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
33
+        (avctx->idct_algo == FF_IDCT_AUTO ||
34
+         avctx->idct_algo == FF_IDCT_SIMPLEARMV5TE)) {
34 35
         c->idct_put              = ff_simple_idct_put_armv5te;
35 36
         c->idct_add              = ff_simple_idct_add_armv5te;
36 37
         c->idct                  = ff_simple_idct_armv5te;
... ...
@@ -74,8 +74,9 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
74 74
 {
75 75
     const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
76 76
 
77
-    if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
78
-                           avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
77
+    if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
78
+        (avctx->idct_algo == FF_IDCT_AUTO ||
79
+         avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
79 80
         c->idct_put              = ff_simple_idct_put_armv6;
80 81
         c->idct_add              = ff_simple_idct_add_armv6;
81 82
         c->idct                  = ff_simple_idct_armv6;
... ...
@@ -177,7 +177,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
177 177
 {
178 178
     const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
179 179
 
180
-    if (!avctx->lowres) {
180
+    if (!avctx->lowres && avctx->bits_per_raw_sample <= 8) {
181 181
         if (avctx->idct_algo == FF_IDCT_AUTO ||
182 182
             avctx->idct_algo == FF_IDCT_SIMPLENEON) {
183 183
             c->idct_put              = ff_simple_idct_put_neon;
... ...
@@ -256,16 +256,18 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
256 256
     if (avctx->dct_algo == FF_DCT_AUTO)
257 257
         c->fdct               = ff_bfin_fdct;
258 258
 
259
-    if (avctx->idct_algo==FF_IDCT_VP3) {
260
-        c->idct_permutation_type = FF_NO_IDCT_PERM;
261
-        c->idct               = ff_bfin_vp3_idct;
262
-        c->idct_add           = ff_bfin_vp3_idct_add;
263
-        c->idct_put           = ff_bfin_vp3_idct_put;
264
-    } else if (avctx->idct_algo == FF_IDCT_AUTO) {
265
-        c->idct_permutation_type = FF_NO_IDCT_PERM;
266
-        c->idct               = ff_bfin_idct;
267
-        c->idct_add           = bfin_idct_add;
268
-        c->idct_put           = bfin_idct_put;
259
+    if (avctx->bits_per_raw_sample <= 8) {
260
+        if (avctx->idct_algo == FF_IDCT_VP3) {
261
+            c->idct_permutation_type = FF_NO_IDCT_PERM;
262
+            c->idct                  = ff_bfin_vp3_idct;
263
+            c->idct_add              = ff_bfin_vp3_idct_add;
264
+            c->idct_put              = ff_bfin_vp3_idct_put;
265
+        } else if (avctx->idct_algo == FF_IDCT_AUTO) {
266
+            c->idct_permutation_type = FF_NO_IDCT_PERM;
267
+            c->idct                  = ff_bfin_idct;
268
+            c->idct_add              = bfin_idct_add;
269
+            c->idct_put              = bfin_idct_put;
270
+        }
269 271
     }
270 272
 }
271 273
 
... ...
@@ -27,82 +27,6 @@
27 27
 #include "avcodec.h"
28 28
 #include "celp_math.h"
29 29
 
30
-#ifdef G729_BITEXACT
31
-/**
32
- * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
33
- */
34
-static const int16_t base_cos[64] =
35
-{
36
-  32767,  32729,  32610,  32413,  32138,  31786,  31357,  30853,
37
-  30274,  29622,  28899,  28106,  27246,  26320,  25330,  24279,
38
-  23170,  22006,  20788,  19520,  18205,  16846,  15447,  14010,
39
-  12540,  11039,   9512,   7962,   6393,   4808,   3212,   1608,
40
-      0,  -1608,  -3212,  -4808,  -6393,  -7962,  -9512, -11039,
41
- -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006,
42
- -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622,
43
- -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729
44
-};
45
-
46
-/**
47
- * Slope used to compute cos(x)
48
- *
49
- * cos(ind*64+offset) = base_cos[ind]+offset*slope_cos[ind]
50
- * values multiplied by 1<<19
51
- */
52
-static const int16_t slope_cos[64] =
53
-{
54
-   -632,  -1893,  -3150,  -4399,  -5638,  -6863,  -8072,  -9261,
55
- -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744,
56
- -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526,
57
- -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726,
58
- -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009,
59
- -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637,
60
- -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428,
61
-  -9261,  -8072,  -6863,  -5638,  -4399,  -3150,  -1893,   -632
62
-};
63
-
64
-/**
65
- * Table used to compute exp2(x)
66
- *
67
- * tab_exp2[i] = (1<<14) * exp2(i/32) = 2^(i/32) i=0..32
68
- */
69
-static const uint16_t tab_exp2[33] =
70
-{
71
-  16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911,
72
-  20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726,
73
-  25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706,
74
-  31379, 32066, 32767
75
-};
76
-
77
-int16_t ff_cos(uint16_t arg)
78
-{
79
-    uint8_t offset= arg;
80
-    uint8_t ind = arg >> 8;
81
-
82
-    assert(arg < 0x4000);
83
-
84
-    return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000);
85
-}
86
-
87
-int ff_exp2(uint16_t power)
88
-{
89
-    uint16_t frac_x0;
90
-    uint16_t frac_dx;
91
-    int result;
92
-
93
-    assert(power <= 0x7fff);
94
-
95
-    frac_x0 = power >> 10;
96
-    frac_dx = (power & 0x03ff) << 5;
97
-
98
-    result = tab_exp2[frac_x0] << 15;
99
-    result += frac_dx * (tab_exp2[frac_x0+1] - tab_exp2[frac_x0]);
100
-
101
-    return result >> 10;
102
-}
103
-
104
-#else // G729_BITEXACT
105
-
106 30
 /**
107 31
  * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
108 32
  */
... ...
@@ -154,8 +78,6 @@ int ff_exp2(uint16_t power)
154 154
     return result + ((result*(power&31)*89)>>22);
155 155
 }
156 156
 
157
-#endif // else G729_BITEXACT
158
-
159 157
 /**
160 158
  * Table used to compute log2(x)
161 159
  *
... ...
@@ -163,17 +85,10 @@ int ff_exp2(uint16_t power)
163 163
  */
164 164
 static const uint16_t tab_log2[33] =
165 165
 {
166
-#ifdef G729_BITEXACT
167
-      0,   1455,   2866,   4236,   5568,   6863,   8124,   9352,
168
-  10549,  11716,  12855,  13967,  15054,  16117,  17156,  18172,
169
-  19167,  20142,  21097,  22033,  22951,  23852,  24735,  25603,
170
-  26455,  27291,  28113,  28922,  29716,  30497,  31266,  32023,  32767,
171
-#else
172 166
       4,   1459,   2870,   4240,   5572,   6867,   8127,   9355,
173 167
   10552,  11719,  12858,  13971,  15057,  16120,  17158,  18175,
174 168
   19170,  20145,  21100,  22036,  22954,  23854,  24738,  25605,
175 169
   26457,  27294,  28116,  28924,  29719,  30500,  31269,  32025,  32769,
176
-#endif
177 170
 };
178 171
 
179 172
 int ff_log2(uint32_t value)
... ...
@@ -111,7 +111,7 @@ static const struct algo idct_tab[] = {
111 111
     { "FAANI",          ff_faanidct,           NO_PERM  },
112 112
     { "REF-DBL",        ff_ref_idct,           NO_PERM  },
113 113
     { "INT",            j_rev_dct,             MMX_PERM },
114
-    { "SIMPLE-C",       ff_simple_idct,        NO_PERM  },
114
+    { "SIMPLE-C",       ff_simple_idct_8,      NO_PERM  },
115 115
 
116 116
 #if HAVE_MMX
117 117
 #if CONFIG_GPL
... ...
@@ -41,7 +41,7 @@ static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL
41 41
 
42 42
 #define LAMBDA_FRAC_BITS 10
43 43
 
44
-static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
44
+static void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
45 45
 {
46 46
     int i;
47 47
     for (i = 0; i < 4; i++) {
... ...
@@ -52,10 +52,10 @@ static av_always_inline void dnxhd_get_pixels_8x4(DCTELEM *restrict block, const
52 52
         pixels += line_size;
53 53
         block += 8;
54 54
     }
55
-    memcpy(block   , block- 8, sizeof(*block)*8);
56
-    memcpy(block+ 8, block-16, sizeof(*block)*8);
57
-    memcpy(block+16, block-24, sizeof(*block)*8);
58
-    memcpy(block+24, block-32, sizeof(*block)*8);
55
+    memcpy(block,      block -  8, sizeof(*block) * 8);
56
+    memcpy(block +  8, block - 16, sizeof(*block) * 8);
57
+    memcpy(block + 16, block - 24, sizeof(*block) * 8);
58
+    memcpy(block + 24, block - 32, sizeof(*block) * 8);
59 59
 }
60 60
 
61 61
 static int dnxhd_init_vlc(DNXHDEncContext *ctx)
... ...
@@ -64,9 +64,9 @@ static int dnxhd_init_vlc(DNXHDEncContext *ctx)
64 64
     int max_level = 1<<(ctx->cid_table->bit_depth+2);
65 65
 
66 66
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_codes, max_level*4*sizeof(*ctx->vlc_codes), fail);
67
-    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits , max_level*4*sizeof(*ctx->vlc_bits ), fail);
68
-    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2                               , fail);
69
-    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits , 63                                 , fail);
67
+    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->vlc_bits,  max_level*4*sizeof(*ctx->vlc_bits) , fail);
68
+    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_codes, 63*2,                                fail);
69
+    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->run_bits,  63,                                  fail);
70 70
 
71 71
     ctx->vlc_codes += max_level*2;
72 72
     ctx->vlc_bits  += max_level*2;
... ...
@@ -119,8 +119,8 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
119 119
     uint16_t weight_matrix[64] = {1,}; // convert_matrix needs uint16_t*
120 120
     int qscale, i;
121 121
 
122
-    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l,   (ctx->m.avctx->qmax+1) * 64 *     sizeof(int)     , fail);
123
-    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c,   (ctx->m.avctx->qmax+1) * 64 *     sizeof(int)     , fail);
122
+    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l,   (ctx->m.avctx->qmax+1) * 64 *     sizeof(int),      fail);
123
+    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c,   (ctx->m.avctx->qmax+1) * 64 *     sizeof(int),      fail);
124 124
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_l16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail);
125 125
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->qmatrix_c16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t), fail);
126 126
 
... ...
@@ -218,7 +218,7 @@ static int dnxhd_encode_init(AVCodecContext *avctx)
218 218
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_size, ctx->m.mb_height*sizeof(uint32_t), fail);
219 219
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->slice_offs, ctx->m.mb_height*sizeof(uint32_t), fail);
220 220
     FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits,    ctx->m.mb_num   *sizeof(uint16_t), fail);
221
-    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale,  ctx->m.mb_num   *sizeof(uint8_t) , fail);
221
+    FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale,  ctx->m.mb_num   *sizeof(uint8_t),  fail);
222 222
 
223 223
     ctx->frame.key_frame = 1;
224 224
     ctx->frame.pict_type = AV_PICTURE_TYPE_I;
... ...
@@ -341,7 +341,7 @@ static av_always_inline int dnxhd_ssd_block(DCTELEM *qblock, DCTELEM *block)
341 341
     int score = 0;
342 342
     int i;
343 343
     for (i = 0; i < 64; i++)
344
-        score += (block[i]-qblock[i])*(block[i]-qblock[i]);
344
+        score += (block[i] - qblock[i]) * (block[i] - qblock[i]);
345 345
     return score;
346 346
 }
347 347
 
... ...
@@ -369,26 +369,28 @@ static av_always_inline void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, in
369 369
     const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << 3);
370 370
     DSPContext *dsp = &ctx->m.dsp;
371 371
 
372
-    dsp->get_pixels(ctx->blocks[0], ptr_y    , ctx->m.linesize);
372
+    dsp->get_pixels(ctx->blocks[0], ptr_y,     ctx->m.linesize);
373 373
     dsp->get_pixels(ctx->blocks[1], ptr_y + 8, ctx->m.linesize);
374
-    dsp->get_pixels(ctx->blocks[2], ptr_u    , ctx->m.uvlinesize);
375
-    dsp->get_pixels(ctx->blocks[3], ptr_v    , ctx->m.uvlinesize);
374
+    dsp->get_pixels(ctx->blocks[2], ptr_u,     ctx->m.uvlinesize);
375
+    dsp->get_pixels(ctx->blocks[3], ptr_v,     ctx->m.uvlinesize);
376 376
 
377 377
     if (mb_y+1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
378 378
         if (ctx->interlaced) {
379
-            ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset    , ctx->m.linesize);
379
+            ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + ctx->dct_y_offset,     ctx->m.linesize);
380 380
             ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize);
381
-            ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset   , ctx->m.uvlinesize);
382
-            ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset   , ctx->m.uvlinesize);
381
+            ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + ctx->dct_uv_offset,    ctx->m.uvlinesize);
382
+            ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + ctx->dct_uv_offset,    ctx->m.uvlinesize);
383 383
         } else {
384
-            dsp->clear_block(ctx->blocks[4]); dsp->clear_block(ctx->blocks[5]);
385
-            dsp->clear_block(ctx->blocks[6]); dsp->clear_block(ctx->blocks[7]);
384
+            dsp->clear_block(ctx->blocks[4]);
385
+            dsp->clear_block(ctx->blocks[5]);
386
+            dsp->clear_block(ctx->blocks[6]);
387
+            dsp->clear_block(ctx->blocks[7]);
386 388
         }
387 389
     } else {
388
-        dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset    , ctx->m.linesize);
390
+        dsp->get_pixels(ctx->blocks[4], ptr_y + ctx->dct_y_offset,     ctx->m.linesize);
389 391
         dsp->get_pixels(ctx->blocks[5], ptr_y + ctx->dct_y_offset + 8, ctx->m.linesize);
390
-        dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset   , ctx->m.uvlinesize);
391
-        dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset   , ctx->m.uvlinesize);
392
+        dsp->get_pixels(ctx->blocks[6], ptr_u + ctx->dct_uv_offset,    ctx->m.uvlinesize);
393
+        dsp->get_pixels(ctx->blocks[7], ptr_v + ctx->dct_uv_offset,    ctx->m.uvlinesize);
392 394
     }
393 395
 }
394 396
 
... ...
@@ -496,14 +498,14 @@ static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx)
496 496
     for (mb_y = 0; mb_y < ctx->m.mb_height; mb_y++) {
497 497
         int thread_size;
498 498
         ctx->slice_offs[mb_y] = offset;
499
-            ctx->slice_size[mb_y] = 0;
500
-            for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) {
501
-                unsigned mb = mb_y * ctx->m.mb_width + mb_x;
502
-                ctx->slice_size[mb_y] += ctx->mb_bits[mb];
503
-            }
504
-            ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31;
505
-            ctx->slice_size[mb_y] >>= 3;
506
-            thread_size = ctx->slice_size[mb_y];
499
+        ctx->slice_size[mb_y] = 0;
500
+        for (mb_x = 0; mb_x < ctx->m.mb_width; mb_x++) {
501
+            unsigned mb = mb_y * ctx->m.mb_width + mb_x;
502
+            ctx->slice_size[mb_y] += ctx->mb_bits[mb];
503
+        }
504
+        ctx->slice_size[mb_y] = (ctx->slice_size[mb_y]+31)&~31;
505
+        ctx->slice_size[mb_y] >>= 3;
506
+        thread_size = ctx->slice_size[mb_y];
507 507
         offset += thread_size;
508 508
     }
509 509
 }
... ...
@@ -184,7 +184,7 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
184 184
             s += sq[pix[6]];
185 185
             s += sq[pix[7]];
186 186
 #else
187
-#if LONG_MAX > 2147483647
187
+#if HAVE_FAST_64BIT
188 188
             register uint64_t x=*(uint64_t*)pix;
189 189
             s += sq[x&0xff];
190 190
             s += sq[(x>>8)&0xff];
... ...
@@ -2225,7 +2225,7 @@ static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *s
2225 2225
 
2226 2226
     s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
2227 2227
     s->dct_unquantize_inter(s, temp, 0, s->qscale);
2228
-    ff_simple_idct(temp); //FIXME
2228
+    ff_simple_idct_8(temp); //FIXME
2229 2229
 
2230 2230
     for(i=0; i<64; i++)
2231 2231
         sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
... ...
@@ -2866,6 +2866,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
2866 2866
         c->idct    = j_rev_dct1;
2867 2867
         c->idct_permutation_type= FF_NO_IDCT_PERM;
2868 2868
     }else{
2869
+        if (avctx->bits_per_raw_sample == 10) {
2870
+            c->idct_put              = ff_simple_idct_put_10;
2871
+            c->idct_add              = ff_simple_idct_add_10;
2872
+            c->idct                  = ff_simple_idct_10;
2873
+            c->idct_permutation_type = FF_NO_IDCT_PERM;
2874
+        } else {
2869 2875
         if(avctx->idct_algo==FF_IDCT_INT){
2870 2876
             c->idct_put= ff_jref_idct_put;
2871 2877
             c->idct_add= ff_jref_idct_add;
... ...
@@ -2896,11 +2902,12 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
2896 2896
             c->idct_put = ff_bink_idct_put_c;
2897 2897
             c->idct_permutation_type = FF_NO_IDCT_PERM;
2898 2898
         }else{ //accurate/default
2899
-            c->idct_put= ff_simple_idct_put;
2900
-            c->idct_add= ff_simple_idct_add;
2901
-            c->idct    = ff_simple_idct;
2899
+            c->idct_put = ff_simple_idct_put_8;
2900
+            c->idct_add = ff_simple_idct_add_8;
2901
+            c->idct     = ff_simple_idct_8;
2902 2902
             c->idct_permutation_type= FF_NO_IDCT_PERM;
2903 2903
         }
2904
+        }
2904 2905
     }
2905 2906
 
2906 2907
     c->get_pixels = get_pixels_c;
... ...
@@ -3169,21 +3176,18 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
3169 3169
     dspfunc2(avg_h264_qpel, 1,  8, depth);\
3170 3170
     dspfunc2(avg_h264_qpel, 2,  4, depth);
3171 3171
 
3172
-    if (avctx->codec_id != CODEC_ID_H264 || avctx->bits_per_raw_sample == 8) {
3173
-        BIT_DEPTH_FUNCS(8)
3174
-    } else {
3175
-        switch (avctx->bits_per_raw_sample) {
3176
-            case 9:
3177
-                BIT_DEPTH_FUNCS(9)
3178
-                break;
3179
-            case 10:
3180
-                BIT_DEPTH_FUNCS(10)
3181
-                break;
3182
-            default:
3183
-                av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample);
3184
-                BIT_DEPTH_FUNCS(8)
3185
-                break;
3186
-        }
3172
+    switch (avctx->bits_per_raw_sample) {
3173
+    case 9:
3174
+        BIT_DEPTH_FUNCS(9);
3175
+        break;
3176
+    case 10:
3177
+        BIT_DEPTH_FUNCS(10);
3178
+        break;
3179
+    default:
3180
+        av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample);
3181
+    case 8:
3182
+        BIT_DEPTH_FUNCS(8);
3183
+        break;
3187 3184
     }
3188 3185
 
3189 3186
 
... ...
@@ -3243,4 +3247,3 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
3243 3243
         av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
3244 3244
     }
3245 3245
 }
3246
-
... ...
@@ -230,150 +230,6 @@ static void FUNCC(add_pixels4)(uint8_t *restrict p_pixels, DCTELEM *p_block, int
230 230
     }
231 231
 }
232 232
 
233
-#if 0
234
-
235
-#define PIXOP2(OPNAME, OP) \
236
-static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
237
-{\
238
-    int i;\
239
-    for(i=0; i<h; i++){\
240
-        OP(*((uint64_t*)block), AV_RN64(pixels));\
241
-        pixels+=line_size;\
242
-        block +=line_size;\
243
-    }\
244
-}\
245
-\
246
-static void OPNAME ## _no_rnd_pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
247
-{\
248
-    int i;\
249
-    for(i=0; i<h; i++){\
250
-        const uint64_t a= AV_RN64(pixels  );\
251
-        const uint64_t b= AV_RN64(pixels+1);\
252
-        OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
253
-        pixels+=line_size;\
254
-        block +=line_size;\
255
-    }\
256
-}\
257
-\
258
-static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
259
-{\
260
-    int i;\
261
-    for(i=0; i<h; i++){\
262
-        const uint64_t a= AV_RN64(pixels  );\
263
-        const uint64_t b= AV_RN64(pixels+1);\
264
-        OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
265
-        pixels+=line_size;\
266
-        block +=line_size;\
267
-    }\
268
-}\
269
-\
270
-static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
271
-{\
272
-    int i;\
273
-    for(i=0; i<h; i++){\
274
-        const uint64_t a= AV_RN64(pixels          );\
275
-        const uint64_t b= AV_RN64(pixels+line_size);\
276
-        OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
277
-        pixels+=line_size;\
278
-        block +=line_size;\
279
-    }\
280
-}\
281
-\
282
-static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
283
-{\
284
-    int i;\
285
-    for(i=0; i<h; i++){\
286
-        const uint64_t a= AV_RN64(pixels          );\
287
-        const uint64_t b= AV_RN64(pixels+line_size);\
288
-        OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
289
-        pixels+=line_size;\
290
-        block +=line_size;\
291
-    }\
292
-}\
293
-\
294
-static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
295
-{\
296
-        int i;\
297
-        const uint64_t a= AV_RN64(pixels  );\
298
-        const uint64_t b= AV_RN64(pixels+1);\
299
-        uint64_t l0=  (a&0x0303030303030303ULL)\
300
-                    + (b&0x0303030303030303ULL)\
301
-                    + 0x0202020202020202ULL;\
302
-        uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
303
-                   + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
304
-        uint64_t l1,h1;\
305
-\
306
-        pixels+=line_size;\
307
-        for(i=0; i<h; i+=2){\
308
-            uint64_t a= AV_RN64(pixels  );\
309
-            uint64_t b= AV_RN64(pixels+1);\
310
-            l1=  (a&0x0303030303030303ULL)\
311
-               + (b&0x0303030303030303ULL);\
312
-            h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
313
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
314
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
315
-            pixels+=line_size;\
316
-            block +=line_size;\
317
-            a= AV_RN64(pixels  );\
318
-            b= AV_RN64(pixels+1);\
319
-            l0=  (a&0x0303030303030303ULL)\
320
-               + (b&0x0303030303030303ULL)\
321
-               + 0x0202020202020202ULL;\
322
-            h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
323
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
324
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
325
-            pixels+=line_size;\
326
-            block +=line_size;\
327
-        }\
328
-}\
329
-\
330
-static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
331
-{\
332
-        int i;\
333
-        const uint64_t a= AV_RN64(pixels  );\
334
-        const uint64_t b= AV_RN64(pixels+1);\
335
-        uint64_t l0=  (a&0x0303030303030303ULL)\
336
-                    + (b&0x0303030303030303ULL)\
337
-                    + 0x0101010101010101ULL;\
338
-        uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
339
-                   + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
340
-        uint64_t l1,h1;\
341
-\
342
-        pixels+=line_size;\
343
-        for(i=0; i<h; i+=2){\
344
-            uint64_t a= AV_RN64(pixels  );\
345
-            uint64_t b= AV_RN64(pixels+1);\
346
-            l1=  (a&0x0303030303030303ULL)\
347
-               + (b&0x0303030303030303ULL);\
348
-            h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
349
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
350
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
351
-            pixels+=line_size;\
352
-            block +=line_size;\
353
-            a= AV_RN64(pixels  );\
354
-            b= AV_RN64(pixels+1);\
355
-            l0=  (a&0x0303030303030303ULL)\
356
-               + (b&0x0303030303030303ULL)\
357
-               + 0x0101010101010101ULL;\
358
-            h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
359
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
360
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
361
-            pixels+=line_size;\
362
-            block +=line_size;\
363
-        }\
364
-}\
365
-\
366
-CALL_2X_PIXELS(OPNAME ## _pixels16_c    , OPNAME ## _pixels_c    , 8*sizeof(pixel))\
367
-CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8*sizeof(pixel))\
368
-CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8*sizeof(pixel))\
369
-CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8*sizeof(pixel))\
370
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8*sizeof(pixel))\
371
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8*sizeof(pixel))\
372
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8*sizeof(pixel))
373
-
374
-#define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) )
375
-#else // 64 bit variant
376
-
377 233
 #define PIXOP2(OPNAME, OP) \
378 234
 static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
379 235
     int i;\
... ...
@@ -749,7 +605,6 @@ CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pi
749 749
 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\
750 750
 
751 751
 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
752
-#endif
753 752
 #define op_put(a, b) a = b
754 753
 
755 754
 PIXOP2(avg, op_avg)
756 755
deleted file mode 100644
... ...
@@ -1,278 +0,0 @@
1
-/*
2
- * data for G.729 decoder
3
- * Copyright (c) 2007 Vladimir Voroshilov
4
- *
5
- * This file is part of FFmpeg.
6
- *
7
- * FFmpeg is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * FFmpeg is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with FFmpeg; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- */
21
-
22
-#ifndef AVCODEC_G729DATA_H
23
-#define AVCODEC_G729DATA_H
24
-
25
-#include <stdint.h>
26
-
27
-#define MA_NP                4  ///< Moving Average (MA) prediction order
28
-
29
-#define VQ_1ST_BITS          7  ///< first stage vector of quantizer (size in bits)
30
-#define VQ_2ND_BITS          5  ///< second stage vector of quantizer (size in bits)
31
-
32
-#define GC_1ST_IDX_BITS_8K   3  ///< gain codebook (first stage) index, 8k mode (size in bits)
33
-#define GC_2ND_IDX_BITS_8K   4  ///< gain codebook (second stage) index, 8k mode (size in bits)
34
-
35
-#define GC_1ST_IDX_BITS_6K4  3  ///< gain codebook (first stage) index, 6.4k mode (size in bits)
36
-#define GC_2ND_IDX_BITS_6K4  3  ///< gain codebook (second stage) index, 6.4k mode (size in bits)
37
-
38
-/**
39
- * first stage LSP codebook
40
- * (10-dimensional, with 128 entries (3.24 of G.729)
41
- */
42
-static const int16_t cb_lsp_1st[1<<VQ_1ST_BITS][10] = { /* (2.13) */
43
-  { 1486,  2168,  3751,  9074, 12134, 13944, 17983, 19173, 21190, 21820},
44
-  { 1730,  2640,  3450,  4870,  6126,  7876, 15644, 17817, 20294, 21902},
45
-  { 1568,  2256,  3088,  4874, 11063, 13393, 18307, 19293, 21109, 21741},
46
-  { 1733,  2512,  3357,  4708,  6977, 10296, 17024, 17956, 19145, 20350},
47
-  { 1744,  2436,  3308,  8731, 10432, 12007, 15614, 16639, 21359, 21913},
48
-  { 1786,  2369,  3372,  4521,  6795, 12963, 17674, 18988, 20855, 21640},
49
-  { 1631,  2433,  3361,  6328, 10709, 12013, 13277, 13904, 19441, 21088},
50
-  { 1489,  2364,  3291,  6250,  9227, 10403, 13843, 15278, 17721, 21451},
51
-  { 1869,  2533,  3475,  4365,  9152, 14513, 15908, 17022, 20611, 21411},
52
-  { 2070,  3025,  4333,  5854,  7805,  9231, 10597, 16047, 20109, 21834},
53
-  { 1910,  2673,  3419,  4261, 11168, 15111, 16577, 17591, 19310, 20265},
54
-  { 1141,  1815,  2624,  4623,  6495,  9588, 13968, 16428, 19351, 21286},
55
-  { 2192,  3171,  4707,  5808, 10904, 12500, 14162, 15664, 21124, 21789},
56
-  { 1286,  1907,  2548,  3453,  9574, 11964, 15978, 17344, 19691, 22495},
57
-  { 1921,  2720,  4604,  6684, 11503, 12992, 14350, 15262, 16997, 20791},
58
-  { 2052,  2759,  3897,  5246,  6638, 10267, 15834, 16814, 18149, 21675},
59
-  { 1798,  2497,  5617, 11449, 13189, 14711, 17050, 18195, 20307, 21182},
60
-  { 1009,  1647,  2889,  5709,  9541, 12354, 15231, 18494, 20966, 22033},
61
-  { 3016,  3794,  5406,  7469, 12488, 13984, 15328, 16334, 19952, 20791},
62
-  { 2203,  3040,  3796,  5442, 11987, 13512, 14931, 16370, 17856, 18803},
63
-  { 2912,  4292,  7988,  9572, 11562, 13244, 14556, 16529, 20004, 21073},
64
-  { 2861,  3607,  5923,  7034,  9234, 12054, 13729, 18056, 20262, 20974},
65
-  { 3069,  4311,  5967,  7367, 11482, 12699, 14309, 16233, 18333, 19172},
66
-  { 2434,  3661,  4866,  5798, 10383, 11722, 13049, 15668, 18862, 19831},
67
-  { 2020,  2605,  3860,  9241, 13275, 14644, 16010, 17099, 19268, 20251},
68
-  { 1877,  2809,  3590,  4707, 11056, 12441, 15622, 17168, 18761, 19907},
69
-  { 2107,  2873,  3673,  5799, 13579, 14687, 15938, 17077, 18890, 19831},
70
-  { 1612,  2284,  2944,  3572,  8219, 13959, 15924, 17239, 18592, 20117},
71
-  { 2420,  3156,  6542, 10215, 12061, 13534, 15305, 16452, 18717, 19880},
72
-  { 1667,  2612,  3534,  5237, 10513, 11696, 12940, 16798, 18058, 19378},
73
-  { 2388,  3017,  4839,  9333, 11413, 12730, 15024, 16248, 17449, 18677},
74
-  { 1875,  2786,  4231,  6320,  8694, 10149, 11785, 17013, 18608, 19960},
75
-  {  679,  1411,  4654,  8006, 11446, 13249, 15763, 18127, 20361, 21567},
76
-  { 1838,  2596,  3578,  4608,  5650, 11274, 14355, 15886, 20579, 21754},
77
-  { 1303,  1955,  2395,  3322, 12023, 13764, 15883, 18077, 20180, 21232},
78
-  { 1438,  2102,  2663,  3462,  8328, 10362, 13763, 17248, 19732, 22344},
79
-  {  860,  1904,  6098,  7775,  9815, 12007, 14821, 16709, 19787, 21132},
80
-  { 1673,  2723,  3704,  6125,  7668,  9447, 13683, 14443, 20538, 21731},
81
-  { 1246,  1849,  2902,  4508,  7221, 12710, 14835, 16314, 19335, 22720},
82
-  { 1525,  2260,  3862,  5659,  7342, 11748, 13370, 14442, 18044, 21334},
83
-  { 1196,  1846,  3104,  7063, 10972, 12905, 14814, 17037, 19922, 22636},
84
-  { 2147,  3106,  4475,  6511,  8227,  9765, 10984, 12161, 18971, 21300},
85
-  { 1585,  2405,  2994,  4036, 11481, 13177, 14519, 15431, 19967, 21275},
86
-  { 1778,  2688,  3614,  4680,  9465, 11064, 12473, 16320, 19742, 20800},
87
-  { 1862,  2586,  3492,  6719, 11708, 13012, 14364, 16128, 19610, 20425},
88
-  { 1395,  2156,  2669,  3386, 10607, 12125, 13614, 16705, 18976, 21367},
89
-  { 1444,  2117,  3286,  6233,  9423, 12981, 14998, 15853, 17188, 21857},
90
-  { 2004,  2895,  3783,  4897,  6168,  7297, 12609, 16445, 19297, 21465},
91
-  { 1495,  2863,  6360,  8100, 11399, 14271, 15902, 17711, 20479, 22061},
92
-  { 2484,  3114,  5718,  7097,  8400, 12616, 14073, 14847, 20535, 21396},
93
-  { 2424,  3277,  5296,  6284, 11290, 12903, 16022, 17508, 19333, 20283},
94
-  { 2565,  3778,  5360,  6989,  8782, 10428, 14390, 15742, 17770, 21734},
95
-  { 2727,  3384,  6613,  9254, 10542, 12236, 14651, 15687, 20074, 21102},
96
-  { 1916,  2953,  6274,  8088,  9710, 10925, 12392, 16434, 20010, 21183},
97
-  { 3384,  4366,  5349,  7667, 11180, 12605, 13921, 15324, 19901, 20754},
98
-  { 3075,  4283,  5951,  7619,  9604, 11010, 12384, 14006, 20658, 21497},
99
-  { 1751,  2455,  5147,  9966, 11621, 13176, 14739, 16470, 20788, 21756},
100
-  { 1442,  2188,  3330,  6813,  8929, 12135, 14476, 15306, 19635, 20544},
101
-  { 2294,  2895,  4070,  8035, 12233, 13416, 14762, 17367, 18952, 19688},
102
-  { 1937,  2659,  4602,  6697,  9071, 12863, 14197, 15230, 16047, 18877},
103
-  { 2071,  2663,  4216,  9445, 10887, 12292, 13949, 14909, 19236, 20341},
104
-  { 1740,  2491,  3488,  8138,  9656, 11153, 13206, 14688, 20896, 21907},
105
-  { 2199,  2881,  4675,  8527, 10051, 11408, 14435, 15463, 17190, 20597},
106
-  { 1943,  2988,  4177,  6039,  7478,  8536, 14181, 15551, 17622, 21579},
107
-  { 1825,  3175,  7062,  9818, 12824, 15450, 18330, 19856, 21830, 22412},
108
-  { 2464,  3046,  4822,  5977,  7696, 15398, 16730, 17646, 20588, 21320},
109
-  { 2550,  3393,  5305,  6920, 10235, 14083, 18143, 19195, 20681, 21336},
110
-  { 3003,  3799,  5321,  6437,  7919, 11643, 15810, 16846, 18119, 18980},
111
-  { 3455,  4157,  6838,  8199,  9877, 12314, 15905, 16826, 19949, 20892},
112
-  { 3052,  3769,  4891,  5810,  6977, 10126, 14788, 15990, 19773, 20904},
113
-  { 3671,  4356,  5827,  6997,  8460, 12084, 14154, 14939, 19247, 20423},
114
-  { 2716,  3684,  5246,  6686,  8463, 10001, 12394, 14131, 16150, 19776},
115
-  { 1945,  2638,  4130,  7995, 14338, 15576, 17057, 18206, 20225, 20997},
116
-  { 2304,  2928,  4122,  4824,  5640, 13139, 15825, 16938, 20108, 21054},
117
-  { 1800,  2516,  3350,  5219, 13406, 15948, 17618, 18540, 20531, 21252},
118
-  { 1436,  2224,  2753,  4546,  9657, 11245, 15177, 16317, 17489, 19135},
119
-  { 2319,  2899,  4980,  6936,  8404, 13489, 15554, 16281, 20270, 20911},
120
-  { 2187,  2919,  4610,  5875,  7390, 12556, 14033, 16794, 20998, 21769},
121
-  { 2235,  2923,  5121,  6259,  8099, 13589, 15340, 16340, 17927, 20159},
122
-  { 1765,  2638,  3751,  5730,  7883, 10108, 13633, 15419, 16808, 18574},
123
-  { 3460,  5741,  9596, 11742, 14413, 16080, 18173, 19090, 20845, 21601},
124
-  { 3735,  4426,  6199,  7363,  9250, 14489, 16035, 17026, 19873, 20876},
125
-  { 3521,  4778,  6887,  8680, 12717, 14322, 15950, 18050, 20166, 21145},
126
-  { 2141,  2968,  6865,  8051, 10010, 13159, 14813, 15861, 17528, 18655},
127
-  { 4148,  6128,  9028, 10871, 12686, 14005, 15976, 17208, 19587, 20595},
128
-  { 4403,  5367,  6634,  8371, 10163, 11599, 14963, 16331, 17982, 18768},
129
-  { 4091,  5386,  6852,  8770, 11563, 13290, 15728, 16930, 19056, 20102},
130
-  { 2746,  3625,  5299,  7504, 10262, 11432, 13172, 15490, 16875, 17514},
131
-  { 2248,  3556,  8539, 10590, 12665, 14696, 16515, 17824, 20268, 21247},
132
-  { 1279,  1960,  3920,  7793, 10153, 14753, 16646, 18139, 20679, 21466},
133
-  { 2440,  3475,  6737,  8654, 12190, 14588, 17119, 17925, 19110, 19979},
134
-  { 1879,  2514,  4497,  7572, 10017, 14948, 16141, 16897, 18397, 19376},
135
-  { 2804,  3688,  7490, 10086, 11218, 12711, 16307, 17470, 20077, 21126},
136
-  { 2023,  2682,  3873,  8268, 10255, 11645, 15187, 17102, 18965, 19788},
137
-  { 2823,  3605,  5815,  8595, 10085, 11469, 16568, 17462, 18754, 19876},
138
-  { 2851,  3681,  5280,  7648,  9173, 10338, 14961, 16148, 17559, 18474},
139
-  { 1348,  2645,  5826,  8785, 10620, 12831, 16255, 18319, 21133, 22586},
140
-  { 2141,  3036,  4293,  6082,  7593, 10629, 17158, 18033, 21466, 22084},
141
-  { 1608,  2375,  3384,  6878,  9970, 11227, 16928, 17650, 20185, 21120},
142
-  { 2774,  3616,  5014,  6557,  7788,  8959, 17068, 18302, 19537, 20542},
143
-  { 1934,  4813,  6204,  7212,  8979, 11665, 15989, 17811, 20426, 21703},
144
-  { 2288,  3507,  5037,  6841,  8278,  9638, 15066, 16481, 21653, 22214},
145
-  { 2951,  3771,  4878,  7578,  9016, 10298, 14490, 15242, 20223, 20990},
146
-  { 3256,  4791,  6601,  7521,  8644,  9707, 13398, 16078, 19102, 20249},
147
-  { 1827,  2614,  3486,  6039, 12149, 13823, 16191, 17282, 21423, 22041},
148
-  { 1000,  1704,  3002,  6335,  8471, 10500, 14878, 16979, 20026, 22427},
149
-  { 1646,  2286,  3109,  7245, 11493, 12791, 16824, 17667, 18981, 20222},
150
-  { 1708,  2501,  3315,  6737,  8729,  9924, 16089, 17097, 18374, 19917},
151
-  { 2623,  3510,  4478,  5645,  9862, 11115, 15219, 18067, 19583, 20382},
152
-  { 2518,  3434,  4728,  6388,  8082,  9285, 13162, 18383, 19819, 20552},
153
-  { 1726,  2383,  4090,  6303,  7805, 12845, 14612, 17608, 19269, 20181},
154
-  { 2860,  3735,  4838,  6044,  7254,  8402, 14031, 16381, 18037, 19410},
155
-  { 4247,  5993,  7952,  9792, 12342, 14653, 17527, 18774, 20831, 21699},
156
-  { 3502,  4051,  5680,  6805,  8146, 11945, 16649, 17444, 20390, 21564},
157
-  { 3151,  4893,  5899,  7198, 11418, 13073, 15124, 17673, 20520, 21861},
158
-  { 3960,  4848,  5926,  7259,  8811, 10529, 15661, 16560, 18196, 20183},
159
-  { 4499,  6604,  8036,  9251, 10804, 12627, 15880, 17512, 20020, 21046},
160
-  { 4251,  5541,  6654,  8318,  9900, 11686, 15100, 17093, 20572, 21687},
161
-  { 3769,  5327,  7865,  9360, 10684, 11818, 13660, 15366, 18733, 19882},
162
-  { 3083,  3969,  6248,  8121,  9798, 10994, 12393, 13686, 17888, 19105},
163
-  { 2731,  4670,  7063,  9201, 11346, 13735, 16875, 18797, 20787, 22360},
164
-  { 1187,  2227,  4737,  7214,  9622, 12633, 15404, 17968, 20262, 23533},
165
-  { 1911,  2477,  3915, 10098, 11616, 12955, 16223, 17138, 19270, 20729},
166
-  { 1764,  2519,  3887,  6944,  9150, 12590, 16258, 16984, 17924, 18435},
167
-  { 1400,  3674,  7131,  8718, 10688, 12508, 15708, 17711, 19720, 21068},
168
-  { 2322,  3073,  4287,  8108,  9407, 10628, 15862, 16693, 19714, 21474},
169
-  { 2630,  3339,  4758,  8360, 10274, 11333, 12880, 17374, 19221, 19936},
170
-  { 1721,  2577,  5553,  7195,  8651, 10686, 15069, 16953, 18703, 19929}
171
-};
172
-
173
-/**
174
- * second stage LSP codebook, high and low parts
175
-   (both 5-dimensional, with 32 entries (3.2.4 of G.729)
176
- */
177
-static const int16_t cb_lsp_2nd[1<<VQ_2ND_BITS][10] = { /* (2.13) */
178
-  { -435,  -815,  -742,  1033,  -518,   582, -1201,   829,    86,   385},
179
-  { -833,  -891,   463,    -8, -1251,  1450,    72,  -231,   864,   661},
180
-  {-1021,   231,  -306,   321,  -220,  -163,  -526,  -754, -1633,   267},
181
-  {   57,  -198,  -339,   -33, -1468,   573,   796,  -169,  -631,   816},
182
-  {  171,  -350,   294,  1660,   453,   519,   291,   159,  -640, -1296},
183
-  { -701,  -842,   -58,   950,   892,  1549,   715,   527,  -714,  -193},
184
-  {  584,    31,  -289,   356,  -333,  -457,   612,  -283, -1381,  -741},
185
-  { -109,  -808,   231,    77,   -87,  -344,  1341,  1087,  -654,  -569},
186
-  { -859,  1236,   550,   854,   714,  -543, -1752,  -195,   -98,  -276},
187
-  { -877,  -954, -1248,  -299,   212,  -235,  -728,   949,  1517,   895},
188
-  {  -77,   344,  -620,   763,   413,   502,  -362,  -960,  -483,  1386},
189
-  { -314,  -307,  -256, -1260,  -429,   450,  -466,  -108,  1010,  2223},
190
-  {  711,   693,   521,   650,  1305,   -28,  -378,   744, -1005,   240},
191
-  { -112,  -271,  -500,   946,  1733,   271,   -15,   909,  -259,  1688},
192
-  {  575,   -10,  -468,  -199,  1101, -1011,   581,   -53,  -747,   878},
193
-  {  145,  -285, -1280,  -398,    36,  -498, -1377,    18,  -444,  1483},
194
-  {-1133,  -835,  1350,  1284,   -95,  1015,  -222,   443,   372,  -354},
195
-  {-1459, -1237,   416,  -213,   466,   669,   659,  1640,   932,   534},
196
-  {  -15,    66,   468,  1019,  -748,  1385,  -182,  -907,  -721,  -262},
197
-  { -338,   148,  1445,    75,  -760,   569,  1247,   337,   416,  -121},
198
-  {  389,   239,  1568,   981,   113,   369, -1003,  -507,  -587,  -904},
199
-  { -312,   -98,   949,    31,  1104,    72,  -141,  1465,    63,  -785},
200
-  { 1127,   584,   835,   277, -1159,   208,   301,  -882,   117,  -404},
201
-  {  539,  -114,   856,  -493,   223,  -912,   623,   -76,   276,  -440},
202
-  { 2197,  2337,  1268,   670,   304,  -267,  -525,   140,   882,  -139},
203
-  {-1596,   550,   801,  -456,   -56,  -697,   865,  1060,   413,   446},
204
-  { 1154,   593,   -77,  1237,   -31,   581, -1037,  -895,   669,   297},
205
-  {  397,   558,   203,  -797,  -919,     3,   692,  -292,  1050,   782},
206
-  {  334,  1475,   632,   -80,    48, -1061,  -484,   362,  -597,  -852},
207
-  { -545,  -330,  -429,  -680,  1133, -1182,  -744,  1340,   262,    63},
208
-  { 1320,   827,  -398,  -576,   341,  -774,  -483, -1247,   -70,    98},
209
-  { -163,   674,   -11,  -886,   531, -1125,  -265,  -242,   724,   934}
210
-};
211
-
212
-/**
213
- * gain codebook (first stage), 8k mode (3.9.2 of G.729)
214
- */
215
-static const int16_t cb_gain_1st_8k[1<<GC_1ST_IDX_BITS_8K][2] = { /*(0.14) (2.13) */
216
-  { 3242 ,  9949 },
217
-  { 1551 ,  2425 },
218
-  { 2678 , 27162 },
219
-  { 1921 ,  9291 },
220
-  { 1831 ,  5022 },
221
-  {    1 ,  1516 },
222
-  {  356 , 14756 },
223
-  {   57 ,  5404 },
224
-};
225
-
226
-/**
227
- * gain codebook (second stage), 8k mode (3.9.2 of G.729)
228
- */
229
-static const int16_t cb_gain_2nd_8k[1<<GC_2ND_IDX_BITS_8K][2] = { /*(1.14) (1.13) */
230
-  {  5142 ,   592 },
231
-  { 17299 ,  1861 },
232
-  {  6160 ,  2395 },
233
-  { 16112 ,  3392 },
234
-  {   826 ,  2005 },
235
-  { 18973 ,  5935 },
236
-  {  1994 ,     0 },
237
-  { 15434 ,   237 },
238
-  { 10573 ,  2966 },
239
-  { 15132 ,  4914 },
240
-  { 11569 ,  1196 },
241
-  { 14194 ,  1630 },
242
-  {  8091 ,  4861 },
243
-  { 15161 , 14276 },
244
-  {  9120 ,   525 },
245
-  { 13260 ,  3256 },
246
-};
247
-
248
-/**
249
- * 4th order Moving Average (MA) Predictor codebook (3.2.4 of G.729)
250
- */
251
-static const int16_t cb_ma_predictor[2][MA_NP][10] = { /* (0.15) */
252
-  {
253
-    { 8421,  9109,  9175,  8965,  9034,  9057,  8765,  8775,  9106,  8673},
254
-    { 7018,  7189,  7638,  7307,  7444,  7379,  7038,  6956,  6930,  6868},
255
-    { 5472,  4990,  5134,  5177,  5246,  5141,  5206,  5095,  4830,  5147},
256
-    { 4056,  3031,  2614,  3024,  2916,  2713,  3309,  3237,  2857,  3473}
257
-  },
258
-  {
259
-    { 7733,  7880,  8188,  8175,  8247,  8490,  8637,  8601,  8359,  7569},
260
-    { 4210,  3031,  2552,  3473,  3876,  3853,  4184,  4154,  3909,  3968},
261
-    { 3214,  1930,  1313,  2143,  2493,  2385,  2755,  2706,  2542,  2919},
262
-    { 3024,  1592,   940,  1631,  1723,  1579,  2034,  2084,  1913,  2601}
263
-  }
264
-};
265
-
266
-static const int16_t cb_ma_predictor_sum[2][10] = { /* (0.15) */
267
-  { 7798,  8447,  8205,  8293,  8126,  8477,  8447,  8703,  9043,  8604},
268
-  {14585, 18333, 19772, 17344, 16426, 16459, 15155, 15220, 16043, 15708}
269
-};
270
-
271
-/**
272
- * initial LSP coefficients belongs to virtual frame preceding  the
273
- * first frame of the stream
274
- */
275
-static const int16_t lsp_init[10]= { /* (0.15) */
276
-   30000, 26000, 21000, 15000, 8000, 0, -8000,-15000,-21000,-26000
277
-};
278
-#endif /* AVCODEC_G729DATA_H */
279 1
deleted file mode 100644
... ...
@@ -1,331 +0,0 @@
1
-/*
2
- * G.729 decoder
3
- * Copyright (c) 2008 Vladimir Voroshilov
4
- *
5
- * This file is part of FFmpeg.
6
- *
7
- * FFmpeg is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * FFmpeg is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with FFmpeg; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- */
21
-#include <stdlib.h>
22
-#include <inttypes.h>
23
-#include <limits.h>
24
-#include <stdio.h>
25
-#include <string.h>
26
-#include <math.h>
27
-#include <assert.h>
28
-
29
-#include "avcodec.h"
30
-#include "libavutil/avutil.h"
31
-#include "get_bits.h"
32
-
33
-#include "lsp.h"
34
-#include "celp_math.h"
35
-#include "acelp_filters.h"
36
-#include "acelp_pitch_delay.h"
37
-#include "acelp_vectors.h"
38
-#include "g729data.h"
39
-
40
-/**
41
- * minimum quantized LSF value (3.2.4)
42
- * 0.005 in Q13
43
- */
44
-#define LSFQ_MIN                   40
45
-
46
-/**
47
- * maximum quantized LSF value (3.2.4)
48
- * 3.135 in Q13
49
- */
50
-#define LSFQ_MAX                   25681
51
-
52
-/**
53
- * minimum LSF distance (3.2.4)
54
- * 0.0391 in Q13
55
- */
56
-#define LSFQ_DIFF_MIN              321
57
-
58
-/**
59
- * minimum gain pitch value (3.8, Equation 47)
60
- * 0.2 in (1.14)
61
- */
62
-#define SHARP_MIN                  3277
63
-
64
-/**
65
- * maximum gain pitch value (3.8, Equation 47)
66
- * (EE) This does not comply with the specification.
67
- * Specification says about 0.8, which should be
68
- * 13107 in (1.14), but reference C code uses
69
- * 13017 (equals to 0.7945) instead of it.
70
- */
71
-#define SHARP_MAX                  13017
72
-
73
-/**
74
- * subframe size
75
- */
76
-#define SUBFRAME_SIZE              40
77
-
78
-
79
-typedef struct {
80
-    uint8_t ac_index_bits[2];   ///< adaptive codebook index for second subframe (size in bits)
81
-    uint8_t parity_bit;         ///< parity bit for pitch delay
82
-    uint8_t gc_1st_index_bits;  ///< gain codebook (first stage) index (size in bits)
83
-    uint8_t gc_2nd_index_bits;  ///< gain codebook (second stage) index (size in bits)
84
-    uint8_t fc_signs_bits;      ///< number of pulses in fixed-codebook vector
85
-    uint8_t fc_indexes_bits;    ///< size (in bits) of fixed-codebook index entry
86
-} G729FormatDescription;
87
-
88
-typedef struct {
89
-    int pitch_delay_int_prev;   ///< integer part of previous subframe's pitch delay (4.1.3)
90
-
91
-    /// (2.13) LSP quantizer outputs
92
-    int16_t  past_quantizer_output_buf[MA_NP + 1][10];
93
-    int16_t* past_quantizer_outputs[MA_NP + 1];
94
-
95
-    int16_t lsfq[10];           ///< (2.13) quantized LSF coefficients from previous frame
96
-    int16_t lsp_buf[2][10];     ///< (0.15) LSP coefficients (previous and current frames) (3.2.5)
97
-    int16_t *lsp[2];            ///< pointers to lsp_buf
98
-}  G729Context;
99
-
100
-static const G729FormatDescription format_g729_8k = {
101
-    .ac_index_bits     = {8,5},
102
-    .parity_bit        = 1,
103
-    .gc_1st_index_bits = GC_1ST_IDX_BITS_8K,
104
-    .gc_2nd_index_bits = GC_2ND_IDX_BITS_8K,
105
-    .fc_signs_bits     = 4,
106
-    .fc_indexes_bits   = 13,
107
-};
108
-
109
-static const G729FormatDescription format_g729d_6k4 = {
110
-    .ac_index_bits     = {8,4},
111
-    .parity_bit        = 0,
112
-    .gc_1st_index_bits = GC_1ST_IDX_BITS_6K4,
113
-    .gc_2nd_index_bits = GC_2ND_IDX_BITS_6K4,
114
-    .fc_signs_bits     = 2,
115
-    .fc_indexes_bits   = 9,
116
-};
117
-
118
-/**
119
- * @brief pseudo random number generator
120
- */
121
-static inline uint16_t g729_prng(uint16_t value)
122
-{
123
-    return 31821 * value + 13849;
124
-}
125
-
126
-/**
127
- * Get parity bit of bit 2..7
128
- */
129
-static inline int get_parity(uint8_t value)
130
-{
131
-   return (0x6996966996696996ULL >> (value >> 2)) & 1;
132
-}
133
-
134
-static void lsf_decode(int16_t* lsfq, int16_t* past_quantizer_outputs[MA_NP + 1],
135
-                       int16_t ma_predictor,
136
-                       int16_t vq_1st, int16_t vq_2nd_low, int16_t vq_2nd_high)
137
-{
138
-    int i,j;
139
-    static const uint8_t min_distance[2]={10, 5}; //(2.13)
140
-    int16_t* quantizer_output = past_quantizer_outputs[MA_NP];
141
-
142
-    for (i = 0; i < 5; i++) {
143
-        quantizer_output[i]     = cb_lsp_1st[vq_1st][i    ] + cb_lsp_2nd[vq_2nd_low ][i    ];
144
-        quantizer_output[i + 5] = cb_lsp_1st[vq_1st][i + 5] + cb_lsp_2nd[vq_2nd_high][i + 5];
145
-    }
146
-
147
-    for (j = 0; j < 2; j++) {
148
-        for (i = 1; i < 10; i++) {
149
-            int diff = (quantizer_output[i - 1] - quantizer_output[i] + min_distance[j]) >> 1;
150
-            if (diff > 0) {
151
-                quantizer_output[i - 1] -= diff;
152
-                quantizer_output[i    ] += diff;
153
-            }
154
-        }
155
-    }
156
-
157
-    for (i = 0; i < 10; i++) {
158
-        int sum = quantizer_output[i] * cb_ma_predictor_sum[ma_predictor][i];
159
-        for (j = 0; j < MA_NP; j++)
160
-            sum += past_quantizer_outputs[j][i] * cb_ma_predictor[ma_predictor][j][i];
161
-
162
-        lsfq[i] = sum >> 15;
163
-    }
164
-
165
-    /* Rotate past_quantizer_outputs. */
166
-    memmove(past_quantizer_outputs + 1, past_quantizer_outputs, MA_NP * sizeof(int16_t*));
167
-    past_quantizer_outputs[0] = quantizer_output;
168
-
169
-    ff_acelp_reorder_lsf(lsfq, LSFQ_DIFF_MIN, LSFQ_MIN, LSFQ_MAX, 10);
170
-}
171
-
172
-static av_cold int decoder_init(AVCodecContext * avctx)
173
-{
174
-    G729Context* ctx = avctx->priv_data;
175
-    int i,k;
176
-
177
-    if (avctx->channels != 1) {
178
-        av_log(avctx, AV_LOG_ERROR, "Only mono sound is supported (requested channels: %d).\n", avctx->channels);
179
-        return AVERROR(EINVAL);
180
-    }
181
-
182
-    /* Both 8kbit/s and 6.4kbit/s modes uses two subframes per frame. */
183
-    avctx->frame_size = SUBFRAME_SIZE << 1;
184
-
185
-    for (k = 0; k < MA_NP + 1; k++) {
186
-        ctx->past_quantizer_outputs[k] = ctx->past_quantizer_output_buf[k];
187
-        for (i = 1; i < 11; i++)
188
-            ctx->past_quantizer_outputs[k][i - 1] = (18717 * i) >> 3;
189
-    }
190
-
191
-    ctx->lsp[0] = ctx->lsp_buf[0];
192
-    ctx->lsp[1] = ctx->lsp_buf[1];
193
-    memcpy(ctx->lsp[0], lsp_init, 10 * sizeof(int16_t));
194
-
195
-    return 0;
196
-}
197
-
198
-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
199
-                        AVPacket *avpkt)
200
-{
201
-    const uint8_t *buf = avpkt->data;
202
-    int buf_size       = avpkt->size;
203
-    int16_t *out_frame = data;
204
-    GetBitContext gb;
205
-    G729FormatDescription format;
206
-    int frame_erasure = 0;    ///< frame erasure detected during decoding
207
-    int bad_pitch = 0;        ///< parity check failed
208
-    int i;
209
-    G729Context *ctx = avctx->priv_data;
210
-    int16_t lp[2][11];           // (3.12)
211
-    uint8_t ma_predictor;     ///< switched MA predictor of LSP quantizer
212
-    uint8_t quantizer_1st;    ///< first stage vector of quantizer
213
-    uint8_t quantizer_2nd_lo; ///< second stage lower vector of quantizer (size in bits)
214
-    uint8_t quantizer_2nd_hi; ///< second stage higher vector of quantizer (size in bits)
215
-
216
-    int pitch_delay_int;         // pitch delay, integer part
217
-    int pitch_delay_3x;          // pitch delay, multiplied by 3
218
-
219
-    if (*data_size < SUBFRAME_SIZE << 2) {
220
-        av_log(avctx, AV_LOG_ERROR, "Error processing packet: output buffer too small\n");
221
-        return AVERROR(EIO);
222
-    }
223
-
224
-    if (buf_size == 10) {
225
-        format = format_g729_8k;
226
-        av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729 @ 8kbit/s");
227
-    } else if (buf_size == 8) {
228
-        format = format_g729d_6k4;
229
-        av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729D @ 6.4kbit/s");
230
-    } else {
231
-        av_log(avctx, AV_LOG_ERROR, "Packet size %d is unknown.\n", buf_size);
232
-        return AVERROR_INVALIDDATA;
233
-    }
234
-
235
-    for (i=0; i < buf_size; i++)
236
-        frame_erasure |= buf[i];
237
-    frame_erasure = !frame_erasure;
238
-
239
-    init_get_bits(&gb, buf, buf_size);
240
-
241
-    ma_predictor     = get_bits(&gb, 1);
242
-    quantizer_1st    = get_bits(&gb, VQ_1ST_BITS);
243
-    quantizer_2nd_lo = get_bits(&gb, VQ_2ND_BITS);
244
-    quantizer_2nd_hi = get_bits(&gb, VQ_2ND_BITS);
245
-
246
-    lsf_decode(ctx->lsfq, ctx->past_quantizer_outputs,
247
-               ma_predictor,
248
-               quantizer_1st, quantizer_2nd_lo, quantizer_2nd_hi);
249
-
250
-    ff_acelp_lsf2lsp(ctx->lsp[1], ctx->lsfq, 10);
251
-
252
-    ff_acelp_lp_decode(&lp[0][0], &lp[1][0], ctx->lsp[1], ctx->lsp[0], 10);
253
-
254
-    FFSWAP(int16_t*, ctx->lsp[1], ctx->lsp[0]);
255
-
256
-    for (i = 0; i < 2; i++) {
257
-        uint8_t ac_index;      ///< adaptive codebook index
258
-        uint8_t pulses_signs;  ///< fixed-codebook vector pulse signs
259
-        int fc_indexes;        ///< fixed-codebook indexes
260
-        uint8_t gc_1st_index;  ///< gain codebook (first stage) index
261
-        uint8_t gc_2nd_index;  ///< gain codebook (second stage) index
262
-
263
-        ac_index      = get_bits(&gb, format.ac_index_bits[i]);
264
-        if(!i && format.parity_bit)
265
-            bad_pitch = get_parity(ac_index) == get_bits1(&gb);
266
-        fc_indexes    = get_bits(&gb, format.fc_indexes_bits);
267
-        pulses_signs  = get_bits(&gb, format.fc_signs_bits);
268
-        gc_1st_index  = get_bits(&gb, format.gc_1st_index_bits);
269
-        gc_2nd_index  = get_bits(&gb, format.gc_2nd_index_bits);
270
-
271
-        if(!i) {
272
-            if (bad_pitch)
273
-                pitch_delay_3x   = 3 * ctx->pitch_delay_int_prev;
274
-            else
275
-                pitch_delay_3x = ff_acelp_decode_8bit_to_1st_delay3(ac_index);
276
-        } else {
277
-            int pitch_delay_min = av_clip(ctx->pitch_delay_int_prev - 5,
278
-                                          PITCH_DELAY_MIN, PITCH_DELAY_MAX - 9);
279
-
280
-            if(packet_type == FORMAT_G729D_6K4)
281
-                pitch_delay_3x = ff_acelp_decode_4bit_to_2nd_delay3(ac_index, pitch_delay_min);
282
-            else
283
-                pitch_delay_3x = ff_acelp_decode_5_6_bit_to_2nd_delay3(ac_index, pitch_delay_min);
284
-        }
285
-
286
-        /* Round pitch delay to nearest (used everywhere except ff_acelp_interpolate). */
287
-        pitch_delay_int  = (pitch_delay_3x + 1) / 3;
288
-
289
-        ff_acelp_weighted_vector_sum(fc + pitch_delay_int,
290
-                                     fc + pitch_delay_int,
291
-                                     fc, 1 << 14,
292
-                                     av_clip(ctx->gain_pitch, SHARP_MIN, SHARP_MAX),
293
-                                     0, 14,
294
-                                     SUBFRAME_SIZE - pitch_delay_int);
295
-
296
-        if (frame_erasure) {
297
-            ctx->gain_pitch = (29491 * ctx->gain_pitch) >> 15; // 0.90 (0.15)
298
-            ctx->gain_code  = ( 2007 * ctx->gain_code ) >> 11; // 0.98 (0.11)
299
-
300
-            gain_corr_factor = 0;
301
-        } else {
302
-            ctx->gain_pitch  = cb_gain_1st_8k[gc_1st_index][0] +
303
-                               cb_gain_2nd_8k[gc_2nd_index][0];
304
-            gain_corr_factor = cb_gain_1st_8k[gc_1st_index][1] +
305
-                               cb_gain_2nd_8k[gc_2nd_index][1];
306
-
307
-        ff_acelp_weighted_vector_sum(ctx->exc + i * SUBFRAME_SIZE,
308
-                                     ctx->exc + i * SUBFRAME_SIZE, fc,
309
-                                     (!voicing && frame_erasure) ? 0 : ctx->gain_pitch,
310
-                                     ( voicing && frame_erasure) ? 0 : ctx->gain_code,
311
-                                     1 << 13, 14, SUBFRAME_SIZE);
312
-
313
-            ctx->pitch_delay_int_prev = pitch_delay_int;
314
-    }
315
-
316
-    *data_size = SUBFRAME_SIZE << 2;
317
-    return buf_size;
318
-}
319
-
320
-AVCodec ff_g729_decoder =
321
-{
322
-    "g729",
323
-    AVMEDIA_TYPE_AUDIO,
324
-    CODEC_ID_G729,
325
-    sizeof(G729Context),
326
-    decoder_init,
327
-    NULL,
328
-    NULL,
329
-    decode_frame,
330
-    .long_name = NULL_IF_CONFIG_SMALL("G.729"),
331
-};
... ...
@@ -150,11 +150,7 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd
150 150
 
151 151
     /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/
152 152
     for(i=0; i<lp_order; i++)
153
-#ifdef G729_BITEXACT
154
-        lsp_1st[i] = (lsp_2nd[i] >> 1) + (lsp_prev[i] >> 1);
155
-#else
156 153
         lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1;
157
-#endif
158 154
 
159 155
     ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1);
160 156
 
... ...
@@ -318,7 +318,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
318 318
     s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type;
319 319
     if (pic->f.age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->f.age] == AV_PICTURE_TYPE_B)
320 320
         pic->f.age = INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
321
-    pic->owner2 = NULL;
321
+    pic->owner2 = s;
322 322
 
323 323
     return 0;
324 324
 fail: //for the FF_ALLOCZ_OR_GOTO macro
... ...
@@ -1036,14 +1036,16 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1036 1036
     /* mark&release old frames */
1037 1037
     if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->f.data[0]) {
1038 1038
       if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
1039
-          free_frame_buffer(s, s->last_picture_ptr);
1039
+          if (s->last_picture_ptr->owner2 == s)
1040
+              free_frame_buffer(s, s->last_picture_ptr);
1040 1041
 
1041 1042
         /* release forgotten pictures */
1042 1043
         /* if(mpeg124/h263) */
1043 1044
         if(!s->encoding){
1044 1045
             for(i=0; i<s->picture_count; i++){
1045
-                if (s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) {
1046
-                    av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
1046
+                if (s->picture[i].owner2 == s && s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) {
1047
+                    if (!(avctx->active_thread_type & FF_THREAD_FRAME))
1048
+                        av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
1047 1049
                     free_frame_buffer(s, &s->picture[i]);
1048 1050
                 }
1049 1051
             }
... ...
@@ -178,7 +178,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
178 178
         }
179 179
 #endif //CONFIG_ENCODERS
180 180
 
181
-        if (avctx->lowres==0) {
181
+        if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
182 182
             if ((avctx->idct_algo == FF_IDCT_AUTO) ||
183 183
                 (avctx->idct_algo == FF_IDCT_ALTIVEC)) {
184 184
                 c->idct_put = idct_put_altivec;
... ...
@@ -156,7 +156,8 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
156 156
 
157 157
     c->get_pixels = get_pixels_mmi;
158 158
 
159
-    if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2){
159
+    if (avctx->bits_per_raw_sample <= 8 &&
160
+        (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2)) {
160 161
         c->idct_put= ff_mmi_idct_put;
161 162
         c->idct_add= ff_mmi_idct_add;
162 163
         c->idct    = ff_mmi_idct;
... ...
@@ -97,7 +97,8 @@ void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
97 97
 
98 98
         if (!high_bit_depth)
99 99
         c->clear_blocks = clear_blocks_sh4;
100
-        if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){
100
+        if (avctx->bits_per_raw_sample <= 8 &&
101
+            (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
101 102
                 c->idct_put = idct_put;
102 103
                 c->idct_add = idct_add;
103 104
                c->idct     = idct_sh4;
... ...
@@ -25,339 +25,19 @@
25 25
  * simpleidct in C.
26 26
  */
27 27
 
28
-/*
29
-  based upon some outcommented c code from mpeg2dec (idct_mmx.c
30
-  written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
31
- */
32
-
33 28
 #include "libavutil/intreadwrite.h"
34 29
 #include "avcodec.h"
35 30
 #include "dsputil.h"
36 31
 #include "mathops.h"
37 32
 #include "simple_idct.h"
38 33
 
39
-#define W1  22725  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
40
-#define W2  21407  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
41
-#define W3  19266  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
42
-#define W4  16383  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
43
-#define W5  12873  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
44
-#define W6  8867   //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
45
-#define W7  4520   //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
46
-#define ROW_SHIFT 11
47
-#define COL_SHIFT 20 // 6
48
-
49
-static inline void idctRowCondDC (DCTELEM * row)
50
-{
51
-        int a0, a1, a2, a3, b0, b1, b2, b3;
52
-
53
-#if HAVE_FAST_64BIT
54
-#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
55
-        if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
56
-            uint64_t temp = (row[0] << 3) & 0xffff;
57
-            temp += temp << 16;
58
-            temp += temp << 32;
59
-            ((uint64_t *)row)[0] = temp;
60
-            ((uint64_t *)row)[1] = temp;
61
-            return;
62
-        }
63
-#else
64
-        if (!(((uint32_t*)row)[1] |
65
-              ((uint32_t*)row)[2] |
66
-              ((uint32_t*)row)[3] |
67
-              row[1])) {
68
-            uint32_t temp = (row[0] << 3) & 0xffff;
69
-            temp += temp << 16;
70
-            ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
71
-                ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
72
-            return;
73
-        }
74
-#endif
75
-
76
-        a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
77
-        a1 = a0;
78
-        a2 = a0;
79
-        a3 = a0;
80
-
81
-        /* no need to optimize : gcc does it */
82
-        a0 += W2 * row[2];
83
-        a1 += W6 * row[2];
84
-        a2 -= W6 * row[2];
85
-        a3 -= W2 * row[2];
86
-
87
-        b0 = MUL16(W1, row[1]);
88
-        MAC16(b0, W3, row[3]);
89
-        b1 = MUL16(W3, row[1]);
90
-        MAC16(b1, -W7, row[3]);
91
-        b2 = MUL16(W5, row[1]);
92
-        MAC16(b2, -W1, row[3]);
93
-        b3 = MUL16(W7, row[1]);
94
-        MAC16(b3, -W5, row[3]);
95
-
96
-        if (AV_RN64A(row + 4)) {
97
-            a0 += W4*row[4] + W6*row[6];
98
-            a1 += - W4*row[4] - W2*row[6];
99
-            a2 += - W4*row[4] + W2*row[6];
100
-            a3 += W4*row[4] - W6*row[6];
101
-
102
-            MAC16(b0, W5, row[5]);
103
-            MAC16(b0, W7, row[7]);
104
-
105
-            MAC16(b1, -W1, row[5]);
106
-            MAC16(b1, -W5, row[7]);
107
-
108
-            MAC16(b2, W7, row[5]);
109
-            MAC16(b2, W3, row[7]);
110
-
111
-            MAC16(b3, W3, row[5]);
112
-            MAC16(b3, -W1, row[7]);
113
-        }
114
-
115
-        row[0] = (a0 + b0) >> ROW_SHIFT;
116
-        row[7] = (a0 - b0) >> ROW_SHIFT;
117
-        row[1] = (a1 + b1) >> ROW_SHIFT;
118
-        row[6] = (a1 - b1) >> ROW_SHIFT;
119
-        row[2] = (a2 + b2) >> ROW_SHIFT;
120
-        row[5] = (a2 - b2) >> ROW_SHIFT;
121
-        row[3] = (a3 + b3) >> ROW_SHIFT;
122
-        row[4] = (a3 - b3) >> ROW_SHIFT;
123
-}
124
-
125
-static inline void idctSparseColPut (uint8_t *dest, int line_size,
126
-                                     DCTELEM * col)
127
-{
128
-        int a0, a1, a2, a3, b0, b1, b2, b3;
129
-        uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
130
-
131
-        /* XXX: I did that only to give same values as previous code */
132
-        a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
133
-        a1 = a0;
134
-        a2 = a0;
135
-        a3 = a0;
136
-
137
-        a0 +=  + W2*col[8*2];
138
-        a1 +=  + W6*col[8*2];
139
-        a2 +=  - W6*col[8*2];
140
-        a3 +=  - W2*col[8*2];
141
-
142
-        b0 = MUL16(W1, col[8*1]);
143
-        b1 = MUL16(W3, col[8*1]);
144
-        b2 = MUL16(W5, col[8*1]);
145
-        b3 = MUL16(W7, col[8*1]);
146
-
147
-        MAC16(b0, + W3, col[8*3]);
148
-        MAC16(b1, - W7, col[8*3]);
149
-        MAC16(b2, - W1, col[8*3]);
150
-        MAC16(b3, - W5, col[8*3]);
151
-
152
-        if(col[8*4]){
153
-            a0 += + W4*col[8*4];
154
-            a1 += - W4*col[8*4];
155
-            a2 += - W4*col[8*4];
156
-            a3 += + W4*col[8*4];
157
-        }
158
-
159
-        if (col[8*5]) {
160
-            MAC16(b0, + W5, col[8*5]);
161
-            MAC16(b1, - W1, col[8*5]);
162
-            MAC16(b2, + W7, col[8*5]);
163
-            MAC16(b3, + W3, col[8*5]);
164
-        }
165
-
166
-        if(col[8*6]){
167
-            a0 += + W6*col[8*6];
168
-            a1 += - W2*col[8*6];
169
-            a2 += + W2*col[8*6];
170
-            a3 += - W6*col[8*6];
171
-        }
172
-
173
-        if (col[8*7]) {
174
-            MAC16(b0, + W7, col[8*7]);
175
-            MAC16(b1, - W5, col[8*7]);
176
-            MAC16(b2, + W3, col[8*7]);
177
-            MAC16(b3, - W1, col[8*7]);
178
-        }
179
-
180
-        dest[0] = cm[(a0 + b0) >> COL_SHIFT];
181
-        dest += line_size;
182
-        dest[0] = cm[(a1 + b1) >> COL_SHIFT];
183
-        dest += line_size;
184
-        dest[0] = cm[(a2 + b2) >> COL_SHIFT];
185
-        dest += line_size;
186
-        dest[0] = cm[(a3 + b3) >> COL_SHIFT];
187
-        dest += line_size;
188
-        dest[0] = cm[(a3 - b3) >> COL_SHIFT];
189
-        dest += line_size;
190
-        dest[0] = cm[(a2 - b2) >> COL_SHIFT];
191
-        dest += line_size;
192
-        dest[0] = cm[(a1 - b1) >> COL_SHIFT];
193
-        dest += line_size;
194
-        dest[0] = cm[(a0 - b0) >> COL_SHIFT];
195
-}
196
-
197
-static inline void idctSparseColAdd (uint8_t *dest, int line_size,
198
-                                     DCTELEM * col)
199
-{
200
-        int a0, a1, a2, a3, b0, b1, b2, b3;
201
-        uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
202
-
203
-        /* XXX: I did that only to give same values as previous code */
204
-        a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
205
-        a1 = a0;
206
-        a2 = a0;
207
-        a3 = a0;
208
-
209
-        a0 +=  + W2*col[8*2];
210
-        a1 +=  + W6*col[8*2];
211
-        a2 +=  - W6*col[8*2];
212
-        a3 +=  - W2*col[8*2];
213
-
214
-        b0 = MUL16(W1, col[8*1]);
215
-        b1 = MUL16(W3, col[8*1]);
216
-        b2 = MUL16(W5, col[8*1]);
217
-        b3 = MUL16(W7, col[8*1]);
34
+#define BIT_DEPTH 8
35
+#include "simple_idct_template.c"
36
+#undef BIT_DEPTH
218 37
 
219
-        MAC16(b0, + W3, col[8*3]);
220
-        MAC16(b1, - W7, col[8*3]);
221
-        MAC16(b2, - W1, col[8*3]);
222
-        MAC16(b3, - W5, col[8*3]);
223
-
224
-        if(col[8*4]){
225
-            a0 += + W4*col[8*4];
226
-            a1 += - W4*col[8*4];
227
-            a2 += - W4*col[8*4];
228
-            a3 += + W4*col[8*4];
229
-        }
230
-
231
-        if (col[8*5]) {
232
-            MAC16(b0, + W5, col[8*5]);
233
-            MAC16(b1, - W1, col[8*5]);
234
-            MAC16(b2, + W7, col[8*5]);
235
-            MAC16(b3, + W3, col[8*5]);
236
-        }
237
-
238
-        if(col[8*6]){
239
-            a0 += + W6*col[8*6];
240
-            a1 += - W2*col[8*6];
241
-            a2 += + W2*col[8*6];
242
-            a3 += - W6*col[8*6];
243
-        }
244
-
245
-        if (col[8*7]) {
246
-            MAC16(b0, + W7, col[8*7]);
247
-            MAC16(b1, - W5, col[8*7]);
248
-            MAC16(b2, + W3, col[8*7]);
249
-            MAC16(b3, - W1, col[8*7]);
250
-        }
251
-
252
-        dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)];
253
-        dest += line_size;
254
-        dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)];
255
-        dest += line_size;
256
-        dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)];
257
-        dest += line_size;
258
-        dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)];
259
-        dest += line_size;
260
-        dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)];
261
-        dest += line_size;
262
-        dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)];
263
-        dest += line_size;
264
-        dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
265
-        dest += line_size;
266
-        dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
267
-}
268
-
269
-static inline void idctSparseCol (DCTELEM * col)
270
-{
271
-        int a0, a1, a2, a3, b0, b1, b2, b3;
272
-
273
-        /* XXX: I did that only to give same values as previous code */
274
-        a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
275
-        a1 = a0;
276
-        a2 = a0;
277
-        a3 = a0;
278
-
279
-        a0 +=  + W2*col[8*2];
280
-        a1 +=  + W6*col[8*2];
281
-        a2 +=  - W6*col[8*2];
282
-        a3 +=  - W2*col[8*2];
283
-
284
-        b0 = MUL16(W1, col[8*1]);
285
-        b1 = MUL16(W3, col[8*1]);
286
-        b2 = MUL16(W5, col[8*1]);
287
-        b3 = MUL16(W7, col[8*1]);
288
-
289
-        MAC16(b0, + W3, col[8*3]);
290
-        MAC16(b1, - W7, col[8*3]);
291
-        MAC16(b2, - W1, col[8*3]);
292
-        MAC16(b3, - W5, col[8*3]);
293
-
294
-        if(col[8*4]){
295
-            a0 += + W4*col[8*4];
296
-            a1 += - W4*col[8*4];
297
-            a2 += - W4*col[8*4];
298
-            a3 += + W4*col[8*4];
299
-        }
300
-
301
-        if (col[8*5]) {
302
-            MAC16(b0, + W5, col[8*5]);
303
-            MAC16(b1, - W1, col[8*5]);
304
-            MAC16(b2, + W7, col[8*5]);
305
-            MAC16(b3, + W3, col[8*5]);
306
-        }
307
-
308
-        if(col[8*6]){
309
-            a0 += + W6*col[8*6];
310
-            a1 += - W2*col[8*6];
311
-            a2 += + W2*col[8*6];
312
-            a3 += - W6*col[8*6];
313
-        }
314
-
315
-        if (col[8*7]) {
316
-            MAC16(b0, + W7, col[8*7]);
317
-            MAC16(b1, - W5, col[8*7]);
318
-            MAC16(b2, + W3, col[8*7]);
319
-            MAC16(b3, - W1, col[8*7]);
320
-        }
321
-
322
-        col[0 ] = ((a0 + b0) >> COL_SHIFT);
323
-        col[8 ] = ((a1 + b1) >> COL_SHIFT);
324
-        col[16] = ((a2 + b2) >> COL_SHIFT);
325
-        col[24] = ((a3 + b3) >> COL_SHIFT);
326
-        col[32] = ((a3 - b3) >> COL_SHIFT);
327
-        col[40] = ((a2 - b2) >> COL_SHIFT);
328
-        col[48] = ((a1 - b1) >> COL_SHIFT);
329
-        col[56] = ((a0 - b0) >> COL_SHIFT);
330
-}
331
-
332
-void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
333
-{
334
-    int i;
335
-    for(i=0; i<8; i++)
336
-        idctRowCondDC(block + i*8);
337
-
338
-    for(i=0; i<8; i++)
339
-        idctSparseColPut(dest + i, line_size, block + i);
340
-}
341
-
342
-void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
343
-{
344
-    int i;
345
-    for(i=0; i<8; i++)
346
-        idctRowCondDC(block + i*8);
347
-
348
-    for(i=0; i<8; i++)
349
-        idctSparseColAdd(dest + i, line_size, block + i);
350
-}
351
-
352
-void ff_simple_idct(DCTELEM *block)
353
-{
354
-    int i;
355
-    for(i=0; i<8; i++)
356
-        idctRowCondDC(block + i*8);
357
-
358
-    for(i=0; i<8; i++)
359
-        idctSparseCol(block + i);
360
-}
38
+#define BIT_DEPTH 10
39
+#include "simple_idct_template.c"
40
+#undef BIT_DEPTH
361 41
 
362 42
 /* 2x4x8 idct */
363 43
 
... ...
@@ -428,7 +108,7 @@ void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
428 428
 
429 429
     /* IDCT8 on each line */
430 430
     for(i=0; i<8; i++) {
431
-        idctRowCondDC(block + i*8);
431
+        idctRowCondDC_8(block + i*8);
432 432
     }
433 433
 
434 434
     /* IDCT4 and store */
... ...
@@ -503,7 +183,7 @@ void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
503 503
 
504 504
     /* IDCT8 on each line */
505 505
     for(i=0; i<4; i++) {
506
-        idctRowCondDC(block + i*8);
506
+        idctRowCondDC_8(block + i*8);
507 507
     }
508 508
 
509 509
     /* IDCT4 and store */
... ...
@@ -523,7 +203,7 @@ void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
523 523
 
524 524
     /* IDCT8 and store */
525 525
     for(i=0; i<4; i++){
526
-        idctSparseColAdd(dest + i, line_size, block + i);
526
+        idctSparseColAdd_8(dest + i, line_size, block + i);
527 527
     }
528 528
 }
529 529
 
... ...
@@ -31,12 +31,17 @@
31 31
 #include <stdint.h>
32 32
 #include "dsputil.h"
33 33
 
34
-void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
35
-void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
34
+void ff_simple_idct_put_8(uint8_t *dest, int line_size, DCTELEM *block);
35
+void ff_simple_idct_add_8(uint8_t *dest, int line_size, DCTELEM *block);
36
+void ff_simple_idct_8(DCTELEM *block);
37
+
38
+void ff_simple_idct_put_10(uint8_t *dest, int line_size, DCTELEM *block);
39
+void ff_simple_idct_add_10(uint8_t *dest, int line_size, DCTELEM *block);
40
+void ff_simple_idct_10(DCTELEM *block);
41
+
36 42
 void ff_simple_idct_mmx(int16_t *block);
37 43
 void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
38 44
 void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
39
-void ff_simple_idct(DCTELEM *block);
40 45
 
41 46
 void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block);
42 47
 
43 48
new file mode 100644
... ...
@@ -0,0 +1,316 @@
0
+/*
1
+ * Simple IDCT
2
+ *
3
+ * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at>
4
+ *
5
+ * This file is part of Libav.
6
+ *
7
+ * Libav is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * Libav is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with Libav; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ */
21
+
22
+/**
23
+ * @file
24
+ * simpleidct in C.
25
+ */
26
+
27
+/*
28
+  based upon some outcommented c code from mpeg2dec (idct_mmx.c
29
+  written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
30
+ */
31
+
32
+#include "bit_depth_template.c"
33
+
34
+#undef W1
35
+#undef W2
36
+#undef W3
37
+#undef W4
38
+#undef W5
39
+#undef W6
40
+#undef W7
41
+#undef ROW_SHIFT
42
+#undef COL_SHIFT
43
+#undef DC_SHIFT
44
+#undef MUL
45
+#undef MAC
46
+
47
+#if BIT_DEPTH == 8
48
+
49
+#define W1  22725  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
50
+#define W2  21407  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
51
+#define W3  19266  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
52
+#define W4  16383  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
53
+#define W5  12873  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
54
+#define W6  8867   //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
55
+#define W7  4520   //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
56
+
57
+#define ROW_SHIFT 11
58
+#define COL_SHIFT 20
59
+#define DC_SHIFT 3
60
+
61
+#define MUL(a, b)    MUL16(a, b)
62
+#define MAC(a, b, c) MAC16(a, b, c)
63
+
64
+#elif BIT_DEPTH == 10
65
+
66
+#define W1 90901
67
+#define W2 85627
68
+#define W3 77062
69
+#define W4 65535
70
+#define W5 51491
71
+#define W6 35468
72
+#define W7 18081
73
+
74
+#define ROW_SHIFT 15
75
+#define COL_SHIFT 20
76
+#define DC_SHIFT 1
77
+
78
+#define MUL(a, b)    ((a) * (b))
79
+#define MAC(a, b, c) ((a) += (b) * (c))
80
+
81
+#else
82
+
83
+#error "Unsupported bitdepth"
84
+
85
+#endif
86
+
87
+static inline void FUNC(idctRowCondDC)(DCTELEM *row)
88
+{
89
+    int a0, a1, a2, a3, b0, b1, b2, b3;
90
+
91
+#if HAVE_FAST_64BIT
92
+#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
93
+    if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
94
+        uint64_t temp = (row[0] << DC_SHIFT) & 0xffff;
95
+        temp += temp << 16;
96
+        temp += temp << 32;
97
+        ((uint64_t *)row)[0] = temp;
98
+        ((uint64_t *)row)[1] = temp;
99
+        return;
100
+    }
101
+#else
102
+    if (!(((uint32_t*)row)[1] |
103
+          ((uint32_t*)row)[2] |
104
+          ((uint32_t*)row)[3] |
105
+          row[1])) {
106
+        uint32_t temp = (row[0] << DC_SHIFT) & 0xffff;
107
+        temp += temp << 16;
108
+        ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
109
+            ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
110
+        return;
111
+    }
112
+#endif
113
+
114
+    a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
115
+    a1 = a0;
116
+    a2 = a0;
117
+    a3 = a0;
118
+
119
+    a0 += W2 * row[2];
120
+    a1 += W6 * row[2];
121
+    a2 -= W6 * row[2];
122
+    a3 -= W2 * row[2];
123
+
124
+    b0 = MUL(W1, row[1]);
125
+    MAC(b0, W3, row[3]);
126
+    b1 = MUL(W3, row[1]);
127
+    MAC(b1, -W7, row[3]);
128
+    b2 = MUL(W5, row[1]);
129
+    MAC(b2, -W1, row[3]);
130
+    b3 = MUL(W7, row[1]);
131
+    MAC(b3, -W5, row[3]);
132
+
133
+    if (AV_RN64A(row + 4)) {
134
+        a0 +=   W4*row[4] + W6*row[6];
135
+        a1 += - W4*row[4] - W2*row[6];
136
+        a2 += - W4*row[4] + W2*row[6];
137
+        a3 +=   W4*row[4] - W6*row[6];
138
+
139
+        MAC(b0,  W5, row[5]);
140
+        MAC(b0,  W7, row[7]);
141
+
142
+        MAC(b1, -W1, row[5]);
143
+        MAC(b1, -W5, row[7]);
144
+
145
+        MAC(b2,  W7, row[5]);
146
+        MAC(b2,  W3, row[7]);
147
+
148
+        MAC(b3,  W3, row[5]);
149
+        MAC(b3, -W1, row[7]);
150
+    }
151
+
152
+    row[0] = (a0 + b0) >> ROW_SHIFT;
153
+    row[7] = (a0 - b0) >> ROW_SHIFT;
154
+    row[1] = (a1 + b1) >> ROW_SHIFT;
155
+    row[6] = (a1 - b1) >> ROW_SHIFT;
156
+    row[2] = (a2 + b2) >> ROW_SHIFT;
157
+    row[5] = (a2 - b2) >> ROW_SHIFT;
158
+    row[3] = (a3 + b3) >> ROW_SHIFT;
159
+    row[4] = (a3 - b3) >> ROW_SHIFT;
160
+}
161
+
162
+#define IDCT_COLS do {                                  \
163
+        a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); \
164
+        a1 = a0;                                        \
165
+        a2 = a0;                                        \
166
+        a3 = a0;                                        \
167
+                                                        \
168
+        a0 +=  W2*col[8*2];                             \
169
+        a1 +=  W6*col[8*2];                             \
170
+        a2 += -W6*col[8*2];                             \
171
+        a3 += -W2*col[8*2];                             \
172
+                                                        \
173
+        b0 = MUL(W1, col[8*1]);                         \
174
+        b1 = MUL(W3, col[8*1]);                         \
175
+        b2 = MUL(W5, col[8*1]);                         \
176
+        b3 = MUL(W7, col[8*1]);                         \
177
+                                                        \
178
+        MAC(b0,  W3, col[8*3]);                         \
179
+        MAC(b1, -W7, col[8*3]);                         \
180
+        MAC(b2, -W1, col[8*3]);                         \
181
+        MAC(b3, -W5, col[8*3]);                         \
182
+                                                        \
183
+        if (col[8*4]) {                                 \
184
+            a0 +=  W4*col[8*4];                         \
185
+            a1 += -W4*col[8*4];                         \
186
+            a2 += -W4*col[8*4];                         \
187
+            a3 +=  W4*col[8*4];                         \
188
+        }                                               \
189
+                                                        \
190
+        if (col[8*5]) {                                 \
191
+            MAC(b0,  W5, col[8*5]);                     \
192
+            MAC(b1, -W1, col[8*5]);                     \
193
+            MAC(b2,  W7, col[8*5]);                     \
194
+            MAC(b3,  W3, col[8*5]);                     \
195
+        }                                               \
196
+                                                        \
197
+        if (col[8*6]) {                                 \
198
+            a0 +=  W6*col[8*6];                         \
199
+            a1 += -W2*col[8*6];                         \
200
+            a2 +=  W2*col[8*6];                         \
201
+            a3 += -W6*col[8*6];                         \
202
+        }                                               \
203
+                                                        \
204
+        if (col[8*7]) {                                 \
205
+            MAC(b0,  W7, col[8*7]);                     \
206
+            MAC(b1, -W5, col[8*7]);                     \
207
+            MAC(b2,  W3, col[8*7]);                     \
208
+            MAC(b3, -W1, col[8*7]);                     \
209
+        }                                               \
210
+    } while (0)
211
+
212
+static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,
213
+                                          DCTELEM *col)
214
+{
215
+    int a0, a1, a2, a3, b0, b1, b2, b3;
216
+    INIT_CLIP;
217
+
218
+    IDCT_COLS;
219
+
220
+    dest[0] = CLIP((a0 + b0) >> COL_SHIFT);
221
+    dest += line_size;
222
+    dest[0] = CLIP((a1 + b1) >> COL_SHIFT);
223
+    dest += line_size;
224
+    dest[0] = CLIP((a2 + b2) >> COL_SHIFT);
225
+    dest += line_size;
226
+    dest[0] = CLIP((a3 + b3) >> COL_SHIFT);
227
+    dest += line_size;
228
+    dest[0] = CLIP((a3 - b3) >> COL_SHIFT);
229
+    dest += line_size;
230
+    dest[0] = CLIP((a2 - b2) >> COL_SHIFT);
231
+    dest += line_size;
232
+    dest[0] = CLIP((a1 - b1) >> COL_SHIFT);
233
+    dest += line_size;
234
+    dest[0] = CLIP((a0 - b0) >> COL_SHIFT);
235
+}
236
+
237
+static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size,
238
+                                          DCTELEM *col)
239
+{
240
+    int a0, a1, a2, a3, b0, b1, b2, b3;
241
+    INIT_CLIP;
242
+
243
+    IDCT_COLS;
244
+
245
+    dest[0] = CLIP(dest[0] + ((a0 + b0) >> COL_SHIFT));
246
+    dest += line_size;
247
+    dest[0] = CLIP(dest[0] + ((a1 + b1) >> COL_SHIFT));
248
+    dest += line_size;
249
+    dest[0] = CLIP(dest[0] + ((a2 + b2) >> COL_SHIFT));
250
+    dest += line_size;
251
+    dest[0] = CLIP(dest[0] + ((a3 + b3) >> COL_SHIFT));
252
+    dest += line_size;
253
+    dest[0] = CLIP(dest[0] + ((a3 - b3) >> COL_SHIFT));
254
+    dest += line_size;
255
+    dest[0] = CLIP(dest[0] + ((a2 - b2) >> COL_SHIFT));
256
+    dest += line_size;
257
+    dest[0] = CLIP(dest[0] + ((a1 - b1) >> COL_SHIFT));
258
+    dest += line_size;
259
+    dest[0] = CLIP(dest[0] + ((a0 - b0) >> COL_SHIFT));
260
+}
261
+
262
+static inline void FUNC(idctSparseCol)(DCTELEM *col)
263
+{
264
+    int a0, a1, a2, a3, b0, b1, b2, b3;
265
+
266
+    IDCT_COLS;
267
+
268
+    col[0 ] = ((a0 + b0) >> COL_SHIFT);
269
+    col[8 ] = ((a1 + b1) >> COL_SHIFT);
270
+    col[16] = ((a2 + b2) >> COL_SHIFT);
271
+    col[24] = ((a3 + b3) >> COL_SHIFT);
272
+    col[32] = ((a3 - b3) >> COL_SHIFT);
273
+    col[40] = ((a2 - b2) >> COL_SHIFT);
274
+    col[48] = ((a1 - b1) >> COL_SHIFT);
275
+    col[56] = ((a0 - b0) >> COL_SHIFT);
276
+}
277
+
278
+void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block)
279
+{
280
+    pixel *dest = (pixel *)dest_;
281
+    int i;
282
+
283
+    line_size /= sizeof(pixel);
284
+
285
+    for (i = 0; i < 8; i++)
286
+        FUNC(idctRowCondDC)(block + i*8);
287
+
288
+    for (i = 0; i < 8; i++)
289
+        FUNC(idctSparseColPut)(dest + i, line_size, block + i);
290
+}
291
+
292
+void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block)
293
+{
294
+    pixel *dest = (pixel *)dest_;
295
+    int i;
296
+
297
+    line_size /= sizeof(pixel);
298
+
299
+    for (i = 0; i < 8; i++)
300
+        FUNC(idctRowCondDC)(block + i*8);
301
+
302
+    for (i = 0; i < 8; i++)
303
+        FUNC(idctSparseColAdd)(dest + i, line_size, block + i);
304
+}
305
+
306
+void FUNC(ff_simple_idct)(DCTELEM *block)
307
+{
308
+    int i;
309
+
310
+    for (i = 0; i < 8; i++)
311
+        FUNC(idctRowCondDC)(block + i*8);
312
+
313
+    for (i = 0; i < 8; i++)
314
+        FUNC(idctSparseCol)(block + i);
315
+}
... ...
@@ -3956,7 +3956,8 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx)
3956 3956
   const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
3957 3957
 
3958 3958
   if (accel & ACCEL_SPARC_VIS) {
3959
-      if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){
3959
+      if (avctx->bits_per_raw_sample <= 8 &&
3960
+          avctx->idct_algo == FF_IDCT_SIMPLEVIS) {
3960 3961
           c->idct_put = ff_simple_idct_put_vis;
3961 3962
           c->idct_add = ff_simple_idct_add_vis;
3962 3963
           c->idct     = ff_simple_idct_vis;
... ...
@@ -337,11 +337,11 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
337 337
     v->res_fasttx = get_bits1(gb);
338 338
     if (!v->res_fasttx)
339 339
     {
340
-        v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct;
340
+        v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct_8;
341 341
         v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
342 342
         v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
343 343
         v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
344
-        v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add;
344
+        v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_8;
345 345
         v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
346 346
         v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
347 347
         v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
... ...
@@ -2369,7 +2369,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
2369 2369
     if (mm_flags & AV_CPU_FLAG_MMX) {
2370 2370
         const int idct_algo= avctx->idct_algo;
2371 2371
 
2372
-        if(avctx->lowres==0){
2372
+        if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
2373 2373
             if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
2374 2374
                 c->idct_put= ff_simple_idct_put_mmx;
2375 2375
                 c->idct_add= ff_simple_idct_add_mmx;
... ...
@@ -182,11 +182,13 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt)
182 182
         || (x)==PIX_FMT_YUV420P9LE    \
183 183
         || (x)==PIX_FMT_YUV420P10LE   \
184 184
         || (x)==PIX_FMT_YUV420P16LE   \
185
+        || (x)==PIX_FMT_YUV422P10LE   \
185 186
         || (x)==PIX_FMT_YUV422P16LE   \
186 187
         || (x)==PIX_FMT_YUV444P16LE   \
187 188
         || (x)==PIX_FMT_YUV422P10BE   \
188 189
         || (x)==PIX_FMT_YUV420P9BE    \
189 190
         || (x)==PIX_FMT_YUV420P10BE   \
191
+        || (x)==PIX_FMT_YUV422P10BE   \
190 192
         || (x)==PIX_FMT_YUV420P16BE   \
191 193
         || (x)==PIX_FMT_YUV422P16BE   \
192 194
         || (x)==PIX_FMT_YUV444P16BE   \