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

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

Proposed patch, as plain text

Line 
1From 09c4bbd3d4ef6fbcb1558fce5cff4d15d7839526 Mon Sep 17 00:00:00 2001
2From: John Coiner <jcoiner@google.com>
3Date: Thu, 26 Jan 2023 13:34:24 -0500
4Subject: [PATCH] Proposed fix for https://trac.ffmpeg.org/ticket/10148
5
6---
7 libavformat/mpegtsenc.c | 18 +++++++++++-------
8 1 file changed, 11 insertions(+), 7 deletions(-)
9
10diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
11index 48d39e6a7d..6cb398f99c 100644
12--- a/libavformat/mpegtsenc.c
13+++ b/libavformat/mpegtsenc.c
14@@ -1886,17 +1886,21 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
15 if (extradd && AV_RB24(st->codecpar->extradata) > 1)
16 extradd = 0;
17
18- do {
19+ while (p < buf_end
20+ && extradd > 0
21+ && (state & 0x1f) != 5 // IDR picture
22+ && (state & 0x1f) != 1 // non-IDR picture
23+ ) {
24 p = avpriv_find_start_code(p, buf_end, &state);
25 av_log(s, AV_LOG_TRACE, "nal %"PRId32"\n", state & 0x1f);
26- if ((state & 0x1f) == 7)
27+ if ((state & 0x1f) == 7) // SPS NAL
28 extradd = 0;
29- } while (p < buf_end && (state & 0x1f) != 9 &&
30- (state & 0x1f) != 5 && (state & 0x1f) != 1);
31-
32- if ((state & 0x1f) != 5)
33+ }
34+ if ((state & 0x1f) != 5) {
35+ // Not an IDR picture
36 extradd = 0;
37- if ((state & 0x1f) != 9) { // AUD NAL
38+ }
39+ if (extradd > 0) {
40 data = av_malloc(pkt->size + 6 + extradd);
41 if (!data)
42 return AVERROR(ENOMEM);
43--
442.39.1.456.gfc5497dd1b-goog
45