From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id CFB194711B for ; Sun, 27 Aug 2023 23:00:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7B0DF68C5F3; Mon, 28 Aug 2023 02:00:02 +0300 (EEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8886568C263 for ; Mon, 28 Aug 2023 01:59:56 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4BE0460002 for ; Sun, 27 Aug 2023 22:59:55 +0000 (UTC) Date: Mon, 28 Aug 2023 00:59:54 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230827225954.GW7802@pb2> References: <20230826165350.8838-1-michael@niedermayer.cc> <20230826165350.8838-2-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Implement interim mode detection X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: multipart/mixed; boundary="===============0038276358540957146==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============0038276358540957146== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NopUSMBPYtAHPrxU" Content-Disposition: inline --NopUSMBPYtAHPrxU Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Aug 26, 2023 at 07:29:40PM +0200, Paul B Mahol wrote: > On Sat, Aug 26, 2023 at 6:54=E2=80=AFPM Michael Niedermayer > wrote: >=20 > > Fixes: NoLegacy.ape > > Found-by: Matt Ashland > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/apedec.c | 106 +++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 84 insertions(+), 22 deletions(-) > > > > diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c > > index 8bd625ca05..249fc22e24 100644 > > --- a/libavcodec/apedec.c > > +++ b/libavcodec/apedec.c > > @@ -171,6 +171,9 @@ typedef struct APEContext { > > int32_t *decoded_buffer; > > int decoded_size; > > int32_t *decoded[MAX_CHANNELS]; ///< decoded data for each > > channel > > + int32_t *interim_buffer; > > + int interim_size; > > + int32_t *interim[MAX_CHANNELS]; ///< decoded data for each > > channel > > int blocks_per_loop; ///< maximum number of > > samples to decode for each call > > > > int16_t* filterbuf[APE_FILTER_LEVELS]; ///< filter memory > > @@ -187,6 +190,7 @@ typedef struct APEContext { > > const uint8_t *ptr; ///< current position in > > frame data > > > > int error; > > + int interim_mode; > > > > void (*entropy_decode_mono)(struct APEContext *ctx, int > > blockstodecode); > > void (*entropy_decode_stereo)(struct APEContext *ctx, int > > blockstodecode); > > @@ -223,6 +227,7 @@ static av_cold int ape_decode_close(AVCodecContext > > *avctx) > > av_freep(&s->filterbuf[i]); > > > > av_freep(&s->decoded_buffer); > > + av_freep(&s->interim_buffer); > > av_freep(&s->data); > > s->decoded_size =3D s->data_size =3D 0; > > > > @@ -248,12 +253,15 @@ static av_cold int ape_decode_init(AVCodecContext > > *avctx) > > switch (s->bps) { > > case 8: > > avctx->sample_fmt =3D AV_SAMPLE_FMT_U8P; > > + s->interim_mode =3D 0; > > break; > > case 16: > > avctx->sample_fmt =3D AV_SAMPLE_FMT_S16P; > > + s->interim_mode =3D 0; > > break; > > case 24: > > avctx->sample_fmt =3D AV_SAMPLE_FMT_S32P; > > + s->interim_mode =3D -1; > > break; > > default: > > avpriv_request_sample(avctx, > > @@ -1181,7 +1189,7 @@ static av_always_inline int > > predictor_update_filter(APEPredictor64 *p, > > const int decoded, > > const int filter, > > const int delayA, > > const int delayB, > > const int adaptA, > > const int adaptB, > > - int compression_le= vel) > > + int interim_mode) > > { > > int64_t predictionA, predictionB; > > int32_t sign; > > @@ -1209,7 +1217,7 @@ static av_always_inline int > > predictor_update_filter(APEPredictor64 *p, > > p->buf[delayB - 3] * p->coeffsB[filter][3] + > > p->buf[delayB - 4] * p->coeffsB[filter][4]; > > > > - if (compression_level < COMPRESSION_LEVEL_INSANE) { > > + if (interim_mode < 1) { > > predictionA =3D (int32_t)predictionA; > > predictionB =3D (int32_t)predictionB; > > p->lastA[filter] =3D decoded + ((int32_t)(predictionA + > > (predictionB >> 1)) >> 10); > > @@ -1234,33 +1242,74 @@ static av_always_inline int > > predictor_update_filter(APEPredictor64 *p, > > > > static void predictor_decode_stereo_3950(APEContext *ctx, int count) > > { > > - APEPredictor64 *p =3D &ctx->predictor64; > > - int32_t *decoded0 =3D ctx->decoded[0]; > > - int32_t *decoded1 =3D ctx->decoded[1]; > > + APEPredictor64 *p_default =3D &ctx->predictor64; > > + APEPredictor64 p_interim; > > + int lcount =3D count; > > + int num_passes =3D 1; > > > > ape_apply_filters(ctx, ctx->decoded[0], ctx->decoded[1], count); > > + if (ctx->interim_mode =3D=3D -1) { > > + p_interim =3D *p_default; > > + num_passes ++; > > + memcpy(ctx->interim[0], ctx->decoded[0], > > sizeof(*ctx->interim[0])*count); > > + memcpy(ctx->interim[1], ctx->decoded[1], > > sizeof(*ctx->interim[1])*count); > > + } > > > > - while (count--) { > > - /* Predictor Y */ > > - *decoded0 =3D predictor_update_filter(p, *decoded0, 0, YDELAYA, > > YDELAYB, > > - YADAPTCOEFFSA, YADAPTCOEFF= SB, > > - ctx->compression_level); > > - decoded0++; > > - *decoded1 =3D predictor_update_filter(p, *decoded1, 1, XDELAYA, > > XDELAYB, > > - XADAPTCOEFFSA, XADAPTCOEFF= SB, > > - ctx->compression_level); > > - decoded1++; > > + for(int pass =3D 0; pass < num_passes; pass++) { > > >=20 > Please fix your style in patches. Noone can know from this what exactly you meant but ill apply with the whitespace issue i found, which may be what you meant. No need to be precisse, thats ok with me if you prefer that but a inprecisse review comment will result in inprecisse results thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable --NopUSMBPYtAHPrxU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZOvVZgAKCRBhHseHBAsP q08uAKCb6q2iZUmQScuxr6W2LNYhBUn8UACgldpPBRbsUj0tabOMeHQTyIP0wHE= =0GcJ -----END PGP SIGNATURE----- --NopUSMBPYtAHPrxU-- --===============0038276358540957146== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============0038276358540957146==--