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
31
32 #define AES3_HEADER_LEN 4
33
38
40 int buf_size)
41 {
44
48 }
49
50 /*
51 * AES3 header :
52 * size: 16
53 * number channels 2
54 * channel_id 8
55 * bits per samples 2
56 * alignments 4
57 */
58
62 bits = ((
h >> 4) & 0x0003) * 4 + 16;
63
67 }
68
69 /* Set output properties */
73 else
75
78 case 2:
80 break;
81 case 4:
83 break;
84 case 6:
86 break;
87 case 8:
90 break;
91 default:
94 break;
95 }
96
98 }
99
101 int *got_frame_ptr,
AVPacket *avpkt)
102 {
104 const uint8_t *buf = avpkt->
data;
105 int buf_size = avpkt->
size;
108 int non_pcm_data_type = -1;
109
113
116
117 /* get output buffer */
123
125 32 * 48000 /
frame->nb_samples;
127
129 uint32_t *o = (uint32_t *)
frame->data[0];
130 for (; buf_size > 6; buf_size -= 7) {
134 *o++ = ((unsigned)
ff_reverse[buf[6] & 0xf0] << 28) |
138 buf += 7;
139 }
140 o = (uint32_t *)
frame->data[0];
142 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
143 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
144 break;
145 if (o[
i+4] == 0x96F87200U && o[
i+5] == 0xA54E1F00) {
146 non_pcm_data_type = (o[
i+6] >> 16) & 0x1F;
147 break;
148 }
149 }
151 uint32_t *o = (uint32_t *)
frame->data[0];
152 for (; buf_size > 5; buf_size -= 6) {
153 *o++ = ((unsigned)
ff_reverse[buf[2] & 0xf0] << 28) |
156 *o++ = ((unsigned)
ff_reverse[buf[5] & 0xf0] << 28) |
159 buf += 6;
160 }
161 o = (uint32_t *)
frame->data[0];
163 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
164 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
165 break;
166 if (o[
i+4] == 0x6F872000U && o[
i+5] == 0x54E1F000) {
167 non_pcm_data_type = (o[
i+6] >> 16) & 0x1F;
168 break;
169 }
170 }
171 } else {
172 uint16_t *o = (uint16_t *)
frame->data[0];
173 for (; buf_size > 4; buf_size -= 5) {
179 buf += 5;
180 }
181 o = (uint16_t *)
frame->data[0];
183 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
184 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
185 break;
186 if (o[
i+4] == 0xF872U && o[
i+5] == 0x4E1F) {
187 non_pcm_data_type = (o[
i+6] & 0x1F);
188 break;
189 }
190 }
191 }
192
193 if (non_pcm_data_type != -1) {
194 if (
s->non_pcm_mode == 3) {
196 "S302 non PCM mode with data type %d not supported\n",
197 non_pcm_data_type);
199 }
200 if (
s->non_pcm_mode & 1) {
202 }
203 }
204
206
207 *got_frame_ptr = 1;
208
210 }
211
212 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_DECODING_PARAM
214 {
"non_pcm_mode",
"Chooses what to do with NON-PCM", offsetof(
S302Context, non_pcm_mode),
AV_OPT_TYPE_INT, {.i64 = 3}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
215 {
"copy" ,
"Pass NON-PCM through unchanged" , 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
217 {
"decode_copy" ,
"Decode if possible else passthrough", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
218 {
"decode_drop" ,
"Decode if possible else drop" , 0,
AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
220 };
221
227 };
228
239 };