MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / aac_encode_frame

Function aac_encode_frame

libavcodec/aacenc.c:824–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

822}
823
824static 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 {

Callers

nothing calls this directly

Calls 15

ff_af_queue_addFunction · 0.85
copy_input_samplesFunction · 0.85
fabsfFunction · 0.85
fabsFunction · 0.85
av_logFunction · 0.85
avoid_clippingFunction · 0.85
ff_alloc_packetFunction · 0.85
init_put_bitsFunction · 0.85
put_bitstream_infoFunction · 0.85
apply_mid_side_stereoFunction · 0.85
adjust_frame_informationFunction · 0.85
put_ics_infoFunction · 0.85

Tested by

no test coverage detected