summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2013-03-12 08:13:21 +0100
committerClément Bœsch <ubitux@gmail.com>2013-03-13 01:30:20 +0100
commit02a6b06d9ea0009f058b0f43c98f640f63f1359a (patch)
tree82f24479614103567ba1542d1790934c6adcc9d6
parentb94df21a5164c7f1591935deccc13f85d8c43717 (diff)
downloadffmpeg-streaming-02a6b06d9ea0009f058b0f43c98f640f63f1359a.zip
ffmpeg-streaming-02a6b06d9ea0009f058b0f43c98f640f63f1359a.tar.gz
avpacket: do not copy data when buf ref is available.
This at least fixes issues with lavf/subtitles. The behaviour of av_dup_packet() is unchanged, only av_copy_packet() is affected.
-rw-r--r--libavcodec/avpacket.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 16496e2..651036e 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -184,7 +184,15 @@ static int copy_packet_data(AVPacket *pkt, AVPacket *src)
{
pkt->data = NULL;
pkt->side_data = NULL;
- DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
+ if (pkt->buf) {
+ AVBufferRef *ref = av_buffer_ref(src->buf);
+ if (!ref)
+ return AVERROR(ENOMEM);
+ pkt->buf = ref;
+ pkt->data = ref->data;
+ } else {
+ DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
+ }
#if FF_API_DESTRUCT_PACKET
pkt->destruct = dummy_destruct_packet;
#endif
@@ -228,7 +236,6 @@ int av_dup_packet(AVPacket *pkt)
int av_copy_packet(AVPacket *dst, AVPacket *src)
{
*dst = *src;
- dst->buf = av_buffer_ref(src->buf);
return copy_packet_data(dst, src);
}
OpenPOWER on IntegriCloud