annotate dtsdec.c @ 4889:beeb03aad909 libavcodec

patch so that the deprecated items show up correctly when building doxygen docs patch by mark cox melbournemark plus ffmpeg minus devel chez gmail dot com
author benoit
date Wed, 02 May 2007 09:13:47 +0000
parents ee7422a921cb
children 8f47dc8782f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
1 /*
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
2 * dtsdec.c : free DTS Coherent Acoustics stream decoder.
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
3 * Copyright (C) 2004 Benjamin Zores <ben@geexbox.org>
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3267
diff changeset
5 * This file is part of FFmpeg.
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
6 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3267
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or modify
2126
181cb6785f6b remove dts_internal.h
michael
parents: 2123
diff changeset
8 * it under the terms of the GNU General Public License as published by
3965
418b123f1b74 Fix GPL/LGPL license version mismatch.
diego
parents: 3947
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
2126
181cb6785f6b remove dts_internal.h
michael
parents: 2123
diff changeset
10 * (at your option) any later version.
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2222
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3267
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2126
181cb6785f6b remove dts_internal.h
michael
parents: 2123
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181cb6785f6b remove dts_internal.h
michael
parents: 2123
diff changeset
15 * GNU General Public License for more details.
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2222
diff changeset
16 *
2126
181cb6785f6b remove dts_internal.h
michael
parents: 2123
diff changeset
17 * You should have received a copy of the GNU General Public License
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3267
diff changeset
18 * along with FFmpeg; if not, write to the Free Software
4385
c0e2e4249145 Fix FSF postal address.
diego
parents: 4170
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
20 */
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
21
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
22 #include "avcodec.h"
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
23 #include <dts.h>
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
24
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
25 #include <stdlib.h>
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
26 #include <string.h>
2186
be0ad4f3e8ea bsd patch by (Bohdan Horst <nexus at irc dot pl>)
michael
parents: 2141
diff changeset
27
3267
8072ed8993f6 dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents: 2979
diff changeset
28 #define BUFFER_SIZE 18726
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
29 #define HEADER_SIZE 14
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
30
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
31 #define CONVERT_LEVEL 1
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
32 #define CONVERT_BIAS 0
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
33
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
34 typedef struct DTSContext {
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
35 dts_state_t *state;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
36 uint8_t buf[BUFFER_SIZE];
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
37 uint8_t *bufptr;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
38 uint8_t *bufpos;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
39 } DTSContext;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
40
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
41 static inline int16_t
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
42 convert(sample_t s)
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
43 {
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
44 return s * 0x7fff;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
45 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
46
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
47 static void
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
48 convert2s16_multi(sample_t *f, int16_t *s16, int flags)
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
49 {
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
50 int i;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
51
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
52 switch(flags & (DTS_CHANNEL_MASK | DTS_LFE)){
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
53 case DTS_MONO:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
54 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
55 s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
56 s16[5*i+4] = convert(f[i]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
57 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
58 case DTS_CHANNEL:
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
59 case DTS_STEREO:
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
60 case DTS_DOLBY:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
61 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
62 s16[2*i] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
63 s16[2*i+1] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
64 }
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
65 case DTS_3F:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
66 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
67 s16[5*i] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
68 s16[5*i+1] = convert(f[i+512]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
69 s16[5*i+2] = s16[5*i+3] = 0;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
70 s16[5*i+4] = convert(f[i]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
71 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
72 case DTS_2F2R:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
73 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
74 s16[4*i] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
75 s16[4*i+1] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
76 s16[4*i+2] = convert(f[i+512]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
77 s16[4*i+3] = convert(f[i+768]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
78 }
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
79 case DTS_3F2R:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
80 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
81 s16[5*i] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
82 s16[5*i+1] = convert(f[i+512]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
83 s16[5*i+2] = convert(f[i+768]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
84 s16[5*i+3] = convert(f[i+1024]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
85 s16[5*i+4] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
86 }
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
87 case DTS_MONO | DTS_LFE:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
88 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
89 s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
90 s16[6*i+4] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
91 s16[6*i+5] = convert(f[i+256]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
92 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
93 case DTS_CHANNEL | DTS_LFE:
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
94 case DTS_STEREO | DTS_LFE:
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
95 case DTS_DOLBY | DTS_LFE:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
96 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
97 s16[6*i] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
98 s16[6*i+1] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
99 s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
100 s16[6*i+5] = convert(f[i+512]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
101 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
102 case DTS_3F | DTS_LFE:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
103 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
104 s16[6*i] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
105 s16[6*i+1] = convert(f[i+512]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
106 s16[6*i+2] = s16[6*i+3] = 0;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
107 s16[6*i+4] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
108 s16[6*i+5] = convert(f[i+768]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
109 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
110 case DTS_2F2R | DTS_LFE:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
111 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
112 s16[6*i] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
113 s16[6*i+1] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
114 s16[6*i+2] = convert(f[i+512]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
115 s16[6*i+3] = convert(f[i+768]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
116 s16[6*i+4] = 0;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
117 s16[6*i+5] = convert(f[i+1024]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
118 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
119 case DTS_3F2R | DTS_LFE:
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
120 for(i = 0; i < 256; i++){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
121 s16[6*i] = convert(f[i+256]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
122 s16[6*i+1] = convert(f[i+512]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
123 s16[6*i+2] = convert(f[i+768]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
124 s16[6*i+3] = convert(f[i+1024]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
125 s16[6*i+4] = convert(f[i]);
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
126 s16[6*i+5] = convert(f[i+1280]);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
127 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
128 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
129 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
130
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
131 static int
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
132 channels_multi(int flags)
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
133 {
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
134 switch(flags & (DTS_CHANNEL_MASK | DTS_LFE)){
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
135 case DTS_CHANNEL:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
136 case DTS_STEREO:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
137 case DTS_DOLBY:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
138 return 2;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
139 case DTS_2F2R:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
140 return 4;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
141 case DTS_MONO:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
142 case DTS_3F:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
143 case DTS_3F2R:
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
144 return 5;
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
145 case DTS_MONO | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
146 case DTS_CHANNEL | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
147 case DTS_STEREO | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
148 case DTS_DOLBY | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
149 case DTS_3F | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
150 case DTS_2F2R | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
151 case DTS_3F2R | DTS_LFE:
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
152 return 6;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
153 }
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
154
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
155 return -1;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
156 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
157
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
158 static int
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
159 dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
160 uint8_t * buff, int buff_size)
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
161 {
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
162 DTSContext *s = avctx->priv_data;
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
163 uint8_t *start = buff;
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
164 uint8_t *end = buff + buff_size;
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
165 int16_t *out_samples = data;
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
166 int sample_rate;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
167 int frame_length;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
168 int flags;
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
169 int bit_rate;
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
170 int len;
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
171 level_t level;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
172 sample_t bias;
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
173 int nblocks;
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
174 int i;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
175
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
176 *data_size = 0;
2222
ef568cc0972c 10l (gcc 2.95 compilation)
michael
parents: 2186
diff changeset
177
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
178 while(1) {
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
179 int length;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
180
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
181 len = end - start;
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
182 if(!len)
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
183 break;
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
184 if(len > s->bufpos - s->bufptr)
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
185 len = s->bufpos - s->bufptr;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
186 memcpy(s->bufptr, start, len);
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
187 s->bufptr += len;
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
188 start += len;
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
189 if(s->bufptr != s->bufpos)
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
190 return start - buff;
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
191 if(s->bufpos != s->buf + HEADER_SIZE)
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
192 break;
3267
8072ed8993f6 dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents: 2979
diff changeset
193
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
194 length = dts_syncinfo(s->state, s->buf, &flags, &sample_rate,
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
195 &bit_rate, &frame_length);
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
196 if(!length) {
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
197 av_log(NULL, AV_LOG_INFO, "skip\n");
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
198 for(s->bufptr = s->buf; s->bufptr < s->buf + HEADER_SIZE - 1; s->bufptr++)
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
199 s->bufptr[0] = s->bufptr[1];
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
200 continue;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
201 }
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
202 s->bufpos = s->buf + length;
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
203 }
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
204
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
205 level = CONVERT_LEVEL;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
206 bias = CONVERT_BIAS;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
207
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
208 flags |= DTS_ADJUST_LEVEL;
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
209 if(dts_frame(s->state, s->buf, &flags, &level, bias)) {
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
210 av_log(avctx, AV_LOG_ERROR, "dts_frame() failed\n");
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
211 goto end;
3267
8072ed8993f6 dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents: 2979
diff changeset
212 }
8072ed8993f6 dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents: 2979
diff changeset
213
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
214 avctx->sample_rate = sample_rate;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
215 avctx->channels = channels_multi(flags);
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
216 avctx->bit_rate = bit_rate;
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
217
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
218 nblocks = dts_blocks_num(s->state);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
219
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
220 for(i = 0; i < nblocks; i++) {
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
221 if(dts_block(s->state)) {
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
222 av_log(avctx, AV_LOG_ERROR, "dts_block() failed\n");
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
223 goto end;
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
224 }
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
225
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
226 convert2s16_multi(dts_samples(s->state), out_samples, flags);
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
227
4482
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
228 out_samples += 256 * avctx->channels;
ee7422a921cb fix multichannel decoding
mru
parents: 4481
diff changeset
229 *data_size += 256 * sizeof(int16_t) * avctx->channels;
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
230 }
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
231
4479
f1057be02298 cosmetics: don't needlessly open new blocks
mru
parents: 4478
diff changeset
232 end:
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
233 s->bufptr = s->buf;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
234 s->bufpos = s->buf + HEADER_SIZE;
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
235 return start - buff;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
236 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
237
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
238 static int
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
239 dts_decode_init(AVCodecContext * avctx)
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
240 {
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
241 DTSContext *s = avctx->priv_data;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
242 s->bufptr = s->buf;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
243 s->bufpos = s->buf + HEADER_SIZE;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
244 s->state = dts_init(0);
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
245 if(s->state == NULL)
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
246 return -1;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
247
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
248 return 0;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
249 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
250
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
251 static int
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
252 dts_decode_end(AVCodecContext * avctx)
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
253 {
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
254 DTSContext *s = avctx->priv_data;
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
255 dts_free(s->state);
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
256 return 0;
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
257 }
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
258
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
259 AVCodec dts_decoder = {
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
260 "dts",
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
261 CODEC_TYPE_AUDIO,
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
262 CODEC_ID_DTS,
4481
f3987e08b9da move static variables to private context struct
mru
parents: 4480
diff changeset
263 sizeof(DTSContext),
4478
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
264 dts_decode_init,
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
265 NULL,
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
266 dts_decode_end,
ca8c6efd00d3 cosmetic: indent sensibly so code can be read at all
mru
parents: 4411
diff changeset
267 dts_decode_frame,
2123
ef54decf5624 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff changeset
268 };