* Copy input samples. * Channels are reordered from libavcodec's default order to AAC order. */
| 800 | * Channels are reordered from libavcodec's default order to AAC order. |
| 801 | */ |
| 802 | static void copy_input_samples(AACEncContext *s, const AVFrame *frame) |
| 803 | { |
| 804 | int ch; |
| 805 | int end = 2048 + (frame ? frame->nb_samples : 0); |
| 806 | const uint8_t *channel_map = s->reorder_map; |
| 807 | |
| 808 | /* copy and remap input samples */ |
| 809 | for (ch = 0; ch < s->channels; ch++) { |
| 810 | /* copy last 1024 samples of previous frame to the start of the current frame */ |
| 811 | memcpy(&s->planar_samples[ch][1024], &s->planar_samples[ch][2048], 1024 * sizeof(s->planar_samples[0][0])); |
| 812 | |
| 813 | /* copy new samples and zero any remaining samples */ |
| 814 | if (frame) { |
| 815 | memcpy(&s->planar_samples[ch][2048], |
| 816 | frame->extended_data[channel_map[ch]], |
| 817 | frame->nb_samples * sizeof(s->planar_samples[0][0])); |
| 818 | } |
| 819 | memset(&s->planar_samples[ch][end], 0, |
| 820 | (3072 - end) * sizeof(s->planar_samples[0][0])); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
| 825 | const AVFrame *frame, int *got_packet_ptr) |