Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ffmpeg codecs and move it to /vendor #3

Open
wants to merge 8 commits into
base: lineage-18.1
Choose a base branch
from

Conversation

hmtheboy154
Copy link
Contributor

No description provided.

goffioul and others added 8 commits January 22, 2024 20:59
- Increase input buffer size (needs to be larger than default 4k).
- Make extractor compatible with Google codec, which expects the magic
  sequence and STREAMINFO header as part of init data.
Use yadif filter for SW-only, and VA-API for HW-accelerated
deinterlacing.

Using hw-accelerated deinterlacing reduces the CPU usage of the FFMPEG
codec, up to 50% for full HD streams. Deinterlacing is controlled by new
properties:
- debug.ffmpeg-codec2.deinterlace = auto | software | none
- debug.ffmpeg-codec2.deinterlace.vaapi = default | bob | weave |
  motion_adaptive | motion_compensated

This requires FFMPEG >= 3.4. Previous version of FFMPEG (3.3-dev) had an
issue with bottom-first interlaced streams, resulting in
no-deinterlacing when using VA-API.

Interlaced status is determined during the first 30 frames, to handle
case of sporadic interlaced frames in progressive stream.
Create VA surfaces from DRM prime handle provided by gralloc. These can
then be returned by codec2 to framework with zero copy operation.

Hot-patch the ffmpeg HW accel device to inject custom frame pool
handling functions. Use C2BlockPool to generate a buffer and create a VA
surface from the DRM prime handle. Keep track of the generated buffers
based on the IGBP slot index.

Handle video resolution change (e.g. with HLS) by keeping track of the
buffer metadata and recreate the VA surface if necessary (only buffer
dimensions are expected to change).

Patching the ffmpeg HW accel device allows to be compatible with using
VA-API also for filtering (e.g. deinterlace). However all VA surfaces
must have the same dimensions, in particular for cases where frame
actual dimensions is different than the coded one. This is necessary as
one cannot control what IGBP slot will be used in what context, so all
VA surfaces must be interchangeable.

Use of DRM prime can be disabled by setting system property
debug.ffmpeg-codec2.hwaccel.drm = 0.
- move all extractor-specific utilities into the extractor lib (this
  drastically reduces the amount of deps for ffmpeg_utils)
- use library constructor to initialize FFMPEG logging
- use library constructor to initialize ffmpeg_source
- drop initialization of FFMPEG network, streaming this is handled by
  Android and the extractor accesses data through CDataSource interface
- move FFMPEG headers #include where they're actually needed
- rename FFMPEG{Audio|Video}CodecInfo to C2FFMPEG{Audio|Video}CodecInfo
  and move to codec2; use library header to provide access to structures
  to extractor
- remove unnecessary headers
- use MakeAVCCodecSpecificData from libstagefright_foundation in
  extractor, libstagefright_metadatautils is not available to vendor

This does not achieve full Treble-compatibility yet. THe extractor
should probably be moved to /system partition.
This declares the FFMPEG codec2 service to support AV1 codec. It
requires FFMPEG to provide at least one working AV1 codec
implementation.
…g_omx in vendor

In order to build libffmpeg_omx on trble builds without touching
libraries in system, we clone getOMXChannelMapping() from ACodec,
which will help us cut from needing to link to libstagefright so
we can finally build on vendor

Signed-off-by: hmtheboy154 <[email protected]>
Signed-off-by: hmtheboy154 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants