Merge pull request #19802 from hrydgard/atrac3-workaround-packet-error

Atrac3 (not +): Keep decoding even on broken frames.
This commit is contained in:
Henrik Rydgård 2025-01-04 10:39:44 +01:00 committed by GitHub
commit 9f42ef62d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -95,8 +95,17 @@ public:
result = atrac3_decode_frame(at3Ctx_, buffers_, &nb_samples, inbuf, inbytes);
}
if (result < 0) {
// NOTE: Here, to recover from single bad packets, we update inBytesConsumed/outSamples with the regular packet size.
// Otherwise we might try to decode the same packet over and over.
// This is seen in some unofficial game mods, mainly.
if (inbytesConsumed) {
*inbytesConsumed = inbytes;
}
if (outSamples) {
*outSamples = 0;
if (*outSamples != 0) {
nb_samples = std::min(*outSamples, nb_samples);
}
*outSamples = nb_samples;
}
return false;
}

View file

@ -755,13 +755,14 @@ int atrac3_decode_frame(ATRAC3Context *ctx, float *out_data[2], int *nb_samples,
databuf = buf;
}
*nb_samples = SAMPLES_PER_FRAME;
ret = decode_frame(ctx, block_align, channels, databuf, out_data);
if (ret) {
av_log(AV_LOG_ERROR, "Frame decoding error!");
return ret;
}
*nb_samples = SAMPLES_PER_FRAME;
return block_align;
}