Ticket #10794: 0001-ffmpeg-Dont-discard-PES-sections-split-across-a-TS-p.patch

File 0001-ffmpeg-Dont-discard-PES-sections-split-across-a-TS-p.patch, 2.7 KB (added by Lawrence Rust <lvr@…>, 7 years ago)
  • mythtv/external/FFmpeg/libavformat/mpegts.c

    From dec43fe2835d7fbf025429674f45dc45e24babab Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Fri, 1 Jun 2012 20:28:15 +0200
    Subject: [PATCH] ffmpeg: Dont discard PES sections split across a TS packet
    
    If a TS packet has a pointer field which marks the boundary of
    PES sections then the first section will be discarded if a
    second section is started by the remainder of the TS packet.
    
    This fix adds a check for a completed section and if prresent, appends
    the section data.
    
    This bug is most noticeable on the BBC MHEG text service which
    often will not start because the boot application or essential
    filles have missing blocks
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythtv/external/FFmpeg/libavformat/mpegts.c |    8 ++++++--
     1 files changed, 6 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/external/FFmpeg/libavformat/mpegts.c b/mythtv/external/FFmpeg/libavformat/mpegts.c
    index fb9b875..17fa15a 100644
    a b static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1, 
    343343                return;
    344344            tss->section_h_size = len;
    345345        }
    346 
    347346        if (tss->section_h_size == -1 ||
    348347            tss->section_index < tss->section_h_size)
    349348        {
    static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1, 
    365364            av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1,
    366365                   tss->section_buf, tss->section_h_size) == 0)
    367366            tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
     367        else
     368            av_log(s, AV_LOG_WARNING, "write_section_data: PID %#x CRC error\n", tss1->pid);
    368369
    369370        if (tss->section_index > tss->section_h_size) {
    370371            int left = tss->section_index - tss->section_h_size;
    static void mpegts_push_section(MpegTSFilter *filter, const uint8_t *section, in 
    633634        return;
    634635    }
    635636
    636     if (sect->new_packet && pkt && sect->st) {
     637    if (sect->new_packet && pkt && sect->st && pkt->size == 0) {
    637638        int pktLen = section_len + 184; /* Add enough for a complete TS payload. */
    638639        sect->new_packet = 0;
    639640        av_free_packet(pkt);
    static int handle_packet(MpegTSContext *ts, const uint8_t *packet) 
    21222123            /* pointer field present */
    21232124            len = *p++;
    21242125            if (p + len > p_end)
     2126            {
     2127                av_log(s, AV_LOG_WARNING, "handle_packet: Last section data too long on PID=%#x, %d\n", pid, cc);
    21252128                return 0;
     2129            }
    21262130            if (len && cc_ok) {
    21272131                /* write remaining section bytes */
    21282132                write_section_data(s, tss,