Branch data Line data Source code
1 : : /* 2 : : * This file is part of libplacebo. 3 : : * 4 : : * libplacebo is free software; you can redistribute it and/or 5 : : * modify it under the terms of the GNU Lesser General Public 6 : : * License as published by the Free Software Foundation; either 7 : : * version 2.1 of the License, or (at your option) any later version. 8 : : * 9 : : * libplacebo is distributed in the hope that it will be useful, 10 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : : * GNU Lesser General Public License for more details. 13 : : * 14 : : * You should have received a copy of the GNU Lesser General Public 15 : : * License along with libplacebo. If not, see <http://www.gnu.org/licenses/>. 16 : : */ 17 : : 18 : : #include "common.h" 19 : : #include <libplacebo/utils/dolbyvision.h> 20 : : 21 : : #ifdef PL_HAVE_LIBDOVI 22 : : #include <libplacebo/tone_mapping.h> 23 : : #include <libdovi/rpu_parser.h> 24 : : #endif 25 : : 26 : 0 : void pl_hdr_metadata_from_dovi_rpu(struct pl_hdr_metadata *out, 27 : : const uint8_t *buf, size_t size) 28 : : { 29 : : #ifdef PL_HAVE_LIBDOVI 30 : : if (buf && size) { 31 : : DoviRpuOpaque *rpu = 32 : : dovi_parse_unspec62_nalu(buf, size); 33 : : const DoviRpuDataHeader *header = dovi_rpu_get_header(rpu); 34 : : 35 : : if (header && header->vdr_dm_metadata_present_flag) { 36 : : // Profile 4 reshaping isn't done as it is a dual layer format. 37 : : // However there are still unknowns on its EOTF, so it cannot be enabled. 38 : : // 39 : : // For profile 7, the brightness metadata can still be used as most 40 : : // titles are going to have accurate metadata<->image brightness, 41 : : // with the exception of some titles that require the enhancement layer 42 : : // to be processed to restore the intended brightness, which would then 43 : : // match the metadata values. 44 : : if (header->guessed_profile == 4) { 45 : : goto done; 46 : : } 47 : : 48 : : const DoviVdrDmData *vdr_dm_data = dovi_rpu_get_vdr_dm_data(rpu); 49 : : if (vdr_dm_data->dm_data.level1) { 50 : : const DoviExtMetadataBlockLevel1 *l1 = vdr_dm_data->dm_data.level1; 51 : : out->max_pq_y = l1->max_pq / 4095.0f; 52 : : out->avg_pq_y = l1->avg_pq / 4095.0f; 53 : : } 54 : : 55 : : dovi_rpu_free_vdr_dm_data(vdr_dm_data); 56 : : } 57 : : 58 : : done: 59 : : dovi_rpu_free_header(header); 60 : : dovi_rpu_free(rpu); 61 : : } 62 : : #endif 63 : 0 : }