diff options
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 10 | ||||
-rw-r--r-- | libavformat/mux.c | 17 |
2 files changed, 8 insertions, 19 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index b41888f335..10cf0a034b 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1945,15 +1945,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) // buffer an audio packet to ensure the packet containing the video // keyframe's timecode is contained in the same cluster for WebM if (codec_type == AVMEDIA_TYPE_AUDIO) { - mkv->cur_audio_pkt = *pkt; - 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); - if (mkv->cur_audio_pkt.side_data_elems > 0) { - ret = av_copy_packet_side_data(&mkv->cur_audio_pkt, &mkv->cur_audio_pkt); - } + ret = av_packet_ref(&mkv->cur_audio_pkt, pkt); } else ret = mkv_write_packet_internal(s, pkt, 0); return ret; diff --git a/libavformat/mux.c b/libavformat/mux.c index b2d843bc38..bf7a47296c 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -740,19 +740,14 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, this_pktl = av_mallocz(sizeof(AVPacketList)); if (!this_pktl) return AVERROR(ENOMEM); - this_pktl->pkt = *pkt; - pkt->buf = NULL; - pkt->side_data = NULL; - pkt->side_data_elems = 0; if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) { av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE); av_assert0(((AVFrame *)pkt->data)->buf); - } else { - // Duplicate the packet if it uses non-allocated memory - if ((ret = av_dup_packet(&this_pktl->pkt)) < 0) { - av_free(this_pktl); - return ret; - } + } + + if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) { + av_free(this_pktl); + return ret; } if (s->streams[pkt->stream_index]->last_in_packet_buffer) { @@ -803,6 +798,8 @@ next_non_null: s->streams[pkt->stream_index]->last_in_packet_buffer = *next_point = this_pktl; + av_packet_unref(pkt); + return 0; } |