* [FFmpeg-devel] [PATCH 1/2] avcodec/apedec: Fix CRC for 24bps and bigendian
@ 2023-08-25 15:13 Michael Niedermayer
2023-08-25 15:13 ` [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level Michael Niedermayer
0 siblings, 1 reply; 4+ messages in thread
From: Michael Niedermayer @ 2023-08-25 15:13 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes CRC for vlc.ape and APE_48K_24bit_2CH_02_01.ape
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/apedec.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 613c76df0b..7bad8500e1 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1625,13 +1625,24 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame,
s->samples -= blockstodecode;
if (avctx->err_recognition & AV_EF_CRCCHECK &&
- s->fileversion >= 3900 && s->bps < 24) {
+ s->fileversion >= 3900) {
uint32_t crc = s->CRC_state;
const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
+ int stride = s->bps == 24 ? 4 : (s->bps>>3);
+ int offset = s->bps == 24;
+ int bytes = s->bps >> 3;
+
for (i = 0; i < blockstodecode; i++) {
for (ch = 0; ch < s->channels; ch++) {
- uint8_t *smp = frame->data[ch] + (i*(s->bps >> 3));
- crc = av_crc(crc_tab, crc, smp, s->bps >> 3);
+#if HAVE_BIGENDIAN
+ uint8_t *smp_native = frame->data[ch] + i*stride;
+ uint8_t smp[4];
+ for(int j = 0; j<stride; j++)
+ smp[j] = smp_native[stride-j-1];
+#else
+ uint8_t *smp = frame->data[ch] + i*stride;
+#endif
+ crc = av_crc(crc_tab, crc, smp+offset, bytes);
}
}
--
2.17.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level
2023-08-25 15:13 [FFmpeg-devel] [PATCH 1/2] avcodec/apedec: Fix CRC for 24bps and bigendian Michael Niedermayer
@ 2023-08-25 15:13 ` Michael Niedermayer
2023-08-25 15:27 ` Paul B Mahol
0 siblings, 1 reply; 4+ messages in thread
From: Michael Niedermayer @ 2023-08-25 15:13 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: Ticket9816
Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape
Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/apedec.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 7bad8500e1..b1cceb9395 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1184,7 +1184,9 @@ static void predictor_decode_mono_3930(APEContext *ctx, int count)
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)
+ const int adaptA, const int adaptB,
+ int compression_level
+ )
{
int64_t predictionA, predictionB;
int32_t sign;
@@ -1212,7 +1214,12 @@ 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];
- p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10);
+ if (compression_level < COMPRESSION_LEVEL_INSANE) {
+ predictionA = (int32_t)predictionA;
+ predictionB = (int32_t)predictionB;
+ p->lastA[filter] = decoded + ((int32_t)(predictionA + (predictionB >> 1)) >> 10);
+ } else
+ p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10);
p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5);
sign = APESIGN(decoded);
@@ -1240,10 +1247,10 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count)
while (count--) {
/* Predictor Y */
*decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,
- YADAPTCOEFFSA, YADAPTCOEFFSB);
+ YADAPTCOEFFSA, YADAPTCOEFFSB, ctx->compression_level);
decoded0++;
*decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,
- XADAPTCOEFFSA, XADAPTCOEFFSB);
+ XADAPTCOEFFSA, XADAPTCOEFFSB, ctx->compression_level);
decoded1++;
/* Combined */
--
2.17.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level
2023-08-25 15:13 ` [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level Michael Niedermayer
@ 2023-08-25 15:27 ` Paul B Mahol
2023-08-25 17:04 ` Michael Niedermayer
0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2023-08-25 15:27 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, Aug 25, 2023 at 5:13 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:
> Fixes: Ticket9816
> Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape
>
> Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavcodec/apedec.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> index 7bad8500e1..b1cceb9395 100644
> --- a/libavcodec/apedec.c
> +++ b/libavcodec/apedec.c
> @@ -1184,7 +1184,9 @@ static void predictor_decode_mono_3930(APEContext
> *ctx, int count)
> 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)
> + const int adaptA,
> const int adaptB,
> + int compression_level
> + )
>
Why on ')' separate line?
> {
> int64_t predictionA, predictionB;
> int32_t sign;
> @@ -1212,7 +1214,12 @@ 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];
>
> - p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA +
> (predictionB >> 1)) >> 10);
> + if (compression_level < COMPRESSION_LEVEL_INSANE) {
> + predictionA = (int32_t)predictionA;
> + predictionB = (int32_t)predictionB;
> + p->lastA[filter] = decoded + ((int32_t)(predictionA +
> (predictionB >> 1)) >> 10);
> + } else
> + p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA +
> (predictionB >> 1)) >> 10);
>
Please make {} block.
> p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter]
> * 31ULL) >> 5);
>
> sign = APESIGN(decoded);
> @@ -1240,10 +1247,10 @@ static void
> predictor_decode_stereo_3950(APEContext *ctx, int count)
> while (count--) {
> /* Predictor Y */
> *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA,
> YDELAYB,
> - YADAPTCOEFFSA, YADAPTCOEFFSB);
> + YADAPTCOEFFSA, YADAPTCOEFFSB,
> ctx->compression_level);
> decoded0++;
> *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA,
> XDELAYB,
> - XADAPTCOEFFSA, XADAPTCOEFFSB);
> + XADAPTCOEFFSA, XADAPTCOEFFSB,
> ctx->compression_level);
> decoded1++;
>
> /* Combined */
> --
> 2.17.1
>
>
OK with that style fixed, assuming it fixes that ticket and is still
bitexact with both files.
> _______________________________________________
> 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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level
2023-08-25 15:27 ` Paul B Mahol
@ 2023-08-25 17:04 ` Michael Niedermayer
0 siblings, 0 replies; 4+ messages in thread
From: Michael Niedermayer @ 2023-08-25 17:04 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 3735 bytes --]
On Fri, Aug 25, 2023 at 05:27:14PM +0200, Paul B Mahol wrote:
> On Fri, Aug 25, 2023 at 5:13 PM Michael Niedermayer <michael@niedermayer.cc>
> wrote:
>
> > Fixes: Ticket9816
> > Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape
> >
> > Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.
> >
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavcodec/apedec.c | 15 +++++++++++----
> > 1 file changed, 11 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> > index 7bad8500e1..b1cceb9395 100644
> > --- a/libavcodec/apedec.c
> > +++ b/libavcodec/apedec.c
> > @@ -1184,7 +1184,9 @@ static void predictor_decode_mono_3930(APEContext
> > *ctx, int count)
> > 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)
> > + const int adaptA,
> > const int adaptB,
> > + int compression_level
> > + )
> >
>
> Why on ')' separate line?
I asked the ')' but it doesnt seem to remember
fixed
>
>
> > {
> > int64_t predictionA, predictionB;
> > int32_t sign;
> > @@ -1212,7 +1214,12 @@ 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];
> >
> > - p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA +
> > (predictionB >> 1)) >> 10);
> > + if (compression_level < COMPRESSION_LEVEL_INSANE) {
> > + predictionA = (int32_t)predictionA;
> > + predictionB = (int32_t)predictionB;
> > + p->lastA[filter] = decoded + ((int32_t)(predictionA +
> > (predictionB >> 1)) >> 10);
> > + } else
> > + p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA +
> > (predictionB >> 1)) >> 10);
> >
>
> Please make {} block.
ok
>
>
> > p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter]
> > * 31ULL) >> 5);
> >
> > sign = APESIGN(decoded);
> > @@ -1240,10 +1247,10 @@ static void
> > predictor_decode_stereo_3950(APEContext *ctx, int count)
> > while (count--) {
> > /* Predictor Y */
> > *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA,
> > YDELAYB,
> > - YADAPTCOEFFSA, YADAPTCOEFFSB);
> > + YADAPTCOEFFSA, YADAPTCOEFFSB,
> > ctx->compression_level);
> > decoded0++;
> > *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA,
> > XDELAYB,
> > - XADAPTCOEFFSA, XADAPTCOEFFSB);
> > + XADAPTCOEFFSA, XADAPTCOEFFSB,
> > ctx->compression_level);
> > decoded1++;
> >
> > /* Combined */
> > --
> > 2.17.1
> >
> >
> OK with that style fixed, assuming it fixes that ticket and is still
> bitexact with both files.
ive fixed the style issues i found, i hope i found all
CRC tests pass on the 3 files i have
will apply with my next git push
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have often repented speaking, but never of holding my tongue.
-- Xenocrates
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-25 17:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25 15:13 [FFmpeg-devel] [PATCH 1/2] avcodec/apedec: Fix CRC for 24bps and bigendian Michael Niedermayer
2023-08-25 15:13 ` [FFmpeg-devel] [PATCH 2/2] avcodec/apedec: Fix 48khz 24bit below insane level Michael Niedermayer
2023-08-25 15:27 ` Paul B Mahol
2023-08-25 17:04 ` Michael Niedermayer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git