From patchwork Tue Mar 23 14:12:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 26562 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7228944BC28 for ; Tue, 23 Mar 2021 16:13:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4B97768AB48; Tue, 23 Mar 2021 16:13:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out2.migadu.com (unknown [188.165.223.204]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4F8C6804FC for ; Tue, 23 Mar 2021 16:13:38 +0200 (EET) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=key1; t=1616508809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K2v6zj1Py1wUqkQbIYU6BBWIUyXtTGNBShDbbXWUJ7I=; b=hgnTIMYHfqdXWutrrOj5aoYYuRNrPiEU6a/wYGRGayFcEvd04RwR+gnksW0daMwSidceXj /CaoOilbkLFlGZZXC7tLWCNJdGjaOqOwSg9tVsrgo+i21Rg32v85NP4R11XrM1/eHezD83 Dc4lGAJkoF3dUmBTX+0oZEPQ+T4ElMQztUfRjNIAUnfwHcAx7ZPlyVVsdI+P8awESyD8pZ ouO523ihS43OebUPWZZJDDDhKfWfTmoSJLqVhmwHaNgf27Lpbwk5sMfUdPwKEy+ltRIG4j cQR0p6JWmENEYWA8msbn940T9POKoydCI+XHb/jrpoB3jId8xrfXP9khkTZ+0A== From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Mar 2021 00:12:56 +1000 Message-Id: <20210323141305.19229-2-zane@zanevaniperen.com> In-Reply-To: <20210323141305.19229-1-zane@zanevaniperen.com> References: <20210323141305.19229-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: git-morningstar@zanevaniperen.com Subject: [FFmpeg-devel] [PATCH 02/11] avcodec/adpcm_zork: reset state in flush callback X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Zane van Iperen --- libavcodec/adpcm.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 5c28b745b9..b145622f4f 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -2077,13 +2077,6 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_ZORK: - if (!c->has_status) { - for (channel = 0; channel < avctx->channels; channel++) { - c->status[channel].predictor = 0; - c->status[channel].step_index = 0; - } - c->has_status = 1; - } for (n = 0; n < nb_samples * avctx->channels; n++) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v); @@ -2121,7 +2114,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, static void adpcm_flush(AVCodecContext *avctx) { ADPCMDecodeContext *c = avctx->priv_data; - c->has_status = 0; + + switch(avctx->codec_id) { + case AV_CODEC_ID_ADPCM_ZORK: + for (int channel = 0; channel < avctx->channels; channel++) { + c->status[channel].predictor = 0; + c->status[channel].step_index = 0; + } + break; + + default: + /* Other codecs may want to handle this during decoding. */ + c->has_status = 0; + return; + } + + c->has_status = 1; }