aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorLuca Abeni <lucabe72@email.it>2009-01-15 14:03:07 +0000
committerLuca Abeni <lucabe72@email.it>2009-01-15 14:03:07 +0000
commit0a63a676ec5cc1e69768024df51ffca6a5cfbd08 (patch)
tree31b233b41814ec0604ebe429448fab5812c53fd8 /libavformat/matroskaenc.c
parent2ea512a6c2ff3404563ad364a3e806a8630cdc84 (diff)
downloadffmpeg-0a63a676ec5cc1e69768024df51ffca6a5cfbd08.tar.gz
Do not reallocate AVPacket's data when muxing a packet
Originally committed as revision 16616 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 44c23a4057..83881ed1be 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -785,6 +785,7 @@ static void mkv_write_block(AVFormatContext *s, unsigned int blockid, AVPacket *
{
MatroskaMuxContext *mkv = s->priv_data;
ByteIOContext *pb = s->pb;
+ AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, "
"pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n",
@@ -794,7 +795,14 @@ static void mkv_write_block(AVFormatContext *s, unsigned int blockid, AVPacket *
put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
put_be16(pb, pkt->pts - mkv->cluster_pts);
put_byte(pb, flags);
+ if (codec->codec_id == CODEC_ID_H264 &&
+ codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) {
+ /* from x264 or from bytestream h264 */
+ /* nal reformating needed */
+ ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
+ } else {
put_buffer(pb, pkt->data, pkt->size);
+ }
}
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
@@ -822,16 +830,6 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
av_md5_update(mkv->md5_ctx, pkt->data, FFMIN(200, pkt->size));
}
- if (codec->codec_id == CODEC_ID_H264 &&
- codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) {
- /* from x264 or from bytestream h264 */
- /* nal reformating needed */
- int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
- if (ret < 0)
- return ret;
- assert(pkt->size);
- }
-
if (codec->codec_type != CODEC_TYPE_SUBTITLE) {
mkv_write_block(s, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7);
} else if (codec->codec_id == CODEC_ID_SSA) {