Mercurial > libavcodec.hg
annotate dtsdec.c @ 4481:f3987e08b9da libavcodec
move static variables to private context struct
| author | mru |
|---|---|
| date | Mon, 05 Feb 2007 20:17:02 +0000 |
| parents | 3a31e2fc1b9b |
| children | ee7422a921cb |
| 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 | 8 * it under the terms of the GNU General Public License as published by |
| 3965 | 9 * the Free Software Foundation; either version 2 of the License, or |
| 2126 | 10 * (at your option) any later version. |
| 2967 | 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 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 * GNU General Public License for more details. | |
| 2967 | 16 * |
| 2126 | 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 | 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 | 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 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
31 #ifdef LIBDTS_FIXED |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
32 #define CONVERT_LEVEL (1 << 26) |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
33 #define CONVERT_BIAS 0 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
34 #else |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
35 #define CONVERT_LEVEL 1 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
36 #define CONVERT_BIAS 384 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
37 #endif |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
38 |
| 4481 | 39 typedef struct DTSContext { |
| 40 dts_state_t *state; | |
| 41 uint8_t buf[BUFFER_SIZE]; | |
| 42 uint8_t *bufptr; | |
| 43 uint8_t *bufpos; | |
| 44 } DTSContext; | |
| 45 | |
| 4478 | 46 static inline int16_t |
| 47 convert(int32_t i) | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
48 { |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
49 #ifdef LIBDTS_FIXED |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
50 i >>= 15; |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
51 #else |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
52 i -= 0x43c00000; |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
53 #endif |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
54 return (i > 32767) ? 32767 : ((i < -32768) ? -32768 : i); |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
55 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
56 |
| 4170 | 57 static void |
| 4478 | 58 convert2s16_2(sample_t * _f, int16_t * s16) |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
59 { |
| 4478 | 60 int i; |
| 61 int32_t *f = (int32_t *) _f; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
62 |
| 4478 | 63 for(i = 0; i < 256; i++) { |
| 64 s16[2 * i] = convert(f[i]); | |
| 65 s16[2 * i + 1] = convert(f[i + 256]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
66 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
67 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
68 |
| 4170 | 69 static void |
| 4478 | 70 convert2s16_4(sample_t * _f, int16_t * s16) |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
71 { |
| 4478 | 72 int i; |
| 73 int32_t *f = (int32_t *) _f; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
74 |
| 4478 | 75 for(i = 0; i < 256; i++) { |
| 76 s16[4 * i] = convert(f[i]); | |
| 77 s16[4 * i + 1] = convert(f[i + 256]); | |
| 78 s16[4 * i + 2] = convert(f[i + 512]); | |
| 79 s16[4 * i + 3] = convert(f[i + 768]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
80 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
81 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
82 |
| 4170 | 83 static void |
| 4478 | 84 convert2s16_5(sample_t * _f, int16_t * s16) |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
85 { |
| 4478 | 86 int i; |
| 87 int32_t *f = (int32_t *) _f; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
88 |
| 4478 | 89 for(i = 0; i < 256; i++) { |
| 90 s16[5 * i] = convert(f[i]); | |
| 91 s16[5 * i + 1] = convert(f[i + 256]); | |
| 92 s16[5 * i + 2] = convert(f[i + 512]); | |
| 93 s16[5 * i + 3] = convert(f[i + 768]); | |
| 94 s16[5 * i + 4] = convert(f[i + 1024]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
95 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
96 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
97 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
98 static void |
| 4478 | 99 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
|
100 { |
| 4478 | 101 int i; |
| 102 int32_t *f = (int32_t *) _f; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
103 |
| 4478 | 104 switch (flags) { |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
105 case DTS_MONO: |
| 4478 | 106 for(i = 0; i < 256; i++) { |
| 107 s16[5 * i] = s16[5 * i + 1] = s16[5 * i + 2] = s16[5 * i + 3] = | |
| 108 0; | |
| 109 s16[5 * i + 4] = convert(f[i]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
110 } |
| 4478 | 111 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
112 case DTS_CHANNEL: |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
113 case DTS_STEREO: |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
114 case DTS_DOLBY: |
| 4478 | 115 convert2s16_2(_f, s16); |
| 116 break; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
117 case DTS_3F: |
| 4478 | 118 for(i = 0; i < 256; i++) { |
| 119 s16[5 * i] = convert(f[i]); | |
| 120 s16[5 * i + 1] = convert(f[i + 512]); | |
| 121 s16[5 * i + 2] = s16[5 * i + 3] = 0; | |
| 122 s16[5 * i + 4] = convert(f[i + 256]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
123 } |
| 4478 | 124 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
125 case DTS_2F2R: |
| 4478 | 126 convert2s16_4(_f, s16); |
| 127 break; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
128 case DTS_3F2R: |
| 4478 | 129 convert2s16_5(_f, s16); |
| 130 break; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
131 case DTS_MONO | DTS_LFE: |
| 4478 | 132 for(i = 0; i < 256; i++) { |
| 133 s16[6 * i] = s16[6 * i + 1] = s16[6 * i + 2] = s16[6 * i + 3] = | |
| 134 0; | |
| 135 s16[6 * i + 4] = convert(f[i + 256]); | |
| 136 s16[6 * i + 5] = convert(f[i]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
137 } |
| 4478 | 138 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
139 case DTS_CHANNEL | DTS_LFE: |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
140 case DTS_STEREO | DTS_LFE: |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
141 case DTS_DOLBY | DTS_LFE: |
| 4478 | 142 for(i = 0; i < 256; i++) { |
| 143 s16[6 * i] = convert(f[i + 256]); | |
| 144 s16[6 * i + 1] = convert(f[i + 512]); | |
| 145 s16[6 * i + 2] = s16[6 * i + 3] = s16[6 * i + 4] = 0; | |
| 146 s16[6 * i + 5] = convert(f[i]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
147 } |
| 4478 | 148 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
149 case DTS_3F | DTS_LFE: |
| 4478 | 150 for(i = 0; i < 256; i++) { |
| 151 s16[6 * i] = convert(f[i + 256]); | |
| 152 s16[6 * i + 1] = convert(f[i + 768]); | |
| 153 s16[6 * i + 2] = s16[6 * i + 3] = 0; | |
| 154 s16[6 * i + 4] = convert(f[i + 512]); | |
| 155 s16[6 * i + 5] = convert(f[i]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
156 } |
| 4478 | 157 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
158 case DTS_2F2R | DTS_LFE: |
| 4478 | 159 for(i = 0; i < 256; i++) { |
| 160 s16[6 * i] = convert(f[i + 256]); | |
| 161 s16[6 * i + 1] = convert(f[i + 512]); | |
| 162 s16[6 * i + 2] = convert(f[i + 768]); | |
| 163 s16[6 * i + 3] = convert(f[i + 1024]); | |
| 164 s16[6 * i + 4] = 0; | |
| 165 s16[6 * i + 5] = convert(f[i]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
166 } |
| 4478 | 167 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
168 case DTS_3F2R | DTS_LFE: |
| 4478 | 169 for(i = 0; i < 256; i++) { |
| 170 s16[6 * i] = convert(f[i + 256]); | |
| 171 s16[6 * i + 1] = convert(f[i + 768]); | |
| 172 s16[6 * i + 2] = convert(f[i + 1024]); | |
| 173 s16[6 * i + 3] = convert(f[i + 1280]); | |
| 174 s16[6 * i + 4] = convert(f[i + 512]); | |
| 175 s16[6 * i + 5] = convert(f[i]); | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
176 } |
| 4478 | 177 break; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
178 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
179 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
180 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
181 static int |
| 4478 | 182 channels_multi(int flags) |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
183 { |
| 4478 | 184 if(flags & DTS_LFE) |
| 185 return 6; | |
| 186 else if(flags & 1) /* center channel */ | |
| 187 return 5; | |
| 188 else if((flags & DTS_CHANNEL_MASK) == DTS_2F2R) | |
| 189 return 4; | |
| 190 else | |
| 191 return 2; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
192 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
193 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
194 static int |
| 4478 | 195 dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size, |
| 196 uint8_t * buff, int buff_size) | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
197 { |
| 4481 | 198 DTSContext *s = avctx->priv_data; |
| 4478 | 199 uint8_t *start = buff; |
| 200 uint8_t *end = buff + buff_size; | |
| 201 int16_t *out_samples = data; | |
| 4481 | 202 int sample_rate; |
| 203 int frame_length; | |
| 204 int flags; | |
| 4478 | 205 int bit_rate; |
| 206 int len; | |
| 4479 | 207 level_t level; |
| 208 sample_t bias; | |
| 209 int i; | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
210 |
| 4478 | 211 *data_size = 0; |
| 2222 | 212 |
| 4478 | 213 while(1) { |
| 4479 | 214 int length; |
| 215 | |
| 4478 | 216 len = end - start; |
| 217 if(!len) | |
| 218 break; | |
| 4481 | 219 if(len > s->bufpos - s->bufptr) |
| 220 len = s->bufpos - s->bufptr; | |
| 221 memcpy(s->bufptr, start, len); | |
| 222 s->bufptr += len; | |
| 4478 | 223 start += len; |
| 4481 | 224 if(s->bufptr != s->bufpos) |
| 4478 | 225 return start - buff; |
| 4481 | 226 if(s->bufpos != s->buf + HEADER_SIZE) |
| 4478 | 227 break; |
|
3267
8072ed8993f6
dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents:
2979
diff
changeset
|
228 |
| 4481 | 229 length = dts_syncinfo(s->state, s->buf, &flags, &sample_rate, |
| 230 &bit_rate, &frame_length); | |
| 4479 | 231 if(!length) { |
| 232 av_log(NULL, AV_LOG_INFO, "skip\n"); | |
| 4481 | 233 for(s->bufptr = s->buf; s->bufptr < s->buf + HEADER_SIZE - 1; s->bufptr++) |
| 234 s->bufptr[0] = s->bufptr[1]; | |
| 4479 | 235 continue; |
| 236 } | |
| 4481 | 237 s->bufpos = s->buf + length; |
| 4479 | 238 } |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
239 |
| 4479 | 240 flags = 2; /* ???????????? */ |
| 241 level = CONVERT_LEVEL; | |
| 242 bias = CONVERT_BIAS; | |
| 243 | |
| 244 flags |= DTS_ADJUST_LEVEL; | |
| 4481 | 245 if(dts_frame(s->state, s->buf, &flags, &level, bias)) { |
| 4479 | 246 av_log(avctx, AV_LOG_ERROR, "dts_frame() failed\n"); |
| 247 goto end; | |
|
3267
8072ed8993f6
dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents:
2979
diff
changeset
|
248 } |
|
8072ed8993f6
dtsdec.c copies one input packet at a time to a (static) buffer of size
rtognimp
parents:
2979
diff
changeset
|
249 |
| 4479 | 250 avctx->sample_rate = sample_rate; |
| 251 avctx->channels = channels_multi(flags); | |
| 252 avctx->bit_rate = bit_rate; | |
| 4478 | 253 |
| 4481 | 254 for(i = 0; i < dts_blocks_num(s->state); i++) { |
| 4479 | 255 int chans; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
256 |
| 4481 | 257 if(dts_block(s->state)) { |
| 4479 | 258 av_log(avctx, AV_LOG_ERROR, "dts_block() failed\n"); |
| 259 goto end; | |
| 260 } | |
| 4478 | 261 |
| 4479 | 262 chans = channels_multi(flags); |
| 4481 | 263 convert2s16_multi(dts_samples(s->state), out_samples, |
| 4479 | 264 flags & (DTS_CHANNEL_MASK | DTS_LFE)); |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
265 |
| 4479 | 266 out_samples += 256 * chans; |
| 267 *data_size += 256 * sizeof(int16_t) * chans; | |
| 4478 | 268 } |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
269 |
| 4479 | 270 end: |
| 4481 | 271 s->bufptr = s->buf; |
| 272 s->bufpos = s->buf + HEADER_SIZE; | |
| 4478 | 273 return start - buff; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
274 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
275 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
276 static int |
| 4478 | 277 dts_decode_init(AVCodecContext * avctx) |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
278 { |
| 4481 | 279 DTSContext *s = avctx->priv_data; |
| 280 s->bufptr = s->buf; | |
| 281 s->bufpos = s->buf + HEADER_SIZE; | |
| 282 s->state = dts_init(0); | |
| 283 if(s->state == NULL) | |
| 4478 | 284 return -1; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
285 |
| 4478 | 286 return 0; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
287 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
288 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
289 static int |
| 4481 | 290 dts_decode_end(AVCodecContext * avctx) |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
291 { |
| 4481 | 292 DTSContext *s = avctx->priv_data; |
| 293 dts_free(s->state); | |
| 4478 | 294 return 0; |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
295 } |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
296 |
|
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
297 AVCodec dts_decoder = { |
| 4478 | 298 "dts", |
| 299 CODEC_TYPE_AUDIO, | |
| 300 CODEC_ID_DTS, | |
| 4481 | 301 sizeof(DTSContext), |
| 4478 | 302 dts_decode_init, |
| 303 NULL, | |
| 304 dts_decode_end, | |
| 305 dts_decode_frame, | |
|
2123
ef54decf5624
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
diff
changeset
|
306 }; |
