| 822 | } |
| 823 | |
| 824 | static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
| 825 | const AVFrame *frame, int *got_packet_ptr) |
| 826 | { |
| 827 | AACEncContext *s = avctx->priv_data; |
| 828 | float **samples = s->planar_samples, *samples2, *la, *overlap; |
| 829 | ChannelElement *cpe; |
| 830 | SingleChannelElement *sce; |
| 831 | IndividualChannelStream *ics; |
| 832 | int i, its, ch, w, chans, tag, start_ch, ret, frame_bits; |
| 833 | int target_bits, rate_bits, too_many_bits, too_few_bits; |
| 834 | int ms_mode = 0, is_mode = 0, tns_mode = 0, pred_mode = 0; |
| 835 | int chan_el_counter[4]; |
| 836 | FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; |
| 837 | |
| 838 | /* add current frame to queue */ |
| 839 | if (frame) { |
| 840 | if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) |
| 841 | return ret; |
| 842 | } else { |
| 843 | if (!s->afq.remaining_samples || (!s->afq.frame_alloc && !s->afq.frame_count)) |
| 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | copy_input_samples(s, frame); |
| 848 | |
| 849 | if (!avctx->frame_num) |
| 850 | return 0; |
| 851 | |
| 852 | start_ch = 0; |
| 853 | for (i = 0; i < s->chan_map[0]; i++) { |
| 854 | FFPsyWindowInfo* wi = windows + start_ch; |
| 855 | tag = s->chan_map[i+1]; |
| 856 | chans = tag == TYPE_CPE ? 2 : 1; |
| 857 | cpe = &s->cpe[i]; |
| 858 | for (ch = 0; ch < chans; ch++) { |
| 859 | int k; |
| 860 | float clip_avoidance_factor; |
| 861 | sce = &cpe->ch[ch]; |
| 862 | ics = &sce->ics; |
| 863 | s->cur_channel = start_ch + ch; |
| 864 | overlap = &samples[s->cur_channel][0]; |
| 865 | samples2 = overlap + 1024; |
| 866 | la = samples2 + (448+64); |
| 867 | if (!frame) |
| 868 | la = NULL; |
| 869 | if (tag == TYPE_LFE) { |
| 870 | wi[ch].window_type[0] = wi[ch].window_type[1] = ONLY_LONG_SEQUENCE; |
| 871 | wi[ch].window_shape = 0; |
| 872 | wi[ch].num_windows = 1; |
| 873 | wi[ch].grouping[0] = 1; |
| 874 | wi[ch].clipping[0] = 0; |
| 875 | |
| 876 | /* Only the lowest 12 coefficients are used in a LFE channel. |
| 877 | * The expression below results in only the bottom 8 coefficients |
| 878 | * being used for 11.025kHz to 16kHz sample rates. |
| 879 | */ |
| 880 | ics->num_swb = s->samplerate_index >= 8 ? 1 : 3; |
| 881 | } else { |
nothing calls this directly
no test coverage detected