Skip to content

Commit

Permalink
PHP8 Compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Phencys committed Jan 29, 2024
1 parent b9653e2 commit eb62f0c
Show file tree
Hide file tree
Showing 49 changed files with 2,382 additions and 2,090 deletions.
4 changes: 2 additions & 2 deletions CMAF/impl/checkCMAFTracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
);
}

if ($mdatFile == null) {
if ($mdatFile === false) {
continue;
}

Expand Down Expand Up @@ -169,7 +169,7 @@
"Representation $id, chunk $j not valid"
);
}
if ($mdatFile !== null) {
if ($mdatFile !== false) {
fclose($mdatFile);
}

Expand Down
54 changes: 33 additions & 21 deletions CMAF/impl/determineCMAFMediaProfiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if ($nalUnits->length != 0) {
$spsUnitIndex = -1;
for ($nalIndex = 0; $nalIndex < $nalUnits->length; $nalIndex++) {
if ($nalUnits->item($nalIndex)->getAttribute("nal_type") == "0x07") {
if (hexdec($nalUnits->item($nalIndex)->getAttribute("nal_type")) == 7) {
$spsUnitIndex = $nalIndex;
break;
}
Expand All @@ -26,24 +26,30 @@
///\Resiliency Add checks for existing spsUnit
$avcC = $videoSampleDescription->getElementsByTagName('avcC')->item(0);
$comment = $nalUnits->item($spsUnitIndex)->getElementsByTagName("comment")->item(0);
$mediaProfileParameters['profile'] = $avcC->getAttribute("profile");
$mediaProfileParameters['profile'] = hexdec($avcC->getAttribute("profile"));
$mediaProfileParameters['level'] = (float)($comment->getAttribute("level_idc")) / 10;
$mediaProfileParameters['width'] = $videoSampleDescription->getAttribute("width");
$mediaProfileParameters['height'] = $videoSampleDescription->getAttribute("height");

if ($comment->getAttribute("vui_parameters_present_flag") == "0x1") {
if ($comment->getAttribute("video_signal_type_present_flag") == "0x1") {
if ($comment->getAttribute("colour_description_present_flag") == "0x1") {
$mediaProfileParameters['color_primaries'] = $comment->getAttribute("colour_primaries");
$mediaProfileParameters['transfer_char'] = $comment->getAttribute("transfer_characteristics");
$mediaProfileParameters['matrix_coeff'] = $comment->getAttribute("matrix_coefficients");
} elseif ($comment->getAttribute("colour_description_present_flag") == "0x0") {
$mediaProfileParameters['color_primaries'] = "0x1";
$mediaProfileParameters['transfer_char'] = "0x1";
$mediaProfileParameters['matrix_coeff'] = "0x1";
if (hexdec($comment->getAttribute("vui_parameters_present_flag")) == 1) {
if (hexdec($comment->getAttribute("video_signal_type_present_flag")) == 1) {
if (hexdec($comment->getAttribute("colour_description_present_flag")) == 1) {
$mediaProfileParameters['color_primaries'] = hexdec(
$comment->getAttribute("colour_primaries")
);
$mediaProfileParameters['transfer_char'] = hexdec(
$comment->getAttribute("transfer_characteristics")
);
$mediaProfileParameters['matrix_coeff'] = hexdec(
$comment->getAttribute("matrix_coefficients")
);
} elseif (hexdec($comment->getAttribute("colour_description_present_flag")) == 0) {
$mediaProfileParameters['color_primaries'] = 1;
$mediaProfileParameters['transfer_char'] = 1;
$mediaProfileParameters['matrix_coeff'] = 1;
}
}
if ($comment->getAttribute("timing_info_present_flag") == "0x1") {
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);
Expand Down Expand Up @@ -100,13 +106,19 @@
if ($sps->getAttribute("vui_parameters_present_flag") == "1") {
if ($sps->getAttribute("video_signal_type_present_flag") == "1") {
if ($sps->getAttribute("colour_description_present_flag") == "1") {
$mediaProfileParameters['color_primaries'] = $sps->getAttribute("colour_primaries");
$mediaProfileParameters['transfer_char'] = $sps->getAttribute("transfer_characteristics");
$mediaProfileParameters['matrix_coeff'] = $sps->getAttribute("matrix_coeffs");
$mediaProfileParameters['color_primaries'] = hexdec(
$sps->getAttribute("colour_primaries")
);
$mediaProfileParameters['transfer_char'] = hexdec(
$sps->getAttribute("transfer_characteristics")
);
$mediaProfileParameters['matrix_coeff'] = hexdec(
$sps->getAttribute("matrix_coeffs")
);
} elseif ($sps->getAttribute("colour_description_present_flag") == "0") {
$mediaProfileParameters['color_primaries'] = "1";
$mediaProfileParameters['transfer_char'] = "1";
$mediaProfileParameters['matrix_coeff'] = "1";
$mediaProfileParameters['color_primaries'] = 1;
$mediaProfileParameters['transfer_char'] = 1;
$mediaProfileParameters['matrix_coeff'] = 1;
}
}
if ($sps->getAttribute("vui_timing_info_present_flag") == "1") {
Expand Down Expand Up @@ -142,8 +154,8 @@
$mediaProfileParameters['codec'] = "AAC";
$decoderSpecificInfo = $audioSampleDescription->getElementsByTagName("DecoderSpecificInfo")->item(0);
$mediaProfileParameters['sampleRate'] = $audioSampleDescription->getAttribute('sampleRate');
$mediaProfileParameters['profile'] = $decoderSpecificInfo->getAttribute("audioObjectType");
$mediaProfileParameters['channels'] = $decoderSpecificInfo->getAttribute("channelConfig");
$mediaProfileParameters['profile'] = hexdec($decoderSpecificInfo->getAttribute("audioObjectType"));
$mediaProfileParameters['channels'] = hexdec($decoderSpecificInfo->getAttribute("channelConfig"));

if (strpos($compatibleBrands, "caaa") !== false) {
$mediaProfileParameters['brand'] = "caaa";
Expand Down
4 changes: 2 additions & 2 deletions CMAF/impl/getAudioTrackMediaProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"CMAF",
"Section 10.4",
"Each AAC elementary stream SHALL be encoded using MPEG-4 AAC LC, HE-AAC Level 2, or HE-AACv2 Level 2",
in_array($mpParameters['profile'], array("0x02", "0x05", "0x1d")),
in_array($mpParameters['profile'], array(2, 5, 29)),
"FAIL",
"Valid profile found",
"Nonvalid profile found"
Expand Down Expand Up @@ -38,7 +38,7 @@
"CMAF",
"Section 10.4",
"AAC Core CMAF tracks SHALL not exceed two audio channels",
$mpParameters['channels'] == "0x1" || $mpParameters['channels'] == "0x2",
$mpParameters['channels'] == 1 || $mpParameters['channels'] == 2,
"FAIL",
"Valid channel count found",
"Nonvalid channel count found"
Expand Down
55 changes: 27 additions & 28 deletions CMAF/impl/getVideoTrackMediaProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

$level = $mpParameters['level'];
$profile = $mpParameters['profile'];
$colorPrimaries = $mpParameters['color_primaries'];
$transferCharacteristics = $mpParameters['transfer_char'];
$matrixCoefficients = $mpParameters['matrix_coeff'];
$height = $mpParameters['height'];
Expand Down Expand Up @@ -38,9 +37,9 @@
$mpParameters,
"A.2",
"A.1",
array("0x1","0x5","0x6"),
array("0x1","0x6"),
array("0x1","0x5","0x6"),
array(1,5,6),
array(1,6),
array(1,5,6),
576,
864,
60
Expand All @@ -56,9 +55,9 @@
$mpParameters,
"A.2",
"A.1",
array("0x1"),
array("0x1"),
array("0x1"),
array(1),
array(1),
array(1),
1080,
1920,
60
Expand All @@ -74,9 +73,9 @@
$mpParameters,
"A.2",
"A.1",
array("0x1"),
array("0x1"),
array("0x1"),
array(1),
array(1),
array(1),
1080,
1920,
60
Expand Down Expand Up @@ -138,9 +137,9 @@
$mpParameters,
"B.5",
"B.1",
array("0x1"),
array("0x1"),
array("0x1"),
array(1),
array(1),
array(1),
1080,
1920,
60
Expand All @@ -156,9 +155,9 @@
$mpParameters,
"B.5",
"B.1",
array("0x1"),
array("0x1"),
array("0x1"),
array(1),
array(1),
array(1),
2160,
3840,
60
Expand Down Expand Up @@ -193,9 +192,9 @@
$mpParameters,
"B.5",
"B.1",
array("0x1"),
array("0x1"),
array("0x1"),
array(1),
array(1),
array(1),
1080,
1920,
60
Expand All @@ -211,9 +210,9 @@
$mpParameters,
"B.5",
"B.1",
array("0x1", "0x9"),
array("0x1", "0x14", "0x15"),
array("0x1", "0x9", "0x10"),
array(1, 9),
array(1, 20, 21),
array(1, 9, 16),
2160,
3840,
60
Expand All @@ -233,9 +232,9 @@
$mpParameters,
"B.5",
"B.1",
array("0x9"),
array("0x16"),
array("0x9", "0x10"),
array(9),
array(22),
array(9, 16),
2160,
3840,
60
Expand All @@ -249,9 +248,9 @@
$mpParameters,
"B.5",
"B.1",
array("0x9"),
array("0x14","0x18"),
array("0x9"),
array(9),
array(20,24),
array(9),
2160,
3840,
60
Expand Down
Loading

0 comments on commit eb62f0c

Please sign in to comment.