codec2: add P010 output support for HEVC Main10 and 4k AV1#1
Conversation
|
this contribution contains two(2) prs. the other (and tests) is here: |
Add YUV_420_P010 as an ffmpeg Codec2 output format and map it to HAL_PIXEL_FORMAT_YCBCR_P010, VA_FOURCC_P010, VA_RT_FORMAT_YUV420_10BPP, DRM_FORMAT_P010 and AV_PIX_FMT_P010. For VAAPI hardware frames, switch the active output format to P010 only when the frame context reports AV_PIX_FMT_P010 as the software format. This keeps the default debug.ffmpeg-codec2.pixel_format at YUV_420 for 8-bit codecs such as H.264, VP9 and AV1, while still allowing HEVC Main10 streams to expose P010 output buffers. Also advertise HEVC Main10 in the decoder profile list so MediaCodec clients can select c2.ffmpeg.hevc.decoder for Main10 content. Test: m -j8 android.hardware.media.c2-ffmpeg-service media_codecs_ffmpeg_c2.xml android.hardware.media.c2-ffmpeg.policy Test: With debug.ffmpeg-codec2.pixel_format=YUV_420, played a 2160p H.264 sample in Next Player; logcat showed c2.ffmpeg.h264.decoder and non-P010 output. Test: With debug.ffmpeg-codec2.pixel_format=YUV_420, played a 2160p HEVC Main10 sample in Next Player; logcat showed c2.ffmpeg.hevc.decoder, VAAPI hwaccel and HAL_PIXEL_FORMAT_YCBCR_P010 output. Test: With debug.ffmpeg-codec2.pixel_format=YUV_420, played a 1080p VP9 Profile 0 sample in Next Player; logcat showed c2.ffmpeg.vp9.decoder and non-P010 output. Co-authored-by: OpenAI Codex <codex@openai.com>
a098a93 to
dca6992
Compare
Raise the ffmpeg AV1 decoder size limit to 4096x4096 and add the same basic throughput and performance limits used by other 4K-capable video decoders.\n\nThe previous 2048x2048 limit can prevent 4K AV1 streams from matching c2.ffmpeg.av1.decoder through MediaCodec capabilities.\n\nTest: m -j8 media_codecs_ffmpeg_c2.xml android.hardware.media.c2-ffmpeg-service\nTest: Deployed media_codecs_ffmpeg_c2.xml and confirmed c2.ffmpeg.av1.decoder advertises max=4096x4096.\nTest: Played a controlled 1080p AV1 10-bit sample with Next Player; logcat showed c2.ffmpeg.av1.decoder, VAAPI hwaccel and HAL_PIXEL_FORMAT_YCBCR_P010 output.\n\nCo-authored-by: OpenAI Codex <codex@openai.com>
Keep VAAPI Main10 downloads in P010 instead of forcing YUV420P. Also handle decoder EAGAIN by draining pending output before retrying the same input packet, avoiding playback stalls under backpressure. Co-authored-by: OpenAI Codex <codex@openai.com>
Expose default, coded, and output color aspect parameters and update them from FFmpeg AVFrame metadata when decoded frames carry range, primaries, transfer, or matrix information. Attach the current color aspects to output buffers so HDR/Main10 streams keep their color metadata. Co-authored-by: OpenAI Codex <codex@openai.com>
|
additional works i did but not in this pr: |
|
responsible vibe-coding: |
| if (shouldUseP010Output(hwfc)) { | ||
| return VA_FOURCC_P010; | ||
| } | ||
| return mUtils->getVAFOURCCFormat(); |
There was a problem hiding this comment.
Modify getVAFOURCCFormat/getVAFormat/getPixelFormat instead of creating a new function?
There was a problem hiding this comment.
Ok I'll change that to add a line into getVAFOURCCFormat
| struct SwsContext* currentImgConvertCtx = mImgConvertCtx; | ||
|
|
||
| if (mUtils->getPixelFormat(false) == HAL_PIXEL_FORMAT_YV12) { | ||
| if (getActivePixelFormat(false) == HAL_PIXEL_FORMAT_YCBCR_P010) { |
There was a problem hiding this comment.
Maybe add HAL_PIXEL_FORMAT_NV12 here? This should also works on NV12
There was a problem hiding this comment.
Maybe yes, but I don't have a video / device to test that, so I'll leave that to you and future contributers 😇❤️
| AVHWFramesContext *hwfc = (AVHWFramesContext *)frame->hw_frames_ctx->data; | ||
| if (hwfc && hwfc->sw_format == AV_PIX_FMT_P010) { | ||
| sw_format = AV_PIX_FMT_P010; | ||
| } |
There was a problem hiding this comment.
Write to output->format directly?
There was a problem hiding this comment.
We have output->format = sw_format; later and we may need to use this variable again in the future, for specific cases / hardware support , etc. but if you prefer, it's totally fine to just change that! It's just a future proof.
|
Thanks for the PR! However Waydroid's hwcomposer doesn't support HDR output yet, so I am not sure whether we need this at this moment Btw you might open a PR in upstream (https://github.com/android-generic/external_stagefright-plugins) so that other Android x86 projects like BlissOS can share your patches |
|
At least we can play the video, and 10bit output can be implemented later (which is wip now on my machine)
For upstream, thanks for the info! I'll consider testing other distros like BlissOs later, but for now, my local pipeline still uses debug options built by Waydroid-Atv.
…On May 29, 2026 8:35:57 AM UTC, SupeChicken666 ***@***.***> wrote:
supechicken left a comment (WayDroid-ATV/android_external_stagefright-plugins#1)
Thanks for the PR! However Waydroid's hwcomposer doesn't support HDR output yet, so I am not sure whether we need this at this moment
Btw you might open a PR in upstream (https://github.com/android-generic/external_stagefright-plugins) so that other Android x86 OS like BlissOS can share your patches
--
Reply to this email directly or view it on GitHub:
#1 (comment)
You are receiving this because you authored the thread.
Message ID: ***@***.***>
|









Add YUV_420_P010 as a selectable ffmpeg Codec2 output format and map it to HAL_PIXEL_FORMAT_YCBCR_P010, VA_FOURCC_P010, VA_RT_FORMAT_YUV420_10BPP, DRM_FORMAT_P010 and AV_PIX_FMT_P010.
When VAAPI reports a P010 software format for hardware frames, switch the active output format to P010 and update Codec2 color info to 10-bit YUV 4:2:0. This allows HEVC Main10 streams to expose a P010 output buffer instead of being forced through the existing 8-bit YUV path.
Also advertise HEVC Main10 in the decoder profile list so MediaCodec clients can select c2.ffmpeg.hevc.decoder for Main10 content.
Test: m -j8 android.hardware.media.c2-ffmpeg-service media_codecs_ffmpeg_c2.xml android.hardware.media.c2-ffmpeg.policy
Test: Played a 2160p HEVC Main10 sample with Next Player on WayDroid; logcat showed c2.ffmpeg.hevc.decoder, VAAPI hwaccel and HAL_PIXEL_FORMAT_YCBCR_P010 output.