Add a way to force the 'hvc1' fourCC until a better solution is developed.
This commit is contained in:
3 files changed
+30
-3
No files matched your search
@@ -41,6 +41,7 @@ extern "C" {
|
||||
int analyze_AVC(const uint8_t *cookie, uint32_t cookieLen);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1199,7 +1199,7 @@ typedef struct HEVCConfig {
|
||||
struct NAL_units *NAL_units;
|
||||
} 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;
|
||||
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);
|
||||
|
||||
try {
|
||||
info->configurationVersion = b.GetBits(8);
|
||||
if (forceCompleteness) {
|
||||
b.PutBits(1, 8);
|
||||
} else {
|
||||
info->configurationVersion = b.GetBits(8);
|
||||
}
|
||||
info->general_profile_space = b.GetBits(2);
|
||||
info->general_tier_flag = b.GetBits(1);
|
||||
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++) {
|
||||
bool unitIsComplete = true;
|
||||
u_int32_t completenessPos = b.GetBitPosition();
|
||||
|
||||
info->NAL_units[j].array_completeness = b.GetBits(1);
|
||||
|
||||
if (info->NAL_units[j].array_completeness == 0) {
|
||||
unitIsComplete = false;
|
||||
}
|
||||
@@ -1258,7 +1265,14 @@ int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
||||
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_PPS) {
|
||||
complete = unitIsComplete;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
for (UInt8 i = 0; i < info->NAL_units[j].numNalus; i++) {
|
||||
@@ -1278,3 +1292,12 @@ int analyze_HEVC(const uint8_t *cookie, uint32_t cookieLen, bool *completeness)
|
||||
|
||||
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]] &&
|
||||
(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.
|
||||
bool completeness = 0;
|
||||
if (magicCookie.length && !analyze_HEVC(magicCookie.bytes, magicCookie.length, &completeness)) {
|
||||
|
||||
Reference in new issue
Block a user