--- libavcodec/siren.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index ccc69aaf40..31fb9346da 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -752,7 +752,34 @@ static int siren_decode(AVCodecContext *avctx, void *data,
frame_error = 1;
}
- skip_bits(gb, s->checksum_bits);
+ if (s->checksum_bits) {
+ static const uint16_t ChecksumTable[4] = {0x7F80, 0x7878, 0x6666,
0x5555};
+ int wpf, checksum, sum, calculated_checksum, temp1, temp2;
+
+ wpf = bits_per_frame / 16;
+
+ checksum = AV_RB16(avpkt->data + (wpf - 1) * 2) & ((1 <<
s->checksum_bits) - 1);
+
+ sum = 0;
+ for (int i = 0; i < wpf - 1; i++)
+ sum ^= AV_RB16(avpkt->data + i * 2) << (i % 15);
+ sum ^= (AV_RB16(avpkt->data + (wpf - 1) * 2) & ~checksum) << ((wpf -
1) % 15);
+ sum = (sum >> 15) ^ (sum & 0x7FFF);
+
+ calculated_checksum = 0;
+ for (int i = 0; i < 4; i++) {
+ temp1 = ChecksumTable[i] & sum;
+ for (int j = 8; j > 0; j >>= 1) {
+ temp2 = temp1 >> j;
+ temp1 ^= temp2;
+ }
+ calculated_checksum <<= 1;
+ calculated_checksum |= temp1 & 1;
+ }
+
+ if (checksum != calculated_checksum)
+ frame_error = 1;
+ }
if (frame_error) {
memcpy(s->imdct_in, s->backup_frame, number_of_valid_coefs *
sizeof(float));
--
2.33.0
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list [email protected] https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
