| 479 | } |
| 480 | |
| 481 | static av_cold int mlp_encode_init(AVCodecContext *avctx) |
| 482 | { |
| 483 | static AVOnce init_static_once = AV_ONCE_INIT; |
| 484 | MLPEncodeContext *ctx = avctx->priv_data; |
| 485 | uint64_t channels_present; |
| 486 | int ret; |
| 487 | |
| 488 | ctx->avctx = avctx; |
| 489 | |
| 490 | switch (avctx->sample_rate) { |
| 491 | case 44100 << 0: |
| 492 | avctx->frame_size = 40 << 0; |
| 493 | ctx->coded_sample_rate[0] = 0x08 + 0; |
| 494 | ctx->fs = 0x08 + 1; |
| 495 | break; |
| 496 | case 44100 << 1: |
| 497 | avctx->frame_size = 40 << 1; |
| 498 | ctx->coded_sample_rate[0] = 0x08 + 1; |
| 499 | ctx->fs = 0x0C + 1; |
| 500 | break; |
| 501 | case 44100 << 2: |
| 502 | ctx->substream_info |= SUBSTREAM_INFO_HIGH_RATE; |
| 503 | avctx->frame_size = 40 << 2; |
| 504 | ctx->coded_sample_rate[0] = 0x08 + 2; |
| 505 | ctx->fs = 0x10 + 1; |
| 506 | break; |
| 507 | case 48000 << 0: |
| 508 | avctx->frame_size = 40 << 0; |
| 509 | ctx->coded_sample_rate[0] = 0x00 + 0; |
| 510 | ctx->fs = 0x08 + 2; |
| 511 | break; |
| 512 | case 48000 << 1: |
| 513 | avctx->frame_size = 40 << 1; |
| 514 | ctx->coded_sample_rate[0] = 0x00 + 1; |
| 515 | ctx->fs = 0x0C + 2; |
| 516 | break; |
| 517 | case 48000 << 2: |
| 518 | ctx->substream_info |= SUBSTREAM_INFO_HIGH_RATE; |
| 519 | avctx->frame_size = 40 << 2; |
| 520 | ctx->coded_sample_rate[0] = 0x00 + 2; |
| 521 | ctx->fs = 0x10 + 2; |
| 522 | break; |
| 523 | default: |
| 524 | av_unreachable("Checked via CODEC_SAMPLERATES"); |
| 525 | } |
| 526 | ctx->coded_sample_rate[1] = -1 & 0xf; |
| 527 | |
| 528 | ctx->coded_peak_bitrate = mlp_peak_bitrate(9600000, avctx->sample_rate); |
| 529 | |
| 530 | ctx->substream_info |= SUBSTREAM_INFO_ALWAYS_SET; |
| 531 | if (avctx->ch_layout.nb_channels <= 2) |
| 532 | ctx->substream_info |= SUBSTREAM_INFO_MAX_2_CHAN; |
| 533 | |
| 534 | switch (avctx->sample_fmt) { |
| 535 | case AV_SAMPLE_FMT_S16P: |
| 536 | ctx->coded_sample_fmt[0] = BITS_16; |
| 537 | ctx->wordlength = 16; |
| 538 | avctx->bits_per_raw_sample = 16; |
nothing calls this directly
no test coverage detected