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.
Showing the changes to libavdevice/decklink_dec.cpp (1 of 1 file). Show all
Unified · Split
| @@ -98,6 +98,14 @@ static VANCLineNumber vanc_line_numbers[] = { · 97 unmodified lines | ||
| 98 | 98 | {bmdModeUnknown, 0, -1, -1, -1} |
| 99 | 99 | }; |
| 100 | 100 | |
| 101 | +extern "C" { | |
| 102 | +static void decklink_object_free(void *opaque, uint8_t *data) | |
| 103 | +{ | |
| 104 | + IUnknown *obj = (class IUnknown *)opaque; | |
| 105 | + obj->Release(); | |
| 106 | +} | |
| 107 | +} | |
| 108 | + | |
| 101 | 109 | static int get_vanc_line_idx(BMDDisplayMode mode) |
| 102 | 110 | { |
| 103 | 111 | unsigned int i; |
| @@ -797,6 +805,10 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 693 unmodified lines | ||
| 797 | 805 | } |
| 798 | 806 | } |
| 799 | 807 | |
| 808 | + pkt.buf = av_buffer_create(pkt.data, pkt.size, decklink_object_free, videoFrame, 0); | |
| 809 | + if (pkt.buf) | |
| 810 | + videoFrame->AddRef(); | |
| 811 | + | |
| 800 | 812 | if (avpacket_queue_put(&ctx->queue, &pkt) < 0) { |
| 801 | 813 | ++ctx->dropped; |
| 802 | 814 | } |