Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/LibISDB/Filters/TSPacketParserFilter.cpp b/LibISDB/Filters/TSPacketParserFilter.cpp
- index f76916c..8e4eb7c 100644
- --- a/LibISDB/Filters/TSPacketParserFilter.cpp
- +++ b/LibISDB/Filters/TSPacketParserFilter.cpp
- @@ -42,6 +42,8 @@ TSPacketParserFilter::TSPacketParserFilter()
- , m_OutputErrorPacket(false)
- , m_Generate1SegPAT(true)
- + , m_SlotNum(0)
- +
- , m_InputBytes(0)
- , m_TotalInputBytes(0)
- {
- @@ -70,6 +72,8 @@ void TSPacketParserFilter::Reset()
- m_PacketSequence.SetDataCount(0);
- m_OutOfSyncCount = 0;
- + m_SlotNum = 0;
- +
- m_PATGenerator.Reset();
- }
- @@ -256,7 +260,17 @@ void TSPacketParserFilter::SyncPacket(const uint8_t *pData, size_t Size)
- if (CurSize == TS_PACKET_SIZE) {
- // パケットサイズ分データが揃った
- - const TSPacket::ParseResult Result = m_Packet.ParsePacket(m_ContinuityCounter.data());
- + bool processSlot = true;
- + if (m_SlotNum > 0) {
- + // スロット数が半分未満のものは処理しない
- + if (m_SlotCounter[m_TsNum[m_SlotNum]] < 26) {
- + processSlot = false;
- + }
- + if (++m_SlotNum == 53) {
- + m_SlotNum = 0;// フレーム終了
- + }
- + }
- + const TSPacket::ParseResult Result = m_Packet.ParsePacket(processSlot ? m_ContinuityCounter.data() : nullptr);
- if ((m_OutOfSyncCount > TS_PACKET_SIZE_MAX - TS_PACKET_SIZE)
- && ((Result == TSPacket::ParseResult::FormatError)
- @@ -270,11 +284,16 @@ void TSPacketParserFilter::SyncPacket(const uint8_t *pData, size_t Size)
- break;
- }
- }
- - if (Resync)
- + if (Resync) {
- + m_SlotNum = 0;// フレームをリセット
- continue;
- + }
- }
- - ProcessPacket(Result);
- + if (processSlot)
- + ProcessPacket(Result);
- + else
- + m_Packet.ClearSize();
- m_OutOfSyncCount = 0;
- }
- @@ -297,6 +316,33 @@ void TSPacketParserFilter::ProcessPacket(TSPacket::ParseResult Result)
- [[fallthrough]];
- case TSPacket::ParseResult::OK:
- {
- + if (PID == 0x002F_u16) {
- + // 多重フレームヘッダのチェック
- + uint8_t* FrameHeader = m_Packet.GetData();
- + // 多重フレーム同期情報(+4)
- + uint16_t framesync = ((uint16_t)(FrameHeader[4] & 0x1F) << 8) | (uint16_t)FrameHeader[5];
- + //多重フレーム形式の種別(+6)
- + // 0x1 多重フレーム数 53 / 最大多重ストリーム数 15
- + uint8_t framemode = FrameHeader[6] & 0x0F_u8;
- + if (framemode == 1 && (framesync == 0x1A86_u16 || framesync == 0x0579_u16)) {
- + m_SlotNum = 1;
- + //相対ストリーム番号/スロット対応情報(+73)
- + size_t offset = 73;
- + m_SlotCounter.fill(0);
- + size_t slot = 1;
- + do {
- + m_TsNum[slot] = (FrameHeader[offset] & 0xF0_u8) >> 4;
- + ++m_SlotCounter[m_TsNum[slot]];
- + ++slot;
- + m_TsNum[slot] = FrameHeader[offset] & 0x0F_u8;
- + ++m_SlotCounter[m_TsNum[slot]];
- + ++slot;
- + } while (++offset < 99);
- +
- + break;
- + }
- + }
- +
- ++m_PIDPacketCount[PID].Input;
- if (m_Packet.IsScrambled()) {
- diff --git a/LibISDB/Filters/TSPacketParserFilter.hpp b/LibISDB/Filters/TSPacketParserFilter.hpp
- index c8de156..db5cb56 100644
- --- a/LibISDB/Filters/TSPacketParserFilter.hpp
- +++ b/LibISDB/Filters/TSPacketParserFilter.hpp
- @@ -115,6 +115,10 @@ namespace LibISDB
- DataStreamSequence<TSPacket> m_PacketSequence;
- size_t m_OutOfSyncCount;
- + uint8_t m_SlotNum;
- + std::array<uint8_t, 52 + 1> m_TsNum;
- + std::array<uint8_t, 16> m_SlotCounter;
- +
- bool m_OutputSequence;
- size_t m_MaxSequencePacketCount;
- bool m_OutputNullPacket;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement