1 /*
2 * SMPTE 302M decoder
3 * Copyright (c) 2008 Laurent Aimar <fenrir@videolan.org>
4 * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
30
31 #define AES3_HEADER_LEN 4
32
37
39 int buf_size)
40 {
43
47 }
48
49 /*
50 * AES3 header :
51 * size: 16
52 * number channels 2
53 * channel_id 8
54 * bits per samples 2
55 * alignments 4
56 */
57
61 bits = ((
h >> 4) & 0x0003) * 4 + 16;
62
66 }
67
68 /* Set output properties */
72 else
74
77 case 2:
79 break;
80 case 4:
82 break;
83 case 6:
85 break;
86 case 8:
88 }
89
91 }
92
95 {
98 const uint8_t *buf = avpkt->
data;
99 int buf_size = avpkt->
size;
102 int non_pcm_data_type = -1;
103
107
110
111 /* get output buffer */
113 frame->nb_samples = 2 * (buf_size / block_size) / avctx->
channels;
116
118 32 * 48000 /
frame->nb_samples;
119 buf_size = (
frame->nb_samples * avctx->
channels / 2) * block_size;
120
122 uint32_t *o = (uint32_t *)
frame->data[0];
123 for (; buf_size > 6; buf_size -= 7) {
127 *o++ = ((unsigned)
ff_reverse[buf[6] & 0xf0] << 28) |
131 buf += 7;
132 }
133 o = (uint32_t *)
frame->data[0];
135 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
136 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
137 break;
138 if (o[
i+4] == 0x96F87200U && o[
i+5] == 0xA54E1F00) {
139 non_pcm_data_type = (o[
i+6] >> 16) & 0x1F;
140 break;
141 }
142 }
144 uint32_t *o = (uint32_t *)
frame->data[0];
145 for (; buf_size > 5; buf_size -= 6) {
146 *o++ = ((unsigned)
ff_reverse[buf[2] & 0xf0] << 28) |
149 *o++ = ((unsigned)
ff_reverse[buf[5] & 0xf0] << 28) |
152 buf += 6;
153 }
154 o = (uint32_t *)
frame->data[0];
156 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
157 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
158 break;
159 if (o[
i+4] == 0x6F872000U && o[
i+5] == 0x54E1F000) {
160 non_pcm_data_type = (o[
i+6] >> 16) & 0x1F;
161 break;
162 }
163 }
164 } else {
165 uint16_t *o = (uint16_t *)
frame->data[0];
166 for (; buf_size > 4; buf_size -= 5) {
172 buf += 5;
173 }
174 o = (uint16_t *)
frame->data[0];
176 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
177 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
178 break;
179 if (o[
i+4] == 0xF872U && o[
i+5] == 0x4E1F) {
180 non_pcm_data_type = (o[
i+6] & 0x1F);
181 break;
182 }
183 }
184 }
185
186 if (non_pcm_data_type != -1) {
187 if (
s->non_pcm_mode == 3) {
189 "S302 non PCM mode with data type %d not supported\n",
190 non_pcm_data_type);
192 }
193 if (
s->non_pcm_mode & 1) {
195 }
196 }
197
199
200 *got_frame_ptr = 1;
201
203 }
204
205 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_DECODING_PARAM
207 {
"non_pcm_mode",
"Chooses what to do with NON-PCM", offsetof(
S302Context, non_pcm_mode),
AV_OPT_TYPE_INT, {.i64 = 3}, 0, 3,
FLAGS,
"non_pcm_mode"},
208 {
"copy" ,
"Pass NON-PCM through unchanged" , 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 3,
FLAGS,
"non_pcm_mode"},
210 {
"decode_copy" ,
"Decode if possible else passthrough", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 3,
FLAGS,
"non_pcm_mode"},
211 {
"decode_drop" ,
"Decode if possible else drop" , 0,
AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 3,
FLAGS,
"non_pcm_mode"},
213 };
214
220 };
221
232 };