diff mbox

[FFmpeg-devel,2/2] ffmpeg: pass reference counted packets on codec copy when possible

Message ID 20180321150332.5244-2-jamrial@gmail.com
State Accepted
Commit 231a73308f183484317c3fdfe098f543cd401898
Headers show

Commit Message

James Almer March 21, 2018, 3:03 p.m. UTC
Should prevent unnecessary copy of data in cases where new references
to the packet are created within the muxer or a bitstream filter.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/ffmpeg.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer March 21, 2018, 11:08 p.m. UTC | #1
On Wed, Mar 21, 2018 at 12:03:32PM -0300, James Almer wrote:
> Should prevent unnecessary copy of data in cases where new references
> to the packet are created within the muxer or a bitstream filter.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  fftools/ffmpeg.c | 5 +++++
>  1 file changed, 5 insertions(+)

should be ok

thx

[...]
James Almer March 24, 2018, 1:12 a.m. UTC | #2
On 3/21/2018 8:08 PM, Michael Niedermayer wrote:
> On Wed, Mar 21, 2018 at 12:03:32PM -0300, James Almer wrote:
>> Should prevent unnecessary copy of data in cases where new references
>> to the packet are created within the muxer or a bitstream filter.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  fftools/ffmpeg.c | 5 +++++
>>  1 file changed, 5 insertions(+)
> 
> should be ok
> 
> thx

Patchset pushed. Thanks.
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ec9ce29097..1b2e37b8d8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2049,6 +2049,11 @@  static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
 
     opkt.flags    = pkt->flags;
 
+    if (pkt->buf) {
+        opkt.buf = av_buffer_ref(pkt->buf);
+        if (!opkt.buf)
+            exit_program(1);
+    }
     opkt.data = pkt->data;
     opkt.size = pkt->size;