zero-copy pipelines in gstreamer · “two elements are doing zero-copy when the data produced by...
TRANSCRIPT
![Page 1: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/1.jpg)
Open FirstOpen First
Zero-Copy Pipelines in GStreamer by Nicolas DufresneIRC: ndufresneEmail: [email protected]
![Page 2: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/2.jpg)
● What does zero-copy mean ?● Why do we copy ?● What are the side effects ?
GStreamer Conference 2017 2
Overview
![Page 3: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/3.jpg)
What does zero-copy mean?
GStreamer Conference 2017 3
![Page 4: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/4.jpg)
“Two Elements are doing zero-copy when the data produced by one Element is used by the
other Element without requiring an idempotent transform.”
GStreamer Conference 2017 4
Definition
![Page 5: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/5.jpg)
GStreamer Conference 2017 5
GStreamer Mechanisms Allocation
Query
BufferPools and / or
Allocators
Refcounted Buffers and Memories
Memory Logical
Grouping
Caps Features
(Since 1.2)
![Page 6: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/6.jpg)
GStreamer Conference 2017 6
Upstream vs Downstream
Allocation
DownstreamUpstream
Queries the AllocationFills the Query
Decides Allocation
Queries the Caps
Decides Caps
Sends the Caps Event
Sends Buffers
![Page 7: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/7.jpg)
Why do we copy ?
GStreamer Conference 2017 7
![Page 8: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/8.jpg)
GStreamer Conference 2017 8
Allocation Type
Virtual Memory
Contiguous
Scatter Gather
GPUMemory
![Page 9: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/9.jpg)
GStreamer Conference 2017 9
Abstractions leads to trial and error
...GEM
Surface DMA-Buf
![Page 10: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/10.jpg)
GStreamer Conference 2017 10
Video AlignmentY Plane
Y Plane
U Plane
Stride
Width
Offse
t
Height
![Page 11: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/11.jpg)
GStreamer Conference 2017 11
Audio CopiesUnified Channel
Order
Format and Sampling
Conversion
Ring Buffers with Threads
![Page 12: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/12.jpg)
Ring Buffer Based Buffer Pools ?
GstFlowReturngst_buffer_pool_acquire_buffer (GstBufferPool *pool, GstBuffer **buffer, GstBufferPoolAcquireParams *params);
struct GstBufferPoolAcquireParams { GstFormat format; gint64 start; gint64 stop; GstBufferPoolAcquireFlags flags;};
![Page 13: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/13.jpg)
GStreamer Conference 2017 13
Why should I copy ?
To help with transitions
To Support Software Elements
To help testing
![Page 14: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/14.jpg)
What are the side effects ?
GStreamer Conference 2017 14
![Page 15: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/15.jpg)
GStreamer Conference 2017 15
Pooling
Source
Encoder
Tee Display
Transmitter
![Page 16: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/16.jpg)
GStreamer Conference 2017 16
BufferReclaiming
Required with V4L2 and OMX
DownstreamUpstream
Allocation or Drain QueryDrains and returns ref frames
orCopy and return ref frame
Mostly Needed for legacy APIs
Should not be needed
for DMABuf (it’s a bug!)
![Page 17: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/17.jpg)
What do we gain ?
Higher Performance
More CPU Time
Lower Processing
Latency
![Page 18: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/18.jpg)
Questions
![Page 19: Zero-Copy Pipelines in GStreamer · “Two Elements are doing zero-copy when the data produced by one Element is used by the other Element without requiring an idempotent transform.”](https://reader033.vdocuments.net/reader033/viewer/2022041704/5e4380a8166eec7c364f268d/html5/thumbnails/19.jpg)
GStreamer Conference 2017
Thank you!