Lines Matching defs:avctx
596 static av_cold int sonic_encode_init(AVCodecContext *avctx)
598 SonicContext *s = avctx->priv_data;
605 if (avctx->ch_layout.nb_channels > MAX_CHANNELS)
607 av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
611 if (avctx->ch_layout.nb_channels == 2)
616 if (avctx->codec->id == AV_CODEC_ID_SONIC_LS)
632 av_log(avctx, AV_LOG_ERROR, "Invalid number of taps\n");
644 s->channels = avctx->ch_layout.nb_channels;
645 s->samplerate = avctx->sample_rate;
672 avctx->extradata = av_mallocz(16);
673 if (!avctx->extradata)
675 init_put_bits(&pb, avctx->extradata, 16*8);
696 avctx->extradata_size = put_bytes_output(&pb);
698 av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
701 avctx->frame_size = s->block_align*s->downsampling;
706 static av_cold int sonic_encode_close(AVCodecContext *avctx)
708 SonicContext *s = avctx->priv_data;
720 static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
723 SonicContext *s = avctx->priv_data;
730 if ((ret = ff_alloc_packet(avctx, avpkt, s->frame_size * 5 + 1000)) < 0)
821 // av_log(avctx, AV_LOG_DEBUG, "quant: %d energy: %f / %f\n", quant, energy1, energy2);
852 static av_cold int sonic_decode_init(AVCodecContext *avctx)
854 SonicContext *s = avctx->priv_data;
860 s->channels = avctx->ch_layout.nb_channels;
861 s->samplerate = avctx->sample_rate;
863 if (!avctx->extradata)
865 av_log(avctx, AV_LOG_ERROR, "No mandatory headers present\n");
869 ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
880 av_log(avctx, AV_LOG_ERROR, "Unsupported Sonic version, please report\n");
890 av_log(avctx, AV_LOG_ERROR, "Invalid sample_rate_index %d\n", sample_rate_index);
894 av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n",
900 av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
903 av_channel_layout_uninit(&avctx->ch_layout);
904 avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
905 avctx->ch_layout.nb_channels = s->channels;
912 av_log(avctx, AV_LOG_ERROR, "invalid decorrelation %d\n", s->decorrelation);
918 av_log(avctx, AV_LOG_ERROR, "invalid downsampling value\n");
924 av_log(avctx, AV_LOG_INFO, "Custom quant table\n");
928 // avctx->frame_size = s->block_align;
931 av_log(avctx, AV_LOG_ERROR,
937 av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
966 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
970 static av_cold int sonic_decode_close(AVCodecContext *avctx)
972 SonicContext *s = avctx->priv_data;
983 static int sonic_decode_frame(AVCodecContext *avctx, AVFrame *frame,
988 SonicContext *s = avctx->priv_data;
996 frame->nb_samples = s->frame_size / avctx->ch_layout.nb_channels;
997 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)