annotate vorbis_enc.c @ 3831:7d27ba61600e libavcodec

Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines add proper uninit/free to all vorbis encoder context
author ods15
date Mon, 02 Oct 2006 05:56:01 +0000
parents 477ee30c6fc6
children 3d159e4cde5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
1 /*
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
2 * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org>
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
3 *
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
8 *
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
12 * Lesser General Public License for more details.
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
13 *
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
15 * License along with this library; if not, write to the Free Software
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
17 */
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
18
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
19 /**
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
20 * @file vorbis_enc.c
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
21 * Native Vorbis encoder.
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
22 * @author Oded Shimon <ods15@ods15.dyndns.org>
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
23 */
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
24
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
25 #include "avcodec.h"
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
26
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
27 #undef NDEBUG
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
28 #include <assert.h>
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
29
3810
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
30 #define ALT_BITSTREAM_READER_LE
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
31 #include "bitstream.h"
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
32
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
33 #define VORBIS_FRAME_SIZE 64
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
34
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
35 #define BUFFER_SIZE (1024*64)
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
36
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
37 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
38 int len;
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
39 uint32_t codeword;
3818
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
40 } cb_entry_t;
3810
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
41
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
42 typedef struct {
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 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
44 cb_entry_t * entries;
3810
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 ndimentions;
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
46 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
47 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
48 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
49 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
50 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
51 float * dimentions;
3810
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
52 } 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
53
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
54 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
55 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
56 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
57 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
58 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
59 } 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
60
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 int values;
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
69 struct { int x; } * 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
70 } 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
71
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
72 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
73 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
74 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
75 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
76 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
77 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
78 int classbook;
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
79 int (*books)[8];
3813
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
80 } 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
81
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
82 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
83 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
84 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
85 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
86 int * residue;
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;
3818
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
97 int blocksize[2]; // in (1<<n) format
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
98
3810
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
99 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
100 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
101
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
102 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
103 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
104
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
105 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
106 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
107
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
108 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
109 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
110
3ca15f0d4882 Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents: 3816
diff changeset
111 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
112 vorbis_mode_t * modes;
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
113 } venc_context_t;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
114
3818
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
115 static int cb_lookup_vals(int lookup, int dimentions, int entries) {
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
116 if (lookup == 1) {
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
117 int tmp, i;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
118 for (tmp = 0; ; tmp++) {
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
119 int n = 1;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
120 for (i = 0; i < dimentions; i++) n *= tmp;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
121 if (n > entries) break;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
122 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
123 return tmp - 1;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
124 } else if (lookup == 2) return dimentions * entries;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
125 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
126 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
127
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
128 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
129 int h[33] = { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
130 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
131
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
132 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
133 cb_entry_t * e = &cb->entries[i];
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
134 int j = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
135 if (h[0]) h[0] = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
136 else for (j = e->len; !h[j]; j--) assert(j);
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
137 e->codeword = h[j];
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
138 h[j] = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
139 for (j++; j <= e->len; j++) h[j] = e->codeword | (1 << (j - 1));
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
140 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
141 for (i = 0; i < 33; i++) assert(!h[i]);
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
142
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
143 if (!cb->lookup) cb->dimentions = NULL;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
144 else {
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
145 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
146 cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
147 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
148 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
149 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
150 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
151 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
152 int off;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
153 if (cb->lookup == 1) off = (i / div) % vals; // lookup type 1
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
154 else off = i * cb->ndimentions + j; // lookup type 2
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
155
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
156 cb->dimentions[i * cb->ndimentions + j] = last + cb->min + cb->quantlist[off] * cb->delta;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
157 if (cb->seq_p) last = cb->dimentions[i * 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
158 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
159 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
160 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
161 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
162
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
163 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
164
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
165 static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) {
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
166 codebook_t * cb;
3825
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
167 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
168 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
169 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
170 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
171
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
172 venc->channels = avccontext->channels;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
173 venc->sample_rate = avccontext->sample_rate;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
174 venc->blocksize[0] = venc->blocksize[1] = 8;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
175
3820
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
176 venc->ncodebooks = 10;
3818
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
177 venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks);
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
178
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
179 // codebook 1 - floor1 book, values 0..255
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
180 cb = &venc->codebooks[0];
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
181 cb->nentries = 256;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
182 cb->entries = av_malloc(sizeof(cb_entry_t) * 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
183 for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 8;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
184 cb->ndimentions = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
185 cb->min = 0.;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
186 cb->delta = 0.;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
187 cb->seq_p = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
188 cb->lookup = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
189 cb->quantlist = NULL;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
190 ready_codebook(cb);
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
191
3822
a7f46bc1fea0 Original Commit: r16 | ods15 | 2006-09-22 12:27:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3821
diff changeset
192 // codebook 2 - residue classbook, values 0..1, dimentions 200
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 cb = &venc->codebooks[1];
3822
a7f46bc1fea0 Original Commit: r16 | ods15 | 2006-09-22 12:27:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3821
diff changeset
194 cb->nentries = 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
195 cb->entries = av_malloc(sizeof(cb_entry_t) * 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
196 for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 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 cb->ndimentions = 200;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
198 cb->min = 0.;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
199 cb->delta = 0.;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
200 cb->seq_p = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
201 cb->lookup = 0;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
202 cb->quantlist = NULL;
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
203 ready_codebook(cb);
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
204
3820
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
205 // codebook 3..10 - vector, for the residue, values -32767..32767, dimentions 1
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
206 for (book = 0; book < 8; book++) {
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
207 cb = &venc->codebooks[2 + book];
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
208 cb->nentries = 5;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
209 cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
210 for (i = 0; i < cb->nentries; i++) cb->entries[i].len = i == 2 ? 1 : 3;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
211 cb->ndimentions = 1;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
212 cb->delta = 1 << ((7 - book) * 2);
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
213 cb->min = -cb->delta*2;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
214 cb->seq_p = 0;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
215 cb->lookup = 2;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
216 cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
217 for (i = 0; i < cb->nentries; i++) cb->quantlist[i] = i;
3cfdf99da951 Original Commit: r14 | ods15 | 2006-09-22 12:26:17 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3819
diff changeset
218 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
219 }
3818
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
220
3825
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
221 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
222 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
223
c583e895f980 Original Commit: r20 | ods15 | 2006-09-22 13:12:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3825
diff changeset
224 // 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
225 fc = &venc->floors[0];
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
226 fc->partitions = 1;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
227 fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
228 for (i = 0; i < fc->partitions; i++) fc->partition_to_class = 0;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
229 fc->nclasses = 1;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
230 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
231 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
232 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
233 int j, books;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
234 c->dim = 1;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
235 c->subclass = 0;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
236 c->masterbook = 0;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
237 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
238 c->books = av_malloc(sizeof(int) * books);
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
239 for (j = 0; j < books; j++) c->books[j] = 0;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
240 }
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
241 fc->multiplier = 1;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
242 fc->rangebits = venc->blocksize[0];
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
243
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
244 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
245 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
246 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
247
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
248 fc->list = av_malloc(sizeof(*fc->list) * fc->values);
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
249 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
250 fc->list[1].x = 1 << fc->rangebits;
9983437a00a1 Original Commit: r19 | ods15 | 2006-09-22 12:54:18 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3824
diff changeset
251 for (i = 2; i < fc->values; i++) fc->list[i].x = i * 5;
3827
91f130d6c3f4 Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3826
diff changeset
252
91f130d6c3f4 Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3826
diff changeset
253 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
254 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
255
3828
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
256 // 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
257 rc = &venc->residues[0];
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
258 rc->type = 0;
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
259 rc->begin = 0;
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
260 rc->end = 1 << venc->blocksize[0];
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
261 rc->partition_size = 64;
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
262 rc->classifications = 1;
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
263 rc->classbook = 1;
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
264 rc->books = av_malloc(sizeof(int[8]) * rc->classifications);
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
265 for (i = 0; i < 8; i++) rc->books[0][i] = 2 + i;
f9c449155a0e Original Commit: r22 | ods15 | 2006-09-22 13:49:56 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3827
diff changeset
266
3827
91f130d6c3f4 Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3826
diff changeset
267 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
268 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
269
3829
e8e340cbc7f2 Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3828
diff changeset
270 // 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
271 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
272 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
273 mc->mux = av_malloc(sizeof(int) * venc->channels);
e8e340cbc7f2 Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3828
diff changeset
274 for (i = 0; i < venc->channels; i++) mc->mux[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
275 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
276 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
277 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
278 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
279 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
280 }
e8e340cbc7f2 Original Commit: r23 | ods15 | 2006-09-22 13:55:48 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3828
diff changeset
281
3827
91f130d6c3f4 Original Commit: r21 | ods15 | 2006-09-22 13:40:31 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3826
diff changeset
282 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
283 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
284
477ee30c6fc6 Original Commit: r24 | ods15 | 2006-09-22 13:57:09 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3829
diff changeset
285 // 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
286 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
287 venc->modes[0].mapping = 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
288 }
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
289
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
290 static inline int ilog(unsigned int a) {
3810
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
291 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
292 for (i = 0; a >> i; 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
293 return i;
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
294 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
295
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
296 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
297 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
298 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
299 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
300 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
301 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
302 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
303 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
304 }
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
305
3810
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
306 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
307 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
308 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
309
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
310 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
311 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
312 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
313
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
314 for (i = 1; i < cb->nentries; i++) if (cb->entries[i].len < cb->entries[i-1].len) break;
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
315 if (i == cb->nentries) 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
316
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
317 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
318 if (ordered) {
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
319 int len = cb->entries[0].len;
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
320 put_bits(pb, 5, len);
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
321 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
322 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
323 int 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
324 for (j = 0; j+i < cb->nentries; j++) if (cb->entries[j+i].len != 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
325 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
326 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
327 len++;
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
328 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
329 } else {
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
330 int sparse = 0;
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
331 for (i = 0; i < cb->nentries; i++) if (!cb->entries[i].len) break;
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
332 if (i != cb->nentries) 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
333 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
334
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
335 for (i = 0; i < cb->nentries; i++) {
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
336 if (sparse) put_bits(pb, 1, !!cb->entries[i].len);
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
337 if (cb->entries[i].len) put_bits(pb, 5, cb->entries[i].len);
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
338 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
339 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
340
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
341 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
342 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
343 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
344 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
345
3823
41ad23b61a2c Original Commit: r17 | ods15 | 2006-09-22 12:28:28 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3822
diff changeset
346 for (i = 1; i < tmp; i++) 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
347
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
348 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
349 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
350
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
351 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
352 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
353
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
354 for (i = 0; i < tmp; i++) 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
355 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
356 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
357
3814
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
358 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
359 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
360
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
361 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
362
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
363 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
364
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
365 for (i = 0; i < fc->partitions; i++) put_bits(pb, 4, fc->partition_to_class[i]);
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
366
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
367 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
368 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
369
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
370 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
371 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
372
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
373 if (fc->classes[i].subclass) put_bits(pb, 8, fc->classes[i].masterbook);
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
374
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
375 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
376
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
377 for (j = 0; j < books; j++) put_bits(pb, 8, fc->classes[i].books[j] + 1);
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
378 }
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
379
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
380 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
381 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
382
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
383 for (i = 2; i < fc->values; i++) 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
384 }
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
385
3814
464eca766731 Original Commit: r8 | ods15 | 2006-09-17 09:43:38 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3813
diff changeset
386 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
387 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
388
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
389 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
390
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
391 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
392 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
393 put_bits(pb, 24, rc->partition_size - 1);
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
394 put_bits(pb, 6, rc->classifications);
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
395 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
396
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
397 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
398 int j, tmp = 0;
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
399 for (j = 0; j < 8; j++) tmp |= (!!rc->books[i][j]) << j;
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
400
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
401 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
402 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
403
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
404 if (tmp > 7) put_bits(pb, 5, tmp >> 3);
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
405 }
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
406
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
407 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
408 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
409 for (j = 0; j < 8; j++)
3fa081422f78 Original Commit: r9 | ods15 | 2006-09-17 18:56:41 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3814
diff changeset
410 if (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
411 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
412 }
3813
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
413 }
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
414
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 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
416 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
417 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
418 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
419 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
420 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
421
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
422 // 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
423 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
424 put_bits(&pb, 8, 1); //magic
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
425 for (i = 0; "vorbis"[i]; i++) put_bits(&pb, 8, "vorbis"[i]);
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
426 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
427 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
428 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
429 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
430 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
431 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
432 put_bits(&pb, 4, venc->blocksize[0]);
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
433 put_bits(&pb, 4, venc->blocksize[1]);
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
434 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
435
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
436 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
437 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
438 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
439 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
440
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
441 // 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
442 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
443 put_bits(&pb, 8, 3); //magic
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
444 for (i = 0; "vorbis"[i]; i++) put_bits(&pb, 8, "vorbis"[i]);
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
445 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
446 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
447 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
448
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
449 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
450 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
451 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
452 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
453
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
454 // 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
455 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
456 put_bits(&pb, 8, 5); //magic
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
457 for (i = 0; "vorbis"[i]; i++) put_bits(&pb, 8, "vorbis"[i]);
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
458
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
459 // codebooks
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
460 put_bits(&pb, 8, venc->ncodebooks - 1);
3821
5fdb0fa900cd Original Commit: r15 | ods15 | 2006-09-22 12:26:42 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3820
diff changeset
461 for (i = 0; i < venc->ncodebooks; i++) 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
462
3813
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
463 // 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
464 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
465 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
466
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
467 // floors
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
468 put_bits(&pb, 6, venc->nfloors - 1);
3821
5fdb0fa900cd Original Commit: r15 | ods15 | 2006-09-22 12:26:42 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3820
diff changeset
469 for (i = 0; i < venc->nfloors; i++) 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
470
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
471 // residues
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
472 put_bits(&pb, 6, venc->nresidues - 1);
3821
5fdb0fa900cd Original Commit: r15 | ods15 | 2006-09-22 12:26:42 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3820
diff changeset
473 for (i = 0; i < venc->nresidues; i++) 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
474
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
475 // mappings
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
476 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
477 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
478 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
479 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
480 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
481
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
482 put_bits(&pb, 1, mc->submaps > 1);
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
483 if (mc->submaps > 1) put_bits(&pb, 4, mc->submaps - 1);
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
484
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
485 put_bits(&pb, 1, 0); // channel coupling
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
486
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
487 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
488
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
489 if (mc->submaps > 1) for (j = 0; j < venc->channels; j++) put_bits(&pb, 4, mc->mux[j]);
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
490
6eba53afa0b0 Original Commit: r10 | ods15 | 2006-09-17 19:37:17 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3815
diff changeset
491 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
492 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
493 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
494 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
495 }
3813
95b70f8bc29e Original Commit: r7 | ods15 | 2006-09-17 08:50:47 +0300 (Sun, 17 Sep 2006) | 2 lines
ods15
parents: 3812
diff changeset
496 }
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
497
3817
3ca15f0d4882 Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents: 3816
diff changeset
498 // modes
3ca15f0d4882 Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents: 3816
diff changeset
499 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
500 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
501 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
502 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
503 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
504 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
505 }
3ca15f0d4882 Original Commit: r11 | ods15 | 2006-09-17 19:41:28 +0300 (Sun, 17 Sep 2006) | 4 lines
ods15
parents: 3816
diff changeset
506
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
507 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
508 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
509
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
510 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
511 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
512
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
513 *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
514 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
515 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
516 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
517 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
518 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
519 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
520 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
521 }
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
522
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
523 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
524 }
a8bebf3e9cb7 Original Commit: r4 | ods15 | 2006-09-16 15:36:03 +0300 (Sat, 16 Sep 2006) | 3 lines
ods15
parents: 3809
diff changeset
525
3809
500d86b68542 Original Commit: r3 | ods15 | 2006-09-16 11:49:07 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents: 3808
diff changeset
526 static int vorbis_encode_init(AVCodecContext * avccontext)
500d86b68542 Original Commit: r3 | ods15 | 2006-09-16 11:49:07 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents: 3808
diff changeset
527 {
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
528 venc_context_t * venc = avccontext->priv_data;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
529
3818
6a737f2d852e Original Commit: r12 | ods15 | 2006-09-22 09:28:30 +0300 (Fri, 22 Sep 2006) | 5 lines
ods15
parents: 3817
diff changeset
530 create_vorbis_context(venc, avccontext);
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
531
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
532 //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
533 //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
534
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
535 avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
536
3809
500d86b68542 Original Commit: r3 | ods15 | 2006-09-16 11:49:07 +0300 (Sat, 16 Sep 2006) | 2 lines
ods15
parents: 3808
diff changeset
537 avccontext->frame_size = VORBIS_FRAME_SIZE;
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
538
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
539 avccontext->coded_frame = avcodec_alloc_frame();
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
540 avccontext->coded_frame->key_frame = 1;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
541
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
542 return 0;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
543 }
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
544
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
545
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
546 static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data)
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
547 {
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
548 #if 0
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
549 venc_context_t * venc = avccontext->priv_data;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
550 signed short * audio = data;
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 int samples = data ? VORBIS_FRAME_SIZE : 0;
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
552
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
553 avccontext->coded_frame->pts = av_rescale_q(op2->granulepos, (AVRational){1, avccontext->sample_rate}, avccontext->time_base);
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
554 memcpy(packets, compressed_frame, l);
3811
9f6acced986e Original Commit: r5 | ods15 | 2006-09-16 17:29:04 +0300 (Sat, 16 Sep 2006) | 4 lines
ods15
parents: 3810
diff changeset
555 #endif
3824
61d312116e71 Original Commit: r18 | ods15 | 2006-09-22 12:29:26 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3823
diff changeset
556 return data ? 50 : 0;
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
557 }
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
558
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
559
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
560 static int vorbis_encode_close(AVCodecContext * avccontext)
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
561 {
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
562 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
563 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
564
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
565 if (venc->codebooks) for (i = 0; i < venc->ncodebooks; i++) {
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
566 av_freep(&venc->codebooks[i].entries);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
567 av_freep(&venc->codebooks[i].quantlist);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
568 av_freep(&venc->codebooks[i].dimentions);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
569 }
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
570 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
571
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
572 if (venc->floors) for (i = 0; i < venc->nfloors; i++) {
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
573 int j;
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
574 av_freep(&venc->floors[i].classes);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
575 if (venc->floors[i].classes)
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
576 for (j = 0; j < venc->floors[i].nclasses; j++)
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
577 av_freep(&venc->floors[i].classes[j].books);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
578 av_freep(&venc->floors[i].partition_to_class);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
579 av_freep(&venc->floors[i].list);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
580 }
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
581 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
582
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
583 if (venc->residues) for (i = 0; i < venc->nresidues; i++) {
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
584 av_freep(&venc->residues[i].books);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
585 }
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
586 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
587
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
588 if (venc->mappings) for (i = 0; i < venc->nmappings; i++) {
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
589 av_freep(&venc->mappings[i].mux);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
590 av_freep(&venc->mappings[i].floor);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
591 av_freep(&venc->mappings[i].residue);
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
592 }
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
593 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
594
7d27ba61600e Original Commit: r25 | ods15 | 2006-09-22 14:06:04 +0300 (Fri, 22 Sep 2006) | 2 lines
ods15
parents: 3830
diff changeset
595 av_freep(&venc->modes);
3808
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
596
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
597 av_freep(&avccontext->coded_frame);
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
598 av_freep(&avccontext->extradata);
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
599
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
600 return 0 ;
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
601 }
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
602
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
603 AVCodec oggvorbis_encoder = {
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
604 "vorbis",
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
605 CODEC_TYPE_AUDIO,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
606 CODEC_ID_VORBIS,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
607 sizeof(venc_context_t),
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
608 vorbis_encode_init,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
609 vorbis_encode_frame,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
610 vorbis_encode_close,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
611 .capabilities= CODEC_CAP_DELAY,
5551768b5a4f skeleton for vorbis_enc.c
ods15
parents:
diff changeset
612 };