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

Function mpa_encode_frame

libavcodec/mpegaudioenc.c:755–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755static int mpa_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
756 const AVFrame *frame, int *got_packet_ptr)
757{
758 MpegAudioContext *s = avctx->priv_data;
759 const int16_t *samples = (const int16_t *)frame->data[0];
760 short smr[MPA_MAX_CHANNELS][SBLIMIT];
761 unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
762 int padding, i, ret;
763
764 for(i=0;i<s->nb_channels;i++) {
765 filter(s, i, samples + i, s->nb_channels);
766 }
767
768 for(i=0;i<s->nb_channels;i++) {
769 compute_scale_factors(s, s->scale_code[i], s->scale_factors[i],
770 s->sb_samples[i], s->sblimit);
771 }
772 for(i=0;i<s->nb_channels;i++) {
773 psycho_acoustic_model(s, smr[i]);
774 }
775 unsigned frame_size = compute_bit_allocation(s, smr, bit_alloc, &padding);
776
777 ret = ff_get_encode_buffer(avctx, avpkt, frame_size, 0);
778 if (ret < 0)
779 return ret;
780
781 encode_frame(s, avpkt->data, frame_size, bit_alloc, padding);
782
783 if (frame->pts != AV_NOPTS_VALUE)
784 avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
785
786 *got_packet_ptr = 1;
787 return 0;
788}
789
790static const FFCodecDefault mp2_defaults[] = {
791 { "b", "0" },

Callers

nothing calls this directly

Calls 7

compute_scale_factorsFunction · 0.85
psycho_acoustic_modelFunction · 0.85
compute_bit_allocationFunction · 0.85
ff_get_encode_bufferFunction · 0.85
ff_samples_to_time_baseFunction · 0.85
filterFunction · 0.70
encode_frameFunction · 0.70

Tested by

no test coverage detected