Skip to content

Commit

Permalink
Reorder AVC parameter set availability calculation
Browse files Browse the repository at this point in the history
Signal access to parameter sets in every access unit over the other
availability flags.

Signal access to a parameter set in every GOP over only present in the
first access unit if there is only 1 GOP.
  • Loading branch information
philipnbbc committed Sep 4, 2024
1 parent 4fd447e commit 75a3a9d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/writer_helper/AVCWriterHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void AVCWriterHelper::ProcessFrame(const unsigned char *data, uint32_t size)
mSPSEveryAU = true;
mSPSGOPStart = gop_start;
}

if (mEssenceParser.FrameHasActivePPS()) {
mPPSFirstAUOnly = true;
mPPSEveryAU = true;
Expand All @@ -267,6 +268,7 @@ void AVCWriterHelper::ProcessFrame(const unsigned char *data, uint32_t size)
if (gop_start)
mSPSGOPStart = false;
}

if (mEssenceParser.FrameHasActivePPS()) {
if (mPPSConstant && !mEssenceParser.IsActivePPSDataConstant())
mPPSConstant = false;
Expand All @@ -286,6 +288,7 @@ void AVCWriterHelper::ProcessFrame(const unsigned char *data, uint32_t size)
} else {
mSPSEveryAU = false;
}

if (mEssenceParser.SecondFieldHasActivePPS()) {
if (mPPSConstant && !mEssenceParser.IsActivePPSDataConstant())
mPPSConstant = false;
Expand Down Expand Up @@ -599,12 +602,13 @@ uint8_t AVCWriterHelper::GetSPSFlag() const
uint8_t flag = 0;
if (mSPSConstant)
flag |= 1 << 7;
if (mSPSFirstAUOnly)
flag |= 1 << 4;
else if (mSPSEveryAU)

if (mSPSEveryAU)
flag |= 2 << 4;
else if (mSPSGOPStart)
flag |= 3 << 4;
else if (mSPSFirstAUOnly)
flag |= 1 << 4;

return flag;
}
Expand All @@ -614,12 +618,13 @@ uint8_t AVCWriterHelper::GetPPSFlag() const
uint8_t flag = 0;
if (mPPSConstant)
flag |= 1 << 7;
if (mPPSFirstAUOnly)
flag |= 1 << 4;
else if (mPPSEveryAU)

if (mPPSEveryAU)
flag |= 2 << 4;
else if (mPPSGOPStart)
flag |= 3 << 4;
else if (mPPSFirstAUOnly)
flag |= 1 << 4;

return flag;
}

0 comments on commit 75a3a9d

Please sign in to comment.