diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:38:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:38:23 +0000 |
commit | ff6e3c025658a5fa1affd094f220b623e7e1b24b (patch) | |
tree | 9faab72d69c92d24e349d184f5869b9796f17e0c /src/utils/dolbyvision.c | |
parent | Initial commit. (diff) | |
download | libplacebo-upstream.tar.xz libplacebo-upstream.zip |
Adding upstream version 6.338.2.upstream/6.338.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/utils/dolbyvision.c')
-rw-r--r-- | src/utils/dolbyvision.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/utils/dolbyvision.c b/src/utils/dolbyvision.c new file mode 100644 index 0000000..3798532 --- /dev/null +++ b/src/utils/dolbyvision.c @@ -0,0 +1,63 @@ +/* + * This file is part of libplacebo. + * + * libplacebo is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libplacebo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libplacebo. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "common.h" +#include <libplacebo/utils/dolbyvision.h> + +#ifdef PL_HAVE_LIBDOVI +#include <libplacebo/tone_mapping.h> +#include <libdovi/rpu_parser.h> +#endif + +void pl_hdr_metadata_from_dovi_rpu(struct pl_hdr_metadata *out, + const uint8_t *buf, size_t size) +{ +#ifdef PL_HAVE_LIBDOVI + if (buf && size) { + DoviRpuOpaque *rpu = + dovi_parse_unspec62_nalu(buf, size); + const DoviRpuDataHeader *header = dovi_rpu_get_header(rpu); + + if (header && header->vdr_dm_metadata_present_flag) { + // Profile 4 reshaping isn't done as it is a dual layer format. + // However there are still unknowns on its EOTF, so it cannot be enabled. + // + // For profile 7, the brightness metadata can still be used as most + // titles are going to have accurate metadata<->image brightness, + // with the exception of some titles that require the enhancement layer + // to be processed to restore the intended brightness, which would then + // match the metadata values. + if (header->guessed_profile == 4) { + goto done; + } + + const DoviVdrDmData *vdr_dm_data = dovi_rpu_get_vdr_dm_data(rpu); + if (vdr_dm_data->dm_data.level1) { + const DoviExtMetadataBlockLevel1 *l1 = vdr_dm_data->dm_data.level1; + out->max_pq_y = l1->max_pq / 4095.0f; + out->avg_pq_y = l1->avg_pq / 4095.0f; + } + + dovi_rpu_free_vdr_dm_data(vdr_dm_data); + } + + done: + dovi_rpu_free_header(header); + dovi_rpu_free(rpu); + } +#endif +} |