From: John Coiner <jpcoiner@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: John Coiner <jcoiner@google.com>
Subject: [FFmpeg-devel] [PATCH] libavformat/mpegtsenc.c -- correctly re-emit extradata ahead of IDR pictures
Date: Fri, 27 Jan 2023 16:18:41 -0500
Message-ID: <20230127211841.59628-1-jpcoiner@gmail.com> (raw)
From: John Coiner <jcoiner@google.com>
This is the proposed fix for https://trac.ffmpeg.org/ticket/10148
Very sorry to send the same patch 3 times; this time with `git send-email' so it should be legal :)
---
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/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1886,17 +1886,21 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
if (extradd && AV_RB24(st->codecpar->extradata) > 1)
extradd = 0;
- do {
+ while (p < buf_end
+ && extradd > 0
+ && (state & 0x1f) != 5 // IDR picture
+ && (state & 0x1f) != 1 // non-IDR picture
+ ) {
p = avpriv_find_start_code(p, buf_end, &state);
av_log(s, AV_LOG_TRACE, "nal %"PRId32"\n", state & 0x1f);
- if ((state & 0x1f) == 7)
+ if ((state & 0x1f) == 7) // SPS NAL
extradd = 0;
- } while (p < buf_end && (state & 0x1f) != 9 &&
- (state & 0x1f) != 5 && (state & 0x1f) != 1);
-
- if ((state & 0x1f) != 5)
+ }
+ if ((state & 0x1f) != 5) {
+ // Not an IDR picture
extradd = 0;
- if ((state & 0x1f) != 9) { // AUD NAL
+ }
+ if (extradd > 0) {
data = av_malloc(pkt->size + 6 + extradd);
if (!data)
return AVERROR(ENOMEM);
--
2.39.1.456.gfc5497dd1b-goog
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-01-27 21:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 21:18 John Coiner [this message]
2023-01-29 12:30 ` Marton Balint
-- strict thread matches above, loose matches on Subject: below --
2023-01-31 12:45 John Coiner
2023-02-05 23:33 ` Marton Balint
2023-02-11 16:38 ` John Coiner
2023-01-30 15:13 John Coiner
2023-01-30 17:36 ` John Coiner
2023-01-30 21:12 ` Marton Balint
2023-02-02 17:43 ` John Coiner
2023-01-26 19:16 John Coiner
2023-01-26 18:43 John Coiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230127211841.59628-1-jpcoiner@gmail.com \
--to=jpcoiner@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=jcoiner@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git