[FFmpeg-cvslog] avformat/mpegts: Detect changes in packet through CRC instead of just the 5bit version
Michael Niedermayer
git at videolan.org
Tue May 19 21:06:47 CEST 2015
ffmpeg | branch: release/2.4 | Michael Niedermayer <michaelni at gmx.at> | Fri May 1 02:14:14 2015 +0200| [8f3787d068c14ac2988a098de21118d122504498] | committer: Michael Niedermayer
avformat/mpegts: Detect changes in packet through CRC instead of just the 5bit version
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit e0153145f6f8f3aa813652980862bafc8fd9b5c9)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f3787d068c14ac2988a098de21118d122504498
---
libavformat/mpegts.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8f03500..af5db08 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -76,6 +76,8 @@ typedef struct MpegTSSectionFilter {
int section_index;
int section_h_size;
int last_ver;
+ unsigned crc;
+ unsigned last_crc;
uint8_t *section_buf;
unsigned int check_crc : 1;
unsigned int end_of_section_reached : 1;
@@ -409,6 +411,9 @@ static void write_section_data(MpegTSContext *ts, MpegTSFilter *tss1,
if (tss->check_crc) {
crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);
+ if (tss->section_h_size >= 4)
+ tss->crc = AV_RB32(tss->section_buf + tss->section_h_size - 4);
+
if (crc_valid) {
ts->crc_validity[ tss1->pid ] = 100;
}else if (ts->crc_validity[ tss1->pid ] > -10) {
@@ -573,10 +578,11 @@ typedef struct SectionHeader {
static int skip_identical(const SectionHeader *h, MpegTSSectionFilter *tssf)
{
- if (h->version == tssf->last_ver)
+ if (h->version == tssf->last_ver && tssf->last_crc == tssf->crc)
return 1;
tssf->last_ver = h->version;
+ tssf->last_crc = tssf->crc;
return 0;
}
More information about the ffmpeg-cvslog
mailing list