zero-copy pipelines in gstreamer · “two elements are doing zero-copy when the data produced by...

Post on 27-Jan-2020

6 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Open FirstOpen First

Zero-Copy Pipelines in GStreamer by Nicolas DufresneIRC: ndufresneEmail: nicolas.dufresne@collabora.com

● What does zero-copy mean ?● Why do we copy ?● What are the side effects ?

GStreamer Conference 2017 2

Overview

What does zero-copy mean?

GStreamer Conference 2017 3

“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

GStreamer Conference 2017 5

GStreamer Mechanisms Allocation

Query

BufferPools and / or

Allocators

Refcounted Buffers and Memories

Memory Logical

Grouping

Caps Features

(Since 1.2)

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

Why do we copy ?

GStreamer Conference 2017 7

GStreamer Conference 2017 8

Allocation Type

Virtual Memory

Contiguous

Scatter Gather

GPUMemory

GStreamer Conference 2017 9

Abstractions leads to trial and error

...GEM

Surface DMA-Buf

GStreamer Conference 2017 10

Video AlignmentY Plane

Y Plane

U Plane

Stride

Width

Offse

t

Height

GStreamer Conference 2017 11

Audio CopiesUnified Channel

Order

Format and Sampling

Conversion

Ring Buffers with Threads

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;};

GStreamer Conference 2017 13

Why should I copy ?

To help with transitions

To Support Software Elements

To help testing

What are the side effects ?

GStreamer Conference 2017 14

GStreamer Conference 2017 15

Pooling

Source

Encoder

Tee Display

Transmitter

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!)

What do we gain ?

Higher Performance

More CPU Time

Lower Processing

Latency

Questions

GStreamer Conference 2017

Thank you!

top related