Get BT.2100/HDR10 info from VUI (#189)

Fixes #187.
This commit is contained in:
jcdr428 2020-02-09 16:11:44 +02:00 committed by GitHub
parent ec66ec3e42
commit 54f59df53d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -2,6 +2,8 @@
#include <fs/systemlog.h> #include <fs/systemlog.h>
#include <algorithm>
#include "vodCoreException.h" #include "vodCoreException.h"
#include "vod_common.h" #include "vod_common.h"
@ -268,6 +270,9 @@ HevcSpsUnit::HevcSpsUnit()
vcl_hrd_parameters_present_flag(false), vcl_hrd_parameters_present_flag(false),
sub_pic_hrd_params_present_flag(false), sub_pic_hrd_params_present_flag(false),
num_short_term_ref_pic_sets(0), num_short_term_ref_pic_sets(0),
colour_primaries(0),
transfer_characteristics(0),
matrix_coeffs(0),
num_units_in_tick(0), num_units_in_tick(0),
time_scale(0), time_scale(0),
PicSizeInCtbsY_bits(0) PicSizeInCtbsY_bits(0)
@ -360,9 +365,9 @@ void HevcSpsUnit::vui_parameters()
bool colour_description_present_flag = m_reader.getBit(); bool colour_description_present_flag = m_reader.getBit();
if (colour_description_present_flag) if (colour_description_present_flag)
{ {
m_reader.skipBits(8); // colour_primaries u(8) colour_primaries = m_reader.getBits(8);
m_reader.skipBits(8); // transfer_characteristics u(8) transfer_characteristics = m_reader.getBits(8);
m_reader.skipBits(8); // matrix_coeffs u(8) matrix_coeffs = m_reader.getBits(8);
} }
} }
@ -880,8 +885,12 @@ int HevcSeiUnit::deserialize()
{ {
int maxCLL = m_reader.getBits(16); int maxCLL = m_reader.getBits(16);
int maxFALL = m_reader.getBits(16); int maxFALL = m_reader.getBits(16);
if (maxCLL > (HDR10_metadata[5] >> 16) || maxFALL > (HDR10_metadata[5] & 0x00ff)) if (maxCLL > (HDR10_metadata[5] >> 16) || maxFALL > (HDR10_metadata[5] & 0x0000ffff))
{
maxCLL = (std::max)(maxCLL, HDR10_metadata[5] >> 16);
maxFALL = (std::max)(maxFALL, HDR10_metadata[5] & 0x0000ffff);
HDR10_metadata[5] = (maxCLL << 16) + maxFALL; HDR10_metadata[5] = (maxCLL << 16) + maxFALL;
}
} }
else if (payloadType == 4 && !isHDR10plus) else if (payloadType == 4 && !isHDR10plus)
{ // HDR10Plus Metadata { // HDR10Plus Metadata

View File

@ -160,6 +160,10 @@ struct HevcSpsUnit : public HevcUnitWithProfile
*/ */
std::vector<ShortTermRPS> st_rps; std::vector<ShortTermRPS> st_rps;
int colour_primaries;
int transfer_characteristics;
int matrix_coeffs;
int num_short_term_ref_pic_sets; int num_short_term_ref_pic_sets;
int num_units_in_tick; int num_units_in_tick;
int time_scale; int time_scale;

View File

@ -176,6 +176,12 @@ int HEVCStreamReader::getStreamHeight() const { return m_sps ? m_sps->pic_height
int HEVCStreamReader::getStreamHDR() const int HEVCStreamReader::getStreamHDR() const
{ {
if (m_sps->colour_primaries == 9 && m_sps->transfer_characteristics == 16 &&
m_sps->matrix_coeffs == 9) // BT.2100 colorspace
{
m_sei->isHDR10 = true;
V3_flags |= 2;
}
return m_sei->isDV ? 4 : (m_sei->isHDR10plus ? 16 : (m_sei->isHDR10 ? 2 : 1)); return m_sei->isDV ? 4 : (m_sei->isHDR10plus ? 16 : (m_sei->isHDR10 ? 2 : 1));
} }