From dccba0e95aaafab8039e4ec18d2b47c17d8e0e59 Mon Sep 17 00:00:00 2001 From: jcdr428 Date: Thu, 10 Aug 2023 18:32:04 +0100 Subject: [PATCH] Tidy-up header files --- tsMuxer/BufferedReader.h | 1 - tsMuxer/abstractDemuxer.h | 3 +-- tsMuxer/abstractreader.h | 5 ----- tsMuxer/avCodecs.h | 3 --- tsMuxer/bitStream.h | 6 +++--- tsMuxer/blank_patterns.h | 8 ++++---- tsMuxer/blurayHelper.cpp | 1 - tsMuxer/bufferedFileReader.h | 6 +----- tsMuxer/bufferedFileWriter.h | 2 -- tsMuxer/bufferedReaderManager.h | 2 -- tsMuxer/combinedH264Demuxer.h | 4 +--- tsMuxer/convertUTF.h | 4 ++++ tsMuxer/dtsStreamReader.h | 2 -- tsMuxer/dvbSubStreamReader.h | 4 ---- tsMuxer/h264StreamReader.h | 1 - tsMuxer/hevc.h | 3 +-- tsMuxer/ioContextDemuxer.h | 6 +----- tsMuxer/iso_writer.h | 28 ++++++++++++++-------------- tsMuxer/matroskaDemuxer.h | 4 ++-- tsMuxer/matroskaParser.h | 2 -- tsMuxer/mlpCodec.h | 4 ++-- tsMuxer/movDemuxer.h | 2 -- tsMuxer/mpegVideo.h | 10 ++-------- 23 files changed, 36 insertions(+), 75 deletions(-) diff --git a/tsMuxer/BufferedReader.h b/tsMuxer/BufferedReader.h index df3b6ce7..8bf21527 100644 --- a/tsMuxer/BufferedReader.h +++ b/tsMuxer/BufferedReader.h @@ -3,7 +3,6 @@ #include #include -#include #include #include diff --git a/tsMuxer/abstractDemuxer.h b/tsMuxer/abstractDemuxer.h index d905e582..5a74fcb7 100644 --- a/tsMuxer/abstractDemuxer.h +++ b/tsMuxer/abstractDemuxer.h @@ -2,7 +2,6 @@ #define ABSTRACT_DEMUXER_H_ #include -#include #include #include @@ -39,7 +38,7 @@ class MemoryBlock m_size += num; if (m_data.size() < m_size) { - m_data.resize(FFMIN(m_size * 2, m_size + 1024 * 1024)); + m_data.resize(FFMIN(m_size * 2, m_size + 1024LL * 1024)); } } diff --git a/tsMuxer/abstractreader.h b/tsMuxer/abstractreader.h index 4ecd279c..d84fc6d9 100644 --- a/tsMuxer/abstractreader.h +++ b/tsMuxer/abstractreader.h @@ -1,13 +1,8 @@ #ifndef ABSTRACT_READER_H_ #define ABSTRACT_READER_H_ -#include - #include -#include "abstractDemuxer.h" -#include "avPacket.h" - struct CodecInfo; typedef std::string translateStreamName(const std::string& streamName); diff --git a/tsMuxer/avCodecs.h b/tsMuxer/avCodecs.h index 4127dd7e..a54a29ac 100644 --- a/tsMuxer/avCodecs.h +++ b/tsMuxer/avCodecs.h @@ -2,11 +2,8 @@ #define AV_CODECS_H_ #include - #include -#include "avPacket.h" - static constexpr int CODEC_ID_NONE = 0; static constexpr int CODEC_V_MPEG4_H264 = 1; static constexpr int CODEC_A_AAC = 2; diff --git a/tsMuxer/bitStream.h b/tsMuxer/bitStream.h index 066f9c80..db2a6d4a 100644 --- a/tsMuxer/bitStream.h +++ b/tsMuxer/bitStream.h @@ -74,7 +74,7 @@ class BitStreamReader : public BitStream m_bitLeft += INT_BIT - num; } m_totalBits -= num; - return prevVal + (m_curVal >> m_bitLeft) & m_masks[num]; + return static_cast(prevVal + (m_curVal >> m_bitLeft) & m_masks[num]); } unsigned get32Bits() @@ -110,7 +110,7 @@ class BitStreamReader : public BitStream curVal = getCurVal(m_buffer + 1); bitLeft += INT_BIT - num; } - return prevVal + (curVal >> bitLeft) & m_masks[num]; + return static_cast(prevVal + (curVal >> bitLeft) & m_masks[num]); } int getBit() @@ -126,7 +126,7 @@ class BitStreamReader : public BitStream m_bitLeft = INT_BIT - 1; } m_totalBits--; - return (m_curVal >> m_bitLeft) & 1; + return static_cast(m_curVal >> m_bitLeft) & 1; } void skipBits(const unsigned num) diff --git a/tsMuxer/blank_patterns.h b/tsMuxer/blank_patterns.h index ba7d820e..d434c22c 100644 --- a/tsMuxer/blank_patterns.h +++ b/tsMuxer/blank_patterns.h @@ -1,7 +1,7 @@ #ifndef BLANK_PATTERNS_H_ #define BLANK_PATTERNS_H_ -uint8_t pattern_ntsc[] = { +inline uint8_t pattern_ntsc[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x4D, 0x40, 0x29, 0xB9, 0x10, 0x16, 0x87, 0xB4, 0x20, 0x01, 0x00, 0x00, 0x03, 0x00, 0x2F, 0xF3, 0xB6, 0x51, 0xE3, 0x06, 0x54, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0x80, @@ -20,7 +20,7 @@ uint8_t pattern_ntsc[] = { 0x00, 0x00, 0x00, 0x01, 0x41, 0x9A, 0x18, 0x6C, 0x86, 0xBF, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0C, 0x08}; -uint8_t pattern_pal[] = { +inline uint8_t pattern_pal[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x4D, 0x40, 0x29, 0xB9, 0x10, 0x16, 0x82, 0x4D, 0x08, 0x00, 0x40, 0x00, 0x00, 0x0B, 0xFC, 0xED, 0x94, 0x78, 0xC1, 0x95, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0x80, @@ -40,7 +40,7 @@ uint8_t pattern_pal[] = { 0x00, 0x00, 0x00, 0x01, 0x41, 0x9A, 0x18, 0x6C, 0x86, 0xBF, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x02}; -uint8_t pattern_1280[] = { +inline uint8_t pattern_1280[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x4D, 0x40, 0x29, 0xB9, 0x10, 0x0A, 0x00, 0xB7, 0x42, 0x00, 0x10, 0x00, 0x00, 0x03, 0x02, 0xFF, 0x3B, 0x65, 0x1E, 0x30, 0x65, 0x40, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0x80, 0x00, @@ -65,7 +65,7 @@ uint8_t pattern_1280[] = { 0x00, 0x00, 0x00, 0x01, 0x41, 0x9A, 0x18, 0x6C, 0x86, 0xBF, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x01, 0x2F}; -uint8_t pattern_1920[] = { +inline uint8_t pattern_1920[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x4D, 0x40, 0x29, 0xB9, 0x10, 0x0F, 0x00, 0x44, 0xFC, 0xB0, 0x80, 0x04, 0x00, 0x00, 0x03, 0x00, 0xBF, 0xCE, 0xD9, 0x47, 0x8C, 0x19, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0x80, diff --git a/tsMuxer/blurayHelper.cpp b/tsMuxer/blurayHelper.cpp index 46785aad..b69d6567 100644 --- a/tsMuxer/blurayHelper.cpp +++ b/tsMuxer/blurayHelper.cpp @@ -1,7 +1,6 @@ #include "blurayHelper.h" #include - #include #include "iso_writer.h" diff --git a/tsMuxer/bufferedFileReader.h b/tsMuxer/bufferedFileReader.h index 6374df3e..ab2ed5e3 100644 --- a/tsMuxer/bufferedFileReader.h +++ b/tsMuxer/bufferedFileReader.h @@ -3,7 +3,6 @@ #include #include -#include #include #include "BufferedReader.h" @@ -55,10 +54,7 @@ struct FileReaderData : public ReaderData uint32_t readBlock(uint8_t* buffer, const int max_size) override { - int rez = 0; - rez = m_file.read(buffer, max_size); - - return rez; + return m_file.read(buffer, max_size); } bool openStream() override; diff --git a/tsMuxer/bufferedFileWriter.h b/tsMuxer/bufferedFileWriter.h index 8972684b..ce19e0ee 100644 --- a/tsMuxer/bufferedFileWriter.h +++ b/tsMuxer/bufferedFileWriter.h @@ -6,8 +6,6 @@ #include #include -#include - #include "vod_common.h" constexpr unsigned WRITE_QUEUE_MAX_SIZE = 400 * 1024 * 1024 / DEFAULT_FILE_BLOCK_SIZE; // 400 Mb max queue size diff --git a/tsMuxer/bufferedReaderManager.h b/tsMuxer/bufferedReaderManager.h index 0115529f..f2f7b705 100644 --- a/tsMuxer/bufferedReaderManager.h +++ b/tsMuxer/bufferedReaderManager.h @@ -1,8 +1,6 @@ #ifndef BUFFERED_READER_MANAGER_H_ #define BUFFERED_READER_MANAGER_H_ -#include - #include #include "bufferedFileReader.h" diff --git a/tsMuxer/combinedH264Demuxer.h b/tsMuxer/combinedH264Demuxer.h index 03508c32..9e239e9a 100644 --- a/tsMuxer/combinedH264Demuxer.h +++ b/tsMuxer/combinedH264Demuxer.h @@ -2,10 +2,8 @@ #define COMBINED_H264_DEMUXER_H #include -#include #include -#include "BufferedReader.h" #include "abstractDemuxer.h" #include "abstractreader.h" #include "bufferedReaderManager.h" @@ -61,7 +59,7 @@ class CombinedH264Demuxer : public AbstractDemuxer, public CombinedH264Reader bool isPidFilterSupported() const override { return true; } private: - BufferedReaderManager& m_readManager; + BufferedReaderManager m_readManager; AbstractReader* m_bufferedReader; int m_readerID; int m_lastReadRez; diff --git a/tsMuxer/convertUTF.h b/tsMuxer/convertUTF.h index 391e0906..0013ce0f 100644 --- a/tsMuxer/convertUTF.h +++ b/tsMuxer/convertUTF.h @@ -1,3 +1,6 @@ +#ifndef CONVERT_UTF_ +#define CONVERT_UTF_ + /* * Copyright 2001-2004 Unicode, Inc. * @@ -212,4 +215,5 @@ void IterateUTF8Chars(const std::string& utf8String, Fn f) } // namespace convertUTF +#endif /* --------------------------------------------------------------------- */ diff --git a/tsMuxer/dtsStreamReader.h b/tsMuxer/dtsStreamReader.h index 959369b7..bbd8c16c 100644 --- a/tsMuxer/dtsStreamReader.h +++ b/tsMuxer/dtsStreamReader.h @@ -1,8 +1,6 @@ #ifndef DTS_STREAM_READER_ #define DTS_STREAM_READER_ -#include - #include "simplePacketizerReader.h" class DTSStreamReader : public SimplePacketizerReader diff --git a/tsMuxer/dvbSubStreamReader.h b/tsMuxer/dvbSubStreamReader.h index e4d85fec..c0aa9802 100644 --- a/tsMuxer/dvbSubStreamReader.h +++ b/tsMuxer/dvbSubStreamReader.h @@ -3,8 +3,6 @@ #include "simplePacketizerReader.h" -#if 1 - class DVBSubStreamReader final : public SimplePacketizerReader { public: @@ -40,5 +38,3 @@ class DVBSubStreamReader final : public SimplePacketizerReader }; #endif - -#endif diff --git a/tsMuxer/h264StreamReader.h b/tsMuxer/h264StreamReader.h index 541c92df..eced3e92 100644 --- a/tsMuxer/h264StreamReader.h +++ b/tsMuxer/h264StreamReader.h @@ -1,7 +1,6 @@ #ifndef H264_STREAM_READER_H_ #define H264_STREAM_READER_H_ -#include #include #include "avPacket.h" diff --git a/tsMuxer/hevc.h b/tsMuxer/hevc.h index 2afce193..b0e9e90c 100644 --- a/tsMuxer/hevc.h +++ b/tsMuxer/hevc.h @@ -10,8 +10,7 @@ struct HevcUnit nuh_layer_id(0), nuh_temporal_id_plus1(0), m_nalBuffer(nullptr), - m_nalBufferLen(0), - m_reader() + m_nalBufferLen(0) { } diff --git a/tsMuxer/ioContextDemuxer.h b/tsMuxer/ioContextDemuxer.h index b1f2bd2e..1f1d094e 100644 --- a/tsMuxer/ioContextDemuxer.h +++ b/tsMuxer/ioContextDemuxer.h @@ -1,10 +1,6 @@ #ifndef IO_CONTEXT_DEMUXER_H_ #define IO_CONTEXT_DEMUXER_H_ -#include -#include -#include -#include #include #include "BufferedReader.h" @@ -103,7 +99,7 @@ class IOContextDemuxer : public AbstractDemuxer Track* tracks[MAX_STREAMS]; int num_tracks; - BufferedReaderManager& m_readManager; + BufferedReaderManager m_readManager; AbstractReader* m_bufferedReader; int m_readerID; int m_lastReadRez; diff --git a/tsMuxer/iso_writer.h b/tsMuxer/iso_writer.h index 9c0164f6..3242117c 100644 --- a/tsMuxer/iso_writer.h +++ b/tsMuxer/iso_writer.h @@ -6,24 +6,24 @@ #include #include -static const int SECTOR_SIZE = 2048; -static const int ALLOC_BLOCK_SIZE = 1024 * 64; -static const int METADATA_START_ADDR = 1024 * 640 / SECTOR_SIZE; -static const int MAX_EXTENT_SIZE = 0x40000000; -static const uint32_t NEXT_EXTENT = 0xc0000000; +static constexpr int SECTOR_SIZE = 2048; +static constexpr int ALLOC_BLOCK_SIZE = 1024 * 64; +static constexpr int METADATA_START_ADDR = 1024 * 640 / SECTOR_SIZE; +static constexpr int MAX_EXTENT_SIZE = 0x40000000; +static constexpr uint32_t NEXT_EXTENT = 0xc0000000; -static const int64_t META_BLOCK_PER_DATA = 16 * 1000000000ll; +static constexpr int64_t META_BLOCK_PER_DATA = 16 * 1000000000ll; // it can be allocated inside single sector of a extended file -static const unsigned MAX_EXTENTS_IN_EXTFILE = (SECTOR_SIZE - 216 - 32) / 16; -static const unsigned MAX_EXTENTS_IN_EXTCONT = (SECTOR_SIZE - 24 - 32) / 16; +static constexpr unsigned MAX_EXTENTS_IN_EXTFILE = (SECTOR_SIZE - 216 - 32) / 16; +static constexpr unsigned MAX_EXTENTS_IN_EXTCONT = (SECTOR_SIZE - 24 - 32) / 16; -static const int MAIN_INTERLEAVE_BLOCKSIZE = 6144 * 3168; -static const int SUB_INTERLEAVE_BLOCKSIZE = 6144 * 1312; +static constexpr int MAIN_INTERLEAVE_BLOCKSIZE = 6144 * 3168; +static constexpr int SUB_INTERLEAVE_BLOCKSIZE = 6144 * 1312; -static const int MAX_MAIN_MUXER_RATE = 48000000; -static const int MAX_4K_MUXER_RATE = 109000000; -static const int MAX_SUBMUXER_RATE = 35000000; +static constexpr int MAX_MAIN_MUXER_RATE = 48000000; +static constexpr int MAX_4K_MUXER_RATE = 109000000; +static constexpr int MAX_SUBMUXER_RATE = 35000000; enum class DescriptorTag { @@ -115,7 +115,7 @@ typedef std::vector ExtentList; struct MappingEntry { MappingEntry() : parentLBN(0), LBN(0) {} - MappingEntry(int _parentLBN, int _LBN) : parentLBN(_parentLBN), LBN(_LBN) {} + MappingEntry(const int _parentLBN, const int _lbn) : parentLBN(_parentLBN), LBN(_lbn) {} int parentLBN; int LBN; diff --git a/tsMuxer/matroskaDemuxer.h b/tsMuxer/matroskaDemuxer.h index 5fd49624..4fb5e25a 100644 --- a/tsMuxer/matroskaDemuxer.h +++ b/tsMuxer/matroskaDemuxer.h @@ -55,11 +55,11 @@ class MatroskaDemuxer : public IOContextDemuxer uint64_t segment_start; uint64_t created; - uint64_t fileDuration; + int64_t fileDuration; char *writing_app; char *muxing_app; uint64_t time_scale; - std::map m_firstTimecode; + std::map m_firstTimecode; bool index_parsed; bool metadata_parsed; int num_streams; diff --git a/tsMuxer/matroskaParser.h b/tsMuxer/matroskaParser.h index 2aabef65..ef88d752 100644 --- a/tsMuxer/matroskaParser.h +++ b/tsMuxer/matroskaParser.h @@ -6,10 +6,8 @@ #include "aac.h" #include "abstractStreamReader.h" -#include "avCodecs.h" #include "avPacket.h" #include "ioContextDemuxer.h" -#include "vod_common.h" typedef IOContextTrackType MatroskaTrackType; typedef Track MatroskaTrack; diff --git a/tsMuxer/mlpCodec.h b/tsMuxer/mlpCodec.h index 668472dd..aafadd43 100644 --- a/tsMuxer/mlpCodec.h +++ b/tsMuxer/mlpCodec.h @@ -1,8 +1,8 @@ -#include - #ifndef MLP_CODEC_H_ #define MLP_CODEC_H_ +#include + static constexpr int MLP_HEADER_LEN = 7; enum class MlpSubType diff --git a/tsMuxer/movDemuxer.h b/tsMuxer/movDemuxer.h index 33d3ace8..4332526a 100644 --- a/tsMuxer/movDemuxer.h +++ b/tsMuxer/movDemuxer.h @@ -2,12 +2,10 @@ #define MOV_DEMUXER_H_ #include -#include #include #include #include -#include "BufferedReader.h" #include "bufferedReaderManager.h" #include "ioContextDemuxer.h" diff --git a/tsMuxer/mpegVideo.h b/tsMuxer/mpegVideo.h index 93dc7056..05a03f44 100644 --- a/tsMuxer/mpegVideo.h +++ b/tsMuxer/mpegVideo.h @@ -5,8 +5,6 @@ #include -#include - #include "avPacket.h" #include "bitStream.h" #include "vod_common.h" @@ -47,14 +45,10 @@ class MPEGHeader // uint8_t* bufStart = buffer; for (buffer += 2; buffer < end;) { - if (*buffer > 1) - buffer += 3; - else if (*buffer == 0) + if (*buffer == 0) buffer++; - else if (buffer[-2] == 0 && buffer[-1] == 0) - { + else if (buffer[-2] == 0 && buffer[-1] == 0 && buffer[0] == 1) return buffer - 2; - } else buffer += 3; }