Lines Matching defs:avctx
35 static av_cold int encode_init(AVCodecContext *avctx)
37 WMACodecContext *s = avctx->priv_data;
42 s->avctx = avctx;
44 if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
45 av_log(avctx, AV_LOG_ERROR,
47 avctx->ch_layout.nb_channels, MAX_CHANNELS);
51 if (avctx->sample_rate > 48000) {
52 av_log(avctx, AV_LOG_ERROR, "sample rate is too high: %d > 48kHz\n",
53 avctx->sample_rate);
57 if (avctx->bit_rate < 24 * 1000) {
58 av_log(avctx, AV_LOG_ERROR,
60 avctx->bit_rate);
67 if (avctx->codec->id == AV_CODEC_ID_WMAV1) {
71 avctx->extradata_size = 4;
74 } else if (avctx->codec->id == AV_CODEC_ID_WMAV2) {
78 avctx->extradata_size = 10;
84 avctx->extradata = extradata;
88 if (avctx->ch_layout.nb_channels == 2)
91 if ((ret = ff_wma_init(avctx, flags2)) < 0)
101 block_align = avctx->bit_rate * (int64_t) s->frame_len /
102 (avctx->sample_rate * 8);
104 avctx->block_align = block_align;
105 avctx->frame_size = avctx->initial_padding = s->frame_len;
110 static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
112 WMACodecContext *s = avctx->priv_data;
122 for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
130 av_log(avctx, AV_LOG_ERROR, "Input contains NaN/+-Inf\n");
192 int channels = s->avctx->ch_layout.nb_channels;
371 return put_bits_count(&s->pb) / 8 - s->avctx->block_align;
374 static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
377 WMACodecContext *s = avctx->priv_data;
383 ret = apply_window_and_mdct(avctx, frame);
400 if ((ret = ff_alloc_packet(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE)) < 0)
414 av_log(avctx, AV_LOG_ERROR, "Invalid input data or requested bitrate too low, cannot encode\n");
419 i = avctx->block_align - put_bytes_count(&s->pb, 0);
425 av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align);
428 avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
430 avpkt->size = avctx->block_align;