12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- From 441247d84e8493a49d234fe062100b049956de90 Mon Sep 17 00:00:00 2001
- From: peak3d <pfau@peak3d.de>
- Date: Thu, 22 Jul 2021 10:34:42 +0200
- Subject: [PATCH] Implement SPS Frame parser
- Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
- ---
- Source/C++/Codecs/Ap4AvcParser.cpp | 26 ++++++++++++++++++++++++++
- Source/C++/Codecs/Ap4AvcParser.h | 5 +++++
- 2 files changed, 31 insertions(+)
- diff --git a/Source/C++/Codecs/Ap4AvcParser.cpp b/Source/C++/Codecs/Ap4AvcParser.cpp
- index 7f4fc34..cfa841d 100644
- --- a/Source/C++/Codecs/Ap4AvcParser.cpp
- +++ b/Source/C++/Codecs/Ap4AvcParser.cpp
- @@ -1112,6 +1112,32 @@ AP4_AvcFrameParser::AppendNalUnitData(const unsigned char* data, unsigned int da
- m_AccessUnitData.Append(new AP4_DataBuffer(data, data_size));
- }
-
- +/*----------------------------------------------------------------------
- +| AP4_AvcFrameParser::Feed
- ++---------------------------------------------------------------------*/
- +AP4_Result AP4_AvcFrameParser::ParseFrameForSPS(const AP4_Byte* data, AP4_Size data_size, AP4_UI08 naluLengthSize, AP4_AvcSequenceParameterSet &sps)
- +{
- + if (data_size < naluLengthSize)
- + return AP4_ERROR_EOS;
- +
- + while (data_size > naluLengthSize)
- + {
- + AP4_Size nalSize(0);
- + for (unsigned int i(0); i < naluLengthSize; ++i) { nalSize = (nalSize << 8) + *data++; };
- + data_size -= naluLengthSize;
- + if (nalSize > data_size)
- + return AP4_ERROR_INVALID_PARAMETERS;
- +
- + if ((*data & 0x1F) == AP4_AVC_NAL_UNIT_TYPE_SPS)
- + {
- + AP4_AvcFrameParser fp;
- + return fp.ParseSPS(data, data_size, sps);
- + }
- + data_size -= nalSize;
- + }
- + return AP4_SUCCESS;
- +}
- +
- /*----------------------------------------------------------------------
- | AP4_AvcFrameParser::Feed
- +---------------------------------------------------------------------*/
- diff --git a/Source/C++/Codecs/Ap4AvcParser.h b/Source/C++/Codecs/Ap4AvcParser.h
- index 431a294..99c5320 100644
- --- a/Source/C++/Codecs/Ap4AvcParser.h
- +++ b/Source/C++/Codecs/Ap4AvcParser.h
- @@ -258,6 +258,11 @@ public:
- AP4_AvcFrameParser();
- ~AP4_AvcFrameParser();
-
- + static AP4_Result ParseFrameForSPS(const AP4_Byte* data,
- + AP4_Size data_size,
- + AP4_UI08 naluLengthSize,
- + AP4_AvcSequenceParameterSet &sps);
- +
- /**
- * Feed some data to the parser and look for the next NAL Unit.
- *
- --
- 2.30.2
|