|
|
@ -179,7 +179,7 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, int id, |
|
|
|
tot_len = 3 + 5 + len + 4; |
|
|
|
tot_len = 3 + 5 + len + 4; |
|
|
|
/* check if not too big */ |
|
|
|
/* check if not too big */ |
|
|
|
if (tot_len > 1024) |
|
|
|
if (tot_len > 1024) |
|
|
|
return -1; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
|
|
|
|
|
|
|
q = section; |
|
|
|
q = section; |
|
|
|
*q++ = tid; |
|
|
|
*q++ = tid; |
|
|
@ -651,7 +651,7 @@ static int mpegts_write_header(AVFormatContext *s) |
|
|
|
} |
|
|
|
} |
|
|
|
av_freep(&st->priv_data); |
|
|
|
av_freep(&st->priv_data); |
|
|
|
} |
|
|
|
} |
|
|
|
return -1; |
|
|
|
return AVERROR(EINVAL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* send SDT, PAT and PMT tables regulary */ |
|
|
|
/* send SDT, PAT and PMT tables regulary */ |
|
|
@ -986,7 +986,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
|
|
|
|
|
|
|
|
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) { |
|
|
|
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) { |
|
|
|
av_log(s, AV_LOG_ERROR, "first pts value must set\n"); |
|
|
|
av_log(s, AV_LOG_ERROR, "first pts value must set\n"); |
|
|
|
return -1; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
} |
|
|
|
} |
|
|
|
ts_st->first_pts_check = 0; |
|
|
|
ts_st->first_pts_check = 0; |
|
|
|
|
|
|
|
|
|
|
@ -997,7 +997,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { |
|
|
|
if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { |
|
|
|
av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, " |
|
|
|
av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, " |
|
|
|
"no startcode found, use -vbsf h264_mp4toannexb\n"); |
|
|
|
"no startcode found, use -vbsf h264_mp4toannexb\n"); |
|
|
|
return -1; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
do { |
|
|
@ -1009,7 +1009,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
if ((state & 0x1f) != 9) { // AUD NAL
|
|
|
|
if ((state & 0x1f) != 9) { // AUD NAL
|
|
|
|
data = av_malloc(pkt->size+6); |
|
|
|
data = av_malloc(pkt->size+6); |
|
|
|
if (!data) |
|
|
|
if (!data) |
|
|
|
return -1; |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
memcpy(data+6, pkt->data, pkt->size); |
|
|
|
memcpy(data+6, pkt->data, pkt->size); |
|
|
|
AV_WB32(data, 0x00000001); |
|
|
|
AV_WB32(data, 0x00000001); |
|
|
|
data[4] = 0x09; |
|
|
|
data[4] = 0x09; |
|
|
@ -1019,18 +1019,18 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (st->codec->codec_id == CODEC_ID_AAC) { |
|
|
|
} else if (st->codec->codec_id == CODEC_ID_AAC) { |
|
|
|
if (pkt->size < 2) |
|
|
|
if (pkt->size < 2) |
|
|
|
return -1; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) { |
|
|
|
if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) { |
|
|
|
ADTSContext *adts = ts_st->adts; |
|
|
|
ADTSContext *adts = ts_st->adts; |
|
|
|
int new_size, err; |
|
|
|
int new_size, err; |
|
|
|
if (!adts) { |
|
|
|
if (!adts) { |
|
|
|
av_log(s, AV_LOG_ERROR, "aac bitstream not in adts format " |
|
|
|
av_log(s, AV_LOG_ERROR, "aac bitstream not in adts format " |
|
|
|
"and extradata missing\n"); |
|
|
|
"and extradata missing\n"); |
|
|
|
return -1; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
} |
|
|
|
} |
|
|
|
new_size = ADTS_HEADER_SIZE+adts->pce_size+pkt->size; |
|
|
|
new_size = ADTS_HEADER_SIZE+adts->pce_size+pkt->size; |
|
|
|
if ((unsigned)new_size >= INT_MAX) |
|
|
|
if ((unsigned)new_size >= INT_MAX) |
|
|
|
return -1; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
data = av_malloc(new_size); |
|
|
|
data = av_malloc(new_size); |
|
|
|
if (!data) |
|
|
|
if (!data) |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|