diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-01-14 01:21:45 +0300 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-01-14 01:21:45 +0300 |
commit | 01d6bd525ac964af338c05169f4de473d29ec160 (patch) | |
tree | e7454683be52c0fa283272caadcc8a409e2667bb /libavformat | |
parent | 6f284d197ca8b7a89ce8766b6e9b3cf6cb7513bf (diff) |
Do not split audio frames accross pes packets.
This was not supported by some equipment and cisco analyzer.
Originally committed as revision 21203 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mpegtsenc.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 148507f5f6..be30e68a84 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -775,7 +775,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) { AVStream *st = s->streams[pkt->stream_index]; - int len, size = pkt->size; + int size = pkt->size; uint8_t *buf= pkt->data; uint8_t *data= NULL; MpegTSWriteStream *ts_st = st->priv_data; @@ -818,29 +818,20 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } - if (ts_st->payload_pts == AV_NOPTS_VALUE) { - ts_st->payload_dts = dts; - ts_st->payload_pts = pts; + if (ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) { + mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, + ts_st->payload_pts, ts_st->payload_dts); + ts_st->payload_index = 0; } - // audio - while (size > 0) { - len = DEFAULT_PES_PAYLOAD_SIZE - ts_st->payload_index; - if (len > size) - len = size; - memcpy(ts_st->payload + ts_st->payload_index, buf, len); - buf += len; - size -= len; - ts_st->payload_index += len; - if (ts_st->payload_index >= DEFAULT_PES_PAYLOAD_SIZE) { - mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, - ts_st->payload_pts, ts_st->payload_dts); - ts_st->payload_pts = AV_NOPTS_VALUE; - ts_st->payload_dts = AV_NOPTS_VALUE; - ts_st->payload_index = 0; - } + if (!ts_st->payload_index) { + ts_st->payload_pts = pts; + ts_st->payload_dts = dts; } + memcpy(ts_st->payload + ts_st->payload_index, buf, size); + ts_st->payload_index += size; + return 0; } |