Skip to content

Commit ec8a823

Browse files
committed
BitstreamConverter: Add option to set level 5 metadata to zero offsets
In the past, some users have had issues with media containing invalid metadata for level 5 active area offsets. Adds a workaround to override the offsets so that the displayed image is not cropped incorrectly on some TVs.
1 parent 6a9bb79 commit ec8a823

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

xbmc/utils/BitstreamConverter.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ CBitstreamConverter::CBitstreamConverter()
329329
m_convert_dovi = false;
330330
m_removeDovi = false;
331331
m_removeHdr10Plus = false;
332+
m_setDoviZeroLevel5 = false;
332333
}
333334

334335
CBitstreamConverter::~CBitstreamConverter()
@@ -1308,13 +1309,14 @@ bool CBitstreamConverter::mpeg2_sequence_header(const uint8_t *data, const uint3
13081309
#ifdef HAVE_LIBDOVI
13091310
// Processes Dolby Vision RPU
13101311
// - Converts to profile 8.1 if `m_convert_dovi` is enabled
1312+
// - Sets level 5 metadata to 0 offsets if `m_setDoviZeroLevel5` is enabled
13111313
//
13121314
// The returned data must be freed with `dovi_data_free`
13131315
// May be NULL if no processing was done or if parsing errored
13141316
const DoviData* CBitstreamConverter::processDoviRpu(uint8_t* buf, uint32_t nalSize)
13151317
{
13161318
// early exit if no processing option is enabled
1317-
if (!m_convert_dovi)
1319+
if (!m_convert_dovi && !m_setDoviZeroLevel5)
13181320
return NULL;
13191321

13201322
DoviRpuOpaque* rpu = dovi_parse_unspec62_nalu(buf, nalSize);
@@ -1330,12 +1332,18 @@ const DoviData* CBitstreamConverter::processDoviRpu(uint8_t* buf, uint32_t nalSi
13301332
return rpuData;
13311333
}
13321334

1333-
if (header->guessed_profile == 7)
1335+
if (m_convert_dovi && header->guessed_profile == 7)
13341336
{
13351337
ret = dovi_convert_rpu_with_mode(rpu, 2);
13361338
processed = true;
13371339
}
13381340

1341+
if (ret == 0 && m_setDoviZeroLevel5)
1342+
{
1343+
ret = dovi_rpu_set_active_area_offsets(rpu, 0, 0, 0, 0);
1344+
processed = true;
1345+
}
1346+
13391347
if (ret == 0 && processed)
13401348
rpuData = dovi_write_unspec62_nalu(rpu);
13411349

xbmc/utils/BitstreamConverter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,5 @@ class CBitstreamConverter
157157
bool m_convert_dovi;
158158
bool m_removeDovi;
159159
bool m_removeHdr10Plus;
160+
bool m_setDoviZeroLevel5;
160161
};

0 commit comments

Comments
 (0)