]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/adpcmenc.c
avcodec/adpcm_ima_wav: support custom block size for encoding
[ffmpeg] / libavcodec / adpcmenc.c
index 3d036e1f92a1552aea145ec8f1d120bf5fa6345c..725d418edc49edd4c44dc03e764f4aa0d06d957a 100644 (file)
@@ -113,11 +113,11 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_ADPCM_IMA_WAV:
         /* each 16 bits sample gives one nibble
            and we have 4 bytes per channel overhead */
-        avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /
+        avctx->frame_size = (s->block_size - 4 * avctx->channels) * 8 /
                             (4 * avctx->channels) + 1;
         /* seems frame_size isn't taken into account...
            have to buffer the samples :-( */
-        avctx->block_align = BLKSIZE;
+        avctx->block_align = s->block_size;
         avctx->bits_per_coded_sample = 4;
         break;
     case AV_CODEC_ID_ADPCM_IMA_QT:
@@ -142,8 +142,8 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
         }
         break;
     case AV_CODEC_ID_ADPCM_YAMAHA:
-        avctx->frame_size  = BLKSIZE * 2 / avctx->channels;
-        avctx->block_align = BLKSIZE;
+        avctx->frame_size  = s->block_size * 2 / avctx->channels;
+        avctx->block_align = s->block_size;
         break;
     case AV_CODEC_ID_ADPCM_SWF:
         if (avctx->sample_rate != 11025 &&
@@ -160,8 +160,8 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
         avctx->block_align = s->block_size;
         break;
     case AV_CODEC_ID_ADPCM_IMA_APM:
-        avctx->frame_size = BLKSIZE * 2 / avctx->channels;
-        avctx->block_align = BLKSIZE;
+        avctx->frame_size  = s->block_size * 2 / avctx->channels;
+        avctx->block_align = s->block_size;
 
         if (!(avctx->extradata = av_mallocz(28 + AV_INPUT_BUFFER_PADDING_SIZE)))
             return AVERROR(ENOMEM);