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.
This commit is contained in:
parent
b94df21a51
commit
02a6b06d9e
1 changed files with 9 additions and 2 deletions
|
@ -184,7 +184,15 @@ static int copy_packet_data(AVPacket *pkt, AVPacket *src)
|
||||||
{
|
{
|
||||||
pkt->data = NULL;
|
pkt->data = NULL;
|
||||||
pkt->side_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
|
#if FF_API_DESTRUCT_PACKET
|
||||||
pkt->destruct = dummy_destruct_packet;
|
pkt->destruct = dummy_destruct_packet;
|
||||||
#endif
|
#endif
|
||||||
|
@ -228,7 +236,6 @@ int av_dup_packet(AVPacket *pkt)
|
||||||
int av_copy_packet(AVPacket *dst, AVPacket *src)
|
int av_copy_packet(AVPacket *dst, AVPacket *src)
|
||||||
{
|
{
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
dst->buf = av_buffer_ref(src->buf);
|
|
||||||
return copy_packet_data(dst, src);
|
return copy_packet_data(dst, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue