diff mbox

[FFmpeg-devel,1/2] avdevice/decklink_dec: do not copy video data

Message ID 20180422211822.12870-1-cus@passwd.hu
State Accepted
Commit 75d1529c6e9069b240bf6471d64e5bc81e0b9013
Headers show

Commit Message

Marton Balint April 22, 2018, 9:18 p.m. UTC
Create a buffer from the data instead and use the buffer destructor to free the
DeckLink frame. This avoids a memcpy of the frame data.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavdevice/decklink_dec.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Marton Balint April 30, 2018, 9:16 p.m. UTC | #1
On Sun, 22 Apr 2018, Marton Balint wrote:

> Create a buffer from the data instead and use the buffer destructor to free the
> DeckLink frame. This avoids a memcpy of the frame data.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavdevice/decklink_dec.cpp | 12 ++++++++++++
> 1 file changed, 12 insertions(+)

Pushed the series.

Regards,
Marton
diff mbox

Patch

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index e97a4402ea..10535dc388 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -98,6 +98,14 @@  static VANCLineNumber vanc_line_numbers[] = {
     {bmdModeUnknown, 0, -1, -1, -1}
 };
 
+extern "C" {
+static void decklink_object_free(void *opaque, uint8_t *data)
+{
+    IUnknown *obj = (class IUnknown *)opaque;
+    obj->Release();
+}
+}
+
 static int get_vanc_line_idx(BMDDisplayMode mode)
 {
     unsigned int i;
@@ -797,6 +805,10 @@  HRESULT decklink_input_callback::VideoInputFrameArrived(
             }
         }
 
+        pkt.buf = av_buffer_create(pkt.data, pkt.size, decklink_object_free, videoFrame, 0);
+        if (pkt.buf)
+            videoFrame->AddRef();
+
         if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
             ++ctx->dropped;
         }