Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ross <pross@xvid.org>2014-03-30 05:41:01 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-03-30 18:36:22 +0400
commite61973db6c0111f39f945337aba6174f1ee5e6ba (patch)
tree6ee9010bafe24bfa66dad6aa88d4596a44859ea3 /libavformat/mpegtsenc.c
parent7aa3979b8c2068ae3a352ecb5a92168aca311932 (diff)
avformat/mpegtsenc: move startcode validity check to ff_check_h264_startcode
Signed-off-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mpegtsenc.c')
-rw-r--r--libavformat/mpegtsenc.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 09d1b9e6c6..d24baa4ebc 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1162,6 +1162,19 @@ 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)
+{
+ if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
+ if (!st->nb_frames) {
+ av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
+ "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
+ return AVERROR(EINVAL);
+ }
+ av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
+ }
+ return 0;
+}
+
static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
@@ -1201,15 +1214,9 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
if (st->codec->codec_id == AV_CODEC_ID_H264) {
const uint8_t *p = buf, *buf_end = p+size;
uint32_t state = -1;
-
- if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
- if (!st->nb_frames) {
- av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
- "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
- return AVERROR(EINVAL);
- }
- av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
- }
+ int ret = ff_check_h264_startcode(s, st, pkt);
+ if (ret < 0)
+ return ret;
do {
p = avpriv_find_start_code(p, buf_end, &state);