From: Nuo Mi <nuomi2021@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Nuo Mi <nuomi2021@gmail.com>
Subject: [FFmpeg-devel] [PATCH v5 3/6] avformat/mpegtsenc: refact, move h264, hevc startcode checking to check_h26x_startcode
Date: Tue, 30 Jan 2024 20:49:00 +0800
Message-ID: <TYSPR06MB6433AD81894E03FC0D668138AA7D2@TYSPR06MB6433.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <20240130124903.16892-1-nuomi2021@gmail.com>
---
libavformat/mpegtsenc.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 4e5c264d2a..5e089f2866 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1759,16 +1759,16 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
ts_st->prev_payload_key = key;
}
-int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
+static int check_h26x_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt, const char *codec)
{
if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001 && AV_RB24(pkt->data) != 0x000001) {
if (!st->nb_frames) {
- av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
- "no startcode found, use the video bitstream filter 'h264_mp4toannexb' to fix it "
- "('-bsf:v h264_mp4toannexb' option with ffmpeg)\n");
+ av_log(s, AV_LOG_ERROR, "%s bitstream malformed, "
+ "no startcode found, use the video bitstream filter '%s_mp4toannexb' to fix it "
+ "('-bsf:v %s_mp4toannexb' option with ffmpeg)\n", codec, codec, codec);
return AVERROR_INVALIDDATA;
}
- av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing, size %d", pkt->size);
+ av_log(s, AV_LOG_WARNING, "%s bitstream error, startcode missing, size %d", codec, pkt->size);
if (pkt->size)
av_log(s, AV_LOG_WARNING, " data %08"PRIX32, AV_RB32(pkt->data));
av_log(s, AV_LOG_WARNING, "\n");
@@ -1776,19 +1776,9 @@ int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPack
return 0;
}
-static int check_hevc_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
+int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
{
- if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001 && AV_RB24(pkt->data) != 0x000001) {
- if (!st->nb_frames) {
- av_log(s, AV_LOG_ERROR, "HEVC bitstream malformed, no startcode found\n");
- return AVERROR_PATCHWELCOME;
- }
- av_log(s, AV_LOG_WARNING, "HEVC bitstream error, startcode missing, size %d", pkt->size);
- if (pkt->size)
- av_log(s, AV_LOG_WARNING, " data %08"PRIX32, AV_RB32(pkt->data));
- av_log(s, AV_LOG_WARNING, "\n");
- }
- return 0;
+ return check_h26x_startcode(s, st, pkt, "h264");
}
/* Based on GStreamer's gst-plugins-base/ext/ogg/gstoggstream.c
@@ -1985,7 +1975,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
const uint8_t *p = buf, *buf_end = p + size;
uint32_t state = -1;
int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codecpar->extradata_size : 0;
- int ret = check_hevc_startcode(s, st, pkt);
+ int ret = check_h26x_startcode(s, st, pkt, "hevc");
if (ret < 0)
return ret;
--
2.25.1
_______________________________________________
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 prev parent reply other threads:[~2024-01-30 12:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240130124903.16892-1-nuomi2021@gmail.com>
2024-01-30 12:48 ` [FFmpeg-devel] [PATCH v5 1/6] avformat/mp4: add muxer support for H266/VVC Nuo Mi
2024-01-30 12:48 ` [FFmpeg-devel] [PATCH v5 2/6] avformat/mpegtsenc: refact mpegts_check_bitstream to loop up table Nuo Mi
2024-01-30 12:49 ` Nuo Mi [this message]
2024-01-30 12:49 ` [FFmpeg-devel] [PATCH v5 4/6] avformat/mpegtsenc: refact, remove h264, hevc magic numbers for nal_type Nuo Mi
2024-01-30 12:49 ` [FFmpeg-devel] [PATCH v5 5/6] avformat/mpegtsenc: refact out h26x_prefix_aud Nuo Mi
2024-01-30 12:49 ` [FFmpeg-devel] [PATCH v5 6/6] avformat/mpegts: add ts stream types for H266/VVC Nuo Mi
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=TYSPR06MB6433AD81894E03FC0D668138AA7D2@TYSPR06MB6433.apcprd06.prod.outlook.com \
--to=nuomi2021@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/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