[FFmpeg-cvslog] mpegts: fuzzy crc check for not so spec compliant files
Michael Niedermayer
git at videolan.org
Mon Oct 8 05:32:35 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Oct 8 05:25:27 2012 +0200| [f464b02d2214009344c2b5975e3ca2feb3c3ba38] | committer: Michael Niedermayer
mpegts: fuzzy crc check for not so spec compliant files
Fixes Ticket598
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f464b02d2214009344c2b5975e3ca2feb3c3ba38
---
libavformat/mpegts.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index aed3cea..33a0eaf 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -123,6 +123,7 @@ struct MpegTSContext {
unsigned int nb_prg;
struct Program *prg;
+ int8_t crc_validity[NB_PID_MAX];
/** filters for various streams specified by PMT + for the PAT and PMT */
MpegTSFilter *pids[NB_PID_MAX];
@@ -277,6 +278,7 @@ static int discard_pid(MpegTSContext *ts, unsigned int pid)
static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
{
+ MpegTSContext *ts = s->priv_data;
MpegTSSectionFilter *tss = &tss1->u.section_filter;
int len;
@@ -304,10 +306,19 @@ static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
}
if (tss->section_h_size != -1 && tss->section_index >= tss->section_h_size) {
+ int crc_valid = 1;
tss->end_of_section_reached = 1;
- if (!tss->check_crc ||
- av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1,
- tss->section_buf, tss->section_h_size) == 0)
+
+ 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 (crc_valid){
+ ts->crc_validity[ tss1->pid ] = 100;
+ }else if(ts->crc_validity[ tss1->pid ] > -10){
+ ts->crc_validity[ tss1->pid ]--;
+ }else
+ crc_valid = 2;
+ }
+ if (crc_valid)
tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
}
}
More information about the ffmpeg-cvslog
mailing list