From 75a3a9d9092d7dc70322bcf75414e8eb5461065b Mon Sep 17 00:00:00 2001 From: Philip de Nier Date: Wed, 4 Sep 2024 12:18:28 +0100 Subject: [PATCH] Reorder AVC parameter set availability calculation 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. --- src/writer_helper/AVCWriterHelper.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/writer_helper/AVCWriterHelper.cpp b/src/writer_helper/AVCWriterHelper.cpp index 5dba0b50..fc2eebb7 100644 --- a/src/writer_helper/AVCWriterHelper.cpp +++ b/src/writer_helper/AVCWriterHelper.cpp @@ -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; @@ -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; @@ -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; @@ -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; } @@ -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; }