Ticket #10148: 0001-Proposed-fix-for-https-trac.ffmpeg.org-ticket-10148.patch

File 0001-Proposed-fix-for-https-trac.ffmpeg.org-ticket-10148.patch, 1.6 KB (added by John Coiner, 4 years ago)

Proposed patch

  • libavformat/mpegtsenc.c

    From 09c4bbd3d4ef6fbcb1558fce5cff4d15d7839526 Mon Sep 17 00:00:00 2001
    From: John Coiner <jcoiner@google.com>
    Date: Thu, 26 Jan 2023 13:34:24 -0500
    Subject: [PATCH] Proposed fix for https://trac.ffmpeg.org/ticket/10148
    
    ---
     libavformat/mpegtsenc.c | 18 +++++++++++-------
     1 file changed, 11 insertions(+), 7 deletions(-)
    
    diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
    index 48d39e6a7d..6cb398f99c 100644
    a b static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)  
    18861886        if (extradd && AV_RB24(st->codecpar->extradata) > 1)
    18871887            extradd = 0;
    18881888
    1889         do {
     1889        while (p < buf_end
     1890               && extradd > 0
     1891               && (state & 0x1f) != 5  // IDR picture
     1892               && (state & 0x1f) != 1  // non-IDR picture
     1893               ) {
    18901894            p = avpriv_find_start_code(p, buf_end, &state);
    18911895            av_log(s, AV_LOG_TRACE, "nal %"PRId32"\n", state & 0x1f);
    1892             if ((state & 0x1f) == 7)
     1896            if ((state & 0x1f) == 7)  // SPS NAL
    18931897                extradd = 0;
    1894         } while (p < buf_end && (state & 0x1f) != 9 &&
    1895                  (state & 0x1f) != 5 && (state & 0x1f) != 1);
    1896 
    1897         if ((state & 0x1f) != 5)
     1898        }
     1899        if ((state & 0x1f) != 5) {
     1900            // Not an IDR picture
    18981901            extradd = 0;
    1899         if ((state & 0x1f) != 9) { // AUD NAL
     1902        }
     1903        if (extradd > 0) {
    19001904            data = av_malloc(pkt->size + 6 + extradd);
    19011905            if (!data)
    19021906                return AVERROR(ENOMEM);