Mercurial > libavcodec.hg
annotate vorbis_enc.c @ 7274:25914f8a9bb3 libavcodec
Fix decoding of 320x240.ogg.
author | michael |
---|---|
date | Sun, 13 Jul 2008 23:34:29 +0000 |
parents | 7b8fba44fe9d |
children | 85ab7655ad4d |
rev | line source |
---|---|
3808 | 1 /* |
2 * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org> | |
3 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3919
diff
changeset
|
4 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3919
diff
changeset
|
5 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3919
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
3808 | 7 * modify it under the terms of the GNU Lesser General Public |
8 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3919
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
3808 | 10 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3919
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
3808 | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3919
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
5215 | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3808 | 19 */ |
20 | |
21 /** | |
22 * @file vorbis_enc.c | |
23 * Native Vorbis encoder. | |
24 * @author Oded Shimon <ods15@ods15.dyndns.org> | |
25 */ | |
26 | |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
27 #include <float.h> |
3808 | 28 #include "avcodec.h" |
3892
4fb6be21be4b
Original Commit: r93 | ods15 | 2006-09-30 22:02:21 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3891
diff
changeset
|
29 #include "dsputil.h" |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
30 #include "vorbis.h" |
3915
a4f6e6981930
add vorbis_enc_data.h, remove codebook data from vorbis_enc.c
ods15
parents:
3913
diff
changeset
|
31 #include "vorbis_enc_data.h" |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
32 |
3808 | 33 #undef NDEBUG |
34 #include <assert.h> | |
35 | |
36 typedef struct { | |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
37 int nentries; |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
38 uint8_t * lens; |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
39 uint32_t * codewords; |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
40 int ndimentions; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
41 float min; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
42 float delta; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
43 int seq_p; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
44 int lookup; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
45 int * quantlist; |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
46 float * dimentions; |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
47 float * pow2; |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
48 } codebook_t; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
49 |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
50 typedef struct { |
3814
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
51 int dim; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
52 int subclass; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
53 int masterbook; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
54 int * books; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
55 } floor_class_t; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
56 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
57 typedef struct { |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
58 int partitions; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
59 int * partition_to_class; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
60 int nclasses; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
61 floor_class_t * classes; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
62 int multiplier; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
63 int rangebits; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
64 int values; |
3901
e255692302f0
Original Commit: r102 | ods15 | 2006-10-01 17:58:38 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3900
diff
changeset
|
65 floor1_entry_t * list; |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
66 } floor_t; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
67 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
68 typedef struct { |
3815
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
69 int type; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
70 int begin; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
71 int end; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
72 int partition_size; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
73 int classifications; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
74 int classbook; |
3897
11caa885c449
Original Commit: r98 | ods15 | 2006-10-01 10:15:33 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3896
diff
changeset
|
75 int8_t (*books)[8]; |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
76 float (*maxes)[2]; |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
77 } residue_t; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
78 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
79 typedef struct { |
3816
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
80 int submaps; |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
81 int * mux; |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
82 int * floor; |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
83 int * residue; |
3870
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
84 int coupling_steps; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
85 int * magnitude; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
86 int * angle; |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
87 } mapping_t; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
88 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
89 typedef struct { |
3817
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
90 int blockflag; |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
91 int mapping; |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
92 } vorbis_mode_t; |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
93 |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
94 typedef struct { |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
95 int channels; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
96 int sample_rate; |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
97 int log2_blocksize[2]; |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
98 MDCTContext mdct[2]; |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
99 const float * win[2]; |
3842
5f8cfa1a6fdb
Original Commit: r39 | ods15 | 2006-09-23 09:36:11 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3841
diff
changeset
|
100 int have_saved; |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
101 float * saved; |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
102 float * samples; |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
103 float * floor; // also used for tmp values for mdct |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
104 float * coeffs; // also used for residue after floor |
3891
50e912426a32
Original Commit: r92 | ods15 | 2006-09-30 12:13:47 +0300 (Sat, 30 Sep 2006) | 3 lines
ods15
parents:
3890
diff
changeset
|
105 float quality; |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
106 |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
107 int ncodebooks; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
108 codebook_t * codebooks; |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
109 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
110 int nfloors; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
111 floor_t * floors; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
112 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
113 int nresidues; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
114 residue_t * residues; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
115 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
116 int nmappings; |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
117 mapping_t * mappings; |
3817
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
118 |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
119 int nmodes; |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
120 vorbis_mode_t * modes; |
3808 | 121 } venc_context_t; |
122 | |
3835
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
123 typedef struct { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
124 int total; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
125 int total_pos; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
126 int pos; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
127 uint8_t * buf_ptr; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
128 } PutBitContext; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
129 |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
130 static inline void init_put_bits(PutBitContext * pb, uint8_t * buf, int buffer_len) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
131 pb->total = buffer_len * 8; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
132 pb->total_pos = 0; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
133 pb->pos = 0; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
134 pb->buf_ptr = buf; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
135 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
136 |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
137 static void put_bits(PutBitContext * pb, int bits, uint64_t val) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
138 if ((pb->total_pos += bits) >= pb->total) return; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
139 if (!bits) return; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
140 if (pb->pos) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
141 if (pb->pos > bits) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
142 *pb->buf_ptr |= val << (8 - pb->pos); |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
143 pb->pos -= bits; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
144 bits = 0; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
145 } else { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
146 *pb->buf_ptr++ |= (val << (8 - pb->pos)) & 0xFF; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
147 val >>= pb->pos; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
148 bits -= pb->pos; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
149 pb->pos = 0; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
150 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
151 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
152 for (; bits >= 8; bits -= 8) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
153 *pb->buf_ptr++ = val & 0xFF; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
154 val >>= 8; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
155 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
156 if (bits) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
157 *pb->buf_ptr = val; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
158 pb->pos = 8 - bits; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
159 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
160 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
161 |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
162 static inline void flush_put_bits(PutBitContext * pb) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
163 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
164 |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
165 static inline int put_bits_count(PutBitContext * pb) { |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
166 return pb->total_pos; |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
167 } |
40acb836a6d3
Original Commit: r31 | ods15 | 2006-09-22 18:33:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3834
diff
changeset
|
168 |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
169 static inline void put_codeword(PutBitContext * pb, codebook_t * cb, int entry) { |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
170 assert(entry >= 0); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
171 assert(entry < cb->nentries); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
172 assert(cb->lens[entry]); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
173 put_bits(pb, cb->lens[entry], cb->codewords[entry]); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
174 } |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
175 |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
176 static int cb_lookup_vals(int lookup, int dimentions, int entries) { |
3917 | 177 if (lookup == 1) return ff_vorbis_nth_root(entries, dimentions); |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
178 else if (lookup == 2) return dimentions * entries; |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
179 return 0; |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
180 } |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
181 |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
182 static void ready_codebook(codebook_t * cb) { |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
183 int i; |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
184 |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
185 ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries); |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
186 |
3917 | 187 if (!cb->lookup) |
188 cb->pow2 = cb->dimentions = NULL; | |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
189 else { |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
190 int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries); |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
191 cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions); |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
192 cb->pow2 = av_mallocz(sizeof(float) * cb->nentries); |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
193 for (i = 0; i < cb->nentries; i++) { |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
194 float last = 0; |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
195 int j; |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
196 int div = 1; |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
197 for (j = 0; j < cb->ndimentions; j++) { |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
198 int off; |
3917 | 199 if (cb->lookup == 1) |
200 off = (i / div) % vals; // lookup type 1 | |
201 else | |
202 off = i * cb->ndimentions + j; // lookup type 2 | |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
203 |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
204 cb->dimentions[i * cb->ndimentions + j] = last + cb->min + cb->quantlist[off] * cb->delta; |
3917 | 205 if (cb->seq_p) |
206 last = cb->dimentions[i * cb->ndimentions + j]; | |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
207 cb->pow2[i] += cb->dimentions[i * cb->ndimentions + j]*cb->dimentions[i * cb->ndimentions + j]; |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
208 div *= vals; |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
209 } |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
210 cb->pow2[i] /= 2.; |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
211 } |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
212 } |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
213 } |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
214 |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
215 static void ready_residue(residue_t * rc, venc_context_t * venc) { |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
216 int i; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
217 assert(rc->type == 2); |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
218 rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications); |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
219 for (i = 0; i < rc->classifications; i++) { |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
220 int j; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
221 codebook_t * cb; |
3917 | 222 for (j = 0; j < 8; j++) |
223 if (rc->books[i][j] != -1) break; | |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
224 if (j == 8) continue; // zero |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
225 cb = &venc->codebooks[rc->books[i][j]]; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
226 assert(cb->ndimentions >= 2); |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
227 assert(cb->lookup); |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
228 |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
229 for (j = 0; j < cb->nentries; j++) { |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
230 float a; |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
231 if (!cb->lens[j]) continue; |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
232 a = fabs(cb->dimentions[j * cb->ndimentions]); |
3917 | 233 if (a > rc->maxes[i][0]) |
234 rc->maxes[i][0] = a; | |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
235 a = fabs(cb->dimentions[j * cb->ndimentions + 1]); |
3917 | 236 if (a > rc->maxes[i][1]) |
237 rc->maxes[i][1] = a; | |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
238 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
239 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
240 // small bias |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
241 for (i = 0; i < rc->classifications; i++) { |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
242 rc->maxes[i][0] += 0.8; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
243 rc->maxes[i][1] += 0.8; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
244 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
245 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
246 |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
247 static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) { |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
248 floor_t * fc; |
3828
f9c449155a0e
Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3827
diff
changeset
|
249 residue_t * rc; |
3829
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
250 mapping_t * mc; |
3820
3cfdf99da951
Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3819
diff
changeset
|
251 int i, book; |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
252 |
3893
7c51248a63d3
Original Commit: r94 | ods15 | 2006-09-30 22:09:33 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3892
diff
changeset
|
253 venc->channels = avccontext->channels; |
7c51248a63d3
Original Commit: r94 | ods15 | 2006-09-30 22:09:33 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3892
diff
changeset
|
254 venc->sample_rate = avccontext->sample_rate; |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
255 venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11; |
3893
7c51248a63d3
Original Commit: r94 | ods15 | 2006-09-30 22:09:33 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3892
diff
changeset
|
256 |
3898
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
257 venc->ncodebooks = sizeof(cvectors)/sizeof(cvectors[0]); |
3893
7c51248a63d3
Original Commit: r94 | ods15 | 2006-09-30 22:09:33 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3892
diff
changeset
|
258 venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks); |
7c51248a63d3
Original Commit: r94 | ods15 | 2006-09-30 22:09:33 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3892
diff
changeset
|
259 |
3878
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
260 // codebook 0..14 - floor1 book, values 0..255 |
3880
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
261 // codebook 15 residue masterbook |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
262 // codebook 16..29 residue |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
263 for (book = 0; book < venc->ncodebooks; book++) { |
3898
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
264 codebook_t * cb = &venc->codebooks[book]; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
265 int vals; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
266 cb->ndimentions = cvectors[book].dim; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
267 cb->nentries = cvectors[book].real_len; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
268 cb->min = cvectors[book].min; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
269 cb->delta = cvectors[book].delta; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
270 cb->lookup = cvectors[book].lookup; |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
271 cb->seq_p = 0; |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
272 |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
273 cb->lens = av_malloc(sizeof(uint8_t) * cb->nentries); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
274 cb->codewords = av_malloc(sizeof(uint32_t) * cb->nentries); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
275 memcpy(cb->lens, cvectors[book].clens, cvectors[book].len); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
276 memset(cb->lens + cvectors[book].len, 0, cb->nentries - cvectors[book].len); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
277 |
3898
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
278 if (cb->lookup) { |
3880
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
279 vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries); |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
280 cb->quantlist = av_malloc(sizeof(int) * vals); |
3917 | 281 for (i = 0; i < vals; i++) |
282 cb->quantlist[i] = cvectors[book].quant[i]; | |
3898
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
283 } else { |
c8b9218c3458
Original Commit: r99 | ods15 | 2006-10-01 11:12:44 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3897
diff
changeset
|
284 cb->quantlist = NULL; |
3883
6d15c93bce65
Original Commit: r83 | ods15 | 2006-09-29 21:06:13 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3882
diff
changeset
|
285 } |
3820
3cfdf99da951
Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3819
diff
changeset
|
286 ready_codebook(cb); |
3cfdf99da951
Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3819
diff
changeset
|
287 } |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
288 |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
289 venc->nfloors = 1; |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
290 venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors); |
3826
c583e895f980
Original Commit: r20 | ods15 | 2006-09-22 13:12:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3825
diff
changeset
|
291 |
c583e895f980
Original Commit: r20 | ods15 | 2006-09-22 13:12:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3825
diff
changeset
|
292 // just 1 floor |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
293 fc = &venc->floors[0]; |
3878
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
294 fc->partitions = 8; |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
295 fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions); |
3878
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
296 fc->nclasses = 0; |
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
297 for (i = 0; i < fc->partitions; i++) { |
3912
f56e6d3a1d6e
Original Commit: r113 | ods15 | 2006-10-01 21:35:47 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3911
diff
changeset
|
298 static const int a[] = {0,1,2,2,3,3,4,4}; |
3878
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
299 fc->partition_to_class[i] = a[i]; |
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
300 fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[i]); |
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
301 } |
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
302 fc->nclasses++; |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
303 fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses); |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
304 for (i = 0; i < fc->nclasses; i++) { |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
305 floor_class_t * c = &fc->classes[i]; |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
306 int j, books; |
3912
f56e6d3a1d6e
Original Commit: r113 | ods15 | 2006-10-01 21:35:47 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3911
diff
changeset
|
307 c->dim = floor_classes[i].dim; |
f56e6d3a1d6e
Original Commit: r113 | ods15 | 2006-10-01 21:35:47 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3911
diff
changeset
|
308 c->subclass = floor_classes[i].subclass; |
f56e6d3a1d6e
Original Commit: r113 | ods15 | 2006-10-01 21:35:47 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3911
diff
changeset
|
309 c->masterbook = floor_classes[i].masterbook; |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
310 books = (1 << c->subclass); |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
311 c->books = av_malloc(sizeof(int) * books); |
3917 | 312 for (j = 0; j < books; j++) |
313 c->books[j] = floor_classes[i].nbooks[j]; | |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
314 } |
3878
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
315 fc->multiplier = 2; |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
316 fc->rangebits = venc->log2_blocksize[0] - 1; |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
317 |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
318 fc->values = 2; |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
319 for (i = 0; i < fc->partitions; i++) |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
320 fc->values += fc->classes[fc->partition_to_class[i]].dim; |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
321 |
3901
e255692302f0
Original Commit: r102 | ods15 | 2006-10-01 17:58:38 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3900
diff
changeset
|
322 fc->list = av_malloc(sizeof(floor1_entry_t) * fc->values); |
3825
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
323 fc->list[0].x = 0; |
9983437a00a1
Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3824
diff
changeset
|
324 fc->list[1].x = 1 << fc->rangebits; |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
325 for (i = 2; i < fc->values; i++) { |
3900
2c1a4cce567b
Original Commit: r101 | ods15 | 2006-10-01 14:15:00 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3899
diff
changeset
|
326 static const int a[] = { |
2c1a4cce567b
Original Commit: r101 | ods15 | 2006-10-01 14:15:00 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3899
diff
changeset
|
327 93, 23,372, 6, 46,186,750, 14, 33, 65, |
2c1a4cce567b
Original Commit: r101 | ods15 | 2006-10-01 14:15:00 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3899
diff
changeset
|
328 130,260,556, 3, 10, 18, 28, 39, 55, 79, |
2c1a4cce567b
Original Commit: r101 | ods15 | 2006-10-01 14:15:00 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3899
diff
changeset
|
329 111,158,220,312,464,650,850 |
2c1a4cce567b
Original Commit: r101 | ods15 | 2006-10-01 14:15:00 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3899
diff
changeset
|
330 }; |
3866
4d5f73f10198
Original Commit: r66 | ods15 | 2006-09-25 18:42:13 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3865
diff
changeset
|
331 fc->list[i].x = a[i - 2]; |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
332 } |
3901
e255692302f0
Original Commit: r102 | ods15 | 2006-10-01 17:58:38 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3900
diff
changeset
|
333 ff_vorbis_ready_floor1_list(fc->list, fc->values); |
3827
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
334 |
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
335 venc->nresidues = 1; |
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
336 venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues); |
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
337 |
3828
f9c449155a0e
Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3827
diff
changeset
|
338 // single residue |
f9c449155a0e
Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3827
diff
changeset
|
339 rc = &venc->residues[0]; |
3880
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
340 rc->type = 2; |
3828
f9c449155a0e
Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3827
diff
changeset
|
341 rc->begin = 0; |
3880
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
342 rc->end = 1600; |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
343 rc->partition_size = 32; |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
344 rc->classifications = 10; |
3878
30de59a39f6e
Original Commit: r78 | ods15 | 2006-09-29 15:14:28 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3877
diff
changeset
|
345 rc->classbook = 15; |
3897
11caa885c449
Original Commit: r98 | ods15 | 2006-10-01 10:15:33 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3896
diff
changeset
|
346 rc->books = av_malloc(sizeof(*rc->books) * rc->classifications); |
11caa885c449
Original Commit: r98 | ods15 | 2006-10-01 10:15:33 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3896
diff
changeset
|
347 { |
11caa885c449
Original Commit: r98 | ods15 | 2006-10-01 10:15:33 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3896
diff
changeset
|
348 static const int8_t a[10][8] = { |
3880
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
349 { -1, -1, -1, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
350 { -1, -1, 16, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
351 { -1, -1, 17, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
352 { -1, -1, 18, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
353 { -1, -1, 19, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
354 { -1, -1, 20, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
355 { -1, -1, 21, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
356 { 22, 23, -1, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
357 { 24, 25, -1, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
358 { 26, 27, 28, -1, -1, -1, -1, -1, }, |
3d5920649c39
Original Commit: r80 | ods15 | 2006-09-29 15:44:22 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3879
diff
changeset
|
359 }; |
3897
11caa885c449
Original Commit: r98 | ods15 | 2006-10-01 10:15:33 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3896
diff
changeset
|
360 memcpy(rc->books, a, sizeof a); |
3849
ead3ae56d1b6
Original Commit: r47 | ods15 | 2006-09-23 12:34:48 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3848
diff
changeset
|
361 } |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
362 ready_residue(rc, venc); |
3828
f9c449155a0e
Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3827
diff
changeset
|
363 |
3827
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
364 venc->nmappings = 1; |
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
365 venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings); |
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
366 |
3829
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
367 // single mapping |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
368 mc = &venc->mappings[0]; |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
369 mc->submaps = 1; |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
370 mc->mux = av_malloc(sizeof(int) * venc->channels); |
3917 | 371 for (i = 0; i < venc->channels; i++) |
372 mc->mux[i] = 0; | |
3829
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
373 mc->floor = av_malloc(sizeof(int) * mc->submaps); |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
374 mc->residue = av_malloc(sizeof(int) * mc->submaps); |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
375 for (i = 0; i < mc->submaps; i++) { |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
376 mc->floor[i] = 0; |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
377 mc->residue[i] = 0; |
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
378 } |
3870
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
379 mc->coupling_steps = venc->channels == 2 ? 1 : 0; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
380 mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps); |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
381 mc->angle = av_malloc(sizeof(int) * mc->coupling_steps); |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
382 if (mc->coupling_steps) { |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
383 mc->magnitude[0] = 0; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
384 mc->angle[0] = 1; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
385 } |
3829
e8e340cbc7f2
Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3828
diff
changeset
|
386 |
3827
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
387 venc->nmodes = 1; |
91f130d6c3f4
Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3826
diff
changeset
|
388 venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes); |
3830
477ee30c6fc6
Original Commit: r24 | ods15 | 2006-09-22 13:57:09 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3829
diff
changeset
|
389 |
477ee30c6fc6
Original Commit: r24 | ods15 | 2006-09-22 13:57:09 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3829
diff
changeset
|
390 // single mode |
477ee30c6fc6
Original Commit: r24 | ods15 | 2006-09-22 13:57:09 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3829
diff
changeset
|
391 venc->modes[0].blockflag = 0; |
477ee30c6fc6
Original Commit: r24 | ods15 | 2006-09-22 13:57:09 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3829
diff
changeset
|
392 venc->modes[0].mapping = 0; |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
393 |
3842
5f8cfa1a6fdb
Original Commit: r39 | ods15 | 2006-09-23 09:36:11 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3841
diff
changeset
|
394 venc->have_saved = 0; |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
395 venc->saved = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2); |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
396 venc->samples = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1])); |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
397 venc->floor = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2); |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
398 venc->coeffs = av_malloc(sizeof(float) * venc->channels * (1 << venc->log2_blocksize[1]) / 2); |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
399 |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
400 venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6]; |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
401 venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6]; |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
402 |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
403 ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0); |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
404 ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0); |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
405 } |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
406 |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
407 static void put_float(PutBitContext * pb, float f) { |
3812
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
408 int exp, mant; |
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
409 uint32_t res = 0; |
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
410 mant = (int)ldexp(frexp(f, &exp), 20); |
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
411 exp += 788 - 20; |
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
412 if (mant < 0) { res |= (1 << 31); mant = -mant; } |
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
413 res |= mant | (exp << 21); |
52ff3a5d161e
Original Commit: r6 | ods15 | 2006-09-16 20:36:31 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents:
3811
diff
changeset
|
414 put_bits(pb, 32, res); |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
415 } |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
416 |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
417 static void put_codebook_header(PutBitContext * pb, codebook_t * cb) { |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
418 int i; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
419 int ordered = 0; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
420 |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
421 put_bits(pb, 24, 0x564342); //magic |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
422 put_bits(pb, 16, cb->ndimentions); |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
423 put_bits(pb, 24, cb->nentries); |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
424 |
3917 | 425 for (i = 1; i < cb->nentries; i++) |
426 if (cb->lens[i] < cb->lens[i-1]) break; | |
427 if (i == cb->nentries) | |
428 ordered = 1; | |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
429 |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
430 put_bits(pb, 1, ordered); |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
431 if (ordered) { |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
432 int len = cb->lens[0]; |
3851
a778f86c28e2
Original Commit: r49 | ods15 | 2006-09-23 12:52:21 +0300 (Sat, 23 Sep 2006) | 3 lines
ods15
parents:
3850
diff
changeset
|
433 put_bits(pb, 5, len - 1); |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
434 i = 0; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
435 while (i < cb->nentries) { |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
436 int j; |
3917 | 437 for (j = 0; j+i < cb->nentries; j++) |
438 if (cb->lens[j+i] != len) break; | |
3823
41ad23b61a2c
Original Commit: r17 | ods15 | 2006-09-22 12:28:28 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3822
diff
changeset
|
439 put_bits(pb, ilog(cb->nentries - i), j); |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
440 i += j; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
441 len++; |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
442 } |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
443 } else { |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
444 int sparse = 0; |
3917 | 445 for (i = 0; i < cb->nentries; i++) |
446 if (!cb->lens[i]) break; | |
447 if (i != cb->nentries) | |
448 sparse = 1; | |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
449 put_bits(pb, 1, sparse); |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
450 |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
451 for (i = 0; i < cb->nentries; i++) { |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
452 if (sparse) put_bits(pb, 1, !!cb->lens[i]); |
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
453 if (cb->lens[i]) put_bits(pb, 5, cb->lens[i] - 1); |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
454 } |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
455 } |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
456 |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
457 put_bits(pb, 4, cb->lookup); |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
458 if (cb->lookup) { |
3818
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
459 int tmp = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries); |
6a737f2d852e
Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents:
3817
diff
changeset
|
460 int bits = ilog(cb->quantlist[0]); |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
461 |
3917 | 462 for (i = 1; i < tmp; i++) |
463 bits = FFMAX(bits, ilog(cb->quantlist[i])); | |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
464 |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
465 put_float(pb, cb->min); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
466 put_float(pb, cb->delta); |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
467 |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
468 put_bits(pb, 4, bits - 1); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
469 put_bits(pb, 1, cb->seq_p); |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
470 |
3917 | 471 for (i = 0; i < tmp; i++) |
472 put_bits(pb, bits, cb->quantlist[i]); | |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
473 } |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
474 } |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
475 |
3814
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
476 static void put_floor_header(PutBitContext * pb, floor_t * fc) { |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
477 int i; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
478 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
479 put_bits(pb, 16, 1); // type, only floor1 is supported |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
480 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
481 put_bits(pb, 5, fc->partitions); |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
482 |
3917 | 483 for (i = 0; i < fc->partitions; i++) |
484 put_bits(pb, 4, fc->partition_to_class[i]); | |
3814
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
485 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
486 for (i = 0; i < fc->nclasses; i++) { |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
487 int j, books; |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
488 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
489 put_bits(pb, 3, fc->classes[i].dim - 1); |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
490 put_bits(pb, 2, fc->classes[i].subclass); |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
491 |
3917 | 492 if (fc->classes[i].subclass) |
493 put_bits(pb, 8, fc->classes[i].masterbook); | |
3814
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
494 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
495 books = (1 << fc->classes[i].subclass); |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
496 |
3917 | 497 for (j = 0; j < books; j++) |
498 put_bits(pb, 8, fc->classes[i].books[j] + 1); | |
3814
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
499 } |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
500 |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
501 put_bits(pb, 2, fc->multiplier - 1); |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
502 put_bits(pb, 4, fc->rangebits); |
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
503 |
3917 | 504 for (i = 2; i < fc->values; i++) |
505 put_bits(pb, fc->rangebits, fc->list[i].x); | |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
506 } |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
507 |
3814
464eca766731
Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3813
diff
changeset
|
508 static void put_residue_header(PutBitContext * pb, residue_t * rc) { |
3815
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
509 int i; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
510 |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
511 put_bits(pb, 16, rc->type); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
512 |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
513 put_bits(pb, 24, rc->begin); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
514 put_bits(pb, 24, rc->end); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
515 put_bits(pb, 24, rc->partition_size - 1); |
3838
6ccaab22c4d6
Original Commit: r35 | ods15 | 2006-09-22 18:53:22 +0300 (Fri, 22 Sep 2006) | 4 lines
ods15
parents:
3837
diff
changeset
|
516 put_bits(pb, 6, rc->classifications - 1); |
3815
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
517 put_bits(pb, 8, rc->classbook); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
518 |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
519 for (i = 0; i < rc->classifications; i++) { |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
520 int j, tmp = 0; |
3917 | 521 for (j = 0; j < 8; j++) |
522 tmp |= (rc->books[i][j] != -1) << j; | |
3815
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
523 |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
524 put_bits(pb, 3, tmp & 7); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
525 put_bits(pb, 1, tmp > 7); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
526 |
3917 | 527 if (tmp > 7) |
528 put_bits(pb, 5, tmp >> 3); | |
3815
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
529 } |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
530 |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
531 for (i = 0; i < rc->classifications; i++) { |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
532 int j; |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
533 for (j = 0; j < 8; j++) |
3856
5812c2d48dbd
Original Commit: r55 | ods15 | 2006-09-24 13:54:43 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3855
diff
changeset
|
534 if (rc->books[i][j] != -1) |
3815
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
535 put_bits(pb, 8, rc->books[i][j]); |
3fa081422f78
Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3814
diff
changeset
|
536 } |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
537 } |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
538 |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
539 static int put_main_header(venc_context_t * venc, uint8_t ** out) { |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
540 int i; |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
541 PutBitContext pb; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
542 uint8_t buffer[50000] = {0}, * p = buffer; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
543 int buffer_len = sizeof buffer; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
544 int len, hlens[3]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
545 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
546 // identification header |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
547 init_put_bits(&pb, p, buffer_len); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
548 put_bits(&pb, 8, 1); //magic |
3917 | 549 for (i = 0; "vorbis"[i]; i++) |
550 put_bits(&pb, 8, "vorbis"[i]); | |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
551 put_bits(&pb, 32, 0); // version |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
552 put_bits(&pb, 8, venc->channels); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
553 put_bits(&pb, 32, venc->sample_rate); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
554 put_bits(&pb, 32, 0); // bitrate |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
555 put_bits(&pb, 32, 0); // bitrate |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
556 put_bits(&pb, 32, 0); // bitrate |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
557 put_bits(&pb, 4, venc->log2_blocksize[0]); |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
558 put_bits(&pb, 4, venc->log2_blocksize[1]); |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
559 put_bits(&pb, 1, 1); // framing |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
560 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
561 flush_put_bits(&pb); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
562 hlens[0] = (put_bits_count(&pb) + 7) / 8; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
563 buffer_len -= hlens[0]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
564 p += hlens[0]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
565 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
566 // comment header |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
567 init_put_bits(&pb, p, buffer_len); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
568 put_bits(&pb, 8, 3); //magic |
3917 | 569 for (i = 0; "vorbis"[i]; i++) |
570 put_bits(&pb, 8, "vorbis"[i]); | |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
571 put_bits(&pb, 32, 0); // vendor length TODO |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
572 put_bits(&pb, 32, 0); // amount of comments |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
573 put_bits(&pb, 1, 1); // framing |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
574 |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
575 flush_put_bits(&pb); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
576 hlens[1] = (put_bits_count(&pb) + 7) / 8; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
577 buffer_len -= hlens[1]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
578 p += hlens[1]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
579 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
580 // setup header |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
581 init_put_bits(&pb, p, buffer_len); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
582 put_bits(&pb, 8, 5); //magic |
3917 | 583 for (i = 0; "vorbis"[i]; i++) |
584 put_bits(&pb, 8, "vorbis"[i]); | |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
585 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
586 // codebooks |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
587 put_bits(&pb, 8, venc->ncodebooks - 1); |
3917 | 588 for (i = 0; i < venc->ncodebooks; i++) |
589 put_codebook_header(&pb, &venc->codebooks[i]); | |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
590 |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
591 // time domain, reserved, zero |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
592 put_bits(&pb, 6, 0); |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
593 put_bits(&pb, 16, 0); |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
594 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
595 // floors |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
596 put_bits(&pb, 6, venc->nfloors - 1); |
3917 | 597 for (i = 0; i < venc->nfloors; i++) |
598 put_floor_header(&pb, &venc->floors[i]); | |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
599 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
600 // residues |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
601 put_bits(&pb, 6, venc->nresidues - 1); |
3917 | 602 for (i = 0; i < venc->nresidues; i++) |
603 put_residue_header(&pb, &venc->residues[i]); | |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
604 |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
605 // mappings |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
606 put_bits(&pb, 6, venc->nmappings - 1); |
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
607 for (i = 0; i < venc->nmappings; i++) { |
3816
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
608 mapping_t * mc = &venc->mappings[i]; |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
609 int j; |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
610 put_bits(&pb, 16, 0); // mapping type |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
611 |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
612 put_bits(&pb, 1, mc->submaps > 1); |
3917 | 613 if (mc->submaps > 1) |
614 put_bits(&pb, 4, mc->submaps - 1); | |
3816
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
615 |
3870
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
616 put_bits(&pb, 1, !!mc->coupling_steps); |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
617 if (mc->coupling_steps) { |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
618 put_bits(&pb, 8, mc->coupling_steps - 1); |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
619 for (j = 0; j < mc->coupling_steps; j++) { |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
620 put_bits(&pb, ilog(venc->channels - 1), mc->magnitude[j]); |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
621 put_bits(&pb, ilog(venc->channels - 1), mc->angle[j]); |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
622 } |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
623 } |
3816
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
624 |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
625 put_bits(&pb, 2, 0); // reserved |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
626 |
3917 | 627 if (mc->submaps > 1) |
628 for (j = 0; j < venc->channels; j++) | |
629 put_bits(&pb, 4, mc->mux[j]); | |
3816
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
630 |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
631 for (j = 0; j < mc->submaps; j++) { |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
632 put_bits(&pb, 8, 0); // reserved time configuration |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
633 put_bits(&pb, 8, mc->floor[j]); |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
634 put_bits(&pb, 8, mc->residue[j]); |
6eba53afa0b0
Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3815
diff
changeset
|
635 } |
3813
95b70f8bc29e
Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents:
3812
diff
changeset
|
636 } |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
637 |
3817
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
638 // modes |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
639 put_bits(&pb, 6, venc->nmodes - 1); |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
640 for (i = 0; i < venc->nmodes; i++) { |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
641 put_bits(&pb, 1, venc->modes[i].blockflag); |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
642 put_bits(&pb, 16, 0); // reserved window type |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
643 put_bits(&pb, 16, 0); // reserved transform type |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
644 put_bits(&pb, 8, venc->modes[i].mapping); |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
645 } |
3ca15f0d4882
Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents:
3816
diff
changeset
|
646 |
3836
ff31b13b57df
Original Commit: r32 | ods15 | 2006-09-22 18:37:50 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3835
diff
changeset
|
647 put_bits(&pb, 1, 1); // framing |
ff31b13b57df
Original Commit: r32 | ods15 | 2006-09-22 18:37:50 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3835
diff
changeset
|
648 |
3811
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
649 flush_put_bits(&pb); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
650 hlens[2] = (put_bits_count(&pb) + 7) / 8; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
651 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
652 len = hlens[0] + hlens[1] + hlens[2]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
653 p = *out = av_mallocz(64 + len + len/255); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
654 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
655 *p++ = 2; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
656 p += av_xiphlacing(p, hlens[0]); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
657 p += av_xiphlacing(p, hlens[1]); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
658 buffer_len = 0; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
659 for (i = 0; i < 3; i++) { |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
660 memcpy(p, buffer + buffer_len, hlens[i]); |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
661 p += hlens[i]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
662 buffer_len += hlens[i]; |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
663 } |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
664 |
9f6acced986e
Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents:
3810
diff
changeset
|
665 return p - *out; |
3810
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
666 } |
a8bebf3e9cb7
Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents:
3809
diff
changeset
|
667 |
3890
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
668 static float get_floor_average(floor_t * fc, float * coeffs, int i) { |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
669 int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x; |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
670 int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x; |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
671 int j; |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
672 float average = 0; |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
673 |
3917 | 674 for (j = begin; j < end; j++) |
675 average += fabs(coeffs[j]); | |
3890
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
676 return average / (end - begin); |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
677 } |
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
678 |
3910
aada0ac47451
Original Commit: r111 | ods15 | 2006-10-01 19:40:50 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3909
diff
changeset
|
679 static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, uint_fast16_t * posts, int samples) { |
3861
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
680 int range = 255 / fc->multiplier + 1; |
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
681 int i; |
3890
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
682 float tot_average = 0.; |
3902
bd0cb21d956d
Original Commit: r103 | ods15 | 2006-10-01 18:00:43 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3901
diff
changeset
|
683 float averages[fc->values]; |
3917 | 684 for (i = 0; i < fc->values; i++){ |
685 averages[i] = get_floor_average(fc, coeffs, i); | |
686 tot_average += averages[i]; | |
687 } | |
3890
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
688 tot_average /= fc->values; |
3891
50e912426a32
Original Commit: r92 | ods15 | 2006-09-30 12:13:47 +0300 (Sat, 30 Sep 2006) | 3 lines
ods15
parents:
3890
diff
changeset
|
689 tot_average /= venc->quality; |
3890
de883494646e
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
ods15
parents:
3889
diff
changeset
|
690 |
3861
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
691 for (i = 0; i < fc->values; i++) { |
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
692 int position = fc->list[fc->list[i].sort].x; |
3902
bd0cb21d956d
Original Commit: r103 | ods15 | 2006-10-01 18:00:43 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3901
diff
changeset
|
693 float average = averages[i]; |
3861
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
694 int j; |
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
695 |
3911
a1b41e814052
Original Commit: r112 | ods15 | 2006-10-01 20:48:39 +0200 (Sun, 01 Oct 2006) | 3 lines
ods15
parents:
3910
diff
changeset
|
696 average *= pow(tot_average / average, 0.5) * pow(1.25, position/200.); // MAGIC! |
3917 | 697 for (j = 0; j < range - 1; j++) |
698 if (ff_vorbis_floor1_inverse_db_table[j * fc->multiplier] > average) break; | |
3861
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
699 posts[fc->list[i].sort] = j; |
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
700 } |
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
701 } |
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
702 |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
703 static int render_point(int x0, int y0, int x1, int y1, int x) { |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
704 return y0 + (x - x0) * (y1 - y0) / (x1 - x0); |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
705 } |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
706 |
3910
aada0ac47451
Original Commit: r111 | ods15 | 2006-10-01 19:40:50 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3909
diff
changeset
|
707 static void floor_encode(venc_context_t * venc, floor_t * fc, PutBitContext * pb, uint_fast16_t * posts, float * floor, int samples) { |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
708 int range = 255 / fc->multiplier + 1; |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
709 int coded[fc->values]; // first 2 values are unused |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
710 int i, counter; |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
711 |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
712 put_bits(pb, 1, 1); // non zero |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
713 put_bits(pb, ilog(range - 1), posts[0]); |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
714 put_bits(pb, ilog(range - 1), posts[1]); |
3887
71ba8e680704
Original Commit: r87 | ods15 | 2006-09-29 21:10:05 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3886
diff
changeset
|
715 coded[0] = coded[1] = 1; |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
716 |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
717 for (i = 2; i < fc->values; i++) { |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
718 int predicted = render_point(fc->list[fc->list[i].low].x, |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
719 posts[fc->list[i].low], |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
720 fc->list[fc->list[i].high].x, |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
721 posts[fc->list[i].high], |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
722 fc->list[i].x); |
3865
04d496813135
Original Commit: r65 | ods15 | 2006-09-25 18:40:19 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3864
diff
changeset
|
723 int highroom = range - predicted; |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
724 int lowroom = predicted; |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
725 int room = FFMIN(highroom, lowroom); |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
726 if (predicted == posts[i]) { |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
727 coded[i] = 0; // must be used later as flag! |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
728 continue; |
3864
df84b5d1a8c2
Original Commit: r64 | ods15 | 2006-09-25 18:39:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3863
diff
changeset
|
729 } else { |
3917 | 730 if (!coded[fc->list[i].low ]) coded[fc->list[i].low ] = -1; |
3864
df84b5d1a8c2
Original Commit: r64 | ods15 | 2006-09-25 18:39:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3863
diff
changeset
|
731 if (!coded[fc->list[i].high]) coded[fc->list[i].high] = -1; |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
732 } |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
733 if (posts[i] > predicted) { |
3917 | 734 if (posts[i] - predicted > room) |
735 coded[i] = posts[i] - predicted + lowroom; | |
736 else | |
737 coded[i] = (posts[i] - predicted) << 1; | |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
738 } else { |
3917 | 739 if (predicted - posts[i] > room) |
740 coded[i] = predicted - posts[i] + highroom - 1; | |
741 else | |
742 coded[i] = ((predicted - posts[i]) << 1) - 1; | |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
743 } |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
744 } |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
745 |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
746 counter = 2; |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
747 for (i = 0; i < fc->partitions; i++) { |
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
748 floor_class_t * c = &fc->classes[fc->partition_to_class[i]]; |
3874
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
749 int k, cval = 0, csub = 1<<c->subclass; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
750 if (c->subclass) { |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
751 codebook_t * book = &venc->codebooks[c->masterbook]; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
752 int cshift = 0; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
753 for (k = 0; k < c->dim; k++) { |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
754 int l; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
755 for (l = 0; l < csub; l++) { |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
756 int maxval = 1; |
3917 | 757 if (c->books[l] != -1) |
758 maxval = venc->codebooks[c->books[l]].nentries; | |
5127 | 759 // coded could be -1, but this still works, cause that is 0 |
3874
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
760 if (coded[counter + k] < maxval) break; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
761 } |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
762 assert(l != csub); |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
763 cval |= l << cshift; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
764 cshift += c->subclass; |
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
765 } |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
766 put_codeword(pb, book, cval); |
3874
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
767 } |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
768 for (k = 0; k < c->dim; k++) { |
3877
00623377043e
Original Commit: r77 | ods15 | 2006-09-29 15:12:56 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3876
diff
changeset
|
769 int book = c->books[cval & (csub-1)]; |
3863
2c8d1cadd86e
Original Commit: r63 | ods15 | 2006-09-25 13:51:44 +0300 (Mon, 25 Sep 2006) | 3 lines
ods15
parents:
3862
diff
changeset
|
770 int entry = coded[counter++]; |
3874
84890fea8074
Original Commit: r74 | ods15 | 2006-09-29 13:03:31 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3873
diff
changeset
|
771 cval >>= c->subclass; |
3877
00623377043e
Original Commit: r77 | ods15 | 2006-09-29 15:12:56 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3876
diff
changeset
|
772 if (book == -1) continue; |
3864
df84b5d1a8c2
Original Commit: r64 | ods15 | 2006-09-25 18:39:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3863
diff
changeset
|
773 if (entry == -1) entry = 0; |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
774 put_codeword(pb, &venc->codebooks[book], entry); |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
775 } |
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
776 } |
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
777 |
3910
aada0ac47451
Original Commit: r111 | ods15 | 2006-10-01 19:40:50 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3909
diff
changeset
|
778 ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded, fc->multiplier, floor, samples); |
3860
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
779 } |
be0344cea4ea
Original Commit: r60 | ods15 | 2006-09-25 12:46:30 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3859
diff
changeset
|
780 |
3858
70b4bc721531
Original Commit: r58 | ods15 | 2006-09-24 17:35:28 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3857
diff
changeset
|
781 static float * put_vector(codebook_t * book, PutBitContext * pb, float * num) { |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
782 int i, entry = -1; |
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
783 float distance = FLT_MAX; |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
784 assert(book->dimentions); |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
785 for (i = 0; i < book->nentries; i++) { |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
786 float * vec = book->dimentions + i * book->ndimentions, d = book->pow2[i]; |
3858
70b4bc721531
Original Commit: r58 | ods15 | 2006-09-24 17:35:28 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3857
diff
changeset
|
787 int j; |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
788 if (!book->lens[i]) continue; |
3917 | 789 for (j = 0; j < book->ndimentions; j++) |
790 d -= vec[j] * num[j]; | |
3908
045c650f0951
Original Commit: r109 | ods15 | 2006-10-01 19:14:52 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3907
diff
changeset
|
791 if (distance > d) { |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
792 entry = i; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
793 distance = d; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
794 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
795 } |
3899
c3e90a13ff29
Original Commit: r100 | ods15 | 2006-10-01 14:01:27 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3898
diff
changeset
|
796 put_codeword(pb, book, entry); |
3858
70b4bc721531
Original Commit: r58 | ods15 | 2006-09-24 17:35:28 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3857
diff
changeset
|
797 return &book->dimentions[entry * book->ndimentions]; |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
798 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
799 |
3882
6c03e983f866
Original Commit: r82 | ods15 | 2006-09-29 21:03:43 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3881
diff
changeset
|
800 static void residue_encode(venc_context_t * venc, residue_t * rc, PutBitContext * pb, float * coeffs, int samples, int real_ch) { |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
801 int pass, i, j, p, k; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
802 int psize = rc->partition_size; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
803 int partitions = (rc->end - rc->begin) / psize; |
3882
6c03e983f866
Original Commit: r82 | ods15 | 2006-09-29 21:03:43 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3881
diff
changeset
|
804 int channels = (rc->type == 2) ? 1 : real_ch; |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
805 int classes[channels][partitions]; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
806 int classwords = venc->codebooks[rc->classbook].ndimentions; |
3871
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
807 |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
808 assert(rc->type == 2); |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
809 assert(real_ch == 2); |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
810 for (p = 0; p < partitions; p++) { |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
811 float max1 = 0., max2 = 0.; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
812 int s = rc->begin + p * psize; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
813 for (k = s; k < s + psize; k += 2) { |
3903
7a57a82cfa10
Original Commit: r104 | ods15 | 2006-10-01 18:04:08 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3902
diff
changeset
|
814 max1 = FFMAX(max1, fabs(coeffs[ k / real_ch])); |
7a57a82cfa10
Original Commit: r104 | ods15 | 2006-10-01 18:04:08 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3902
diff
changeset
|
815 max2 = FFMAX(max2, fabs(coeffs[samples + k / real_ch])); |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
816 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
817 |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
818 for (i = 0; i < rc->classifications - 1; i++) { |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
819 if (max1 < rc->maxes[i][0] && max2 < rc->maxes[i][1]) break; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
820 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
821 classes[0][p] = i; |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
822 } |
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
823 |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
824 for (pass = 0; pass < 8; pass++) { |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
825 p = 0; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
826 while (p < partitions) { |
3917 | 827 if (pass == 0) |
828 for (j = 0; j < channels; j++) { | |
829 codebook_t * book = &venc->codebooks[rc->classbook]; | |
830 int entry = 0; | |
831 for (i = 0; i < classwords; i++) { | |
832 entry *= rc->classifications; | |
833 entry += classes[j][p + i]; | |
834 } | |
835 put_codeword(pb, book, entry); | |
3881
b272797e8149
Original Commit: r81 | ods15 | 2006-09-29 21:02:09 +0300 (Fri, 29 Sep 2006) | 2 lines
ods15
parents:
3880
diff
changeset
|
836 } |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
837 for (i = 0; i < classwords && p < partitions; i++, p++) { |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
838 for (j = 0; j < channels; j++) { |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
839 int nbook = rc->books[classes[j][p]][pass]; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
840 codebook_t * book = &venc->codebooks[nbook]; |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
841 float * buf = coeffs + samples*j + rc->begin + p*psize; |
3856
5812c2d48dbd
Original Commit: r55 | ods15 | 2006-09-24 13:54:43 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3855
diff
changeset
|
842 if (nbook == -1) continue; |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
843 |
3871
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
844 assert(rc->type == 0 || rc->type == 2); |
3858
70b4bc721531
Original Commit: r58 | ods15 | 2006-09-24 17:35:28 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3857
diff
changeset
|
845 assert(!(psize % book->ndimentions)); |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
846 |
3871
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
847 if (rc->type == 0) { |
3872
9f99e471bf72
Original Commit: r72 | ods15 | 2006-09-28 21:00:47 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3871
diff
changeset
|
848 for (k = 0; k < psize; k += book->ndimentions) { |
9f99e471bf72
Original Commit: r72 | ods15 | 2006-09-28 21:00:47 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3871
diff
changeset
|
849 float * a = put_vector(book, pb, &buf[k]); |
9f99e471bf72
Original Commit: r72 | ods15 | 2006-09-28 21:00:47 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3871
diff
changeset
|
850 int l; |
3917 | 851 for (l = 0; l < book->ndimentions; l++) |
852 buf[k + l] -= a[l]; | |
3872
9f99e471bf72
Original Commit: r72 | ods15 | 2006-09-28 21:00:47 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3871
diff
changeset
|
853 } |
3871
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
854 } else { |
3907
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
855 int s = rc->begin + p * psize, a1, b1; |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
856 a1 = (s % real_ch) * samples; |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
857 b1 = s / real_ch; |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
858 s = real_ch * samples; |
3871
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
859 for (k = 0; k < psize; k += book->ndimentions) { |
3907
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
860 int dim, a2 = a1, b2 = b1; |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
861 float vec[book->ndimentions], * pv = vec; |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
862 for (dim = book->ndimentions; dim--; ) { |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
863 *pv++ = coeffs[a2 + b2]; |
3917 | 864 if ((a2 += samples) == s) { |
865 a2=0; | |
866 b2++; | |
867 } | |
3907
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
868 } |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
869 pv = put_vector(book, pb, vec); |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
870 for (dim = book->ndimentions; dim--; ) { |
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
871 coeffs[a1 + b1] -= *pv++; |
3917 | 872 if ((a1 += samples) == s) { |
873 a1=0; | |
874 b1++; | |
875 } | |
3907
5f5525341673
Original Commit: r108 | ods15 | 2006-10-01 18:46:06 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3906
diff
changeset
|
876 } |
3871
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
877 } |
7fffd3ab056a
Original Commit: r71 | ods15 | 2006-09-28 21:00:24 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3870
diff
changeset
|
878 } |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
879 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
880 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
881 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
882 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
883 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
884 |
3905
557b95209664
Original Commit: r106 | ods15 | 2006-10-01 18:11:55 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3904
diff
changeset
|
885 static int apply_window_and_mdct(venc_context_t * venc, signed short * audio, int samples) { |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
886 int i, j, channel; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
887 const float * win = venc->win[0]; |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
888 int window_len = 1 << (venc->log2_blocksize[0] - 1); |
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
889 float n = (float)(1 << venc->log2_blocksize[0]) / 4.; |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
890 // FIXME use dsp |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
891 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
892 if (!venc->have_saved && !samples) return 0; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
893 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
894 if (venc->have_saved) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
895 for (channel = 0; channel < venc->channels; channel++) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
896 memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
897 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
898 } else { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
899 for (channel = 0; channel < venc->channels; channel++) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
900 memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
901 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
902 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
903 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
904 if (samples) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
905 for (channel = 0; channel < venc->channels; channel++) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
906 float * offset = venc->samples + channel*window_len*2 + window_len; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
907 j = channel; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
908 for (i = 0; i < samples; i++, j += venc->channels) |
4498
2832b65bd37e
vorbis suffers from the same sign flip issue as wma (so this lame workaround, though it arguably doesnt matter much where the sign is fliped back)
michael
parents:
3947
diff
changeset
|
909 offset[i] = -audio[j] / 32768. / n * win[window_len - i - 1]; //FIXME find out why the sign has to be fliped |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
910 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
911 } else { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
912 for (channel = 0; channel < venc->channels; channel++) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
913 memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
914 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
915 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
916 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
917 for (channel = 0; channel < venc->channels; channel++) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
918 ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor/*tmp*/); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
919 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
920 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
921 if (samples) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
922 for (channel = 0; channel < venc->channels; channel++) { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
923 float * offset = venc->saved + channel*window_len; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
924 j = channel; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
925 for (i = 0; i < samples; i++, j += venc->channels) |
4498
2832b65bd37e
vorbis suffers from the same sign flip issue as wma (so this lame workaround, though it arguably doesnt matter much where the sign is fliped back)
michael
parents:
3947
diff
changeset
|
926 offset[i] = -audio[j] / 32768. / n * win[i]; //FIXME find out why the sign has to be fliped |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
927 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
928 venc->have_saved = 1; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
929 } else { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
930 venc->have_saved = 0; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
931 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
932 return 1; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
933 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
934 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
5215
diff
changeset
|
935 static av_cold int vorbis_encode_init(AVCodecContext * avccontext) |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
936 { |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
937 venc_context_t * venc = avccontext->priv_data; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
938 |
3906
5ae5224790d3
Original Commit: r107 | ods15 | 2006-10-01 18:13:12 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3905
diff
changeset
|
939 if (avccontext->channels != 2) { |
5ae5224790d3
Original Commit: r107 | ods15 | 2006-10-01 18:13:12 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3905
diff
changeset
|
940 av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n"); |
5ae5224790d3
Original Commit: r107 | ods15 | 2006-10-01 18:13:12 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3905
diff
changeset
|
941 return -1; |
5ae5224790d3
Original Commit: r107 | ods15 | 2006-10-01 18:13:12 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3905
diff
changeset
|
942 } |
3896
46ab70354691
Original Commit: r97 | ods15 | 2006-09-30 23:32:19 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3895
diff
changeset
|
943 |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
944 create_vorbis_context(venc, avccontext); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
945 |
3917 | 946 if (avccontext->flags & CODEC_FLAG_QSCALE) |
947 venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; | |
948 else | |
949 venc->quality = 1.; | |
3911
a1b41e814052
Original Commit: r112 | ods15 | 2006-10-01 20:48:39 +0200 (Sun, 01 Oct 2006) | 3 lines
ods15
parents:
3910
diff
changeset
|
950 venc->quality *= venc->quality; |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
951 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
952 avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
953 |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
954 avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1); |
3859
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
955 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
956 avccontext->coded_frame = avcodec_alloc_frame(); |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
957 avccontext->coded_frame->key_frame = 1; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
958 |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
959 return 0; |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
960 } |
0d0bd4b2baef
Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
ods15
parents:
3858
diff
changeset
|
961 |
3808 | 962 static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data) |
963 { | |
964 venc_context_t * venc = avccontext->priv_data; | |
965 signed short * audio = data; | |
3833
d4c01d85fb46
Original Commit: r27 | ods15 | 2006-09-22 14:19:51 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3832
diff
changeset
|
966 int samples = data ? avccontext->frame_size : 0; |
3839
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
967 vorbis_mode_t * mode; |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
968 mapping_t * mapping; |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
969 PutBitContext pb; |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
970 int i; |
3808 | 971 |
3905
557b95209664
Original Commit: r106 | ods15 | 2006-10-01 18:11:55 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3904
diff
changeset
|
972 if (!apply_window_and_mdct(venc, audio, samples)) return 0; |
3913
f2204277a928
Original Commit: r114 | ods15 | 2006-10-01 21:38:37 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3912
diff
changeset
|
973 samples = 1 << (venc->log2_blocksize[0] - 1); |
3842
5f8cfa1a6fdb
Original Commit: r39 | ods15 | 2006-09-23 09:36:11 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3841
diff
changeset
|
974 |
3839
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
975 init_put_bits(&pb, packets, buf_size); |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
976 |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
977 put_bits(&pb, 1, 0); // magic bit |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
978 |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
979 put_bits(&pb, ilog(venc->nmodes - 1), 0); // 0 bits, the mode |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
980 |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
981 mode = &venc->modes[0]; |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
982 mapping = &venc->mappings[mode->mapping]; |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
983 if (mode->blockflag) { |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
984 put_bits(&pb, 1, 0); |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
985 put_bits(&pb, 1, 0); |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
986 } |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
987 |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
988 for (i = 0; i < venc->channels; i++) { |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
989 floor_t * fc = &venc->floors[mapping->floor[mapping->mux[i]]]; |
3910
aada0ac47451
Original Commit: r111 | ods15 | 2006-10-01 19:40:50 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3909
diff
changeset
|
990 uint_fast16_t posts[fc->values]; |
3861
b98ea563e9bc
Original Commit: r61 | ods15 | 2006-09-25 13:10:56 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3860
diff
changeset
|
991 floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples); |
3862
ee9379fc77a9
Original Commit: r62 | ods15 | 2006-09-25 13:12:07 +0300 (Mon, 25 Sep 2006) | 2 lines
ods15
parents:
3861
diff
changeset
|
992 floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples); |
3839
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
993 } |
c5ec6d7710ba
Original Commit: r36 | ods15 | 2006-09-23 08:43:09 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3838
diff
changeset
|
994 |
3909
3cac42cde8ea
Original Commit: r110 | ods15 | 2006-10-01 19:17:32 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3908
diff
changeset
|
995 for (i = 0; i < venc->channels * samples; i++) { |
3cac42cde8ea
Original Commit: r110 | ods15 | 2006-10-01 19:17:32 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3908
diff
changeset
|
996 venc->coeffs[i] /= venc->floor[i]; |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
997 } |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
998 |
3870
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
999 for (i = 0; i < mapping->coupling_steps; i++) { |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1000 float * mag = venc->coeffs + mapping->magnitude[i] * samples; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1001 float * ang = venc->coeffs + mapping->angle[i] * samples; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1002 int j; |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1003 for (j = 0; j < samples; j++) { |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1004 float a = ang[j]; |
3904
24e73ad62e40
Original Commit: r105 | ods15 | 2006-10-01 18:09:55 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3903
diff
changeset
|
1005 ang[j] -= mag[j]; |
24e73ad62e40
Original Commit: r105 | ods15 | 2006-10-01 18:09:55 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3903
diff
changeset
|
1006 if (mag[j] > 0) ang[j] = -ang[j]; |
24e73ad62e40
Original Commit: r105 | ods15 | 2006-10-01 18:09:55 +0200 (Sun, 01 Oct 2006) | 2 lines
ods15
parents:
3903
diff
changeset
|
1007 if (ang[j] < 0) mag[j] = a; |
3870
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1008 } |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1009 } |
986fb3b8fe60
Original Commit: r70 | ods15 | 2006-09-28 19:07:36 +0300 (Thu, 28 Sep 2006) | 2 lines
ods15
parents:
3869
diff
changeset
|
1010 |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
1011 residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels); |
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
1012 |
3895
a9d7e965d24f
Original Commit: r96 | ods15 | 2006-09-30 23:25:18 +0300 (Sat, 30 Sep 2006) | 2 lines
ods15
parents:
3894
diff
changeset
|
1013 flush_put_bits(&pb); |
3844
bffe869bc19c
Original Commit: r41 | ods15 | 2006-09-23 10:52:34 +0300 (Sat, 23 Sep 2006) | 4 lines
ods15
parents:
3843
diff
changeset
|
1014 return (put_bits_count(&pb) + 7) / 8; |
3808 | 1015 } |
1016 | |
1017 | |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
5215
diff
changeset
|
1018 static av_cold int vorbis_encode_close(AVCodecContext * avccontext) |
3808 | 1019 { |
1020 venc_context_t * venc = avccontext->priv_data; | |
3831
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1021 int i; |
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1022 |
3917 | 1023 if (venc->codebooks) |
1024 for (i = 0; i < venc->ncodebooks; i++) { | |
1025 av_freep(&venc->codebooks[i].lens); | |
1026 av_freep(&venc->codebooks[i].codewords); | |
1027 av_freep(&venc->codebooks[i].quantlist); | |
1028 av_freep(&venc->codebooks[i].dimentions); | |
1029 av_freep(&venc->codebooks[i].pow2); | |
1030 } | |
3831
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1031 av_freep(&venc->codebooks); |
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1032 |
3917 | 1033 if (venc->floors) |
1034 for (i = 0; i < venc->nfloors; i++) { | |
1035 int j; | |
1036 if (venc->floors[i].classes) | |
1037 for (j = 0; j < venc->floors[i].nclasses; j++) | |
1038 av_freep(&venc->floors[i].classes[j].books); | |
3918 | 1039 av_freep(&venc->floors[i].classes); |
3917 | 1040 av_freep(&venc->floors[i].partition_to_class); |
1041 av_freep(&venc->floors[i].list); | |
1042 } | |
3831
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1043 av_freep(&venc->floors); |
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1044 |
3917 | 1045 if (venc->residues) |
1046 for (i = 0; i < venc->nresidues; i++) { | |
1047 av_freep(&venc->residues[i].books); | |
1048 av_freep(&venc->residues[i].maxes); | |
1049 } | |
3831
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1050 av_freep(&venc->residues); |
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1051 |
3917 | 1052 if (venc->mappings) |
1053 for (i = 0; i < venc->nmappings; i++) { | |
1054 av_freep(&venc->mappings[i].mux); | |
1055 av_freep(&venc->mappings[i].floor); | |
1056 av_freep(&venc->mappings[i].residue); | |
3919 | 1057 av_freep(&venc->mappings[i].magnitude); |
1058 av_freep(&venc->mappings[i].angle); | |
3917 | 1059 } |
3831
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1060 av_freep(&venc->mappings); |
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1061 |
7d27ba61600e
Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents:
3830
diff
changeset
|
1062 av_freep(&venc->modes); |
3808 | 1063 |
3841
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1064 av_freep(&venc->saved); |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1065 av_freep(&venc->samples); |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1066 av_freep(&venc->floor); |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1067 av_freep(&venc->coeffs); |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1068 |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1069 ff_mdct_end(&venc->mdct[0]); |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1070 ff_mdct_end(&venc->mdct[1]); |
6591b55f6482
Original Commit: r38 | ods15 | 2006-09-23 09:02:34 +0300 (Sat, 23 Sep 2006) | 2 lines
ods15
parents:
3840
diff
changeset
|
1071 |
3808 | 1072 av_freep(&avccontext->coded_frame); |
1073 av_freep(&avccontext->extradata); | |
1074 | |
1075 return 0 ; | |
1076 } | |
1077 | |
7131 | 1078 AVCodec vorbis_encoder = { |
3808 | 1079 "vorbis", |
1080 CODEC_TYPE_AUDIO, | |
1081 CODEC_ID_VORBIS, | |
1082 sizeof(venc_context_t), | |
1083 vorbis_encode_init, | |
1084 vorbis_encode_frame, | |
1085 vorbis_encode_close, | |
1086 .capabilities= CODEC_CAP_DELAY, | |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
1087 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), |
3808 | 1088 }; |