The VVC parser sets avctx->profile/level from the SPS
profile_tier_level, but the decoder never does.  For streams whose
container does not declare a profile (e.g. vvcC with
general_profile_idc == 0, as produced by VVenC, or Matroska),
avctx->profile therefore stays unknown at ff_get_format() time, and
profile-dependent hwaccels such as VAAPI refuse to initialize:

    Codec vvc profile -99 not supported for hardware decode.

Since the SPS is parsed before export_frame_params(), propagate
general_profile_idc and general_level_idc the same way the parser
does, so VAAPI hwaccel can attach for MP4/MKV streams too.  The
values are only set while still unknown, so a container- or
user-provided profile still wins.

This follows the precedent of 8f57b1a086
(avcodec/vvc_parser: move avctx->has_b_frames initialization to dec),
moving parser-only codec context fields into the decoder.

Tested with VVenC-encoded VVC Main 10 samples in MP4 and Matroska
on Intel iHD (VAProfileVVCMain10): hardware decoding now attaches,
where before it always fell back to software.

Signed-off-by: Your Name <[email protected]>
---
 libavcodec/vvc/dec.c | 11 +++++++++++

--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -913,6 +913,17 @@
     const VVCSPS *sps = fc->ps.sps;
     const VVCPPS *pps = fc->ps.pps;

+    // Propagate the profile and level from the SPS, mirroring the VVC
+    // parser.  Without this, hwaccels that require a known profile
+    // (e.g. VAAPI) can never initialize for streams whose container
+    // does not declare one (vvcC with profile_idc 0, Matroska).
+    if (c->profile == AV_PROFILE_UNKNOWN &&
+        sps->r->sps_ptl_dpb_hrd_params_present_flag)
+        c->profile = sps->r->profile_tier_level.general_profile_idc;
+    if (c->level == AV_LEVEL_UNKNOWN &&
+        sps->r->sps_ptl_dpb_hrd_params_present_flag)
+        c->level = sps->r->profile_tier_level.general_level_idc;
+
     // Reset the format if pix_fmt/w/h change.
     if (c->sw_pix_fmt != sps->pix_fmt  c->coded_width != pps->width
c->coded_height != pps->height) {
         c->coded_width  = pps->width;
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to