| @@ -462,14 +462,15 @@ static int write_frame(AlacEncodeContext *s, AVPacket *avpkt, · 461 unmodified lines |
| 462 | 462 | uint8_t * const *samples) |
| 463 | 463 | { |
| 464 | 464 | PutBitContext *pb = &s->pbctx; |
| 465 | | − const enum AlacRawDataBlockType *ch_elements = ff_alac_channel_elements[s->avctx->channels - 1]; |
| 466 | | − const uint8_t *ch_map = ff_alac_channel_layout_offsets[s->avctx->channels - 1]; |
| 465 | + int channels = s->avctx->ch_layout.nb_channels; |
| 466 | + const enum AlacRawDataBlockType *ch_elements = ff_alac_channel_elements[channels - 1]; |
| 467 | + const uint8_t *ch_map = ff_alac_channel_layout_offsets[channels - 1]; |
| 467 | 468 | int ch, element, sce, cpe; |
| 468 | 469 | |
| 469 | 470 | init_put_bits(pb, avpkt->data, avpkt->size); |
| 470 | 471 | |
| 471 | 472 | ch = element = sce = cpe = 0; |
| 472 | | − while (ch < s->avctx->channels) { |
| 473 | + while (ch < channels) { |
| 473 | 474 | if (ch_elements[element] == TYPE_CPE) { |
| 474 | 475 | write_element(s, TYPE_CPE, cpe, samples[ch_map[ch]], |
| 475 | 476 | samples[ch_map[ch + 1]]); |
| @@ -532,7 +533,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 56 unmodified lines |
| 532 | 533 | s->rc.rice_modifier = 4; |
| 533 | 534 | |
| 534 | 535 | s->max_coded_frame_size = get_max_frame_size(avctx->frame_size, |
| 535 | | − avctx->channels, |
| 536 | + avctx->ch_layout.nb_channels, |
| 536 | 537 | avctx->bits_per_raw_sample); |
| 537 | 538 | |
| 538 | 539 | avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); |
| @@ -545,10 +546,10 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 6 unmodified lines |
| 545 | 546 | AV_WB32(alac_extradata+4, MKBETAG('a','l','a','c')); |
| 546 | 547 | AV_WB32(alac_extradata+12, avctx->frame_size); |
| 547 | 548 | AV_WB8 (alac_extradata+17, avctx->bits_per_raw_sample); |
| 548 | | − AV_WB8 (alac_extradata+21, avctx->channels); |
| 549 | + AV_WB8 (alac_extradata+21, avctx->ch_layout.nb_channels); |
| 549 | 550 | AV_WB32(alac_extradata+24, s->max_coded_frame_size); |
| 550 | 551 | AV_WB32(alac_extradata+28, |
| 551 | | − avctx->sample_rate * avctx->channels * avctx->bits_per_raw_sample); // average bitrate |
| 552 | + avctx->sample_rate * avctx->ch_layout.nb_channels * avctx->bits_per_raw_sample); // average bitrate |
| 552 | 553 | AV_WB32(alac_extradata+32, avctx->sample_rate); |
| 553 | 554 | |
| 554 | 555 | // Set relevant extradata fields |
| @@ -585,7 +586,7 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 30 unmodified lines |
| 585 | 586 | s->frame_size = frame->nb_samples; |
| 586 | 587 | |
| 587 | 588 | if (frame->nb_samples < DEFAULT_FRAME_SIZE) |
| 588 | | − max_frame_size = get_max_frame_size(s->frame_size, avctx->channels, |
| 589 | + max_frame_size = get_max_frame_size(s->frame_size, avctx->ch_layout.nb_channels, |
| 589 | 590 | avctx->bits_per_raw_sample); |
| 590 | 591 | else |
| 591 | 592 | max_frame_size = s->max_coded_frame_size; |
| @@ -616,6 +617,21 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 24 unmodified lines |
| 616 | 617 | return 0; |
| 617 | 618 | } |
| 618 | 619 | |
| 620 | +#if FF_API_OLD_CHANNEL_LAYOUT |
| 621 | +static const uint64_t alac_channel_layouts[ALAC_MAX_CHANNELS + 1] = { |
| 622 | + AV_CH_LAYOUT_MONO, |
| 623 | + AV_CH_LAYOUT_STEREO, |
| 624 | + AV_CH_LAYOUT_SURROUND, |
| 625 | + AV_CH_LAYOUT_4POINT0, |
| 626 | + AV_CH_LAYOUT_5POINT0_BACK, |
| 627 | + AV_CH_LAYOUT_5POINT1_BACK, |
| 628 | + AV_CH_LAYOUT_6POINT1_BACK, |
| 629 | + AV_CH_LAYOUT_7POINT1_WIDE_BACK, |
| 630 | + 0 |
| 631 | +}; |
| 632 | +#endif |
| 633 | + |
| 634 | + |
| 619 | 635 | #define OFFSET(x) offsetof(AlacEncodeContext, x) |
| 620 | 636 | #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
| 621 | 637 | static const AVOption options[] = { |
| @@ -632,6 +648,7 @@ static const AVClass alacenc_class = { · 10 unmodified lines |
| 632 | 648 | .version = LIBAVUTIL_VERSION_INT, |
| 633 | 649 | }; |
| 634 | 650 | |
| 651 | +FF_DISABLE_DEPRECATION_WARNINGS |
| 635 | 652 | const AVCodec ff_alac_encoder = { |
| 636 | 653 | .name = "alac", |
| 637 | 654 | .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), |
| @@ -643,9 +660,13 @@ const AVCodec ff_alac_encoder = { · 5 unmodified lines |
| 643 | 660 | .encode2 = alac_encode_frame, |
| 644 | 661 | .close = alac_encode_close, |
| 645 | 662 | .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, |
| 646 | | − .channel_layouts = ff_alac_channel_layouts, |
| 663 | +#if FF_API_OLD_CHANNEL_LAYOUT |
| 664 | + .channel_layouts = alac_channel_layouts, |
| 665 | +#endif |
| 666 | + .ch_layouts = ff_alac_ch_layouts, |
| 647 | 667 | .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P, |
| 648 | 668 | AV_SAMPLE_FMT_S16P, |
| 649 | 669 | AV_SAMPLE_FMT_NONE }, |
| 650 | 670 | .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, |
| 651 | 671 | }; |
| 672 | +FF_ENABLE_DEPRECATION_WARNINGS |