Commit 9dfa93db84 for ffmpeg
commit 9dfa93db8417545d61747394cd99f63e0e4d8e50
Author: romainhedouin <romain.hedouin@epitech.eu>
Date: Wed Oct 14 21:07:20 2026 +0200
avformat/mpegts: read the PID at the sync byte in analyze()
The PID was read from buf + 1, i.e. always from the first packet,
while the adaptation field control on the next line is read at the
current sync byte (buf + i). The null-packet check in probe mode thus
used the wrong packet.
Tested: make fate passes. Probing all 2569 files of the FATE suite
gives the same detected format and score before and after.
Signed-off-by: romainhedouin <romain.hedouin@epitech.eu>
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8c7df85173..6e252e63fc 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -621,7 +621,7 @@ static int analyze(const uint8_t *buf, int size, int packet_size,
for (i = 0; i < size - 3; i++) {
if (buf[i] == SYNC_BYTE) {
- int pid = AV_RB16(buf+1) & 0x1FFF;
+ int pid = AV_RB16(buf + i + 1) & 0x1FFF;
int asc = buf[i + 3] & 0x30;
if (!probe || pid == 0x1FFF || asc) {
int x = i % packet_size;