Add a way to force the 'hvc1' fourCC until a better solution is developed.
This commit is contained in:
3 files changed
+28
-1
No files matched your search
@@ -41,6 +41,7 @@ extern "C" {
|
|||||||
int analyze_AVC(const uint8_t *cookie, uint32_t cookieLen);
|
int analyze_AVC(const uint8_t *cookie, uint32_t cookieLen);
|
||||||
|
|
||||||
int analyze_HEVC(const uint8_t *frame, uint32_t cookieLen, bool *completeness);
|
int analyze_HEVC(const uint8_t *frame, uint32_t cookieLen, bool *completeness);
|
||||||
|
void force_HEVC_completeness(const uint8_t *cookie, uint32_t cookieLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1199,7 +1199,7 @@ typedef struct HEVCConfig {
|
|||||||
struct NAL_units *NAL_units;
|
struct NAL_units *NAL_units;
|
||||||
} HEVCConfig;
|
} HEVCConfig;
|
||||||
|
|
||||||
int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
int parse_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness, bool forceCompleteness)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
bool complete = true;
|
bool complete = true;
|
||||||
@@ -1211,7 +1211,11 @@ int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
|||||||
b.SetBytes((uint8_t *)cookie, cookieLen);
|
b.SetBytes((uint8_t *)cookie, cookieLen);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (forceCompleteness) {
|
||||||
|
b.PutBits(1, 8);
|
||||||
|
} else {
|
||||||
info->configurationVersion = b.GetBits(8);
|
info->configurationVersion = b.GetBits(8);
|
||||||
|
}
|
||||||
info->general_profile_space = b.GetBits(2);
|
info->general_profile_space = b.GetBits(2);
|
||||||
info->general_tier_flag = b.GetBits(1);
|
info->general_tier_flag = b.GetBits(1);
|
||||||
info->general_profile_idc = b.GetBits(5);
|
info->general_profile_idc = b.GetBits(5);
|
||||||
@@ -1245,7 +1249,10 @@ int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
|||||||
|
|
||||||
for (UInt8 j = 0; j < info->numOfArrays; j++) {
|
for (UInt8 j = 0; j < info->numOfArrays; j++) {
|
||||||
bool unitIsComplete = true;
|
bool unitIsComplete = true;
|
||||||
|
u_int32_t completenessPos = b.GetBitPosition();
|
||||||
|
|
||||||
info->NAL_units[j].array_completeness = b.GetBits(1);
|
info->NAL_units[j].array_completeness = b.GetBits(1);
|
||||||
|
|
||||||
if (info->NAL_units[j].array_completeness == 0) {
|
if (info->NAL_units[j].array_completeness == 0) {
|
||||||
unitIsComplete = false;
|
unitIsComplete = false;
|
||||||
}
|
}
|
||||||
@@ -1258,8 +1265,15 @@ int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
|||||||
if (info->NAL_units[j].NAL_unit_type == NAL_UNIT_VPS ||
|
if (info->NAL_units[j].NAL_unit_type == NAL_UNIT_VPS ||
|
||||||
info->NAL_units[j].NAL_unit_type == NAL_UNIT_SPS ||
|
info->NAL_units[j].NAL_unit_type == NAL_UNIT_SPS ||
|
||||||
info->NAL_units[j].NAL_unit_type == NAL_UNIT_PPS) {
|
info->NAL_units[j].NAL_unit_type == NAL_UNIT_PPS) {
|
||||||
|
if (forceCompleteness && info->NAL_units[j].numNalus > 0) {
|
||||||
|
u_int32_t currentPos = b.GetBitPosition();
|
||||||
|
b.SetBitPosition(completenessPos);
|
||||||
|
b.PutBits(1, 1);
|
||||||
|
b.SetBitPosition(currentPos);
|
||||||
|
} else {
|
||||||
complete = unitIsComplete;
|
complete = unitIsComplete;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (UInt8 i = 0; i < info->NAL_units[j].numNalus; i++) {
|
for (UInt8 i = 0; i < info->NAL_units[j].numNalus; i++) {
|
||||||
UInt16 nalUnitLength = b.GetBits(16);
|
UInt16 nalUnitLength = b.GetBits(16);
|
||||||
@@ -1278,3 +1292,12 @@ int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness) {
|
||||||
|
return parse_HEVC(cookie, cookieLen, completeness, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void force_HEVC_completeness(const uint8_t *cookie, uint32_t cookieLen) {
|
||||||
|
bool completeness = 0;
|
||||||
|
parse_HEVC(cookie, cookieLen, &completeness, true);
|
||||||
|
}
|
||||||
@@ -200,6 +200,9 @@
|
|||||||
else if ([track isMemberOfClass:[MP42VideoTrack class]] &&
|
else if ([track isMemberOfClass:[MP42VideoTrack class]] &&
|
||||||
(format == kMP42VideoCodecType_HEVC || format == kMP42VideoCodecType_HEVC_PSinBitstream)) {
|
(format == kMP42VideoCodecType_HEVC || format == kMP42VideoCodecType_HEVC_PSinBitstream)) {
|
||||||
|
|
||||||
|
uint8_t *hvcCAtom = (uint8_t *)magicCookie.bytes;
|
||||||
|
force_HEVC_completeness(hvcCAtom, magicCookie.length);
|
||||||
|
|
||||||
// Check whether we can use hvc1 or hev1 fourcc.
|
// Check whether we can use hvc1 or hev1 fourcc.
|
||||||
bool completeness = 0;
|
bool completeness = 0;
|
||||||
if (magicCookie.length && !analyze_HEVC(magicCookie.bytes, magicCookie.length, &completeness)) {
|
if (magicCookie.length && !analyze_HEVC(magicCookie.bytes, magicCookie.length, &completeness)) {
|
||||||
|
|||||||
Reference in new issue
Block a user