1 /*
2 * SMPTE 302M encoder
3 * Copyright (c) 2010 Google, Inc.
4 * Copyright (c) 2013 Darryl Wallace <wallacdj@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
27
28 #define AES3_HEADER_LEN 4
29
33
35 {
37
40 "Encoding %d channel(s) is not allowed. Only 2, 4, 6 and 8 channels are supported.\n",
43 }
44
48 break;
58 }
59 }
60
65
66 return 0;
67 }
68
71 {
80
83
93
95 const uint32_t *samples = (uint32_t *)frame->
data[0];
96
99
100 for (channels = 0; channels < avctx->
channels; channels += 2) {
101 o[0] =
ff_reverse[(samples[0] & 0x0000FF00) >> 8];
102 o[1] =
ff_reverse[(samples[0] & 0x00FF0000) >> 16];
103 o[2] =
ff_reverse[(samples[0] & 0xFF000000) >> 24];
104 o[3] =
ff_reverse[(samples[1] & 0x00000F00) >> 4] | vucf;
105 o[4] =
ff_reverse[(samples[1] & 0x000FF000) >> 12];
106 o[5] =
ff_reverse[(samples[1] & 0x0FF00000) >> 20];
107 o[6] =
ff_reverse[(samples[1] & 0xF0000000) >> 28];
108 o += 7;
109 samples += 2;
110 }
111
115 }
117 const uint32_t *samples = (uint32_t *)frame->
data[0];
118
121
122 for (channels = 0; channels < avctx->
channels; channels += 2) {
123 o[0] =
ff_reverse[ (samples[0] & 0x000FF000) >> 12];
124 o[1] =
ff_reverse[ (samples[0] & 0x0FF00000) >> 20];
125 o[2] =
ff_reverse[((samples[0] & 0xF0000000) >> 28) | vucf];
126 o[3] =
ff_reverse[ (samples[1] & 0x000FF000) >> 12];
127 o[4] =
ff_reverse[ (samples[1] & 0x0FF00000) >> 20];
128 o[5] =
ff_reverse[ (samples[1] & 0xF0000000) >> 28];
129 o += 6;
130 samples += 2;
131 }
132
136 }
138 const uint16_t *samples = (uint16_t *)frame->
data[0];
139
142
143 for (channels = 0; channels < avctx->
channels; channels += 2) {
145 o[1] =
ff_reverse[(samples[0] & 0xFF00) >> 8];
146 o[2] =
ff_reverse[(samples[1] & 0x0F) << 4] | vucf;
147 o[3] =
ff_reverse[(samples[1] & 0x0FF0) >> 4];
148 o[4] =
ff_reverse[(samples[1] & 0xF000) >> 12];
149 o += 5;
150 samples += 2;
151
152 }
153
157 }
158 }
159
160 *got_packet_ptr = 1;
161
162 return 0;
163 }
164
177 .supported_samplerates = (const int[]) { 48000, 0 },
178 };