from zero to zero-copy - amazon s3...zero-copy "zero-copy" describes computer operations...

19
From Zero to Zero-Copy Accelerating Your Embedded Media Player Lukas Rusak September 2018

Upload: others

Post on 09-Jul-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

From Zero to Zero-CopyAccelerating Your Embedded Media Player

Lukas RusakSeptember 2018

Page 2: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

whoamiLukas Rusak

Bachelors of Applied Science in Mechanical Engineering

Team Kodi Member

Team LibreELEC Member

LibreELEC Board Member

Okanagan Region of B.C.

[email protected]

Mission Hill Vineyard

Kelowna B.C and Okanagan

Lake

Page 3: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Agenda

● Introducing zero-copy● Current proprietary methods● Open source solutions● Video decoding pipeline● Rendering methods● Board specifics

Page 4: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Zero-copy

"Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another. [1]

● Embedded devices with minimal CPU power trying to run 4K HEVC video

● Critical for devices with limited memory bandwidth

● Available in proprietary and open source solutions

Page 5: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Current Proprietary Methods

● Raspberry Pi (broadcom) dispmanx○ libbcm_host

● i.MX6 Vivante○ Blob that does everything for windowing and rendering○ libvpuwrap for decoding

● Amlogic libamcodec○ Userspace library dependent of vendor BSP Kernel (3.14)

● Impossible to fix bugs● Locked to vendor kernels● No chance to update● Code maintenance for vendor specific methods

Page 6: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Open Source Solutions

● Video 4 Linux 2 (V4L2) Driver○ Access to onboard decoding capabilities○ Memory-to-Memory devices○ Codecs are hardware and driver dependent

● Direct Rendering Manager (DRM) Driver○ Only required if utilizing direct to plane rendering

● OpenGLES 2.0 and EGL○ Only required if utilizing EGL image import to OpenGLES○ EXT_image_dma_buf_import [2]○ OES_EGL_image_external [3]○ NV12 or YUYV or YU12 or similar YUV format support

Page 7: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Video Decoding Pipeline

● V4L2 interface directly using IOCTL’s● Gstreamer

○ dma-buf ready● FFmpeg

○ dma-buf patches under review

● Using Gstreamer or FFmpeg shifts video decoding out of your application

Decoded Frame

AVDRMFrameDescriptor

Compressed Frame

Decoder

fd

Page 8: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Direct to Plane RenderingPositives

● Embedded devices may support YUV formats directly

● Most performant (no empirical evidence)● No OpenGLES/EGL context required

○ Skips the GPU entirely● Video overlays are possible using DRM Planes● Very straight forward when using atomic DRM

Negatives

● Requires* in driver scaling capabilities● No OpenGLES capabilities (shaders)● More complex if using multiple planes

Video + GUI

GUI Only

Primary Overlay Cursor (DRM Planes)

Page 9: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

OpenGLES/EGL Image Import

Positives

● Shader support● Only one DRM Plane required

Negatives

● More expensive (requires EGL context and GLES operations)● Requires extensions that are less common

Page 10: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Mali Proprietary Blob

● Open source kernel module paired with closed source binary blob for OpenGLES

● Licensed from ARM● Bundled library containing either:

○ x11○ Wayland/GBM○ GBM

● Impossible to fix bugs● Lima and Panfrost open source efforts underway

Page 11: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Allwinner

● DRM Driver○ “sun4i”○ Supports scaling○ Supports overlays○ Supports NV12

● V4L2 Driver○ Patches pending (requires V4L2 request API)○ Supports NV12

● OpenGLES Driver○ “mali”○ Supports EGL import○ Supports NV12

Orange Pi PC

Page 12: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Amlogic

● DRM Driver○ “meson”○ Supports Scaling (WIP)○ Supports Overlays (WIP)○ Supports NV12○ Neil Armstrong <[email protected]>

● V4L2 Driver○ “Meson” (WIP)○ Supports NV12○ Supports HEVC, H264○ Maxime Jourdan <[email protected]>

● OpenGLES Driver○ “mali”○ Supports EGL import○ Supports NV12

Libre Computer Le Potato (S905)

Page 13: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Broadcom

● DRM Driver○ “vc4”○ Supports scaling○ Supports overlays○ Supports NV12 and YUV420

● V4L2 Driver○ “Bcm2835-v4l2-codec” (WIP)○ Supports NV12 and YUV420

● OpenGLES Driver○ “vc4” ○ No YUV import

Raspberry Pi 3B+

Page 14: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

NXP

● DRM Driver○ “imx” and “etnaviv”○ No scaling (available via a separate ip)○ Supports overlays○ Supports NV12

● V4L2 Driver○ “coda”○ Supports NV12

● OpenGLES Driver○ “etnaviv”○ Supports EGL import○ Supports NV12 (WIP)

■ Target mesa 18.3■ gc3000 good performance■ gc2000 ok performance

Solidrun Cubox i4-Pro (gc2000)

Page 15: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Qualcomm

● DRM Driver○ “msm”○ Supports scaling○ Supports overlays○ Supports NV12

● V4L2 Driver○ “venus”○ Supports NV12

● OpenGLES Driver○ “freedreno”○ Supports EGL import○ Supports NV12

Dragonboard 410c

Page 16: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Others

HiSilicon

MediaTek

Renesas

Rockchip

Asus Tinkerboard S (RK3288)

Renesas R-Car

Page 17: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Index

1. https://en.wikipedia.org/wiki/Zero-copy

2. https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import.txt

3. https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt

Kodi Implementation Links:

https://github.com/xbmc/xbmc/tree/master/xbmc/windowing/gbm

https://github.com/xbmc/xbmc/blob/master/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp

https://github.com/xbmc/xbmc/blob/master/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIMEGLES.cpp

https://github.com/xbmc/xbmc/blob/master/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp

Page 18: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another

Q/ATheme By: Samfisher Design

Page 19: From Zero to Zero-Copy - Amazon S3...Zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another