FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/atrac3plusdec.c
Date: 2023-10-02 11:06:47
Exec Total Coverage
Lines: 130 204 63.7%
Functions: 7 7 100.0%
Branches: 52 92 56.5%

Line Branch Exec Source
1 /*
2 * ATRAC3+ compatible decoder
3 *
4 * Copyright (c) 2010-2013 Maxim Poliakovski
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
23 /**
24 * @file
25 * Sony ATRAC3+ compatible decoder.
26 *
27 * Container formats used to store its data:
28 * RIFF WAV (.at3) and Sony OpenMG (.oma, .aa3).
29 *
30 * Technical description of this codec can be found here:
31 * http://wiki.multimedia.cx/index.php?title=ATRAC3plus
32 *
33 * Kudos to Benjamin Larsson and Michael Karcher
34 * for their precious technical help!
35 */
36
37 #include <stdint.h>
38 #include <string.h>
39
40 #include "libavutil/channel_layout.h"
41 #include "libavutil/float_dsp.h"
42 #include "libavutil/mem_internal.h"
43 #include "libavutil/thread.h"
44 #include "avcodec.h"
45 #include "codec_internal.h"
46 #include "decode.h"
47 #include "get_bits.h"
48 #include "atrac.h"
49 #include "atrac3plus.h"
50
51 static const uint8_t channel_map[8][8] = {
52 { 0, },
53 { 0, 1, },
54 { 0, 1, 2, },
55 { 0, 1, 2, 3, },
56 { 0, },
57 { 0, 1, 2, 4, 5, 3, },
58 { 0, 1, 2, 4, 5, 6, 3, },
59 { 0, 1, 2, 4, 5, 6, 7, 3, },
60 };
61
62 typedef struct ATRAC3PContext {
63 GetBitContext gb;
64 AVFloatDSPContext *fdsp;
65
66 DECLARE_ALIGNED(32, float, samples)[2][ATRAC3P_FRAME_SAMPLES]; ///< quantized MDCT spectrum
67 DECLARE_ALIGNED(32, float, mdct_buf)[2][ATRAC3P_FRAME_SAMPLES]; ///< output of the IMDCT
68 DECLARE_ALIGNED(32, float, time_buf)[2][ATRAC3P_FRAME_SAMPLES]; ///< output of the gain compensation
69 DECLARE_ALIGNED(32, float, outp_buf)[2][ATRAC3P_FRAME_SAMPLES];
70
71 AtracGCContext gainc_ctx; ///< gain compensation context
72 AVTXContext *mdct_ctx;
73 av_tx_fn mdct_fn;
74 AVTXContext *ipqf_dct_ctx; ///< IDCT context used by IPQF
75 av_tx_fn ipqf_dct_fn;
76
77 Atrac3pChanUnitCtx *ch_units; ///< global channel units
78
79 int num_channel_blocks; ///< number of channel blocks
80 uint8_t channel_blocks[5]; ///< channel configuration descriptor
81 const uint8_t *channel_map; ///< channel layout map
82 } ATRAC3PContext;
83
84 8 static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
85 {
86 8 ATRAC3PContext *ctx = avctx->priv_data;
87
88 8 av_freep(&ctx->ch_units);
89 8 av_freep(&ctx->fdsp);
90
91 8 av_tx_uninit(&ctx->mdct_ctx);
92 8 av_tx_uninit(&ctx->ipqf_dct_ctx);
93
94 8 return 0;
95 }
96
97 8 static av_cold int set_channel_params(ATRAC3PContext *ctx,
98 AVCodecContext *avctx)
99 {
100 8 int channels = avctx->ch_layout.nb_channels;
101 8 memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks));
102
103 8 av_channel_layout_uninit(&avctx->ch_layout);
104
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8 switch (channels) {
105 case 1:
106 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
107 ctx->num_channel_blocks = 1;
108 ctx->channel_blocks[0] = CH_UNIT_MONO;
109 break;
110 8 case 2:
111 8 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
112 8 ctx->num_channel_blocks = 1;
113 8 ctx->channel_blocks[0] = CH_UNIT_STEREO;
114 8 break;
115 case 3:
116 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND;
117 ctx->num_channel_blocks = 2;
118 ctx->channel_blocks[0] = CH_UNIT_STEREO;
119 ctx->channel_blocks[1] = CH_UNIT_MONO;
120 break;
121 case 4:
122 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0;
123 ctx->num_channel_blocks = 3;
124 ctx->channel_blocks[0] = CH_UNIT_STEREO;
125 ctx->channel_blocks[1] = CH_UNIT_MONO;
126 ctx->channel_blocks[2] = CH_UNIT_MONO;
127 break;
128 case 6:
129 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK;
130 ctx->num_channel_blocks = 4;
131 ctx->channel_blocks[0] = CH_UNIT_STEREO;
132 ctx->channel_blocks[1] = CH_UNIT_MONO;
133 ctx->channel_blocks[2] = CH_UNIT_STEREO;
134 ctx->channel_blocks[3] = CH_UNIT_MONO;
135 break;
136 case 7:
137 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_BACK;
138 ctx->num_channel_blocks = 5;
139 ctx->channel_blocks[0] = CH_UNIT_STEREO;
140 ctx->channel_blocks[1] = CH_UNIT_MONO;
141 ctx->channel_blocks[2] = CH_UNIT_STEREO;
142 ctx->channel_blocks[3] = CH_UNIT_MONO;
143 ctx->channel_blocks[4] = CH_UNIT_MONO;
144 break;
145 case 8:
146 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1;
147 ctx->num_channel_blocks = 5;
148 ctx->channel_blocks[0] = CH_UNIT_STEREO;
149 ctx->channel_blocks[1] = CH_UNIT_MONO;
150 ctx->channel_blocks[2] = CH_UNIT_STEREO;
151 ctx->channel_blocks[3] = CH_UNIT_STEREO;
152 ctx->channel_blocks[4] = CH_UNIT_MONO;
153 break;
154 default:
155 av_log(avctx, AV_LOG_ERROR,
156 "Unsupported channel count: %d!\n", channels);
157 return AVERROR_INVALIDDATA;
158 }
159
160 8 ctx->channel_map = channel_map[channels - 1];
161
162 8 return 0;
163 }
164
165 5 static av_cold void atrac3p_init_static(void)
166 {
167 5 ff_atrac3p_init_vlcs();
168 5 ff_atrac3p_init_dsp_static();
169 5 }
170
171 8 static av_cold int atrac3p_decode_init(AVCodecContext *avctx)
172 {
173 static AVOnce init_static_once = AV_ONCE_INIT;
174 8 ATRAC3PContext *ctx = avctx->priv_data;
175 float scale;
176 int i, ch, ret;
177
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!avctx->block_align) {
179 av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
180 return AVERROR(EINVAL);
181 }
182
183 /* initialize IPQF */
184 8 scale = 32.0 / 32768.0;
185 8 ret = av_tx_init(&ctx->ipqf_dct_ctx, &ctx->ipqf_dct_fn, AV_TX_FLOAT_MDCT,
186 1, 16, &scale, 0);
187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (ret < 0)
188 return ret;
189
190 8 scale = -1.0f;
191 8 ret = av_tx_init(&ctx->mdct_ctx, &ctx->mdct_fn, AV_TX_FLOAT_MDCT,
192 1, 128, &scale, AV_TX_FULL_IMDCT);
193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (ret < 0)
194 return ret;
195
196 8 ff_atrac_init_gain_compensation(&ctx->gainc_ctx, 6, 2);
197
198
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if ((ret = set_channel_params(ctx, avctx)) < 0)
199 return ret;
200
201 8 ctx->ch_units = av_calloc(ctx->num_channel_blocks, sizeof(*ctx->ch_units));
202 8 ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
203
204
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if (!ctx->ch_units || !ctx->fdsp) {
205 return AVERROR(ENOMEM);
206 }
207
208
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for (i = 0; i < ctx->num_channel_blocks; i++) {
209
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 for (ch = 0; ch < 2; ch++) {
210 16 ctx->ch_units[i].channels[ch].ch_num = ch;
211 16 ctx->ch_units[i].channels[ch].wnd_shape = &ctx->ch_units[i].channels[ch].wnd_shape_hist[0][0];
212 16 ctx->ch_units[i].channels[ch].wnd_shape_prev = &ctx->ch_units[i].channels[ch].wnd_shape_hist[1][0];
213 16 ctx->ch_units[i].channels[ch].gain_data = &ctx->ch_units[i].channels[ch].gain_data_hist[0][0];
214 16 ctx->ch_units[i].channels[ch].gain_data_prev = &ctx->ch_units[i].channels[ch].gain_data_hist[1][0];
215 16 ctx->ch_units[i].channels[ch].tones_info = &ctx->ch_units[i].channels[ch].tones_info_hist[0][0];
216 16 ctx->ch_units[i].channels[ch].tones_info_prev = &ctx->ch_units[i].channels[ch].tones_info_hist[1][0];
217 }
218
219 8 ctx->ch_units[i].waves_info = &ctx->ch_units[i].wave_synth_hist[0];
220 8 ctx->ch_units[i].waves_info_prev = &ctx->ch_units[i].wave_synth_hist[1];
221 }
222
223 8 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
224
225 8 ff_thread_once(&init_static_once, atrac3p_init_static);
226
227 8 return 0;
228 }
229
230 813 static void decode_residual_spectrum(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit,
231 float out[2][ATRAC3P_FRAME_SAMPLES],
232 int num_channels,
233 AVCodecContext *avctx)
234 {
235 int i, sb, ch, qu, nspeclines, RNG_index;
236 float *dst, q;
237 int16_t *src;
238 /* calculate RNG table index for each subband */
239 813 int sb_RNG_index[ATRAC3P_SUBBANDS] = { 0 };
240
241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813 times.
813 if (ch_unit->mute_flag) {
242 for (ch = 0; ch < num_channels; ch++)
243 memset(out[ch], 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out[ch]));
244 return;
245 }
246
247
2/2
✓ Branch 0 taken 21980 times.
✓ Branch 1 taken 813 times.
22793 for (qu = 0, RNG_index = 0; qu < ch_unit->used_quant_units; qu++)
248 21980 RNG_index += ch_unit->channels[0].qu_sf_idx[qu] +
249 21980 ch_unit->channels[1].qu_sf_idx[qu];
250
251
2/2
✓ Branch 0 taken 9564 times.
✓ Branch 1 taken 813 times.
10377 for (sb = 0; sb < ch_unit->num_coded_subbands; sb++, RNG_index += 128)
252 9564 sb_RNG_index[sb] = RNG_index & 0x3FC;
253
254 /* inverse quant and power compensation */
255
2/2
✓ Branch 0 taken 1626 times.
✓ Branch 1 taken 813 times.
2439 for (ch = 0; ch < num_channels; ch++) {
256 /* clear channel's residual spectrum */
257 1626 memset(out[ch], 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out[ch]));
258
259
2/2
✓ Branch 0 taken 43960 times.
✓ Branch 1 taken 1626 times.
45586 for (qu = 0; qu < ch_unit->used_quant_units; qu++) {
260 43960 src = &ch_unit->channels[ch].spectrum[ff_atrac3p_qu_to_spec_pos[qu]];
261 43960 dst = &out[ch][ff_atrac3p_qu_to_spec_pos[qu]];
262 43960 nspeclines = ff_atrac3p_qu_to_spec_pos[qu + 1] -
263 43960 ff_atrac3p_qu_to_spec_pos[qu];
264
265
1/2
✓ Branch 0 taken 43960 times.
✗ Branch 1 not taken.
43960 if (ch_unit->channels[ch].qu_wordlen[qu] > 0) {
266 43960 q = ff_atrac3p_sf_tab[ch_unit->channels[ch].qu_sf_idx[qu]] *
267 43960 ff_atrac3p_mant_tab[ch_unit->channels[ch].qu_wordlen[qu]];
268
2/2
✓ Branch 0 taken 2448384 times.
✓ Branch 1 taken 43960 times.
2492344 for (i = 0; i < nspeclines; i++)
269 2448384 dst[i] = src[i] * q;
270 }
271 }
272
273
2/2
✓ Branch 0 taken 19128 times.
✓ Branch 1 taken 1626 times.
20754 for (sb = 0; sb < ch_unit->num_coded_subbands; sb++)
274 19128 ff_atrac3p_power_compensation(ch_unit, ctx->fdsp, ch, &out[ch][0],
275 sb_RNG_index[sb], sb);
276 }
277
278
1/2
✓ Branch 0 taken 813 times.
✗ Branch 1 not taken.
813 if (ch_unit->unit_type == CH_UNIT_STEREO) {
279
2/2
✓ Branch 0 taken 9564 times.
✓ Branch 1 taken 813 times.
10377 for (sb = 0; sb < ch_unit->num_coded_subbands; sb++) {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9564 times.
9564 if (ch_unit->swap_channels[sb]) {
281 for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++)
282 FFSWAP(float, out[0][sb * ATRAC3P_SUBBAND_SAMPLES + i],
283 out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i]);
284 }
285
286 /* flip coefficients' sign if requested */
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9564 times.
9564 if (ch_unit->negate_coeffs[sb])
288 for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES; i++)
289 out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i] = -(out[1][sb * ATRAC3P_SUBBAND_SAMPLES + i]);
290 }
291 }
292 }
293
294 813 static void reconstruct_frame(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit,
295 int num_channels, AVCodecContext *avctx)
296 {
297 int ch, sb;
298
299
2/2
✓ Branch 0 taken 1626 times.
✓ Branch 1 taken 813 times.
2439 for (ch = 0; ch < num_channels; ch++) {
300
2/2
✓ Branch 0 taken 21672 times.
✓ Branch 1 taken 1626 times.
23298 for (sb = 0; sb < ch_unit->num_subbands; sb++) {
301 /* inverse transform and windowing */
302 21672 ff_atrac3p_imdct(ctx->fdsp, ctx->mdct_ctx, ctx->mdct_fn,
303 21672 &ctx->samples[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
304 21672 &ctx->mdct_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
305 21672 (ch_unit->channels[ch].wnd_shape_prev[sb] << 1) +
306 21672 ch_unit->channels[ch].wnd_shape[sb], sb);
307
308 /* gain compensation and overlapping */
309 21672 ff_atrac_gain_compensation(&ctx->gainc_ctx,
310 21672 &ctx->mdct_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
311 21672 &ch_unit->prev_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
312 21672 &ch_unit->channels[ch].gain_data_prev[sb],
313 21672 &ch_unit->channels[ch].gain_data[sb],
314 ATRAC3P_SUBBAND_SAMPLES,
315 21672 &ctx->time_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES]);
316 }
317
318 /* zero unused subbands in both output and overlapping buffers */
319 1626 memset(&ch_unit->prev_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES],
320 0,
321 1626 (ATRAC3P_SUBBANDS - ch_unit->num_subbands) *
322 ATRAC3P_SUBBAND_SAMPLES *
323 sizeof(ch_unit->prev_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES]));
324 1626 memset(&ctx->time_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES],
325 0,
326 1626 (ATRAC3P_SUBBANDS - ch_unit->num_subbands) *
327 ATRAC3P_SUBBAND_SAMPLES *
328 sizeof(ctx->time_buf[ch][ch_unit->num_subbands * ATRAC3P_SUBBAND_SAMPLES]));
329
330 /* resynthesize and add tonal signal */
331
1/2
✓ Branch 0 taken 1626 times.
✗ Branch 1 not taken.
1626 if (ch_unit->waves_info->tones_present ||
332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1626 times.
1626 ch_unit->waves_info_prev->tones_present) {
333 for (sb = 0; sb < ch_unit->num_subbands; sb++)
334 if (ch_unit->channels[ch].tones_info[sb].num_wavs ||
335 ch_unit->channels[ch].tones_info_prev[sb].num_wavs) {
336 ff_atrac3p_generate_tones(ch_unit, ctx->fdsp, ch, sb,
337 &ctx->time_buf[ch][sb * 128]);
338 }
339 }
340
341 /* subband synthesis and acoustic signal output */
342 1626 ff_atrac3p_ipqf(ctx->ipqf_dct_ctx, ctx->ipqf_dct_fn,
343 1626 &ch_unit->ipqf_ctx[ch], &ctx->time_buf[ch][0],
344 &ctx->outp_buf[ch][0]);
345 }
346
347 /* swap window shape and gain control buffers. */
348
2/2
✓ Branch 0 taken 1626 times.
✓ Branch 1 taken 813 times.
2439 for (ch = 0; ch < num_channels; ch++) {
349 1626 FFSWAP(uint8_t *, ch_unit->channels[ch].wnd_shape,
350 ch_unit->channels[ch].wnd_shape_prev);
351 1626 FFSWAP(AtracGainInfo *, ch_unit->channels[ch].gain_data,
352 ch_unit->channels[ch].gain_data_prev);
353 1626 FFSWAP(Atrac3pWavesData *, ch_unit->channels[ch].tones_info,
354 ch_unit->channels[ch].tones_info_prev);
355 }
356
357 813 FFSWAP(Atrac3pWaveSynthParams *, ch_unit->waves_info, ch_unit->waves_info_prev);
358 813 }
359
360 813 static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame,
361 int *got_frame_ptr, AVPacket *avpkt)
362 {
363 813 ATRAC3PContext *ctx = avctx->priv_data;
364 813 int i, ret, ch_unit_id, ch_block = 0, out_ch_index = 0, channels_to_process;
365 813 float **samples_p = (float **)frame->extended_data;
366
367 813 frame->nb_samples = ATRAC3P_FRAME_SAMPLES;
368
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 813 times.
813 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
369 return ret;
370
371
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 813 times.
813 if ((ret = init_get_bits8(&ctx->gb, avpkt->data, avpkt->size)) < 0)
372 return ret;
373
374
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 813 times.
813 if (get_bits1(&ctx->gb)) {
375 av_log(avctx, AV_LOG_ERROR, "Invalid start bit!\n");
376 return AVERROR_INVALIDDATA;
377 }
378
379
2/2
✓ Branch 1 taken 1625 times.
✓ Branch 2 taken 1 times.
1626 while (get_bits_left(&ctx->gb) >= 2 &&
380
2/2
✓ Branch 1 taken 813 times.
✓ Branch 2 taken 812 times.
1625 (ch_unit_id = get_bits(&ctx->gb, 2)) != CH_UNIT_TERMINATOR) {
381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813 times.
813 if (ch_unit_id == CH_UNIT_EXTENSION) {
382 avpriv_report_missing_feature(avctx, "Channel unit extension");
383 return AVERROR_PATCHWELCOME;
384 }
385
1/2
✓ Branch 0 taken 813 times.
✗ Branch 1 not taken.
813 if (ch_block >= ctx->num_channel_blocks ||
386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813 times.
813 ctx->channel_blocks[ch_block] != ch_unit_id) {
387 av_log(avctx, AV_LOG_ERROR,
388 "Frame data doesn't match channel configuration!\n");
389 return AVERROR_INVALIDDATA;
390 }
391
392 813 ctx->ch_units[ch_block].unit_type = ch_unit_id;
393 813 channels_to_process = ch_unit_id + 1;
394
395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813 times.
813 if ((ret = ff_atrac3p_decode_channel_unit(&ctx->gb,
396 813 &ctx->ch_units[ch_block],
397 channels_to_process,
398 avctx)) < 0)
399 return ret;
400
401 813 decode_residual_spectrum(ctx, &ctx->ch_units[ch_block], ctx->samples,
402 channels_to_process, avctx);
403 813 reconstruct_frame(ctx, &ctx->ch_units[ch_block],
404 channels_to_process, avctx);
405
406
2/2
✓ Branch 0 taken 1626 times.
✓ Branch 1 taken 813 times.
2439 for (i = 0; i < channels_to_process; i++)
407 1626 memcpy(samples_p[ctx->channel_map[out_ch_index + i]], ctx->outp_buf[i],
408 ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p));
409
410 813 ch_block++;
411 813 out_ch_index += channels_to_process;
412 }
413
414 813 *got_frame_ptr = 1;
415
416
1/2
✓ Branch 0 taken 813 times.
✗ Branch 1 not taken.
813 return avctx->codec_id == AV_CODEC_ID_ATRAC3P ? FFMIN(avctx->block_align, avpkt->size) : avpkt->size;
417 }
418
419 const FFCodec ff_atrac3p_decoder = {
420 .p.name = "atrac3plus",
421 CODEC_LONG_NAME("ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)"),
422 .p.type = AVMEDIA_TYPE_AUDIO,
423 .p.id = AV_CODEC_ID_ATRAC3P,
424 .p.capabilities = AV_CODEC_CAP_DR1,
425 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
426 .priv_data_size = sizeof(ATRAC3PContext),
427 .init = atrac3p_decode_init,
428 .close = atrac3p_decode_close,
429 FF_CODEC_DECODE_CB(atrac3p_decode_frame),
430 };
431
432 const FFCodec ff_atrac3pal_decoder = {
433 .p.name = "atrac3plusal",
434 CODEC_LONG_NAME("ATRAC3+ AL (Adaptive TRansform Acoustic Coding 3+ Advanced Lossless)"),
435 .p.type = AVMEDIA_TYPE_AUDIO,
436 .p.id = AV_CODEC_ID_ATRAC3PAL,
437 .p.capabilities = AV_CODEC_CAP_DR1,
438 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
439 .priv_data_size = sizeof(ATRAC3PContext),
440 .init = atrac3p_decode_init,
441 .close = atrac3p_decode_close,
442 FF_CODEC_DECODE_CB(atrac3p_decode_frame),
443 };
444