| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * PCM codecs | ||
| 3 | * Copyright (c) 2001 Fabrice Bellard | ||
| 4 | * | ||
| 5 | * This file is part of FFmpeg. | ||
| 6 | * | ||
| 7 | * FFmpeg is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with FFmpeg; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @file | ||
| 24 | * PCM codecs | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include "config.h" | ||
| 28 | #include "config_components.h" | ||
| 29 | #include "libavutil/attributes.h" | ||
| 30 | #include "libavutil/float_dsp.h" | ||
| 31 | #include "libavutil/mem.h" | ||
| 32 | #include "libavutil/reverse.h" | ||
| 33 | #include "libavutil/thread.h" | ||
| 34 | #include "avcodec.h" | ||
| 35 | #include "bytestream.h" | ||
| 36 | #include "codec_internal.h" | ||
| 37 | #include "decode.h" | ||
| 38 | #include "encode.h" | ||
| 39 | #include "pcm_tablegen.h" | ||
| 40 | |||
| 41 | 1206 | av_unused av_cold static int pcm_encode_init(AVCodecContext *avctx) | |
| 42 | { | ||
| 43 | #if !CONFIG_HARDCODED_TABLES | ||
| 44 |
3/4✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1193 times.
|
1206 | switch (avctx->codec->id) { |
| 45 | #if CONFIG_PCM_ALAW_ENCODER | ||
| 46 | 9 | case AV_CODEC_ID_PCM_ALAW: { | |
| 47 | static AVOnce once_alaw = AV_ONCE_INIT; | ||
| 48 | 9 | ff_thread_once(&once_alaw, pcm_alaw_tableinit); | |
| 49 | 9 | break; | |
| 50 | } | ||
| 51 | #endif | ||
| 52 | #if CONFIG_PCM_MULAW_ENCODER | ||
| 53 | 4 | case AV_CODEC_ID_PCM_MULAW: { | |
| 54 | static AVOnce once_mulaw = AV_ONCE_INIT; | ||
| 55 | 4 | ff_thread_once(&once_mulaw, pcm_ulaw_tableinit); | |
| 56 | 4 | break; | |
| 57 | } | ||
| 58 | #endif | ||
| 59 | #if CONFIG_PCM_VIDC_ENCODER | ||
| 60 | ✗ | case AV_CODEC_ID_PCM_VIDC: { | |
| 61 | static AVOnce once_vidc = AV_ONCE_INIT; | ||
| 62 | ✗ | ff_thread_once(&once_vidc, pcm_vidc_tableinit); | |
| 63 | ✗ | break; | |
| 64 | } | ||
| 65 | #endif | ||
| 66 | 1193 | default: | |
| 67 | 1193 | break; | |
| 68 | } | ||
| 69 | #endif | ||
| 70 | |||
| 71 | 1206 | avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); | |
| 72 | 1206 | avctx->block_align = avctx->ch_layout.nb_channels * avctx->bits_per_coded_sample / 8; | |
| 73 | 1206 | avctx->bit_rate = avctx->block_align * 8LL * avctx->sample_rate; | |
| 74 | |||
| 75 | 1206 | return 0; | |
| 76 | } | ||
| 77 | |||
| 78 | /** | ||
| 79 | * Write PCM samples macro | ||
| 80 | * @param type Datatype of native machine format | ||
| 81 | * @param endian bytestream_put_xxx() suffix | ||
| 82 | * @param src Source pointer (variable name) | ||
| 83 | * @param dst Destination pointer (variable name) | ||
| 84 | * @param n Total number of samples (variable name) | ||
| 85 | * @param shift Bitshift (bits) | ||
| 86 | * @param offset Sample value offset | ||
| 87 | */ | ||
| 88 | #define ENCODE(type, endian, src, dst, n, shift, offset) \ | ||
| 89 | samples_ ## type = (const type *) src; \ | ||
| 90 | for (; n > 0; n--) { \ | ||
| 91 | register type v = (*samples_ ## type++ >> shift) + offset; \ | ||
| 92 | bytestream_put_ ## endian(&dst, v); \ | ||
| 93 | } | ||
| 94 | |||
| 95 | #define ENCODE_PLANAR(type, endian, dst, n, shift, offset) \ | ||
| 96 | n /= avctx->ch_layout.nb_channels; \ | ||
| 97 | for (c = 0; c < avctx->ch_layout.nb_channels; c++) { \ | ||
| 98 | int i; \ | ||
| 99 | samples_ ## type = (const type *) frame->extended_data[c]; \ | ||
| 100 | for (i = n; i > 0; i--) { \ | ||
| 101 | register type v = (*samples_ ## type++ >> shift) + offset; \ | ||
| 102 | bytestream_put_ ## endian(&dst, v); \ | ||
| 103 | } \ | ||
| 104 | } | ||
| 105 | |||
| 106 | 282280 | av_unused static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, | |
| 107 | const AVFrame *frame, int *got_packet_ptr) | ||
| 108 | { | ||
| 109 | int n, c, sample_size, ret; | ||
| 110 | const short *samples; | ||
| 111 | unsigned char *dst; | ||
| 112 | const uint8_t *samples_uint8_t; | ||
| 113 | const int16_t *samples_int16_t; | ||
| 114 | const int32_t *samples_int32_t; | ||
| 115 | const int64_t *samples_int64_t; | ||
| 116 | const uint16_t *samples_uint16_t; | ||
| 117 | const uint32_t *samples_uint32_t; | ||
| 118 | |||
| 119 | 282280 | sample_size = av_get_bits_per_sample(avctx->codec->id) / 8; | |
| 120 | 282280 | n = frame->nb_samples * avctx->ch_layout.nb_channels; | |
| 121 | 282280 | samples = (const short *)frame->data[0]; | |
| 122 | |||
| 123 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 282280 times.
|
282280 | if ((ret = ff_get_encode_buffer(avctx, avpkt, n * sample_size, 0)) < 0) |
| 124 | ✗ | return ret; | |
| 125 | 282280 | dst = avpkt->data; | |
| 126 | |||
| 127 |
20/22✓ Branch 0 taken 65 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 7282 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 313 times.
✓ Branch 5 taken 65 times.
✓ Branch 6 taken 65 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 65 times.
✓ Branch 9 taken 65 times.
✓ Branch 10 taken 172 times.
✓ Branch 11 taken 65 times.
✓ Branch 12 taken 65 times.
✓ Branch 13 taken 174 times.
✓ Branch 14 taken 104 times.
✓ Branch 15 taken 83 times.
✓ Branch 16 taken 272950 times.
✓ Branch 17 taken 130 times.
✓ Branch 18 taken 261 times.
✓ Branch 19 taken 206 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
282280 | switch (avctx->codec->id) { |
| 128 | 65 | case AV_CODEC_ID_PCM_U32LE: | |
| 129 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000) |
| 130 | 65 | break; | |
| 131 | 65 | case AV_CODEC_ID_PCM_U32BE: | |
| 132 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(uint32_t, be32, samples, dst, n, 0, 0x80000000) |
| 133 | 65 | break; | |
| 134 | 7282 | case AV_CODEC_ID_PCM_S24LE: | |
| 135 |
2/2✓ Branch 1 taken 45496102 times.
✓ Branch 2 taken 7282 times.
|
45503384 | ENCODE(int32_t, le24, samples, dst, n, 8, 0) |
| 136 | 7282 | break; | |
| 137 | 65 | case AV_CODEC_ID_PCM_S24LE_PLANAR: | |
| 138 |
4/4✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 65 times.
|
529395 | ENCODE_PLANAR(int32_t, le24, dst, n, 8, 0) |
| 139 | 65 | break; | |
| 140 | 313 | case AV_CODEC_ID_PCM_S24BE: | |
| 141 |
2/2✓ Branch 1 taken 8497686 times.
✓ Branch 2 taken 313 times.
|
8497999 | ENCODE(int32_t, be24, samples, dst, n, 8, 0) |
| 142 | 313 | break; | |
| 143 | 65 | case AV_CODEC_ID_PCM_U24LE: | |
| 144 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(uint32_t, le24, samples, dst, n, 8, 0x800000) |
| 145 | 65 | break; | |
| 146 | 65 | case AV_CODEC_ID_PCM_U24BE: | |
| 147 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(uint32_t, be24, samples, dst, n, 8, 0x800000) |
| 148 | 65 | break; | |
| 149 | 20 | case AV_CODEC_ID_PCM_S24DAUD: | |
| 150 |
2/2✓ Branch 0 taken 983040 times.
✓ Branch 1 taken 20 times.
|
983060 | for (; n > 0; n--) { |
| 151 | 983040 | uint32_t tmp = ff_reverse[(*samples >> 8) & 0xff] + | |
| 152 | 983040 | (ff_reverse[*samples & 0xff] << 8); | |
| 153 | 983040 | tmp <<= 4; // sync flags would go here | |
| 154 | 983040 | bytestream_put_be24(&dst, tmp); | |
| 155 | 983040 | samples++; | |
| 156 | } | ||
| 157 | 20 | break; | |
| 158 | 65 | case AV_CODEC_ID_PCM_U16LE: | |
| 159 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000) |
| 160 | 65 | break; | |
| 161 | 65 | case AV_CODEC_ID_PCM_U16BE: | |
| 162 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000) |
| 163 | 65 | break; | |
| 164 | 172 | case AV_CODEC_ID_PCM_S8: | |
| 165 |
2/2✓ Branch 1 taken 7726268 times.
✓ Branch 2 taken 172 times.
|
7726440 | ENCODE(uint8_t, byte, samples, dst, n, 0, -128) |
| 166 | 172 | break; | |
| 167 | 65 | case AV_CODEC_ID_PCM_S8_PLANAR: | |
| 168 |
4/4✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 65 times.
|
529395 | ENCODE_PLANAR(uint8_t, byte, dst, n, 0, -128) |
| 169 | 65 | break; | |
| 170 | #if HAVE_BIGENDIAN | ||
| 171 | case AV_CODEC_ID_PCM_S64LE: | ||
| 172 | case AV_CODEC_ID_PCM_F64LE: | ||
| 173 | ENCODE(int64_t, le64, samples, dst, n, 0, 0) | ||
| 174 | break; | ||
| 175 | case AV_CODEC_ID_PCM_S32LE: | ||
| 176 | case AV_CODEC_ID_PCM_F32LE: | ||
| 177 | ENCODE(int32_t, le32, samples, dst, n, 0, 0) | ||
| 178 | break; | ||
| 179 | case AV_CODEC_ID_PCM_S32LE_PLANAR: | ||
| 180 | ENCODE_PLANAR(int32_t, le32, dst, n, 0, 0) | ||
| 181 | break; | ||
| 182 | case AV_CODEC_ID_PCM_S16LE: | ||
| 183 | ENCODE(int16_t, le16, samples, dst, n, 0, 0) | ||
| 184 | break; | ||
| 185 | case AV_CODEC_ID_PCM_S16LE_PLANAR: | ||
| 186 | ENCODE_PLANAR(int16_t, le16, dst, n, 0, 0) | ||
| 187 | break; | ||
| 188 | case AV_CODEC_ID_PCM_F64BE: | ||
| 189 | case AV_CODEC_ID_PCM_F32BE: | ||
| 190 | case AV_CODEC_ID_PCM_S64BE: | ||
| 191 | case AV_CODEC_ID_PCM_S32BE: | ||
| 192 | case AV_CODEC_ID_PCM_S16BE: | ||
| 193 | #else | ||
| 194 | 65 | case AV_CODEC_ID_PCM_S64BE: | |
| 195 | case AV_CODEC_ID_PCM_F64BE: | ||
| 196 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | ENCODE(int64_t, be64, samples, dst, n, 0, 0) |
| 197 | 65 | break; | |
| 198 | 174 | case AV_CODEC_ID_PCM_F32BE: | |
| 199 | case AV_CODEC_ID_PCM_S32BE: | ||
| 200 |
2/2✓ Branch 1 taken 1159776 times.
✓ Branch 2 taken 174 times.
|
1159950 | ENCODE(int32_t, be32, samples, dst, n, 0, 0) |
| 201 | 174 | break; | |
| 202 | 104 | case AV_CODEC_ID_PCM_S16BE: | |
| 203 |
2/2✓ Branch 1 taken 673696 times.
✓ Branch 2 taken 104 times.
|
673800 | ENCODE(int16_t, be16, samples, dst, n, 0, 0) |
| 204 | 104 | break; | |
| 205 | 83 | case AV_CODEC_ID_PCM_S16BE_PLANAR: | |
| 206 |
4/4✓ Branch 1 taken 673400 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 159 times.
✓ Branch 4 taken 83 times.
|
673642 | ENCODE_PLANAR(int16_t, be16, dst, n, 0, 0) |
| 207 | 83 | break; | |
| 208 | 272950 | case AV_CODEC_ID_PCM_F64LE: | |
| 209 | case AV_CODEC_ID_PCM_F32LE: | ||
| 210 | case AV_CODEC_ID_PCM_S64LE: | ||
| 211 | case AV_CODEC_ID_PCM_S32LE: | ||
| 212 | case AV_CODEC_ID_PCM_S16LE: | ||
| 213 | #endif /* HAVE_BIGENDIAN */ | ||
| 214 | case AV_CODEC_ID_PCM_U8: | ||
| 215 | 272950 | memcpy(dst, samples, n * sample_size); | |
| 216 | 272950 | break; | |
| 217 | #if HAVE_BIGENDIAN | ||
| 218 | case AV_CODEC_ID_PCM_S16BE_PLANAR: | ||
| 219 | #else | ||
| 220 | 130 | case AV_CODEC_ID_PCM_S16LE_PLANAR: | |
| 221 | case AV_CODEC_ID_PCM_S32LE_PLANAR: | ||
| 222 | #endif /* HAVE_BIGENDIAN */ | ||
| 223 | 130 | n /= avctx->ch_layout.nb_channels; | |
| 224 |
2/2✓ Branch 0 taken 260 times.
✓ Branch 1 taken 130 times.
|
390 | for (c = 0; c < avctx->ch_layout.nb_channels; c++) { |
| 225 | 260 | const uint8_t *src = frame->extended_data[c]; | |
| 226 | 260 | bytestream_put_buffer(&dst, src, n * sample_size); | |
| 227 | } | ||
| 228 | 130 | break; | |
| 229 | #if CONFIG_PCM_ALAW_ENCODER | ||
| 230 | 261 | case AV_CODEC_ID_PCM_ALAW: | |
| 231 |
2/2✓ Branch 0 taken 1852200 times.
✓ Branch 1 taken 261 times.
|
1852461 | for (; n > 0; n--) { |
| 232 | 1852200 | int v = *samples++; | |
| 233 | 1852200 | *dst++ = linear_to_alaw[(v + 32768) >> 2]; | |
| 234 | } | ||
| 235 | 261 | break; | |
| 236 | #endif | ||
| 237 | #if CONFIG_PCM_MULAW_ENCODER | ||
| 238 | 206 | case AV_CODEC_ID_PCM_MULAW: | |
| 239 |
2/2✓ Branch 0 taken 1631700 times.
✓ Branch 1 taken 206 times.
|
1631906 | for (; n > 0; n--) { |
| 240 | 1631700 | int v = *samples++; | |
| 241 | 1631700 | *dst++ = linear_to_ulaw[(v + 32768) >> 2]; | |
| 242 | } | ||
| 243 | 206 | break; | |
| 244 | #endif | ||
| 245 | #if CONFIG_PCM_VIDC_ENCODER | ||
| 246 | ✗ | case AV_CODEC_ID_PCM_VIDC: | |
| 247 | ✗ | for (; n > 0; n--) { | |
| 248 | ✗ | int v = *samples++; | |
| 249 | ✗ | *dst++ = linear_to_vidc[(v + 32768) >> 2]; | |
| 250 | } | ||
| 251 | ✗ | break; | |
| 252 | #endif | ||
| 253 | ✗ | default: | |
| 254 | ✗ | return -1; | |
| 255 | } | ||
| 256 | |||
| 257 | 282280 | *got_packet_ptr = 1; | |
| 258 | 282280 | return 0; | |
| 259 | } | ||
| 260 | |||
| 261 | typedef struct PCMDecode { | ||
| 262 | int sample_size; | ||
| 263 | } PCMDecode; | ||
| 264 | |||
| 265 | 1684 | av_unused av_cold static int pcm_decode_init(AVCodecContext *avctx) | |
| 266 | { | ||
| 267 | 1684 | PCMDecode *s = avctx->priv_data; | |
| 268 | static const struct { | ||
| 269 | enum AVCodecID codec_id; | ||
| 270 | int8_t sample_fmt; | ||
| 271 | uint8_t sample_size; | ||
| 272 | uint8_t bits_per_sample; | ||
| 273 | } codec_id_to_samplefmt[] = { | ||
| 274 | #define ENTRY(CODEC_ID, SAMPLE_FMT, BITS_PER_SAMPLE) \ | ||
| 275 | { AV_CODEC_ID_PCM_ ## CODEC_ID, AV_SAMPLE_FMT_ ## SAMPLE_FMT, \ | ||
| 276 | BITS_PER_SAMPLE / 8, BITS_PER_SAMPLE } | ||
| 277 | ENTRY(S8, U8, 8), ENTRY(S8_PLANAR, U8P, 8), | ||
| 278 | ENTRY(S16BE, S16, 16), ENTRY(S16BE_PLANAR, S16P, 16), | ||
| 279 | ENTRY(S16LE, S16, 16), ENTRY(S16LE_PLANAR, S16P, 16), | ||
| 280 | ENTRY(S24DAUD, S16, 24), ENTRY(S24BE, S32, 24), | ||
| 281 | ENTRY(S24LE, S32, 24), ENTRY(S24LE_PLANAR, S32P, 24), | ||
| 282 | ENTRY(S32BE, S32, 32), ENTRY(S32LE, S32, 32), | ||
| 283 | ENTRY(S32LE_PLANAR, S32P, 32), | ||
| 284 | ENTRY(S64BE, S64, 64), ENTRY(S64LE, S64, 64), | ||
| 285 | ENTRY(SGA, U8, 8), ENTRY(U8, U8, 8), | ||
| 286 | ENTRY(U16BE, S16, 16), ENTRY(U16LE, S16, 16), | ||
| 287 | ENTRY(U24BE, S32, 24), ENTRY(U24LE, S32, 24), | ||
| 288 | ENTRY(U32BE, S32, 32), ENTRY(U32LE, S32, 32), | ||
| 289 | ENTRY(F32BE, FLT, 32), ENTRY(F32LE, FLT, 32), | ||
| 290 | ENTRY(F64BE, DBL, 64), ENTRY(F64LE, DBL, 64), | ||
| 291 | { .codec_id = AV_CODEC_ID_PCM_LXF, .sample_fmt = AV_SAMPLE_FMT_S32P, .sample_size = 5 }, | ||
| 292 | }; | ||
| 293 | |||
| 294 |
1/2✓ Branch 0 taken 10741 times.
✗ Branch 1 not taken.
|
10741 | for (unsigned i = 0; i < FF_ARRAY_ELEMS(codec_id_to_samplefmt); ++i) { |
| 295 |
2/2✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 9057 times.
|
10741 | if (codec_id_to_samplefmt[i].codec_id == avctx->codec_id) { |
| 296 | 1684 | s->sample_size = codec_id_to_samplefmt[i].sample_size; | |
| 297 | 1684 | avctx->sample_fmt = codec_id_to_samplefmt[i].sample_fmt; | |
| 298 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1588 times.
|
1684 | if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) |
| 299 | 96 | avctx->bits_per_raw_sample = codec_id_to_samplefmt[i].bits_per_sample; | |
| 300 | 1684 | break; | |
| 301 | } | ||
| 302 | av_assert1(i + 1 < FF_ARRAY_ELEMS(codec_id_to_samplefmt)); | ||
| 303 | } | ||
| 304 | |||
| 305 | 1684 | return 0; | |
| 306 | } | ||
| 307 | |||
| 308 | typedef struct PCMScaleDecode { | ||
| 309 | PCMDecode base; | ||
| 310 | void (*vector_fmul_scalar)(float *dst, const float *src, float mul, | ||
| 311 | int len); | ||
| 312 | float scale; | ||
| 313 | } PCMScaleDecode; | ||
| 314 | |||
| 315 | ✗ | av_unused av_cold static int pcm_scale_decode_init(AVCodecContext *avctx) | |
| 316 | { | ||
| 317 | ✗ | PCMScaleDecode *s = avctx->priv_data; | |
| 318 | AVFloatDSPContext *fdsp; | ||
| 319 | |||
| 320 | ✗ | avctx->sample_fmt = AV_SAMPLE_FMT_FLT; | |
| 321 | ✗ | s->base.sample_size = 4; | |
| 322 | |||
| 323 | ✗ | if (avctx->bits_per_coded_sample < 1 || avctx->bits_per_coded_sample > 24) | |
| 324 | ✗ | return AVERROR_INVALIDDATA; | |
| 325 | |||
| 326 | ✗ | s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1)); | |
| 327 | ✗ | fdsp = avpriv_float_dsp_alloc(0); | |
| 328 | ✗ | if (!fdsp) | |
| 329 | ✗ | return AVERROR(ENOMEM); | |
| 330 | ✗ | s->vector_fmul_scalar = fdsp->vector_fmul_scalar; | |
| 331 | ✗ | av_free(fdsp); | |
| 332 | |||
| 333 | ✗ | return 0; | |
| 334 | } | ||
| 335 | |||
| 336 | typedef struct PCMLUTDecode { | ||
| 337 | PCMDecode base; | ||
| 338 | int16_t table[256]; | ||
| 339 | } PCMLUTDecode; | ||
| 340 | |||
| 341 | 49 | av_unused av_cold static int pcm_lut_decode_init(AVCodecContext *avctx) | |
| 342 | { | ||
| 343 | 49 | PCMLUTDecode *s = avctx->priv_data; | |
| 344 | |||
| 345 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
49 | switch (avctx->codec_id) { |
| 346 | ✗ | default: | |
| 347 | ✗ | av_unreachable("pcm_lut_decode_init() only used with alaw, mulaw and vidc"); | |
| 348 | #if CONFIG_PCM_ALAW_DECODER | ||
| 349 | 31 | case AV_CODEC_ID_PCM_ALAW: | |
| 350 |
2/2✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
|
7967 | for (int i = 0; i < 256; i++) |
| 351 | 7936 | s->table[i] = alaw2linear(i); | |
| 352 | 31 | break; | |
| 353 | #endif | ||
| 354 | #if CONFIG_PCM_MULAW_DECODER | ||
| 355 | 18 | case AV_CODEC_ID_PCM_MULAW: | |
| 356 |
2/2✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 18 times.
|
4626 | for (int i = 0; i < 256; i++) |
| 357 | 4608 | s->table[i] = ulaw2linear(i); | |
| 358 | 18 | break; | |
| 359 | #endif | ||
| 360 | #if CONFIG_PCM_VIDC_DECODER | ||
| 361 | ✗ | case AV_CODEC_ID_PCM_VIDC: | |
| 362 | ✗ | for (int i = 0; i < 256; i++) | |
| 363 | ✗ | s->table[i] = vidc2linear(i); | |
| 364 | ✗ | break; | |
| 365 | #endif | ||
| 366 | } | ||
| 367 | |||
| 368 | 49 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; | |
| 369 | 49 | s->base.sample_size = 1; | |
| 370 | |||
| 371 | 49 | return 0; | |
| 372 | } | ||
| 373 | |||
| 374 | /** | ||
| 375 | * Read PCM samples macro | ||
| 376 | * @param size Data size of native machine format | ||
| 377 | * @param endian bytestream_get_xxx() endian suffix | ||
| 378 | * @param src Source pointer (variable name) | ||
| 379 | * @param dst Destination pointer (variable name) | ||
| 380 | * @param n Total number of samples (variable name) | ||
| 381 | * @param shift Bitshift (bits) | ||
| 382 | * @param offset Sample value offset | ||
| 383 | */ | ||
| 384 | #define DECODE(size, endian, src, dst, n, shift, offset) \ | ||
| 385 | for (; n > 0; n--) { \ | ||
| 386 | uint ## size ## _t v = bytestream_get_ ## endian(&src); \ | ||
| 387 | AV_WN ## size ## A(dst, (uint ## size ## _t)(v - offset) << shift); \ | ||
| 388 | dst += size / 8; \ | ||
| 389 | } | ||
| 390 | |||
| 391 | #define DECODE_PLANAR(size, endian, src, dst, n, shift, offset) \ | ||
| 392 | n /= channels; \ | ||
| 393 | for (c = 0; c < avctx->ch_layout.nb_channels; c++) { \ | ||
| 394 | int i; \ | ||
| 395 | dst = frame->extended_data[c]; \ | ||
| 396 | for (i = n; i > 0; i--) { \ | ||
| 397 | uint ## size ## _t v = bytestream_get_ ## endian(&src); \ | ||
| 398 | AV_WN ## size ## A(dst, (uint ## size ##_t)(v - offset) << shift); \ | ||
| 399 | dst += size / 8; \ | ||
| 400 | } \ | ||
| 401 | } | ||
| 402 | |||
| 403 | 39725 | static int pcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, | |
| 404 | int *got_frame_ptr, AVPacket *avpkt) | ||
| 405 | { | ||
| 406 | 39725 | const uint8_t *src = avpkt->data; | |
| 407 | 39725 | int buf_size = avpkt->size; | |
| 408 | 39725 | PCMDecode *s = avctx->priv_data; | |
| 409 | 39725 | int channels = avctx->ch_layout.nb_channels; | |
| 410 | 39725 | int sample_size = s->sample_size; | |
| 411 | int c, n, ret, samples_per_block; | ||
| 412 | uint8_t *samples; | ||
| 413 | int32_t *dst_int32_t; | ||
| 414 | |||
| 415 | 39725 | samples_per_block = 1; | |
| 416 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 39725 times.
|
39725 | if (avctx->codec_id == AV_CODEC_ID_PCM_LXF) { |
| 417 | /* we process 40-bit blocks per channel for LXF */ | ||
| 418 | ✗ | samples_per_block = 2; | |
| 419 | } | ||
| 420 | |||
| 421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 39725 times.
|
39725 | if (channels == 0) { |
| 422 | ✗ | av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); | |
| 423 | ✗ | return AVERROR(EINVAL); | |
| 424 | } | ||
| 425 | |||
| 426 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 39725 times.
|
39725 | if (avctx->codec_id != avctx->codec->id) { |
| 427 | ✗ | av_log(avctx, AV_LOG_ERROR, "codec ids mismatch\n"); | |
| 428 | ✗ | return AVERROR(EINVAL); | |
| 429 | } | ||
| 430 | |||
| 431 | 39725 | n = channels * sample_size; | |
| 432 | |||
| 433 |
3/4✓ Branch 0 taken 39725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 39723 times.
|
39725 | if (n && buf_size % n) { |
| 434 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (buf_size < n) { |
| 435 | 1 | av_log(avctx, AV_LOG_ERROR, | |
| 436 | "Invalid PCM packet, data has size %d but at least a size of %d was expected\n", | ||
| 437 | buf_size, n); | ||
| 438 | 1 | return AVERROR_INVALIDDATA; | |
| 439 | } else | ||
| 440 | 1 | buf_size -= buf_size % n; | |
| 441 | } | ||
| 442 | |||
| 443 | 39724 | n = buf_size / sample_size; | |
| 444 | |||
| 445 | /* get output buffer */ | ||
| 446 | 39724 | frame->nb_samples = n * samples_per_block / channels; | |
| 447 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 39724 times.
|
39724 | if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) |
| 448 | ✗ | return ret; | |
| 449 | 39724 | samples = frame->data[0]; | |
| 450 | |||
| 451 |
19/22✓ Branch 0 taken 65 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 930 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 259 times.
✓ Branch 5 taken 65 times.
✓ Branch 6 taken 65 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 65 times.
✓ Branch 9 taken 65 times.
✓ Branch 10 taken 259 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65 times.
✓ Branch 13 taken 65 times.
✓ Branch 14 taken 324 times.
✓ Branch 15 taken 1013 times.
✓ Branch 16 taken 76 times.
✓ Branch 17 taken 33221 times.
✓ Branch 18 taken 272 times.
✓ Branch 19 taken 2699 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
39724 | switch (avctx->codec_id) { |
| 452 | 65 | case AV_CODEC_ID_PCM_U32LE: | |
| 453 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(32, le32, src, samples, n, 0, 0x80000000) |
| 454 | 65 | break; | |
| 455 | 65 | case AV_CODEC_ID_PCM_U32BE: | |
| 456 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(32, be32, src, samples, n, 0, 0x80000000) |
| 457 | 65 | break; | |
| 458 | 930 | case AV_CODEC_ID_PCM_S24LE: | |
| 459 |
2/2✓ Branch 1 taken 27786964 times.
✓ Branch 2 taken 930 times.
|
27787894 | DECODE(32, le24, src, samples, n, 8, 0) |
| 460 | 930 | break; | |
| 461 | 65 | case AV_CODEC_ID_PCM_S24LE_PLANAR: | |
| 462 |
4/4✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 65 times.
|
529395 | DECODE_PLANAR(32, le24, src, samples, n, 8, 0); |
| 463 | 65 | break; | |
| 464 | 259 | case AV_CODEC_ID_PCM_S24BE: | |
| 465 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 259 times.
|
529459 | DECODE(32, be24, src, samples, n, 8, 0) |
| 466 | 259 | break; | |
| 467 | 65 | case AV_CODEC_ID_PCM_U24LE: | |
| 468 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(32, le24, src, samples, n, 8, 0x800000) |
| 469 | 65 | break; | |
| 470 | 65 | case AV_CODEC_ID_PCM_U24BE: | |
| 471 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(32, be24, src, samples, n, 8, 0x800000) |
| 472 | 65 | break; | |
| 473 | 86 | case AV_CODEC_ID_PCM_S24DAUD: | |
| 474 |
2/2✓ Branch 0 taken 1026720 times.
✓ Branch 1 taken 86 times.
|
1026806 | for (; n > 0; n--) { |
| 475 | 1026720 | uint32_t v = bytestream_get_be24(&src); | |
| 476 | 1026720 | v >>= 4; // sync flags are here | |
| 477 | 1026720 | AV_WN16A(samples, ff_reverse[(v >> 8) & 0xff] + | |
| 478 | (ff_reverse[v & 0xff] << 8)); | ||
| 479 | 1026720 | samples += 2; | |
| 480 | } | ||
| 481 | 86 | break; | |
| 482 | 65 | case AV_CODEC_ID_PCM_U16LE: | |
| 483 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(16, le16, src, samples, n, 0, 0x8000) |
| 484 | 65 | break; | |
| 485 | 65 | case AV_CODEC_ID_PCM_U16BE: | |
| 486 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(16, be16, src, samples, n, 0, 0x8000) |
| 487 | 65 | break; | |
| 488 | 259 | case AV_CODEC_ID_PCM_S8: | |
| 489 |
2/2✓ Branch 0 taken 529200 times.
✓ Branch 1 taken 259 times.
|
529459 | for (; n > 0; n--) |
| 490 | 529200 | *samples++ = *src++ + 128; | |
| 491 | 259 | break; | |
| 492 | ✗ | case AV_CODEC_ID_PCM_SGA: | |
| 493 | ✗ | for (; n > 0; n--) { | |
| 494 | ✗ | int sign = *src >> 7; | |
| 495 | ✗ | int magn = *src & 0x7f; | |
| 496 | ✗ | *samples++ = sign ? 128 - magn : 128 + magn; | |
| 497 | ✗ | src++; | |
| 498 | } | ||
| 499 | ✗ | break; | |
| 500 | 65 | case AV_CODEC_ID_PCM_S8_PLANAR: | |
| 501 | 65 | n /= avctx->ch_layout.nb_channels; | |
| 502 |
2/2✓ Branch 0 taken 130 times.
✓ Branch 1 taken 65 times.
|
195 | for (c = 0; c < avctx->ch_layout.nb_channels; c++) { |
| 503 | int i; | ||
| 504 | 130 | samples = frame->extended_data[c]; | |
| 505 |
2/2✓ Branch 0 taken 529200 times.
✓ Branch 1 taken 130 times.
|
529330 | for (i = n; i > 0; i--) |
| 506 | 529200 | *samples++ = *src++ + 128; | |
| 507 | } | ||
| 508 | 65 | break; | |
| 509 | #if HAVE_BIGENDIAN | ||
| 510 | case AV_CODEC_ID_PCM_S64LE: | ||
| 511 | case AV_CODEC_ID_PCM_F64LE: | ||
| 512 | DECODE(64, le64, src, samples, n, 0, 0) | ||
| 513 | break; | ||
| 514 | case AV_CODEC_ID_PCM_S32LE: | ||
| 515 | case AV_CODEC_ID_PCM_F32LE: | ||
| 516 | case AV_CODEC_ID_PCM_F24LE: | ||
| 517 | case AV_CODEC_ID_PCM_F16LE: | ||
| 518 | DECODE(32, le32, src, samples, n, 0, 0) | ||
| 519 | break; | ||
| 520 | case AV_CODEC_ID_PCM_S32LE_PLANAR: | ||
| 521 | DECODE_PLANAR(32, le32, src, samples, n, 0, 0); | ||
| 522 | break; | ||
| 523 | case AV_CODEC_ID_PCM_S16LE: | ||
| 524 | DECODE(16, le16, src, samples, n, 0, 0) | ||
| 525 | break; | ||
| 526 | case AV_CODEC_ID_PCM_S16LE_PLANAR: | ||
| 527 | DECODE_PLANAR(16, le16, src, samples, n, 0, 0); | ||
| 528 | break; | ||
| 529 | case AV_CODEC_ID_PCM_F64BE: | ||
| 530 | case AV_CODEC_ID_PCM_F32BE: | ||
| 531 | case AV_CODEC_ID_PCM_S64BE: | ||
| 532 | case AV_CODEC_ID_PCM_S32BE: | ||
| 533 | case AV_CODEC_ID_PCM_S16BE: | ||
| 534 | #else | ||
| 535 | 65 | case AV_CODEC_ID_PCM_S64BE: | |
| 536 | case AV_CODEC_ID_PCM_F64BE: | ||
| 537 |
2/2✓ Branch 1 taken 529200 times.
✓ Branch 2 taken 65 times.
|
529265 | DECODE(64, be64, src, samples, n, 0, 0) |
| 538 | 65 | break; | |
| 539 | 324 | case AV_CODEC_ID_PCM_F32BE: | |
| 540 | case AV_CODEC_ID_PCM_S32BE: | ||
| 541 |
2/2✓ Branch 1 taken 1058400 times.
✓ Branch 2 taken 324 times.
|
1058724 | DECODE(32, be32, src, samples, n, 0, 0) |
| 542 | 324 | break; | |
| 543 | 1013 | case AV_CODEC_ID_PCM_S16BE: | |
| 544 |
2/2✓ Branch 1 taken 1924678 times.
✓ Branch 2 taken 1013 times.
|
1925691 | DECODE(16, be16, src, samples, n, 0, 0) |
| 545 | 1013 | break; | |
| 546 | 76 | case AV_CODEC_ID_PCM_S16BE_PLANAR: | |
| 547 |
4/4✓ Branch 1 taken 617400 times.
✓ Branch 2 taken 152 times.
✓ Branch 3 taken 152 times.
✓ Branch 4 taken 76 times.
|
617628 | DECODE_PLANAR(16, be16, src, samples, n, 0, 0); |
| 548 | 76 | break; | |
| 549 | 33221 | case AV_CODEC_ID_PCM_F64LE: | |
| 550 | case AV_CODEC_ID_PCM_F32LE: | ||
| 551 | case AV_CODEC_ID_PCM_F24LE: | ||
| 552 | case AV_CODEC_ID_PCM_F16LE: | ||
| 553 | case AV_CODEC_ID_PCM_S64LE: | ||
| 554 | case AV_CODEC_ID_PCM_S32LE: | ||
| 555 | case AV_CODEC_ID_PCM_S16LE: | ||
| 556 | #endif /* HAVE_BIGENDIAN */ | ||
| 557 | case AV_CODEC_ID_PCM_U8: | ||
| 558 | 33221 | memcpy(samples, src, n * sample_size); | |
| 559 | 33221 | break; | |
| 560 | #if HAVE_BIGENDIAN | ||
| 561 | case AV_CODEC_ID_PCM_S16BE_PLANAR: | ||
| 562 | #else | ||
| 563 | 272 | case AV_CODEC_ID_PCM_S16LE_PLANAR: | |
| 564 | case AV_CODEC_ID_PCM_S32LE_PLANAR: | ||
| 565 | #endif /* HAVE_BIGENDIAN */ | ||
| 566 | 272 | n /= avctx->ch_layout.nb_channels; | |
| 567 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 272 times.
|
816 | for (c = 0; c < avctx->ch_layout.nb_channels; c++) { |
| 568 | 544 | samples = frame->extended_data[c]; | |
| 569 | 544 | bytestream_get_buffer(&src, samples, n * sample_size); | |
| 570 | } | ||
| 571 | 272 | break; | |
| 572 | #if CONFIG_PCM_ALAW_DECODER || CONFIG_PCM_MULAW_DECODER || \ | ||
| 573 | CONFIG_PCM_VIDC_DECODER | ||
| 574 | 2699 | case AV_CODEC_ID_PCM_ALAW: | |
| 575 | case AV_CODEC_ID_PCM_MULAW: | ||
| 576 | case AV_CODEC_ID_PCM_VIDC: { | ||
| 577 | 2699 | const int16_t *const lut = ((PCMLUTDecode*)avctx->priv_data)->table; | |
| 578 | 2699 | int16_t *restrict samples_16 = (int16_t*)samples; | |
| 579 | |||
| 580 |
2/2✓ Branch 0 taken 5046363 times.
✓ Branch 1 taken 2699 times.
|
5049062 | for (; n > 0; n--) |
| 581 | 5046363 | *samples_16++ = lut[*src++]; | |
| 582 | 2699 | break; | |
| 583 | } | ||
| 584 | #endif | ||
| 585 | ✗ | case AV_CODEC_ID_PCM_LXF: | |
| 586 | { | ||
| 587 | int i; | ||
| 588 | ✗ | n /= channels; | |
| 589 | ✗ | for (c = 0; c < channels; c++) { | |
| 590 | ✗ | dst_int32_t = (int32_t *)frame->extended_data[c]; | |
| 591 | ✗ | for (i = 0; i < n; i++) { | |
| 592 | // extract low 20 bits and expand to 32 bits | ||
| 593 | ✗ | *dst_int32_t++ = ((uint32_t)src[2]<<28) | | |
| 594 | ✗ | (src[1] << 20) | | |
| 595 | ✗ | (src[0] << 12) | | |
| 596 | ✗ | ((src[2] & 0x0F) << 8) | | |
| 597 | ✗ | src[1]; | |
| 598 | // extract high 20 bits and expand to 32 bits | ||
| 599 | ✗ | *dst_int32_t++ = ((uint32_t)src[4]<<24) | | |
| 600 | ✗ | (src[3] << 16) | | |
| 601 | ✗ | ((src[2] & 0xF0) << 8) | | |
| 602 | ✗ | (src[4] << 4) | | |
| 603 | ✗ | (src[3] >> 4); | |
| 604 | ✗ | src += 5; | |
| 605 | } | ||
| 606 | } | ||
| 607 | ✗ | break; | |
| 608 | } | ||
| 609 | ✗ | default: | |
| 610 | ✗ | return -1; | |
| 611 | } | ||
| 612 | |||
| 613 |
1/2✓ Branch 0 taken 39724 times.
✗ Branch 1 not taken.
|
39724 | if (avctx->codec_id == AV_CODEC_ID_PCM_F16LE || |
| 614 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 39724 times.
|
39724 | avctx->codec_id == AV_CODEC_ID_PCM_F24LE) { |
| 615 | ✗ | PCMScaleDecode *s2 = avctx->priv_data; | |
| 616 | ✗ | s2->vector_fmul_scalar((float *)frame->extended_data[0], | |
| 617 | ✗ | (const float *)frame->extended_data[0], | |
| 618 | ✗ | s2->scale, FFALIGN(frame->nb_samples * avctx->ch_layout.nb_channels, 4)); | |
| 619 | } | ||
| 620 | |||
| 621 | 39724 | *got_frame_ptr = 1; | |
| 622 | |||
| 623 | 39724 | return buf_size; | |
| 624 | } | ||
| 625 | |||
| 626 | #define PCM_ENCODER_0(id_, sample_fmt_, name_, long_name_) | ||
| 627 | #define PCM_ENCODER_1(id_, sample_fmt_, name_, long_name_) \ | ||
| 628 | const FFCodec ff_ ## name_ ## _encoder = { \ | ||
| 629 | .p.name = #name_, \ | ||
| 630 | CODEC_LONG_NAME(long_name_), \ | ||
| 631 | .p.type = AVMEDIA_TYPE_AUDIO, \ | ||
| 632 | .p.id = id_, \ | ||
| 633 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE | \ | ||
| 634 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, \ | ||
| 635 | .init = pcm_encode_init, \ | ||
| 636 | FF_CODEC_ENCODE_CB(pcm_encode_frame), \ | ||
| 637 | CODEC_SAMPLEFMTS(sample_fmt_), \ | ||
| 638 | } | ||
| 639 | |||
| 640 | #define PCM_ENCODER_2(cf, id, sample_fmt, name, long_name) \ | ||
| 641 | PCM_ENCODER_ ## cf(id, sample_fmt, name, long_name) | ||
| 642 | #define PCM_ENCODER_3(cf, id, sample_fmt, name, long_name) \ | ||
| 643 | PCM_ENCODER_2(cf, id, sample_fmt, name, long_name) | ||
| 644 | #define PCM_ENCODER(id, sample_fmt, name, long_name) \ | ||
| 645 | PCM_ENCODER_3(CONFIG_PCM_ ## id ## _ENCODER, AV_CODEC_ID_PCM_ ## id, \ | ||
| 646 | AV_SAMPLE_FMT_ ## sample_fmt, pcm_ ## name, long_name) | ||
| 647 | |||
| 648 | #define PCM_DECODER_0(id, sample_fmt, name, long_name, Context, init_func) | ||
| 649 | #define PCM_DECODER_1(id_, sample_fmt, name_, long_name, Context, init_func)\ | ||
| 650 | const FFCodec ff_ ## name_ ## _decoder = { \ | ||
| 651 | .p.name = #name_, \ | ||
| 652 | CODEC_LONG_NAME(long_name), \ | ||
| 653 | .p.type = AVMEDIA_TYPE_AUDIO, \ | ||
| 654 | .p.id = id_, \ | ||
| 655 | .priv_data_size = sizeof(Context), \ | ||
| 656 | .init = init_func, \ | ||
| 657 | FF_CODEC_DECODE_CB(pcm_decode_frame), \ | ||
| 658 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_PARAM_CHANGE, \ | ||
| 659 | } | ||
| 660 | |||
| 661 | #define PCM_DECODER_2(cf, id, sample_fmt, name, long_name, Context, init_func) \ | ||
| 662 | PCM_DECODER_ ## cf(id, sample_fmt, name, long_name, Context, init_func) | ||
| 663 | #define PCM_DECODER_3(cf, id, sample_fmt, name, long_name, Context, init_func) \ | ||
| 664 | PCM_DECODER_2(cf, id, sample_fmt, name, long_name, Context, init_func) | ||
| 665 | #define PCM_DEC_EXT(id, sample_fmt, name, long_name, Context, init_func) \ | ||
| 666 | PCM_DECODER_3(CONFIG_PCM_ ## id ## _DECODER, AV_CODEC_ID_PCM_ ## id, \ | ||
| 667 | AV_SAMPLE_FMT_ ## sample_fmt, pcm_ ## name, long_name, \ | ||
| 668 | Context, init_func) | ||
| 669 | |||
| 670 | #define PCM_DECODER(id, sample_fmt, name, long_name) \ | ||
| 671 | PCM_DEC_EXT(id, sample_fmt, name, long_name, PCMDecode, pcm_decode_init) | ||
| 672 | |||
| 673 | #define PCM_CODEC(id, sample_fmt_, name, long_name_) \ | ||
| 674 | PCM_ENCODER(id, sample_fmt_, name, long_name_); \ | ||
| 675 | PCM_DECODER(id, sample_fmt_, name, long_name_) | ||
| 676 | |||
| 677 | #define PCM_CODEC_EXT(id, sample_fmt, name, long_name, DecContext, dec_init_func) \ | ||
| 678 | PCM_DEC_EXT(id, sample_fmt, name, long_name, DecContext, dec_init_func); \ | ||
| 679 | PCM_ENCODER(id, sample_fmt, name, long_name) | ||
| 680 | |||
| 681 | /* Note: Do not forget to add new entries to the Makefile and | ||
| 682 | * to the table in pcm_decode_init() as well. */ | ||
| 683 | // AV_CODEC_ID_* pcm_* name | ||
| 684 | // AV_SAMPLE_FMT_* long name DecodeContext decode init func | ||
| 685 | PCM_CODEC_EXT(ALAW, S16, alaw, "PCM A-law / G.711 A-law", PCMLUTDecode, pcm_lut_decode_init); | ||
| 686 | PCM_DEC_EXT (F16LE, FLT, f16le, "PCM 16.8 floating point little-endian", PCMScaleDecode, pcm_scale_decode_init); | ||
| 687 | PCM_DEC_EXT (F24LE, FLT, f24le, "PCM 24.0 floating point little-endian", PCMScaleDecode, pcm_scale_decode_init); | ||
| 688 | PCM_CODEC (F32BE, FLT, f32be, "PCM 32-bit floating point big-endian"); | ||
| 689 | PCM_CODEC (F32LE, FLT, f32le, "PCM 32-bit floating point little-endian"); | ||
| 690 | PCM_CODEC (F64BE, DBL, f64be, "PCM 64-bit floating point big-endian"); | ||
| 691 | PCM_CODEC (F64LE, DBL, f64le, "PCM 64-bit floating point little-endian"); | ||
| 692 | PCM_DECODER (LXF, S32P,lxf, "PCM signed 20-bit little-endian planar"); | ||
| 693 | PCM_CODEC_EXT(MULAW, S16, mulaw, "PCM mu-law / G.711 mu-law", PCMLUTDecode, pcm_lut_decode_init); | ||
| 694 | PCM_CODEC (S8, U8, s8, "PCM signed 8-bit"); | ||
| 695 | PCM_CODEC (S8_PLANAR, U8P, s8_planar, "PCM signed 8-bit planar"); | ||
| 696 | PCM_CODEC (S16BE, S16, s16be, "PCM signed 16-bit big-endian"); | ||
| 697 | PCM_CODEC (S16BE_PLANAR, S16P,s16be_planar, "PCM signed 16-bit big-endian planar"); | ||
| 698 | PCM_CODEC (S16LE, S16, s16le, "PCM signed 16-bit little-endian"); | ||
| 699 | PCM_CODEC (S16LE_PLANAR, S16P,s16le_planar, "PCM signed 16-bit little-endian planar"); | ||
| 700 | PCM_CODEC (S24BE, S32, s24be, "PCM signed 24-bit big-endian"); | ||
| 701 | PCM_CODEC (S24DAUD, S16, s24daud, "PCM D-Cinema audio signed 24-bit"); | ||
| 702 | PCM_CODEC (S24LE, S32, s24le, "PCM signed 24-bit little-endian"); | ||
| 703 | PCM_CODEC (S24LE_PLANAR, S32P,s24le_planar, "PCM signed 24-bit little-endian planar"); | ||
| 704 | PCM_CODEC (S32BE, S32, s32be, "PCM signed 32-bit big-endian"); | ||
| 705 | PCM_CODEC (S32LE, S32, s32le, "PCM signed 32-bit little-endian"); | ||
| 706 | PCM_CODEC (S32LE_PLANAR, S32P,s32le_planar, "PCM signed 32-bit little-endian planar"); | ||
| 707 | PCM_CODEC (U8, U8, u8, "PCM unsigned 8-bit"); | ||
| 708 | PCM_CODEC (U16BE, S16, u16be, "PCM unsigned 16-bit big-endian"); | ||
| 709 | PCM_CODEC (U16LE, S16, u16le, "PCM unsigned 16-bit little-endian"); | ||
| 710 | PCM_CODEC (U24BE, S32, u24be, "PCM unsigned 24-bit big-endian"); | ||
| 711 | PCM_CODEC (U24LE, S32, u24le, "PCM unsigned 24-bit little-endian"); | ||
| 712 | PCM_CODEC (U32BE, S32, u32be, "PCM unsigned 32-bit big-endian"); | ||
| 713 | PCM_CODEC (U32LE, S32, u32le, "PCM unsigned 32-bit little-endian"); | ||
| 714 | PCM_CODEC (S64BE, S64, s64be, "PCM signed 64-bit big-endian"); | ||
| 715 | PCM_CODEC (S64LE, S64, s64le, "PCM signed 64-bit little-endian"); | ||
| 716 | PCM_CODEC_EXT(VIDC, S16, vidc, "PCM Archimedes VIDC", PCMLUTDecode, pcm_lut_decode_init); | ||
| 717 | PCM_DECODER (SGA, U8, sga, "PCM SGA"); | ||
| 718 |