Browse code

Merge remote branch 'qatar/master'

* qatar/master:
ac3enc: ARM optimised ac3_compute_matissa_size
ac3: armv6 optimised bit_alloc_calc_bap
fate: simplify fft test rules
avio: document avio_alloc_context.
lavf: make compute_chapters_end less picky.
sierravmd: fix Indeo3 videos
FFT: simplify fft8()
fate: add fixed-point fft/mdct tests
Fixed-point support in fft-test
ape: check that number of seektable entries is equal to number of frames

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

Michael Niedermayer authored on 2011/04/02 08:51:44
Showing 13 changed files
... ...
@@ -661,7 +661,7 @@ SKIPHEADERS                            += mpegaudio3.h
661 661
 
662 662
 EXAMPLES = api
663 663
 
664
-TESTPROGS = cabac dct eval fft h264 iirfilter rangecoder snow
664
+TESTPROGS = cabac dct eval fft fft-fixed h264 iirfilter rangecoder snow
665 665
 TESTPROGS-$(HAVE_MMX) += motion
666 666
 TESTOBJS = dctref.o
667 667
 
... ...
@@ -1,6 +1,10 @@
1
-OBJS-$(CONFIG_AC3DSP)                  += arm/ac3dsp_init_arm.o
1
+OBJS-$(CONFIG_AC3DSP)                  += arm/ac3dsp_init_arm.o         \
2
+                                          arm/ac3dsp_arm.o
3
+
2 4
 OBJS-$(CONFIG_DCA_DECODER)             += arm/dcadsp_init_arm.o         \
3 5
 
6
+ARMV6-OBJS-$(CONFIG_AC3DSP)            += arm/ac3dsp_armv6.o
7
+
4 8
 OBJS-$(CONFIG_VP5_DECODER)             += arm/vp56dsp_init_arm.o
5 9
 OBJS-$(CONFIG_VP6_DECODER)             += arm/vp56dsp_init_arm.o
6 10
 OBJS-$(CONFIG_VP8_DECODER)             += arm/vp8dsp_init_arm.o
7 11
new file mode 100644
... ...
@@ -0,0 +1,52 @@
0
+/*
1
+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
2
+ *
3
+ * This file is part of Libav.
4
+ *
5
+ * Libav is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * Libav is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with Libav; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#include "asm.S"
21
+
22
+function ff_ac3_compute_mantissa_size_arm, export=1
23
+        push            {r4-r8,lr}
24
+        ldm             r0,  {r4-r8}
25
+        mov             r3,  r0
26
+        mov             r0,  #0
27
+1:
28
+        ldrb            lr,  [r1], #1
29
+        subs            r2,  r2,  #1
30
+        blt             2f
31
+        cmp             lr,  #4
32
+        bgt             3f
33
+        subs            lr,  lr,  #1
34
+        addlt           r4,  r4,  #1
35
+        addeq           r5,  r5,  #1
36
+        ble             1b
37
+        subs            lr,  lr,  #2
38
+        addlt           r6,  r6,  #1
39
+        addeq           r7,  r7,  #1
40
+        addgt           r8,  r8,  #1
41
+        b               1b
42
+3:
43
+        cmp             lr,  #14
44
+        sublt           lr,  lr,  #1
45
+        addgt           r0,  r0,  #16
46
+        addle           r0,  r0,  lr
47
+        b               1b
48
+2:
49
+        stm             r3,  {r4-r8}
50
+        pop             {r4-r8,pc}
51
+endfunc
0 52
new file mode 100644
... ...
@@ -0,0 +1,83 @@
0
+/*
1
+ * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
2
+ *
3
+ * This file is part of Libav.
4
+ *
5
+ * Libav is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * Libav is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with Libav; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#include "asm.S"
21
+
22
+function ff_ac3_bit_alloc_calc_bap_armv6, export=1
23
+        ldr             r12, [sp]
24
+        cmp             r12, #-960
25
+        beq             4f
26
+        push            {r4-r11,lr}
27
+        add             r5,  sp,  #40
28
+        movrel          r4,  X(ff_ac3_bin_to_band_tab)
29
+        movrel          lr,  X(ff_ac3_band_start_tab)
30
+        ldm             r5,  {r5-r7}
31
+        ldrb            r4,  [r4, r2]
32
+        add             r1,  r1,  r2,  lsl #1           @ psd + start
33
+        add             r0,  r0,  r4,  lsl #1           @ mask + band
34
+        add             r4,  lr,  r4
35
+        add             r7,  r7,  r2                    @ bap + start
36
+        ldrb            r10, [r4], #1
37
+1:
38
+        ldrsh           r9,  [r0], #2                   @ mask[band]
39
+        movw            r8,  #0x1fe0
40
+        sub             r9,  r9,  r12                   @   - snr_offset
41
+        mov             r11, r10
42
+        ldrb            r10, [r4], #1                   @ band_start_tab[band++]
43
+        subs            r9,  r9,  r5                    @   - floor
44
+        movlt           r9,  #0
45
+        cmp             r10, r3                         @   - end
46
+        and             r9,  r9,  r8                    @   & 0x1fe0
47
+        subgt           r8,  r3,  r11
48
+        suble           r8,  r10, r11
49
+        add             r9,  r9,  r5                    @   + floor => m
50
+        tst             r8,  #1
51
+        add             r2,  r7,  r8
52
+        bne             3f
53
+        b               5f
54
+2:
55
+        ldrsh           r8,  [r1], #2
56
+        ldrsh           lr,  [r1], #2
57
+        sub             r8,  r8,  r9
58
+        sub             lr,  lr,  r9
59
+        usat            r8,  #6,  r8,  asr #5           @ address
60
+        usat            lr,  #6,  lr,  asr #5
61
+        ldrb            r8,  [r6, r8]                   @ bap_tab[address]
62
+        ldrb            lr,  [r6, lr]
63
+        strb            r8,  [r7], #1                   @ bap[bin]
64
+        strb            lr,  [r7], #1
65
+5:      cmp             r7,  r2
66
+        blo             2b
67
+        cmp             r3,  r11
68
+        bgt             1b
69
+        pop             {r4-r11,pc}
70
+3:
71
+        ldrsh           r8,  [r1], #2                   @ psd[bin]
72
+        sub             r8,  r8,  r9                    @   - m
73
+        usat            r8,  #6,  r8,  asr #5           @ address
74
+        ldrb            r8,  [r6, r8]                   @ bap_tab[address]
75
+        strb            r8,  [r7], #1                   @ bap[bin]
76
+        b               5b
77
+4:
78
+        ldr             r0,  [sp, #12]
79
+        mov             r1,  #0
80
+        mov             r2,  #256
81
+        b               memset
82
+endfunc
... ...
@@ -29,8 +29,21 @@ void ff_ac3_lshift_int16_neon(int16_t *src, unsigned len, unsigned shift);
29 29
 void ff_ac3_rshift_int32_neon(int32_t *src, unsigned len, unsigned shift);
30 30
 void ff_float_to_fixed24_neon(int32_t *dst, const float *src, unsigned int len);
31 31
 
32
+void ff_ac3_bit_alloc_calc_bap_armv6(int16_t *mask, int16_t *psd,
33
+                                     int start, int end,
34
+                                     int snr_offset, int floor,
35
+                                     const uint8_t *bap_tab, uint8_t *bap);
36
+
37
+int ff_ac3_compute_mantissa_size_arm(int cnt[5], uint8_t *bap, int nb_coefs);
38
+
32 39
 av_cold void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact)
33 40
 {
41
+    c->compute_mantissa_size     = ff_ac3_compute_mantissa_size_arm;
42
+
43
+    if (HAVE_ARMV6) {
44
+        c->bit_alloc_calc_bap    = ff_ac3_bit_alloc_calc_bap_armv6;
45
+    }
46
+
34 47
     if (HAVE_NEON) {
35 48
         c->ac3_exponent_min      = ff_ac3_exponent_min_neon;
36 49
         c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_neon;
37 50
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFMpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFMpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#define CONFIG_FFT_FLOAT 0
19
+#include "fft-test.c"
... ...
@@ -27,8 +27,10 @@
27 27
 #include "libavutil/lfg.h"
28 28
 #include "libavutil/log.h"
29 29
 #include "fft.h"
30
+#if CONFIG_FFT_FLOAT
30 31
 #include "dct.h"
31 32
 #include "rdft.h"
33
+#endif
32 34
 #include <math.h>
33 35
 #include <unistd.h>
34 36
 #include <sys/time.h>
... ...
@@ -47,7 +49,19 @@
47 47
    pim += (MUL16(are, bim) + MUL16(bre, aim));\
48 48
 }
49 49
 
50
-FFTComplex *exptab;
50
+#if CONFIG_FFT_FLOAT
51
+#   define RANGE 1.0
52
+#   define REF_SCALE(x, bits)  (x)
53
+#   define FMT "%10.6f"
54
+#else
55
+#   define RANGE 16384
56
+#   define REF_SCALE(x, bits) ((x) / (1<<(bits)))
57
+#   define FMT "%6d"
58
+#endif
59
+
60
+struct {
61
+    float re, im;
62
+} *exptab;
51 63
 
52 64
 static void fft_ref_init(int nbits, int inverse)
53 65
 {
... ...
@@ -55,7 +69,7 @@ static void fft_ref_init(int nbits, int inverse)
55 55
     double c1, s1, alpha;
56 56
 
57 57
     n = 1 << nbits;
58
-    exptab = av_malloc((n / 2) * sizeof(FFTComplex));
58
+    exptab = av_malloc((n / 2) * sizeof(*exptab));
59 59
 
60 60
     for (i = 0; i < (n/2); i++) {
61 61
         alpha = 2 * M_PI * (float)i / (float)n;
... ...
@@ -92,12 +106,12 @@ static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits)
92 92
             CMAC(tmp_re, tmp_im, c, s, q->re, q->im);
93 93
             q++;
94 94
         }
95
-        tabr[i].re = tmp_re;
96
-        tabr[i].im = tmp_im;
95
+        tabr[i].re = REF_SCALE(tmp_re, nbits);
96
+        tabr[i].im = REF_SCALE(tmp_im, nbits);
97 97
     }
98 98
 }
99 99
 
100
-static void imdct_ref(float *out, float *in, int nbits)
100
+static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
101 101
 {
102 102
     int n = 1<<nbits;
103 103
     int k, i, a;
... ...
@@ -110,12 +124,12 @@ static void imdct_ref(float *out, float *in, int nbits)
110 110
             f = cos(M_PI * a / (double)(2 * n));
111 111
             sum += f * in[k];
112 112
         }
113
-        out[i] = -sum;
113
+        out[i] = REF_SCALE(-sum, nbits - 2);
114 114
     }
115 115
 }
116 116
 
117 117
 /* NOTE: no normalisation by 1 / N is done */
118
-static void mdct_ref(float *output, float *input, int nbits)
118
+static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
119 119
 {
120 120
     int n = 1<<nbits;
121 121
     int k, i;
... ...
@@ -128,10 +142,11 @@ static void mdct_ref(float *output, float *input, int nbits)
128 128
             a = (2*M_PI*(2*i+1+n/2)*(2*k+1) / (4 * n));
129 129
             s += input[i] * cos(a);
130 130
         }
131
-        output[k] = s;
131
+        output[k] = REF_SCALE(s, nbits - 1);
132 132
     }
133 133
 }
134 134
 
135
+#if CONFIG_FFT_FLOAT
135 136
 static void idct_ref(float *output, float *input, int nbits)
136 137
 {
137 138
     int n = 1<<nbits;
... ...
@@ -164,11 +179,12 @@ static void dct_ref(float *output, float *input, int nbits)
164 164
         output[k] = s;
165 165
     }
166 166
 }
167
+#endif
167 168
 
168 169
 
169
-static float frandom(AVLFG *prng)
170
+static FFTSample frandom(AVLFG *prng)
170 171
 {
171
-    return (int16_t)av_lfg_get(prng) / 32768.0;
172
+    return (int16_t)av_lfg_get(prng) / 32768.0 * RANGE;
172 173
 }
173 174
 
174 175
 static int64_t gettime(void)
... ...
@@ -178,7 +194,7 @@ static int64_t gettime(void)
178 178
     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
179 179
 }
180 180
 
181
-static int check_diff(float *tab1, float *tab2, int n, double scale)
181
+static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
182 182
 {
183 183
     int i;
184 184
     double max= 0;
... ...
@@ -186,9 +202,9 @@ static int check_diff(float *tab1, float *tab2, int n, double scale)
186 186
     int err = 0;
187 187
 
188 188
     for (i = 0; i < n; i++) {
189
-        double e= fabsf(tab1[i] - (tab2[i] / scale));
189
+        double e = fabsf(tab1[i] - (tab2[i] / scale)) / RANGE;
190 190
         if (e >= 1e-3) {
191
-            av_log(NULL, AV_LOG_ERROR, "ERROR %5d: %10.6f %10.6f\n",
191
+            av_log(NULL, AV_LOG_ERROR, "ERROR %5d: "FMT" "FMT"\n",
192 192
                    i, tab1[i], tab2[i]);
193 193
             err = 1;
194 194
         }
... ...
@@ -233,8 +249,10 @@ int main(int argc, char **argv)
233 233
     int do_inverse = 0;
234 234
     FFTContext s1, *s = &s1;
235 235
     FFTContext m1, *m = &m1;
236
+#if CONFIG_FFT_FLOAT
236 237
     RDFTContext r1, *r = &r1;
237 238
     DCTContext d1, *d = &d1;
239
+#endif
238 240
     int fft_nbits, fft_size, fft_size_2;
239 241
     double scale = 1.0;
240 242
     AVLFG prng;
... ...
@@ -297,6 +315,7 @@ int main(int argc, char **argv)
297 297
         ff_fft_init(s, fft_nbits, do_inverse);
298 298
         fft_ref_init(fft_nbits, do_inverse);
299 299
         break;
300
+#if CONFIG_FFT_FLOAT
300 301
     case TRANSFORM_RDFT:
301 302
         if (do_inverse)
302 303
             av_log(NULL, AV_LOG_INFO,"IDFT_C2R");
... ...
@@ -312,6 +331,10 @@ int main(int argc, char **argv)
312 312
             av_log(NULL, AV_LOG_INFO,"DCT_II");
313 313
         ff_dct_init(d, fft_nbits, do_inverse ? DCT_III : DCT_II);
314 314
         break;
315
+#endif
316
+    default:
317
+        av_log(NULL, AV_LOG_ERROR, "Requested transform not supported\n");
318
+        return 1;
315 319
     }
316 320
     av_log(NULL, AV_LOG_INFO," %d test\n", fft_size);
317 321
 
... ...
@@ -328,15 +351,15 @@ int main(int argc, char **argv)
328 328
     switch (transform) {
329 329
     case TRANSFORM_MDCT:
330 330
         if (do_inverse) {
331
-            imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits);
332
-            m->imdct_calc(m, tab2, (float *)tab1);
333
-            err = check_diff((float *)tab_ref, tab2, fft_size, scale);
331
+            imdct_ref((FFTSample *)tab_ref, (FFTSample *)tab1, fft_nbits);
332
+            m->imdct_calc(m, tab2, (FFTSample *)tab1);
333
+            err = check_diff((FFTSample *)tab_ref, tab2, fft_size, scale);
334 334
         } else {
335
-            mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits);
335
+            mdct_ref((FFTSample *)tab_ref, (FFTSample *)tab1, fft_nbits);
336 336
 
337
-            m->mdct_calc(m, tab2, (float *)tab1);
337
+            m->mdct_calc(m, tab2, (FFTSample *)tab1);
338 338
 
339
-            err = check_diff((float *)tab_ref, tab2, fft_size / 2, scale);
339
+            err = check_diff((FFTSample *)tab_ref, tab2, fft_size / 2, scale);
340 340
         }
341 341
         break;
342 342
     case TRANSFORM_FFT:
... ...
@@ -345,8 +368,9 @@ int main(int argc, char **argv)
345 345
         s->fft_calc(s, tab);
346 346
 
347 347
         fft_ref(tab_ref, tab1, fft_nbits);
348
-        err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0);
348
+        err = check_diff((FFTSample *)tab_ref, (FFTSample *)tab, fft_size * 2, 1.0);
349 349
         break;
350
+#if CONFIG_FFT_FLOAT
350 351
     case TRANSFORM_RDFT:
351 352
         if (do_inverse) {
352 353
             tab1[         0].im = 0;
... ...
@@ -387,6 +411,7 @@ int main(int argc, char **argv)
387 387
         }
388 388
         err = check_diff((float *)tab_ref, (float *)tab, fft_size, 1.0);
389 389
         break;
390
+#endif
390 391
     }
391 392
 
392 393
     /* do a speed test */
... ...
@@ -404,15 +429,16 @@ int main(int argc, char **argv)
404 404
                 switch (transform) {
405 405
                 case TRANSFORM_MDCT:
406 406
                     if (do_inverse) {
407
-                        m->imdct_calc(m, (float *)tab, (float *)tab1);
407
+                        m->imdct_calc(m, (FFTSample *)tab, (FFTSample *)tab1);
408 408
                     } else {
409
-                        m->mdct_calc(m, (float *)tab, (float *)tab1);
409
+                        m->mdct_calc(m, (FFTSample *)tab, (FFTSample *)tab1);
410 410
                     }
411 411
                     break;
412 412
                 case TRANSFORM_FFT:
413 413
                     memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
414 414
                     s->fft_calc(s, tab);
415 415
                     break;
416
+#if CONFIG_FFT_FLOAT
416 417
                 case TRANSFORM_RDFT:
417 418
                     memcpy(tab2, tab1, fft_size * sizeof(FFTSample));
418 419
                     r->rdft_calc(r, tab2);
... ...
@@ -421,6 +447,7 @@ int main(int argc, char **argv)
421 421
                     memcpy(tab2, tab1, fft_size * sizeof(FFTSample));
422 422
                     d->dct_calc(d, tab2);
423 423
                     break;
424
+#endif
424 425
                 }
425 426
             }
426 427
             duration = gettime() - time_start;
... ...
@@ -441,12 +468,14 @@ int main(int argc, char **argv)
441 441
     case TRANSFORM_FFT:
442 442
         ff_fft_end(s);
443 443
         break;
444
+#if CONFIG_FFT_FLOAT
444 445
     case TRANSFORM_RDFT:
445 446
         ff_rdft_end(r);
446 447
         break;
447 448
     case TRANSFORM_DCT:
448 449
         ff_dct_end(d);
449 450
         break;
451
+#endif
450 452
     }
451 453
 
452 454
     av_free(tab);
... ...
@@ -246,21 +246,16 @@ static void fft4(FFTComplex *z)
246 246
 
247 247
 static void fft8(FFTComplex *z)
248 248
 {
249
-    FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
249
+    FFTDouble t1, t2, t3, t4, t5, t6;
250 250
 
251 251
     fft4(z);
252 252
 
253 253
     BF(t1, z[5].re, z[4].re, -z[5].re);
254 254
     BF(t2, z[5].im, z[4].im, -z[5].im);
255
-    BF(t3, z[7].re, z[6].re, -z[7].re);
256
-    BF(t4, z[7].im, z[6].im, -z[7].im);
257
-    BF(t8, t1, t3, t1);
258
-    BF(t7, t2, t2, t4);
259
-    BF(z[4].re, z[0].re, z[0].re, t1);
260
-    BF(z[4].im, z[0].im, z[0].im, t2);
261
-    BF(z[6].re, z[2].re, z[2].re, t7);
262
-    BF(z[6].im, z[2].im, z[2].im, t8);
255
+    BF(t5, z[7].re, z[6].re, -z[7].re);
256
+    BF(t6, z[7].im, z[6].im, -z[7].im);
263 257
 
258
+    BUTTERFLIES(z[0],z[2],z[4],z[6]);
264 259
     TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf);
265 260
 }
266 261
 
... ...
@@ -250,6 +250,11 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
250 250
         av_log(s, AV_LOG_ERROR, "Too many frames: %d\n", ape->totalframes);
251 251
         return -1;
252 252
     }
253
+    if (ape->seektablelength && (ape->seektablelength / sizeof(*ape->seektable)) < ape->totalframes) {
254
+        av_log(s, AV_LOG_ERROR, "Number of seek entries is less than number of frames: %d vs. %d\n",
255
+               ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
256
+        return AVERROR_INVALIDDATA;
257
+    }
253 258
     ape->frames       = av_malloc(ape->totalframes * sizeof(APEFrame));
254 259
     if(!ape->frames)
255 260
         return AVERROR(ENOMEM);
... ...
@@ -454,6 +454,22 @@ attribute_deprecated void init_checksum(AVIOContext *s,
454 454
 attribute_deprecated unsigned long get_checksum(AVIOContext *s);
455 455
 #endif
456 456
 
457
+/**
458
+ * Allocate and initialize an AVIOContext for buffered I/O. It must be later
459
+ * freed with av_free().
460
+ *
461
+ * @param buffer Memory block for input/output operations via AVIOContext.
462
+ * @param buffer_size The buffer size is very important for performance.
463
+ *        For protocols with fixed blocksize it should be set to this blocksize.
464
+ *        For others a typical size is a cache page, e.g. 4kb.
465
+ * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
466
+ * @param opaque An opaque pointer to user-specific data.
467
+ * @param read_packet  A function for refilling the buffer, may be NULL.
468
+ * @param write_packet A function for writing the buffer contents, may be NULL.
469
+ * @param seek A function for seeking to specified byte position, may be NULL.
470
+ *
471
+ * @return Allocated AVIOContext or NULL on failure.
472
+ */
457 473
 AVIOContext *avio_alloc_context(
458 474
                   unsigned char *buffer,
459 475
                   int buffer_size,
... ...
@@ -99,7 +99,7 @@ static int vmd_read_header(AVFormatContext *s,
99 99
     if (avio_read(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
100 100
         return AVERROR(EIO);
101 101
 
102
-    if(vmd->vmd_header[16] == 'i' && vmd->vmd_header[17] == 'v' && vmd->vmd_header[18] == '3')
102
+    if(vmd->vmd_header[24] == 'i' && vmd->vmd_header[25] == 'v' && vmd->vmd_header[26] == '3')
103 103
         vmd->is_indeo3 = 1;
104 104
     else
105 105
         vmd->is_indeo3 = 0;
... ...
@@ -249,7 +249,7 @@ static int vmd_read_packet(AVFormatContext *s,
249 249
         return AVERROR(ENOMEM);
250 250
     pkt->pos= avio_tell(pb);
251 251
     memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
252
-    if(vmd->is_indeo3)
252
+    if(vmd->is_indeo3 && frame->frame_record[0] == 0x02)
253 253
         ret = avio_read(pb, pkt->data, frame->frame_size);
254 254
     else
255 255
         ret = avio_read(pb, pkt->data + BYTES_PER_FRAME_RECORD,
... ...
@@ -2168,22 +2168,23 @@ enum CodecID av_codec_get_id(const AVCodecTag * const *tags, unsigned int tag)
2168 2168
 
2169 2169
 static void compute_chapters_end(AVFormatContext *s)
2170 2170
 {
2171
-    unsigned int i;
2171
+    unsigned int i, j;
2172
+    int64_t max_time = s->duration + (s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time;
2172 2173
 
2173
-    for (i=0; i+1<s->nb_chapters; i++)
2174
+    for (i = 0; i < s->nb_chapters; i++)
2174 2175
         if (s->chapters[i]->end == AV_NOPTS_VALUE) {
2175
-            assert(s->chapters[i]->start <= s->chapters[i+1]->start);
2176
-            assert(!av_cmp_q(s->chapters[i]->time_base, s->chapters[i+1]->time_base));
2177
-            s->chapters[i]->end = s->chapters[i+1]->start;
2176
+            AVChapter *ch = s->chapters[i];
2177
+            int64_t   end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q, ch->time_base)
2178
+                                     : INT64_MAX;
2179
+
2180
+            for (j = 0; j < s->nb_chapters; j++) {
2181
+                AVChapter *ch1 = s->chapters[j];
2182
+                int64_t next_start = av_rescale_q(ch1->start, ch1->time_base, ch->time_base);
2183
+                if (j != i && next_start > ch->start && next_start < end)
2184
+                    end = next_start;
2185
+            }
2186
+            ch->end = (end == INT64_MAX) ? ch->start : end;
2178 2187
         }
2179
-
2180
-    if (s->nb_chapters && s->chapters[i]->end == AV_NOPTS_VALUE) {
2181
-        assert(s->start_time != AV_NOPTS_VALUE);
2182
-        assert(s->duration > 0);
2183
-        s->chapters[i]->end = av_rescale_q(s->start_time + s->duration,
2184
-                                           AV_TIME_BASE_Q,
2185
-                                           s->chapters[i]->time_base);
2186
-    }
2187 2188
 }
2188 2189
 
2189 2190
 static int get_std_framerate(int i){
... ...
@@ -1,35 +1,31 @@
1
-FATE_FFT += fate-fft
2
-fate-fft: libavcodec/fft-test$(EXESUF)
3
-fate-fft: CMD = run libavcodec/fft-test
4
-
5
-FATE_FFT += fate-ifft
6
-fate-ifft: libavcodec/fft-test$(EXESUF)
7
-fate-ifft: CMD = run libavcodec/fft-test -i
8
-
9
-FATE_FFT += fate-mdct
10
-fate-mdct: libavcodec/fft-test$(EXESUF)
11
-fate-mdct: CMD = run libavcodec/fft-test -m
12
-
13
-FATE_FFT += fate-imdct
14
-fate-imdct: libavcodec/fft-test$(EXESUF)
15
-fate-imdct: CMD = run libavcodec/fft-test -m -i
1
+FATE_FFT = fate-fft   fate-ifft   \
2
+           fate-mdct  fate-imdct  \
3
+           fate-rdft  fate-irdft  \
4
+           fate-dct1d fate-idct1d
5
+
6
+fate-fft:    CMD = run libavcodec/fft-test
7
+fate-ifft:   CMD = run libavcodec/fft-test -i
8
+fate-mdct:   CMD = run libavcodec/fft-test -m
9
+fate-imdct:  CMD = run libavcodec/fft-test -m -i
10
+fate-rdft:   CMD = run libavcodec/fft-test -r
11
+fate-irdft:  CMD = run libavcodec/fft-test -r -i
12
+fate-dct1d:  CMD = run libavcodec/fft-test -d
13
+fate-idct1d: CMD = run libavcodec/fft-test -d -i
16 14
 
17
-FATE_FFT += fate-rdft
18
-fate-rdft: libavcodec/fft-test$(EXESUF)
19
-fate-rdft: CMD = run libavcodec/fft-test -r
15
+fate-fft-test: $(FATE_FFT)
16
+$(FATE_FFT): libavcodec/fft-test$(EXESUF)
17
+$(FATE_FFT): REF = /dev/null
20 18
 
21
-FATE_FFT += fate-irdft
22
-fate-irdft: libavcodec/fft-test$(EXESUF)
23
-fate-irdft: CMD = run libavcodec/fft-test -r -i
19
+FATE_FFT_FIXED = fate-fft-fixed  fate-ifft-fixed  \
20
+                 fate-mdct-fixed fate-imdct-fixed
24 21
 
25
-FATE_FFT += fate-dct1d
26
-fate-dct1d: libavcodec/fft-test$(EXESUF)
27
-fate-dct1d: CMD = run libavcodec/fft-test -d
22
+fate-fft-fixed:   CMD = run libavcodec/fft-fixed-test
23
+fate-ifft-fixed:  CMD = run libavcodec/fft-fixed-test -i
24
+fate-mdct-fixed:  CMD = run libavcodec/fft-fixed-test -m
25
+fate-imdct-fixed: CMD = run libavcodec/fft-fixed-test -m -i
28 26
 
29
-FATE_FFT += fate-idct1d
30
-fate-idct1d: libavcodec/fft-test$(EXESUF)
31
-fate-idct1d: CMD = run libavcodec/fft-test -d -i
27
+fate-fft-fixed-test: $(FATE_FFT_FIXED)
28
+$(FATE_FFT_FIXED): libavcodec/fft-fixed-test$(EXESUF)
29
+$(FATE_FFT_FIXED): REF = /dev/null
32 30
 
33
-FATE_TESTS += $(FATE_FFT)
34
-fate-fft-test: $(FATE_FFT)
35
-$(FATE_FFT): REF = /dev/null
31
+FATE_TESTS += $(FATE_FFT) $(FATE_FFT_FIXED)