Skip to content

Commit

Permalink
Update to 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Asd-g committed Dec 23, 2022
1 parent 4d3d9ce commit 5d98f65
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 58 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
##### 1.1.4:
libplacebo_Tonemap: fixed `src_csp` < 3.

##### 1.1.3:
libplacebo_Resample: added `src_width` and `src_height` parameters.
libplacebo_Deband: added `grain_neutral` parameter.
Expand Down
8 changes: 4 additions & 4 deletions src/avs_libplacebo.rc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <winver.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,3,0
PRODUCTVERSION 1,1,3,0
FILEVERSION 1,1,4,0
PRODUCTVERSION 1,1,4,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x0L
FILEOS VOS__WINDOWS32
Expand All @@ -15,11 +15,11 @@ BEGIN
BEGIN
VALUE "Comments", "AviSynth+ plugin interface to libplacebo."
VALUE "FileDescription", "avs_libplacebo for AviSynth+."
VALUE "FileVersion", "1.1.3"
VALUE "FileVersion", "1.1.4"
VALUE "InternalName", "avs_libplacebo"
VALUE "OriginalFilename", "avs_libplacebo.dll"
VALUE "ProductName", "avs_libplacebo"
VALUE "ProductVersion", "1.1.3"
VALUE "ProductVersion", "1.1.4"
END
END
BLOCK "VarFileInfo"
Expand Down
111 changes: 57 additions & 54 deletions src/tonemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,83 +322,86 @@ static AVS_VideoFrame* AVSC_CC tonemap_get_frame(AVS_FilterInfo* fi, int n)
d->chromaLocation = static_cast<pl_chroma_location>(static_cast<int>(d->chromaLocation) + 1);

// DOVI
if (d->src_csp == CSP_DOVI && avs_prop_num_elements(fi->env, props, "DolbyVisionRPU") > -1)
if (d->src_csp == CSP_DOVI)
{
if (d->use_dovi)
if (avs_prop_num_elements(fi->env, props, "DolbyVisionRPU") > -1)
{
uint8_t dovi_profile{ 0 };
const uint8_t* doviRpu{ reinterpret_cast<const uint8_t*>(avs_prop_get_data(fi->env, props, "DolbyVisionRPU", 0, &err)) };
size_t doviRpuSize{ static_cast<size_t>(avs_prop_get_data_size(fi->env, props, "DolbyVisionRPU", 0, &err)) };

if (doviRpu && doviRpuSize)
if (d->use_dovi)
{
// fprintf(stderr, "Got Dolby Vision RPU, size %"PRIi64" at %"PRIxPTR"\n", doviRpuSize, (uintptr_t) doviRpu);

DoviRpuOpaque* rpu{ dovi_parse_unspec62_nalu(doviRpu, doviRpuSize) };
const DoviRpuDataHeader* header{ dovi_rpu_get_header(rpu) };
uint8_t dovi_profile{ 0 };
const uint8_t* doviRpu{ reinterpret_cast<const uint8_t*>(avs_prop_get_data(fi->env, props, "DolbyVisionRPU", 0, &err)) };
size_t doviRpuSize{ static_cast<size_t>(avs_prop_get_data_size(fi->env, props, "DolbyVisionRPU", 0, &err)) };

if (!header)
{
const std::string err{ std::string("libplacebo_Tonemap: failed parsing RPU: ") + std::string(dovi_rpu_get_error(rpu)) };
d->msg = std::make_unique<char[]>(err.size() + 1);
strcpy(d->msg.get(), err.c_str());
ErrorText = d->msg.get();
}
else
if (doviRpu && doviRpuSize)
{
dovi_profile = header->guessed_profile;
// fprintf(stderr, "Got Dolby Vision RPU, size %"PRIi64" at %"PRIxPTR"\n", doviRpuSize, (uintptr_t) doviRpu);

d->dovi_meta = create_dovi_meta(*rpu, *header);
dovi_rpu_free_header(header);
}
DoviRpuOpaque* rpu{ dovi_parse_unspec62_nalu(doviRpu, doviRpuSize) };
const DoviRpuDataHeader* header{ dovi_rpu_get_header(rpu) };

if (!ErrorText)
{
// Profile 5, 7 or 8 mapping
d->src_repr->sys = PL_COLOR_SYSTEM_DOLBYVISION;
d->src_repr->dovi = d->dovi_meta.get();
if (!header)
{
const std::string err{ std::string("libplacebo_Tonemap: failed parsing RPU: ") + std::string(dovi_rpu_get_error(rpu)) };
d->msg = std::make_unique<char[]>(err.size() + 1);
strcpy(d->msg.get(), err.c_str());
ErrorText = d->msg.get();
}
else
{
dovi_profile = header->guessed_profile;

if (dovi_profile == 5)
d->dst_repr->levels = PL_COLOR_LEVELS_FULL;
d->dovi_meta = create_dovi_meta(*rpu, *header);
dovi_rpu_free_header(header);
}

// Update mastering display from RPU
if (header->vdr_dm_metadata_present_flag)
if (!ErrorText)
{
const DoviVdrDmData* vdr_dm_data{ dovi_rpu_get_vdr_dm_data(rpu) };
// Profile 5, 7 or 8 mapping
d->src_repr->sys = PL_COLOR_SYSTEM_DOLBYVISION;
d->src_repr->dovi = d->dovi_meta.get();

if (dovi_profile == 5)
d->dst_repr->levels = PL_COLOR_LEVELS_FULL;

// Should avoid changing the source black point when mapping to PQ
// As the source image already has a specific black point,
// and the RPU isn't necessarily ground truth on the actual coded values
// Update mastering display from RPU
if (header->vdr_dm_metadata_present_flag)
{
const DoviVdrDmData* vdr_dm_data{ dovi_rpu_get_vdr_dm_data(rpu) };

// Set target black point to the same as source
if (d->dst_csp == CSP_HDR10)
d->dst_pl_csp->hdr.min_luma = d->src_pl_csp->hdr.min_luma;
else
d->src_pl_csp->hdr.min_luma = pl_hdr_rescale(PL_HDR_PQ, PL_HDR_NITS, vdr_dm_data->source_min_pq / 4095.0f);
// Should avoid changing the source black point when mapping to PQ
// As the source image already has a specific black point,
// and the RPU isn't necessarily ground truth on the actual coded values

d->src_pl_csp->hdr.max_luma = pl_hdr_rescale(PL_HDR_PQ, PL_HDR_NITS, vdr_dm_data->source_max_pq / 4095.0f);
// Set target black point to the same as source
if (d->dst_csp == CSP_HDR10)
d->dst_pl_csp->hdr.min_luma = d->src_pl_csp->hdr.min_luma;
else
d->src_pl_csp->hdr.min_luma = pl_hdr_rescale(PL_HDR_PQ, PL_HDR_NITS, vdr_dm_data->source_min_pq / 4095.0f);

if (vdr_dm_data->dm_data.level6)
{
const DoviExtMetadataBlockLevel6* meta{ vdr_dm_data->dm_data.level6 };
d->src_pl_csp->hdr.max_luma = pl_hdr_rescale(PL_HDR_PQ, PL_HDR_NITS, vdr_dm_data->source_max_pq / 4095.0f);

if (!maxCll || !maxFall)
if (vdr_dm_data->dm_data.level6)
{
d->src_pl_csp->hdr.max_cll = meta->max_content_light_level;
d->src_pl_csp->hdr.max_fall = meta->max_frame_average_light_level;
const DoviExtMetadataBlockLevel6* meta{ vdr_dm_data->dm_data.level6 };

if (!maxCll || !maxFall)
{
d->src_pl_csp->hdr.max_cll = meta->max_content_light_level;
d->src_pl_csp->hdr.max_fall = meta->max_frame_average_light_level;
}
}
}

dovi_rpu_free_vdr_dm_data(vdr_dm_data);
dovi_rpu_free_vdr_dm_data(vdr_dm_data);
}
}
}

dovi_rpu_free(rpu);
dovi_rpu_free(rpu);
}
}
}
else
ErrorText = "libplacebo_Tonemap: DolbyVisionRPU frame property is required for src_csp=3!";
}
else
ErrorText = "libplacebo_Tonemap: DolbyVisionRPU frame property is required for src_csp=3!";

if (!ErrorText)
{
Expand Down

0 comments on commit 5d98f65

Please sign in to comment.