matroskaenc: restore compatibility with non referenced AVPacket
authorRafaël Carré <funman@videolan.org>
Sun, 23 Jun 2013 21:00:33 +0000 (23:00 +0200)
committerAnton Khirnov <anton@khirnov.net>
Mon, 24 Jun 2013 06:03:26 +0000 (08:03 +0200)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavformat/matroskaenc.c

index 9f7b5f9..67d2350 100644 (file)
@@ -1298,8 +1298,11 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
     // keyframe's timecode is contained in the same cluster for WebM
     if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
         mkv->cur_audio_pkt = *pkt;
-        mkv->cur_audio_pkt.buf = av_buffer_ref(pkt->buf);
-        ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM);
+        if (pkt->buf) {
+            mkv->cur_audio_pkt.buf = av_buffer_ref(pkt->buf);
+            ret = mkv->cur_audio_pkt.buf ? 0 : AVERROR(ENOMEM);
+        } else
+            ret = av_dup_packet(&mkv->cur_audio_pkt);
     } else
         ret = mkv_write_packet_internal(s, pkt);
     return ret;