[FFmpeg-devel] [PATCH] avpacket: do not copy data when buf ref is available.
Clément Bœsch
ubitux at gmail.com
Tue Mar 12 08:22:26 CET 2013
On Tue, Mar 12, 2013 at 08:13:38AM +0100, Clément Bœsch wrote:
> This at least fixes issues with lavf/subtitles.
> ---
> libavcodec/avpacket.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
Functionally identical, but simpler.
--
Clément B.
-------------- next part --------------
From 312fd3c73d83f4cb10b9e7de7e7b4ea45c3c0b72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Tue, 12 Mar 2013 08:13:21 +0100
Subject: [PATCH] avpacket: do not copy data when buf ref is available.
This at least fixes issues with lavf/subtitles.
---
libavcodec/avpacket.c | 11 +++++++++--
1 file 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);
}
--
1.8.1.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130312/0e1d3efd/attachment.asc>
More information about the ffmpeg-devel
mailing list