diff options
author | Clément Bœsch <[email protected]> | 2012-12-03 23:13:53 +0100 |
---|---|---|
committer | Clément Bœsch <[email protected]> | 2012-12-20 16:13:52 +0100 |
commit | 0072116ccbf7637aeb4f3e0d65fd163ecb90f28e (patch) | |
tree | ac36967097c9e0a3c39fcf79e4911795ac748f61 | |
parent | 52f21763667c1fe88581f978304b18c67dbe1e0e (diff) |
lavf: split packets before muxing.
After demuxing, data and side are merged. Before decoding, they are
split. Encoder will perform with data and side split. This means that a
muxer can receive split data (after encoding) but also merged data (if
called directly after demuxing). This commit makes sure data and side
are split for the muxer.
-rw-r--r-- | libavformat/mux.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index 9bcee99ee2..c7e176abb3 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -484,13 +484,29 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt) return 0; } +/** + * Move side data from payload to internal struct, call muxer, and restore + * original packet. + */ +static inline int split_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + int ret; + AVPacket spkt = *pkt; + + av_packet_split_side_data(&spkt); + ret = s->oformat->write_packet(s, &spkt); + spkt.data = NULL; + av_destruct_packet(&spkt); + return ret; +} + int av_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret; if (!pkt) { if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { - ret = s->oformat->write_packet(s, pkt); + ret = s->oformat->write_packet(s, NULL); if (ret >= 0 && s->pb && s->pb->error < 0) ret = s->pb->error; return ret; @@ -503,7 +519,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) return ret; - ret = s->oformat->write_packet(s, pkt); + ret = split_write_packet(s, pkt); if (ret >= 0 && s->pb && s->pb->error < 0) ret = s->pb->error; @@ -733,7 +749,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) if (ret <= 0) //FIXME cleanup needed for ret<0 ? return ret; - ret = s->oformat->write_packet(s, &opkt); + ret = split_write_packet(s, &opkt); if (ret >= 0) s->streams[opkt.stream_index]->nb_frames++; @@ -759,7 +775,7 @@ int av_write_trailer(AVFormatContext *s) if (!ret) break; - ret = s->oformat->write_packet(s, &pkt); + ret = split_write_packet(s, &pkt); if (ret >= 0) s->streams[pkt.stream_index]->nb_frames++; |