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

util/libav: do not bail on MEL-only RPUs w/EL #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

intelfx
Copy link

@intelfx intelfx commented Aug 18, 2024

We can still map DV metadata that indicates enhancement layer usage (!disable_residual_flag, Profile 7 and 4) for MEL-only bitstreams, which is indicated by trivial NLQ parameters.

We can still map DV metadata that indicates enhancement layer usage
(!disable_residual_flag, Profile 7 and 4) for MEL-only bitstreams,
which is indicated by trivial NLQ parameters.
@kasper93
Copy link
Contributor

kasper93 commented Aug 18, 2024

pl_map_avframe_ex() should also be fixed in similar fashion to use pl_can_map_avdovi_metadata(). And for parity with libdovi code path max_pq and avg_pq should be mapped also when dovi meta is not used. Also needs API version bump.

diff --git a/src/include/libplacebo/utils/libav_internal.h b/src/include/libplacebo/utils/libav_internal.h
index a754e98b..928d37f6 100644
--- a/src/include/libplacebo/utils/libav_internal.h
+++ b/src/include/libplacebo/utils/libav_internal.h
@@ -925,14 +925,14 @@ PL_LIBAV_API void pl_map_avdovi_metadata(struct pl_color_space *color,
             pl_hdr_rescale(PL_HDR_PQ, PL_HDR_NITS, dovi_color->source_min_pq / 4095.0f);
         color->hdr.max_luma =
             pl_hdr_rescale(PL_HDR_PQ, PL_HDR_NITS, dovi_color->source_max_pq / 4095.0f);
+    }

 #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(59, 12, 100)
-        if ((dovi_ext = av_dovi_find_level(metadata, 1))) {
-            color->hdr.max_pq_y = dovi_ext->l1.max_pq / 4095.0f;
-            color->hdr.avg_pq_y = dovi_ext->l1.avg_pq / 4095.0f;
-        }
-#endif
+    if ((dovi_ext = av_dovi_find_level(metadata, 1))) {
+        color->hdr.max_pq_y = dovi_ext->l1.max_pq / 4095.0f;
+        color->hdr.avg_pq_y = dovi_ext->l1.avg_pq / 4095.0f;
     }
+#endif
 }

 PL_LIBAV_API void pl_frame_map_avdovi_metadata(struct pl_frame *out_frame,

which makes it awkward with dovi allocation part, but since the API is changed already it can be done while at it. See how pl_map_avframe_ex() maps RPU info always, regardless of header->disable_residual_flag.

// Helper function to check if Dolby Vision metadata can be mapped.
// Returns true if the `AVDOVIRpuDataHeader` `disable_residual_flag` field is
// not zero or if the NLQ parameters are trivial.
PL_LIBAV_API bool pl_can_map_avdovi_metadata(const AVDOVIMetadata *metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pl_map_avdovi_metadata could map more metadata, but without pl_dovi_metadata use. This could be pl_is_dovi_metadata_needed or something and pl_map_avdovi_metadata could take NULL if the former function returns false. This would allow to still make RPU values.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pl_map_avdovi_metadata could take NULL if the former function returns false. This would allow to still make RPU values.

Sorry, I don't follow — how? If we're talking about that av_dovi_find_level() block from your diff above, it still needs the AVDOVIMetadata *, no? Or are we talking about some hypothetical yet-unwritten code?

Copy link
Contributor

@kasper93 kasper93 Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pl_map_avdovi_metadata(&color, &repr, NULL, &metadata); I'm talking about output parameter, when we decide not to use pl_dovi_metadata, but still populate max_pq and avg_pq. This is how pl_map_avframe_ex() works.

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