Lines Matching defs:avctx
81 static av_cold int adpcm_encode_init(AVCodecContext *avctx)
83 ADPCMEncodeContext *s = avctx->priv_data;
84 int channels = avctx->ch_layout.nb_channels;
90 if (avctx->codec->id != AV_CODEC_ID_ADPCM_IMA_AMV &&
92 av_log(avctx, AV_LOG_ERROR, "block size must be power of 2\n");
96 if (avctx->trellis) {
99 if ((unsigned)avctx->trellis > 16U) {
100 av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
104 if (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
105 avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM ||
106 avctx->codec->id == AV_CODEC_ID_ADPCM_ARGO ||
107 avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_WS) {
112 av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
116 frontier = 1 << avctx->trellis;
125 avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
127 switch (avctx->codec->id) {
131 avctx->frame_size = (s->block_size - 4 * channels) * 8 /
135 avctx->block_align = s->block_size;
136 avctx->bits_per_coded_sample = 4;
139 avctx->frame_size = 64;
140 avctx->block_align = 34 * channels;
146 avctx->frame_size = (s->block_size - 7 * channels) * 2 / channels + 2;
147 avctx->bits_per_coded_sample = 4;
148 avctx->block_align = s->block_size;
149 if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE)))
151 avctx->extradata_size = 32;
152 extradata = avctx->extradata;
153 bytestream_put_le16(&extradata, avctx->frame_size);
161 avctx->frame_size = s->block_size * 2 / channels;
162 avctx->block_align = s->block_size;
165 if (avctx->sample_rate != 11025 &&
166 avctx->sample_rate != 22050 &&
167 avctx->sample_rate != 44100) {
168 av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
172 avctx->frame_size = 4096; /* Hardcoded according to the SWF spec. */
173 avctx->block_align = (2 + channels * (22 + 4 * (avctx->frame_size - 1)) + 7) / 8;
177 avctx->frame_size = s->block_size * 2 / channels;
178 avctx->block_align = s->block_size;
181 if (avctx->sample_rate != 22050) {
182 av_log(avctx, AV_LOG_ERROR, "Sample rate must be 22050\n");
187 av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
191 avctx->frame_size = s->block_size;
192 avctx->block_align = 8 + (FFALIGN(avctx->frame_size, 2) / 2);
195 avctx->frame_size = s->block_size * 2 / channels;
196 avctx->block_align = s->block_size;
198 if (!(avctx->extradata = av_mallocz(28 + AV_INPUT_BUFFER_PADDING_SIZE)))
200 avctx->extradata_size = 28;
203 avctx->frame_size = 32;
204 avctx->block_align = 17 * channels;
208 avctx->frame_size = s->block_size * 2 / channels;
209 avctx->block_align = s->block_size;
218 static av_cold int adpcm_encode_close(AVCodecContext *avctx)
220 ADPCMEncodeContext *s = avctx->priv_data;
350 static void adpcm_compress_trellis(AVCodecContext *avctx,
355 ADPCMEncodeContext *s = avctx->priv_data;
356 const int frontier = 1 << avctx->trellis;
357 const int version = avctx->codec->id;
455 av_assert1(pathn < FREEZE_INTERVAL << avctx->trellis);\
599 static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
606 ADPCMEncodeContext *c = avctx->priv_data;
607 int channels = avctx->ch_layout.nb_channels;
613 if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
614 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP ||
615 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM ||
616 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS)
619 pkt_size = avctx->block_align;
620 if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)
624 switch(avctx->codec->id) {
639 if (avctx->trellis > 0) {
644 adpcm_compress_trellis(avctx, &samples_p[ch][1],
678 if (avctx->trellis > 0) {
680 adpcm_compress_trellis(avctx, &samples_p[ch][0], buf, status,
702 av_assert0(avctx->trellis == 0);
716 av_assert0(avctx->trellis == 0);
748 if (avctx->trellis > 0) {
750 adpcm_compress_trellis(avctx, samples + channels, buf,
753 adpcm_compress_trellis(avctx, samples + channels + 1,
793 if (avctx->trellis > 0) {
794 const int n = avctx->block_align - 7 * channels;
799 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
804 adpcm_compress_trellis(avctx, samples, buf,
806 adpcm_compress_trellis(avctx, samples + 1, buf + n,
813 for (int i = 7 * channels; i < avctx->block_align; i++) {
823 if (avctx->trellis > 0) {
829 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
834 adpcm_compress_trellis(avctx, samples, buf,
836 adpcm_compress_trellis(avctx, samples + 1, buf + n,
854 av_assert0(avctx->trellis == 0);
873 bytestream_put_le32(&dst, avctx->frame_size);
875 if (avctx->trellis > 0) {
882 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], 2 * n, channels);
895 if (avctx->frame_size & 1) {
940 av_assert0(avctx->trellis == 0);