| 753 | } |
| 754 | |
| 755 | static 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 | |
| 790 | static const FFCodecDefault mp2_defaults[] = { |
| 791 | { "b", "0" }, |
nothing calls this directly
no test coverage detected