summaryrefslogtreecommitdiff
path: root/libavcodec/adpcmenc.c
diff options
context:
space:
mode:
authorZane van Iperen <zane@zanevaniperen.com>2020-06-11 09:07:49 +1000
committerZane van Iperen <zane@zanevaniperen.com>2020-07-21 11:36:14 +1000
commite35a0f8f3f2884bc712bac84f7b310025780e7f5 (patch)
treee6a1640f4f72b7b89c66ff3e88c706f4c59083dc /libavcodec/adpcmenc.c
parent932edaaa60494fe7d5291321ff25253e7c68ff9c (diff)
downloadffmpeg-e35a0f8f3f2884bc712bac84f7b310025780e7f5.tar.gz
avcodec/adpcmenc: cleanup trellis checks
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Diffstat (limited to 'libavcodec/adpcmenc.c')
-rw-r--r--libavcodec/adpcmenc.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 4985abb163..adb7bf0bbf 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -69,25 +69,26 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
- av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
- return AVERROR(EINVAL);
- }
+ if (avctx->trellis) {
+ int frontier, max_paths;
- if (avctx->trellis &&
- (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
- avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM)) {
- /*
- * The current trellis implementation doesn't work for extended
- * runs of samples without periodic resets. Disallow it.
- */
- av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
- return AVERROR_PATCHWELCOME;
- }
+ if ((unsigned)avctx->trellis > 16U) {
+ av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
+ return AVERROR(EINVAL);
+ }
- if (avctx->trellis) {
- int frontier = 1 << avctx->trellis;
- int max_paths = frontier * FREEZE_INTERVAL;
+ if (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+ avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM) {
+ /*
+ * The current trellis implementation doesn't work for extended
+ * runs of samples without periodic resets. Disallow it.
+ */
+ av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
+ return AVERROR_PATCHWELCOME;
+ }
+
+ frontier = 1 << avctx->trellis;
+ max_paths = frontier * FREEZE_INTERVAL;
if (!FF_ALLOC_TYPED_ARRAY(s->paths, max_paths) ||
!FF_ALLOC_TYPED_ARRAY(s->node_buf, 2 * frontier) ||
!FF_ALLOC_TYPED_ARRAY(s->nodep_buf, 2 * frontier) ||