Skip to content

Commit

Permalink
Merge pull request #705 from Dash-Industry-Forum/bugfix/isoSegmentWar…
Browse files Browse the repository at this point in the history
…nings

Fix IsoSegmentValidator issues - Bypassing review due to > 1m of inactivity.
  • Loading branch information
Phencys authored Aug 26, 2024
2 parents 27af98d + 63985ef commit 6a87ae9
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 111 deletions.
7 changes: 3 additions & 4 deletions CMAF/impl/cfhdMediaProfileConformance.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

global $mpdHandler;

$videoSampleDescription = $xml->getElementsByTagName('vide_sampledescription');
if (!$videoSampleDescription->length) {
return false;
Expand Down Expand Up @@ -53,10 +55,7 @@
}
}

$unitsInTick = $nalComments->item(0)->getAttribute('num_units_in_tick');
$timescale = $nalComments->item(0)->getAttribute('timescale');
$maxFPS = ceil((int)timescale / (2 * (int)unitsInTick));
if ($maxFPS > 60) {
if ($mpdHandler->getFrameRate() > 60) {
return false;
}
}
Expand Down
8 changes: 3 additions & 5 deletions CMAF/impl/checkCMAFTracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@
$nalUnits = $xml->getElementsByTagName('NALUnit');
if ($nalUnits->length > 0) {
$nalComment = $nalUnits->item(0)->getElementsByTagName('comment');
$numberOfUnitsInTick = $nalComment->item(0)->getAttribute('num_units_in_tick');
$timeScale = $nalComment->item(0)->getAttribute('time_scale');
$profileIdc = $nalUnits->item(0)->getAttribute('profile_idc');
$levelIdc = $nalComment->item(0)->getAttribute('level_idc');
}
Expand Down Expand Up @@ -368,10 +366,10 @@
"Section 7.3.2.4",
"Each CMAF Fragment in combination with its associated Header SHALL contain sufficient metadata to be " .
"decoded and displayed when independently accessed",
$numberOfUnitsInTick != null && $timeScale != null,
$mpdHandler->getFrameRate() != null,
"FAIL",
"FPS info (num_ticks & timescale) found for representation / track $id",
"FPS info (num_ticks & timescale) not found for representation / track $id",
"FPS info found in MPD for representation / track $id",
"FPS info not found in MPD for representation / track $id",
);
}
}
Expand Down
8 changes: 2 additions & 6 deletions CMAF/impl/determineCMAFMediaProfiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
}
}
if (hexdec($comment->getAttribute("timing_info_present_flag")) == 1) {
$numUnitsInTick = $comment->getAttribute("num_units_in_tick");
$timeScale = $comment->getAttribute("time_scale");
$mediaProfileParameters['framerate'] = $timeScale / (2 * $numUnitsInTick);
$mediaProfileParameters['framerate'] = $mpdHandler->getFrameRate();
}
}

Expand Down Expand Up @@ -122,9 +120,7 @@
}
}
if ($sps->getAttribute("vui_timing_info_present_flag") == "1") {
$numUnitsInTick = $sps->getAttribute("vui_num_units_in_tick");
$timeScale = $sps->getAttribute("vui_time_scale");
$mediaProfileParameters['framerate'] = $timeScale / ($numUnitsInTick);
$mediaProfileParameters['framerate'] = $mpdHandler->getFrameRate();
}
}

Expand Down
48 changes: 20 additions & 28 deletions CTAWAVE/impl/checkFrameRateSplicePoint.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
<?php

global $session, $MediaProfDatabase, $logger;
global $session, $MediaProfDatabase, $logger, $mpdHandler;

$periodCount = sizeof($MediaProfDatabase);
$adaptationCount = sizeof($MediaProfDatabase[0]);
for ($i = 0; $i < ($periodCount - 1); $i++) {
for ($adapt = 0; $adapt < $adaptationCount; $adapt++) {
$dir1 = $session->getRepresentationDir($i, $adapt, 0);
$xml1 = DASHIF\Utility\parseDOM($dir1 . '/atomInfo.xml', 'atomlist');
if ($xml1) {
$hdlr = $xml1->getElementsByTagName("hdlr")->item(0)->getAttribute("handler_type");
if ($hdlr == "vide") {
$framerate_p1 = $this->getFrameRate($xml1);
}
if ($mpdHandler->getContentType($i, $adapt) != "video") {
continue;
}
$dir2 = $session->getRepresentationDir($i + 1, $adapt, 0);
$xml2 = DASHIF\Utility\parseDOM($dir2 . '/atomInfo.xml', 'atomlist');
if ($xml2) {
$hdlr = $xml2->getElementsByTagName("hdlr")->item(0)->getAttribute("handler_type");
if ($hdlr == "vide") {
$framerate_p2 = $this->getFrameRate($xml2);
if ($mpdHandler->getContentType($i + 1, $adapt) != "video") {
continue;
}
$framerate_p1 = $mpdHandler->getFrameRate($i, $adapt, 0);
$framerate_p2 = $mpdHandler->getFrameRate($i + 1, $adapt, 0);


$remainder = ($framerate_p1 > $framerate_p2 ?
($framerate_p1 % $framerate_p2) :
($framerate_p2 % $framerate_p1));
$remainder = ($framerate_p1 > $framerate_p2 ?
($framerate_p1 % $framerate_p2) :
($framerate_p2 % $framerate_p1));


$logger->test(
"WAVE Content Spec 2018Ed",
"Section 7.2.2",
"Frame rate Should be the same between Sequential Sw Sets at the Splice point",
$remainder == 0,
"WARN",
"Correct for Sw set $adapt between presentations $i and " . ($i + 1),
"Invalid for Sw set $adapt between presentations $i and " . ($i + 1),
);
}
}
$logger->test(
"WAVE Content Spec 2018Ed",
"Section 7.2.2",
"Frame rate Should be the same between Sequential Sw Sets at the Splice point",
$remainder == 0,
"WARN",
"Correct for Sw set $adapt between presentations $i and " . ($i + 1),
"Invalid for Sw set $adapt between presentations $i and " . ($i + 1),
);
}
}
50 changes: 0 additions & 50 deletions CTAWAVE/impl/getFrameRate.php

This file was deleted.

15 changes: 4 additions & 11 deletions CTAWAVE/impl/getMediaProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

global $mediaProfileAttributesVideo, $mediaProfileAttributesAudio, $mediaProfileAttributesSubtitle;

global $logger;
global $logger, $mpdHandler;

$compatibleBrands = $xml->getElementsByTagName("ftyp")->item(0)->getAttribute("compatible_brands");
if ($hdlrType == 'vide') {
Expand Down Expand Up @@ -58,11 +58,8 @@
$mediaProfileParameters['matrix_coeff'] = 1;
}
}
if (hexdec($comment->getAttribute("timing_info_present_flag")) == 1) {
$numberOfUnitsPerTick = $comment->getAttribute("num_units_in_tick");
$timeScale = $comment->getAttribute("time_scale");
$mediaProfileParameters['framerate'] = $timeScale / (2 * $numberOfUnitsPerTick);
}

$mediaProfileParameters['framerate'] = $mpdHandler->getFrameRate();
}

if (strpos($compatibleBrands, "cfsd") !== false) {
Expand Down Expand Up @@ -133,11 +130,7 @@
$mediaProfileParameters['matrix_coeff'] = "1";
}
}
if ($sps->getAttribute("vui_timing_info_present_flag") == "1") {
$numberOfUnitsPerTick = $sps->getAttribute("vui_num_units_in_tick");
$timeScale = $sps->getAttribute("vui_time_scale");
$mediaProfileParameters['framerate'] = $timeScale / ($numberOfUnitsPerTick);
}
$mediaProfileParameters['framerate'] = $mpdHandler->getFrameRate();
}
if (strpos($compatibleBrands, "chh1") !== false) {
$mediaProfileParameters['brand'] = "chh1";
Expand Down
5 changes: 0 additions & 5 deletions CTAWAVE/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ private function checkFrameRateSplicePoint()
include 'impl/checkFrameRateSplicePoint.php';
}

private function getFrameRate($xml)
{
return include 'impl/getFrameRate.php';
}

private function checkAudioChannelSplicePoint()
{
return include 'impl/checkAudioChannelSplicePoint.php';
Expand Down
23 changes: 21 additions & 2 deletions Utils/MPDHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public function __construct($url)
$this->validateSchematron();
}
}
public function getRoles($period, $adaptation){
return include 'impl/MPDHandler/getRoles.php';
public function getRoles($period, $adaptation)
{
return include 'impl/MPDHandler/getRoles.php';
}

public function selectPeriod($period)
Expand Down Expand Up @@ -148,6 +149,24 @@ public function getSegmentUrls($periodIndex = null)
return include 'impl/MPDHandler/getSegmentUrls.php';
}

public function getFrameRate(
$periodIndex = null,
$adaptationIndex = null,
$representationIndex = null
) {
return include 'impl/MPDHandler/getFrameRate.php';
}

public function getContentType(
$periodIndex = null,
$adaptationIndex = null,
$representationIndex = null
) {
return include 'impl/MPDHandler/getContentType.php';
}



private function computeTiming(
$presentationDuration,
$segmentAccess,
Expand Down
20 changes: 20 additions & 0 deletions Utils/impl/MPDHandler/getContentType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$period = ($periodIndex == null ? $this->getSelectedPeriod() : $periodIndex);
$adaptation = ($adaptationIndex == null ? $this->getSelectedAdaptationSet() : $adaptationIndex);

$periods = $mpdHandler->getElementsByTagName("Period");

if ($period >= count($periods)) {
return null;
}

$thisPeriod = $periods->item($period);

$adaptationSets = $thisPeriod->getElementsByTagName("AdaptationSet");
if ($adaptation >= count($adaptationSets)) {
return null;
}


return $adaptationSets->item($adaptation)->getAttribute("contentType");
44 changes: 44 additions & 0 deletions Utils/impl/MPDHandler/getFrameRate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

$period = ($periodIndex == null ? $this->getSelectedPeriod() : $periodIndex);
$adaptation = ($adaptationIndex == null ? $this->getSelectedAdaptationSet() : $adaptationIndex);
$representation = ($representationIndex == null ? $this->getSelectedRepresentation() : $representationIndex);

$framerate = 0;

$periods = $mpdHandler->getElementsByTagName("Period");

if ($period >= count($periods)) {
return null;
}

$thisPeriod = $periods->item($period);

if ($thisPeriod->hasAttribute('frameRate')) {
$framerate = $thisPeriod->getAttribute('frameRate');
}

$adaptationSets = $thisPeriod->getElementsByTagName("AdaptationSet");
if ($adaptation >= count($adaptationSets)) {
return null;
}

$thisAdaptation = $adaptationSets->item($adaptation);

if ($thisAdaptation->hasAttribute('frameRate')) {
$framerate = $thisAdaptation->getAttribute('frameRate');
}

$representations = $thisAdaptation->getElementsByTagName("Representation");

if ($representation >= count($representations)) {
return null;
}

$thisRepresentation = $representations->item($representation);

if ($thisRepresentation->hasAttribute('frameRate')) {
$framerate = $thisRepresentation->getAttribute('frameRate');
}

return $framerate;
12 changes: 12 additions & 0 deletions Utils/validators/isoSegmentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ private function handleOutput()
$content = file_get_contents("$representationDirectory/stderr.txt");
$contentArray = explode("\n", $content);

//Filter false-positive messages as these are simply not handled by the ISOSegmenvalidator,
//but not technically bugs
$contentArray = array_filter($contentArray, static function ($errorLine) {
if (strpos($errorLine, "unknown/unexpected atom 'meta'")) {
return false;
}
if (strpos($errorLine, "colr atom of type nclx")) {
return false;
}
return true;
});

if (!count($contentArray)) {
$logger->test(
"Segment Validation",
Expand Down

0 comments on commit 6a87ae9

Please sign in to comment.