From f3c1d034c6e93e07be762809bc13cd5ab0fc3834 Mon Sep 17 00:00:00 2001 From: jcdr428 Date: Sun, 23 Jan 2022 11:25:30 +0100 Subject: [PATCH] Remove unused variables Also: Add parentheses to clarify precedence of && over || Put class members initialization in the same order as declaration --- tsMuxer/aac.cpp | 10 ++-- tsMuxer/ac3Codec.cpp | 14 ++--- tsMuxer/blurayHelper.cpp | 5 +- tsMuxer/bufferedFileWriter.cpp | 2 +- tsMuxer/bufferedFileWriter.h | 1 - tsMuxer/bufferedReader.cpp | 1 - tsMuxer/combinedH264Demuxer.cpp | 8 +-- tsMuxer/dtsStreamReader.cpp | 36 ++++++------ tsMuxer/dtsStreamReader.h | 6 +- tsMuxer/h264StreamReader.cpp | 13 +---- tsMuxer/hevc.cpp | 6 +- tsMuxer/hevcStreamReader.cpp | 7 +-- tsMuxer/ioContextDemuxer.cpp | 2 +- tsMuxer/iso_writer.cpp | 14 +---- tsMuxer/lpcmStreamReader.cpp | 3 - tsMuxer/matroskaDemuxer.cpp | 11 +--- tsMuxer/matroskaParser.cpp | 9 +-- tsMuxer/movDemuxer.cpp | 26 +++------ tsMuxer/mp3Codec.cpp | 10 ++-- tsMuxer/mpeg2StreamReader.cpp | 1 - tsMuxer/mpegAudioStreamReader.cpp | 2 +- tsMuxer/mpegStreamReader.h | 1 - tsMuxer/mpegVideo.cpp | 93 +++++++++++++++--------------- tsMuxer/muxerManager.cpp | 2 +- tsMuxer/nalUnits.cpp | 26 ++++----- tsMuxer/nalUnits.h | 13 ----- tsMuxer/programStreamDemuxer.cpp | 6 +- tsMuxer/simplePacketizerReader.cpp | 3 +- tsMuxer/srtStreamReader.cpp | 14 ++--- tsMuxer/textSubtitles.cpp | 15 ++--- tsMuxer/tsDemuxer.cpp | 34 +---------- tsMuxer/tsMuxer.cpp | 10 +--- tsMuxer/vc1Parser.h | 1 - tsMuxer/vvc.cpp | 21 ++++--- tsMuxer/vvcStreamReader.cpp | 4 +- 35 files changed, 151 insertions(+), 279 deletions(-) diff --git a/tsMuxer/aac.cpp b/tsMuxer/aac.cpp index 6ca5ec5..6fc3696 100644 --- a/tsMuxer/aac.cpp +++ b/tsMuxer/aac.cpp @@ -52,13 +52,11 @@ bool AACCodec::decodeFrame(uint8_t* buffer, uint8_t* end) bits.skipBit(); /* home */ /* adts_variable_header */ - bits.skipBit(); /* copyright_identification_bit */ - bits.skipBit(); /* copyright_identification_start */ - // -- 32 bit getted + bits.skipBit(); /* copyright_identification_bit */ + bits.skipBit(); /* copyright_identification_start */ int frameSize = bits.getBits(13); /* aac_frame_length */ - // LTRACE(LT_DEBUG, 0, "decodec frame size: " << m_size); - int adts_buffer_fullness = bits.getBits(11); /* adts_buffer_fullness */ - m_rdb = bits.getBits(2); /* number_of_raw_data_blocks_in_frame */ + bits.skipBits(11); /* adts_buffer_fullness */ + m_rdb = bits.getBits(2); /* number_of_raw_data_blocks_in_frame */ m_channels = aac_channels[m_channels_index]; m_sample_rate = aac_sample_rates[m_sample_rates_index]; diff --git a/tsMuxer/ac3Codec.cpp b/tsMuxer/ac3Codec.cpp index 5467782..4fb1c37 100644 --- a/tsMuxer/ac3Codec.cpp +++ b/tsMuxer/ac3Codec.cpp @@ -314,7 +314,6 @@ int AC3Codec::decodeFrame(uint8_t* buf, uint8_t* end, int& skipBytes) if (trueHDData[0] != 0x0B || trueHDData[1] != 0x77 || !testDecodeTestFrame(trueHDData, end)) { - uint8_t* tmpNextFrame = findFrame(buf + 7, end); m_waitMoreData = true; m_state = AC3State::stateDecodeTrueHDFirst; } @@ -388,7 +387,7 @@ AC3Codec::AC3ParseError AC3Codec::testParseHeader(uint8_t* buf, uint8_t* end) } else { - int test_crc1 = gbc.getBits(16); + gbc.skipBits(16); // test_crc1 int test_fscod = gbc.getBits(2); if (test_fscod == 3) return AC3ParseError::SAMPLE_RATE; @@ -407,13 +406,10 @@ AC3Codec::AC3ParseError AC3Codec::testParseHeader(uint8_t* buf, uint8_t* end) return AC3ParseError::SYNC; if ((test_acmod & 1) && test_acmod != AC3_ACMOD_MONO) - { - int test_cmixlev = gbc.getBits(2); - } + gbc.skipBits(2); // test_cmixlev + if (m_acmod & 4) - { - int test_surmixlev = gbc.getBits(2); - } + gbc.skipBits(2); // test_surmixlev if (m_acmod == AC3_ACMOD_STEREO) { @@ -432,7 +428,7 @@ AC3Codec::AC3ParseError AC3Codec::testParseHeader(uint8_t* buf, uint8_t* end) int test_channels = ff_ac3_channels[test_acmod] + test_lfeon; int test_frame_size = ff_ac3_frame_sizes[test_frmsizecod][test_fscod] * 2; if (test_halfratecod != m_halfratecod || test_sample_rate != m_sample_rate || test_bit_rate != m_bit_rate || - test_channels != m_channels /*|| test_frame_size != m_frame_size*/) + test_channels != m_channels || test_frame_size != m_frame_size) return AC3ParseError::SYNC; } return AC3ParseError::NO_ERROR; diff --git a/tsMuxer/blurayHelper.cpp b/tsMuxer/blurayHelper.cpp index c59e3f8..bf15747 100644 --- a/tsMuxer/blurayHelper.cpp +++ b/tsMuxer/blurayHelper.cpp @@ -266,7 +266,7 @@ bool writeBdMovieObjectData(const MuxerManager& muxer, AbstractOutputStream* fil // ------------------------- BlurayHelper --------------------------- -BlurayHelper::BlurayHelper() : m_isoWriter(0), m_dt() {} +BlurayHelper::BlurayHelper() : m_dt(), m_isoWriter(0) {} BlurayHelper::~BlurayHelper() { close(); } @@ -458,9 +458,6 @@ bool BlurayHelper::createCLPIFile(TSMuxer* muxer, int clpiNum, bool doLog) if (muxer->isInterleaveMode()) clpiParser.interleaveInfo = muxer->getInterleaveInfo(i); - double avDuration = (lastPts[i] - firstPts[i]) / 90000.0; - // clpiParser.TS_recording_rate = (packetCount[i] * 192) / avDuration; // avarage bitrate - if (muxer->isSubStream()) clpiParser.TS_recording_rate = MAX_SUBMUXER_RATE / 8; else diff --git a/tsMuxer/bufferedFileWriter.cpp b/tsMuxer/bufferedFileWriter.cpp index 8a6ce02..b037f2a 100644 --- a/tsMuxer/bufferedFileWriter.cpp +++ b/tsMuxer/bufferedFileWriter.cpp @@ -19,7 +19,7 @@ void WriterData::execute() }; } -BufferedFileWriter::BufferedFileWriter() : m_started(false), m_terminated(false), m_writeQueue(WRITE_QUEUE_MAX_SIZE) +BufferedFileWriter::BufferedFileWriter() : m_terminated(false), m_writeQueue(WRITE_QUEUE_MAX_SIZE) { m_lastErrorCode = 0; m_nothingToExecute = true; diff --git a/tsMuxer/bufferedFileWriter.h b/tsMuxer/bufferedFileWriter.h index 52d172e..932ece17 100644 --- a/tsMuxer/bufferedFileWriter.h +++ b/tsMuxer/bufferedFileWriter.h @@ -62,7 +62,6 @@ class BufferedFileWriter : public TerminatableThread bool m_nothingToExecute; int m_lastErrorCode; std::string m_lastErrorStr; - bool m_started; bool m_terminated; WaitableSafeQueue m_writeQueue; diff --git a/tsMuxer/bufferedReader.cpp b/tsMuxer/bufferedReader.cpp index 0265f52..d1d64d8 100644 --- a/tsMuxer/bufferedReader.cpp +++ b/tsMuxer/bufferedReader.cpp @@ -61,7 +61,6 @@ BufferedReader::~BufferedReader() join(); for (std::map::iterator itr = m_readers.begin(); itr != m_readers.end(); ++itr) { - int i = 0; ReaderData* pData = itr->second; delete pData; } diff --git a/tsMuxer/combinedH264Demuxer.cpp b/tsMuxer/combinedH264Demuxer.cpp index 9f34a26..bc8288a 100644 --- a/tsMuxer/combinedH264Demuxer.cpp +++ b/tsMuxer/combinedH264Demuxer.cpp @@ -15,7 +15,7 @@ static const int MAX_TMP_BUFFER_SIZE = 128; // ------------------------ CombinedH264Reader ------------------------------- -CombinedH264Reader::CombinedH264Reader() : m_demuxedPID(0), m_state(ReadState::Primary) +CombinedH264Reader::CombinedH264Reader() : m_state(ReadState::Primary), m_demuxedPID(0) { m_firstDemuxCall = true; m_mvcSPS = -1; @@ -120,7 +120,7 @@ void CombinedH264Reader::fillPids(const PIDSet& acceptedPIDs, int pid) // --------------------------------------------- CombinedH264Demuxer --------------------------- CombinedH264Demuxer::CombinedH264Demuxer(const BufferedReaderManager& readManager, const char* streamName) - : CombinedH264Reader(), AbstractDemuxer(), m_readManager(readManager) + : AbstractDemuxer(), CombinedH264Reader(), m_readManager(readManager) { m_bufferedReader = (const_cast(m_readManager)).getReader(streamName); m_readerID = m_bufferedReader->createReader(MAX_TMP_BUFFER_SIZE); @@ -233,8 +233,6 @@ void CombinedH264Demuxer::openFile(const std::string& streamName) { readClose(); - BufferedFileReader* fileReader = dynamic_cast(m_bufferedReader); - if (!m_bufferedReader->openStream(m_readerID, streamName.c_str())) THROW(ERR_FILE_NOT_FOUND, "Can't open stream " << streamName); @@ -256,7 +254,7 @@ void CombinedH264Demuxer::setFileIterator(FileNameIterator* itr) // ------------------------------ CombinedH264Filter ----------------------------------- -CombinedH264Filter::CombinedH264Filter(int demuxedPID) : CombinedH264Reader(), SubTrackFilter(demuxedPID) {} +CombinedH264Filter::CombinedH264Filter(int demuxedPID) : SubTrackFilter(demuxedPID), CombinedH264Reader() {} int CombinedH264Filter::demuxPacket(DemuxedData& demuxedData, const PIDSet& acceptedPIDs, AVPacket& avPacket) { diff --git a/tsMuxer/dtsStreamReader.cpp b/tsMuxer/dtsStreamReader.cpp index 0e87a69..a114839 100644 --- a/tsMuxer/dtsStreamReader.cpp +++ b/tsMuxer/dtsStreamReader.cpp @@ -2,16 +2,16 @@ #include -static const int DCA_EXT_CORE = 0x001; ///< core in core substream -static const int DCA_EXT_XXCH = 0x002; ///< XXCh channels extension in core substream -static const int DCA_EXT_X96 = 0x004; ///< 96/24 extension in core substream -static const int DCA_EXT_XCH = 0x008; ///< XCh channel extension in core substream -static const int DCA_EXT_EXSS_CORE = 0x010; ///< core in ExSS (extension substream) -static const int DCA_EXT_EXSS_XBR = 0x020; ///< extended bitrate extension in ExSS -static const int DCA_EXT_EXSS_XXCH = 0x040; ///< XXCh channels extension in ExSS -static const int DCA_EXT_EXSS_X96 = 0x080; ///< 96/24 extension in ExSS -static const int DCA_EXT_EXSS_LBR = 0x100; ///< low bitrate component in ExSS -static const int DCA_EXT_EXSS_XLL = 0x200; ///< lossless extension in ExSS +// static const int DCA_EXT_CORE = 0x001; ///< core in core substream +static const int DCA_EXT_XXCH = 0x002; ///< XXCh channels extension in core substream +static const int DCA_EXT_X96 = 0x004; ///< 96/24 extension in core substream +static const int DCA_EXT_XCH = 0x008; ///< XCh channel extension in core substream +// static const int DCA_EXT_EXSS_CORE = 0x010; ///< core in ExSS (extension substream) +// static const int DCA_EXT_EXSS_XBR = 0x020; ///< extended bitrate extension in ExSS +// static const int DCA_EXT_EXSS_XXCH = 0x040; ///< XXCh channels extension in ExSS +// static const int DCA_EXT_EXSS_X96 = 0x080; ///< 96/24 extension in ExSS +// static const int DCA_EXT_EXSS_LBR = 0x100; ///< low bitrate component in ExSS +// static const int DCA_EXT_EXSS_XLL = 0x200; ///< lossless extension in ExSS static const int dca_ext_audio_descr_mask[] = {DCA_EXT_XCH, -1, DCA_EXT_X96, DCA_EXT_XCH | DCA_EXT_X96, -1, -1, DCA_EXT_XXCH, -1}; @@ -51,10 +51,9 @@ static const int AOUT_CHAN_REARRIGHT = 0x40; static const int AOUT_CHAN_MIDDLELEFT = 0x100; static const int AOUT_CHAN_MIDDLERIGHT = 0x200; static const int AOUT_CHAN_LFE = 0x1000; - -static const int AOUT_CHAN_DOLBYSTEREO = 0x10000; +// static const int AOUT_CHAN_DOLBYSTEREO = 0x10000; static const int AOUT_CHAN_DUALMONO = 0x20000; -static const int AOUT_CHAN_REVERSESTEREO = 0x40000; +// static const int AOUT_CHAN_REVERSESTEREO = 0x40000; using namespace std; @@ -170,17 +169,16 @@ void DTSStreamReader::checkIfOnlyHDDataExists(uint8_t* buff, uint8_t* end) BitStreamReader reader{}; reader.setBuffer(buff + 5, end); // skip 4 byte magic and 1 unknown byte - int headerSize; int hdFrameSize; - int nuSubStreamIndex = reader.getBits(2); + reader.skipBits(2); // nuSubStreamIndex if (reader.getBit()) { - headerSize = reader.getBits(12) + 1; + reader.skipBits(12); // headerSize hdFrameSize = reader.getBits(20) + 1; } else { - headerSize = reader.getBits(8) + 1; + reader.skipBits(8); // headerSize hdFrameSize = reader.getBits(16) + 1; } buff += hdFrameSize; @@ -332,7 +330,7 @@ int DTSStreamReader::decodeHdInfo(uint8_t* buff, uint8_t* end) bool bStaticFieldsPresent = reader.getBit(); if (bStaticFieldsPresent) { - int nuRefClockCode = reader.getBits(2); + reader.skipBits(2); // nuRefClockCode int nuExSSFrameDurationCode = reader.getBits(3) + 1; if (pi_frame_length == 0) pi_frame_length = nuExSSFrameDurationCode << 9; @@ -355,7 +353,7 @@ int DTSStreamReader::decodeHdInfo(uint8_t* buff, uint8_t* end) } if (reader.getBit()) { - int nuMixMetadataAdjLevel = reader.getBits(2); + reader.skipBits(2); // nuMixMetadataAdjLevel int nuBits4MixOutMask = reader.getBits(2) * 4 + 4; int nuNumMixOutConfigs = reader.getBits(2) + 1; for (int i = 0; i < nuNumMixOutConfigs; i++) reader.skipBits(nuBits4MixOutMask); diff --git a/tsMuxer/dtsStreamReader.h b/tsMuxer/dtsStreamReader.h index 955010f..e9a87eb 100644 --- a/tsMuxer/dtsStreamReader.h +++ b/tsMuxer/dtsStreamReader.h @@ -27,9 +27,7 @@ class DTSStreamReader : public SimplePacketizerReader i_frame_size(0), pi_audio_mode(0), pi_bit_rate_index(0), - hd_pi_bit_rate_index(0), - pi_channels_conf(0), - hd_sample_rate(0) + pi_channels_conf(0) { pi_sample_rate_index = 0; pi_bit_rate = 0; @@ -112,7 +110,6 @@ class DTSStreamReader : public SimplePacketizerReader unsigned int hd_pi_sample_rate; unsigned int pi_sample_rate_index; unsigned int pi_bit_rate_index; - unsigned int hd_pi_bit_rate_index; unsigned int pi_bit_rate; unsigned int pi_frame_length; unsigned int pi_channels_conf; @@ -123,7 +120,6 @@ class DTSStreamReader : public SimplePacketizerReader unsigned int hd_pi_channels; unsigned int hd_pi_lfeCnt; - unsigned int hd_sample_rate; unsigned int hd_bitDepth; unsigned int m_hdBitrate; bool m_isCoreExists; diff --git a/tsMuxer/h264StreamReader.cpp b/tsMuxer/h264StreamReader.cpp index 68c615a..0e809e8 100644 --- a/tsMuxer/h264StreamReader.cpp +++ b/tsMuxer/h264StreamReader.cpp @@ -78,11 +78,9 @@ CheckStreamRez H264StreamReader::checkStream(uint8_t* buffer, int len) CheckStreamRez rez; uint8_t* end = buffer + len; uint8_t* nextNal = 0; - int pic_parameter_set_id = 0; std::string tmpDescr; bool pulldownInserted = false; bool offsetsInserted = false; - BitStreamReader bitReader{}; for (uint8_t* nal = NALUnit::findNextNAL(buffer, end); nal < end - 4; nal = NALUnit::findNextNAL(nal, end)) { @@ -106,7 +104,6 @@ CheckStreamRez H264StreamReader::checkStream(uint8_t* buffer, int len) delete sps; return rez; } - // m_spsMap.insert(make_pair(sps->seq_parameter_set_id, sps)); m_spsMap.insert(make_pair(sps->seq_parameter_set_id, sps)); if (tmpDescr.empty()) tmpDescr = sps->getStreamDescr(); @@ -127,7 +124,6 @@ CheckStreamRez H264StreamReader::checkStream(uint8_t* buffer, int len) delete pps; break; } - // m_ppsMap.insert(make_pair(pps->pic_parameter_set_id, pps)); m_ppsMap.insert(make_pair(pps->pic_parameter_set_id, pps)); break; } @@ -331,7 +327,7 @@ int H264StreamReader::writeAdditionData(uint8_t* dstBuffer, uint8_t* dstEnd, AVP bool srcSpsPpsFound = avPacket.flags & AVPacket::IS_SPS_PPS_IN_GOP; bool spsDiscontinue = m_h264SPSCont && - ((m_spsCounter < 2 && (m_totalFrameNum > 1 && m_lastSliceIDR || m_totalFrameNum > 250 && isIFrame())) || + ((m_spsCounter < 2 && ((m_totalFrameNum > 1 && m_lastSliceIDR) || (m_totalFrameNum > 250 && isIFrame()))) || (m_firstFileFrame && !srcSpsPpsFound)); bool needInsSpsPps = false; if (isIFrame() && m_lastSliceSPS != -1 && m_lastSlicePPS != -1) @@ -383,8 +379,6 @@ int H264StreamReader::writeAdditionData(uint8_t* dstBuffer, uint8_t* dstEnd, AVP if (needInsTimingSEI) { - SPSUnit* sps = m_spsMap.find(m_lastSliceSPS)->second; - if (m_firstSEIWarn) { m_firstSEIWarn = false; @@ -415,7 +409,7 @@ int H264StreamReader::writeAdditionData(uint8_t* dstBuffer, uint8_t* dstEnd, AVP curPos += NALUnit::encodeNAL(srcData, srcData + m_bdRomMetaDataMsg.size(), curPos, dstEnd - curPos); if (priorityData) priorityData->push_back( - std::pair((int)(prevPos - dstBuffer), (int)(curPos - prevPos))); + std::make_pair((int)(prevPos - dstBuffer), (int)(curPos - prevPos))); m_bdRomMetaDataMsg.clear(); } } @@ -786,7 +780,6 @@ int H264StreamReader::intDecodeNAL(uint8_t* buff) { auto nal_unit_type = (NALUnit::NALType)(*buff & 0x1f); uint8_t* nextNal = 0; - uint8_t* seiEnd = 0; int nalRez = 0; m_spsPpsFound = false; @@ -1097,7 +1090,6 @@ int H264StreamReader::deserializeSliceHeader(SliceUnit& slice, uint8_t* buff, ui int H264StreamReader::processSliceNal(uint8_t* buff) { SliceUnit slice; - int nal_unit_type = *buff & 0x1f; uint8_t* sliceEnd = m_bufEnd; int nalRez = deserializeSliceHeader(slice, buff, sliceEnd); @@ -1398,7 +1390,6 @@ int H264StreamReader::processSPS(uint8_t* buff) updateFPS(sps, buff, nextNal, oldSpsLen); nextNal = NALUnit::findNALWithStartCode(buff, m_bufEnd, true); - oldSpsLen = (int)(nextNal - buff); updateHRDParam(sps); if (sps->nalHrdParams.isPresent) updatedSPSList.insert(sps->seq_parameter_set_id); diff --git a/tsMuxer/hevc.cpp b/tsMuxer/hevc.cpp index 6304a04..82113c3 100644 --- a/tsMuxer/hevc.cpp +++ b/tsMuxer/hevc.cpp @@ -469,7 +469,7 @@ int HevcSpsUnit::short_term_ref_pic_set(unsigned stRpsIdx) { if (extractUEGolombCode() >= 0x8000) // delta_poc_minus1[i] return 1; - m_reader.skipBit(); // used_by_curr_pic_flag[i] + m_reader.skipBit(); // used_by_curr_pic_flag[i] } } num_delta_pocs[stRpsIdx] = numDeltaPocs; @@ -809,7 +809,7 @@ int HevcSliceHeader::deserialize(const HevcSpsUnit* sps, const HevcPpsUnit* pps) { if (pps->dependent_slice_segments_enabled_flag) dependent_slice_segment_flag = m_reader.getBit(); - int slice_segment_address = m_reader.getBits(sps->PicSizeInCtbsY_bits); + m_reader.skipBits(sps->PicSizeInCtbsY_bits); // slice_segment_address } if (!dependent_slice_segment_flag) { @@ -862,7 +862,7 @@ vector> hevc_extract_priv_data(const uint8_t* buff, int size, in { if (src + 3 > end) THROW(ERR_MOV_PARSE, "Invalid HEVC extra data format"); - int type = *src++; + src++; // type int cnt = AV_RB16(src); src += 2; diff --git a/tsMuxer/hevcStreamReader.cpp b/tsMuxer/hevcStreamReader.cpp index 3682861..0ea6807 100644 --- a/tsMuxer/hevcStreamReader.cpp +++ b/tsMuxer/hevcStreamReader.cpp @@ -22,11 +22,11 @@ HEVCStreamReader::HEVCStreamReader() m_firstFrame(true), m_frameNum(0), m_fullPicOrder(0), + m_picOrderBase(0), m_frameDepth(1), m_picOrderMsb(0), m_prevPicOrder(0), - m_picOrderBase(0), m_lastIFrame(false), m_firstFileFrame(false), m_vpsCounter(0), @@ -61,7 +61,7 @@ CheckStreamRez HEVCStreamReader::checkStream(uint8_t* buffer, int len) if (!m_vps) m_vps = new HevcVpsUnit(); m_vps->decodeBuffer(nal, nextNal); - if (m_vps->deserialize()) + if (m_vps->deserialize() != 0) { delete m_vps; return rez; @@ -186,7 +186,7 @@ int HEVCStreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bool hd if (nalType == HevcUnit::NalType::SPS) { int toDecode = FFMIN(sizeof(tmpBuffer) - 8, (unsigned)(nextNal - nal)); - int decodedLen = NALUnit::decodeNAL(nal, nal + toDecode, tmpBuffer, sizeof(tmpBuffer)); + NALUnit::decodeNAL(nal, nal + toDecode, tmpBuffer, sizeof(tmpBuffer)); break; } } @@ -490,7 +490,6 @@ int HEVCStreamReader::intDecodeNAL(uint8_t* buff) uint8_t* curPos = buff; uint8_t* nextNal = NALUnit::findNextNAL(curPos, m_bufEnd); uint8_t* nextNalWithStartCode; - long oldSpsLen = 0; if (!m_eof && nextNal == m_bufEnd) return NOT_ENOUGH_BUFFER; diff --git a/tsMuxer/ioContextDemuxer.cpp b/tsMuxer/ioContextDemuxer.cpp index 41afd11..1ad8498 100644 --- a/tsMuxer/ioContextDemuxer.cpp +++ b/tsMuxer/ioContextDemuxer.cpp @@ -31,7 +31,7 @@ float av_int2flt(int32_t v) } IOContextDemuxer::IOContextDemuxer(const BufferedReaderManager& readManager) - : m_readManager(readManager), m_lastReadRez(0), tracks() + : tracks(), m_readManager(readManager), m_lastReadRez(0) { m_lastProcessedBytes = 0; m_bufferedReader = (const_cast(m_readManager)).getReader(""); diff --git a/tsMuxer/iso_writer.cpp b/tsMuxer/iso_writer.cpp index f0419a1..6694567 100644 --- a/tsMuxer/iso_writer.cpp +++ b/tsMuxer/iso_writer.cpp @@ -317,9 +317,9 @@ FileEntryInfo::FileEntryInfo(IsoWriter* owner, FileEntryInfo* parent, uint32_t o m_sectorNum(0), m_sectorsUsed(0), m_objectId(objectId), + m_fileType(fileType), m_fileSize(0), m_sectorBufferSize(0), - m_fileType(fileType), m_subMode(false) { if (isFile()) @@ -390,11 +390,6 @@ int FileEntryInfo::allocateEntity(int sectorNum) void FileEntryInfo::serializeFile() { - uint8_t dataSize = 0; - uint8_t buffer[SECTOR_SIZE]; - - memset(buffer, 0, sizeof(buffer)); - int writed = m_owner->writeExtentFileDescriptor(m_name == "*UDF Unique ID Mapping Data", m_objectId, m_fileType, m_fileSize, m_sectorNum, 1, &m_extents); assert(writed == m_sectorsUsed); @@ -402,7 +397,6 @@ void FileEntryInfo::serializeFile() void FileEntryInfo::serializeDir() { - uint8_t dataSize = 0; uint8_t buffer[SECTOR_SIZE]; memset(buffer, 0, sizeof(buffer)); @@ -850,7 +844,6 @@ void IsoWriter::close() while (m_file.size() % ALLOC_BLOCK_SIZE != 62 * 1024) m_file.write(m_buffer, SECTOR_SIZE); // mirror metadata file location and length - int64_t sz = m_file.size(); m_metadataMirrorLBN = (int)(m_file.size() / SECTOR_SIZE + 1); m_tagLocationBaseAddr = m_partitionStartAddress; writeExtentFileDescriptor(0, 0, FileTypes::MetadataMirror, m_metadataFileLen, @@ -1204,7 +1197,6 @@ void IsoWriter::writeImpUseDescriptor() writeDescriptorTag(m_buffer, DescriptorTag::ImplUseVol, absoluteSectorNum()); uint32_t* buff32 = (uint32_t*)m_buffer; - uint16_t* buff16 = (uint16_t*)m_buffer; buff32[4] = 0x02; // Descriptor Sequence Number std::string impId = std::string("*UDF LV Info"); @@ -1315,7 +1307,6 @@ void IsoWriter::writeUnallocatedSpaceDescriptor() writeDescriptorTag(m_buffer, DescriptorTag::UnallocSpace, absoluteSectorNum()); uint32_t* buff32 = (uint32_t*)m_buffer; - uint16_t* buff16 = (uint16_t*)m_buffer; buff32[4] = 0x05; // sequence number @@ -1328,9 +1319,6 @@ void IsoWriter::writeTerminationDescriptor() memset(m_buffer, 0, sizeof(m_buffer)); writeDescriptorTag(m_buffer, DescriptorTag::Terminating, absoluteSectorNum()); - uint32_t* buff32 = (uint32_t*)m_buffer; - uint16_t* buff16 = (uint16_t*)m_buffer; - calcDescriptorCRC(m_buffer, 512); m_file.write(m_buffer, SECTOR_SIZE); } diff --git a/tsMuxer/lpcmStreamReader.cpp b/tsMuxer/lpcmStreamReader.cpp index 2bd6f4b..b2347e8 100644 --- a/tsMuxer/lpcmStreamReader.cpp +++ b/tsMuxer/lpcmStreamReader.cpp @@ -106,7 +106,6 @@ int LPCMStreamReader::decodeLPCMHeader(uint8_t* buff) void LPCMStreamReader::storeChannelData(uint8_t* start, uint8_t* end, int chNum, uint8_t* tmpData, int mch) { - // int mch = m_channels + (m_channels%2==1 ? 1 : 0); int ch1SampleSize = (m_bitsPerSample == 20 ? 3 : m_bitsPerSample / 8); int fullSampleSize = mch * ch1SampleSize; uint8_t* curPos = start + ch1SampleSize * (chNum - 1); @@ -119,7 +118,6 @@ void LPCMStreamReader::storeChannelData(uint8_t* start, uint8_t* end, int chNum, void LPCMStreamReader::restoreChannelData(uint8_t* start, uint8_t* end, int chNum, uint8_t* tmpData, int mch) { - // int mch = m_channels + (m_channels%2==1 ? 1 : 0); int ch1SampleSize = (m_bitsPerSample == 20 ? 3 : m_bitsPerSample / 8); int fullSampleSize = mch * ch1SampleSize; uint8_t* curPos = start + ch1SampleSize * (chNum - 1); @@ -745,7 +743,6 @@ int LPCMStreamReader::readPacket(AVPacket& avPacket) assert(m_curPos <= m_bufEnd); if (m_curPos == m_bufEnd) return NEED_MORE_DATA; - uint8_t* prevPos = m_curPos; int skipBytes = 0; int skipBeforeBytes = 0; if (m_needSync) diff --git a/tsMuxer/matroskaDemuxer.cpp b/tsMuxer/matroskaDemuxer.cpp index 9cc72e9..3b1c333 100644 --- a/tsMuxer/matroskaDemuxer.cpp +++ b/tsMuxer/matroskaDemuxer.cpp @@ -189,7 +189,7 @@ int MatroskaDemuxer::matroska_parse_index() } MatroskaDemuxer::MatroskaDemuxer(const BufferedReaderManager &readManager) - : IOContextDemuxer(readManager), created(0), fileDuration(0), levels(), title() + : IOContextDemuxer(readManager), levels(), title(), created(0), fileDuration(0) { m_lastDeliveryPacket = 0; num_levels = 0; @@ -1010,7 +1010,6 @@ int MatroskaDemuxer::ebml_read_element_level_up() void MatroskaDemuxer::openFile(const std::string &streamName) { readClose(); - BufferedFileReader *fileReader = dynamic_cast(m_bufferedReader); if (!m_bufferedReader->openStream(m_readerID, streamName.c_str())) THROW(ERR_FILE_NOT_FOUND, "Can't open stream " << streamName); m_curPos = m_bufEnd = 0; @@ -1318,10 +1317,6 @@ int MatroskaDemuxer::matroska_read_header() for (i = 0; i < num_tracks; i++) { - int codec_id = -1; // Enum CodecID codec_id = CODEC_ID_NONE; - uint8_t *extradata = NULL; - int extradata_size = 0; - int extradata_offset = 0; track = tracks[i]; track->stream_index = -1; if (track->codec_id == NULL) @@ -1331,22 +1326,18 @@ int MatroskaDemuxer::matroska_read_header() if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_AVC_FOURCC) && (track->codec_priv != NULL)) { - MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *)track; track->parsed_priv_data = new ParsedH264TrackData(track->codec_priv, track->codec_priv_size); } else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_HEVC_FOURCC) && (track->codec_priv != NULL)) { - MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *)track; track->parsed_priv_data = new ParsedH265TrackData(track->codec_priv, track->codec_priv_size); } else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_VVC_FOURCC) && (track->codec_priv != NULL)) { - MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *)track; track->parsed_priv_data = new ParsedH266TrackData(track->codec_priv, track->codec_priv_size); } else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) && (track->codec_priv != NULL)) { - MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *)track; track->parsed_priv_data = new ParsedVC1TrackData(track->codec_priv, track->codec_priv_size); } else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_AUDIO_AC3)) diff --git a/tsMuxer/matroskaParser.cpp b/tsMuxer/matroskaParser.cpp index 7ce92c5..cddde26 100644 --- a/tsMuxer/matroskaParser.cpp +++ b/tsMuxer/matroskaParser.cpp @@ -11,8 +11,6 @@ #include "vvc.h" #include "wave.h" -static const int LPCM_HEADER_LEN = 4; - using namespace wave_format; // ------------ H-264 --------------- @@ -26,11 +24,8 @@ ParsedH264TrackData::ParsedH264TrackData(uint8_t* buff, int size) : ParsedTrackP try { bitReader.setBuffer(buff, buff + size); - bitReader.skipBits(8); // reserved - int profile = bitReader.getBits(8); - bitReader.skipBits(8); // reserved - int level = bitReader.getBits(8); - bitReader.skipBits(6); // reserved + bitReader.skipBits(24); // reserved 8, profile 8, reserved 8 + bitReader.skipBits(14); // level 8, reserved 6 m_nalSize = bitReader.getBits(2) + 1; bitReader.skipBits(3); // reserved int spsCnt = bitReader.getBits(5); diff --git a/tsMuxer/movDemuxer.cpp b/tsMuxer/movDemuxer.cpp index 65bb605..4e5d1bd 100644 --- a/tsMuxer/movDemuxer.cpp +++ b/tsMuxer/movDemuxer.cpp @@ -164,7 +164,7 @@ class MovParsedAudioTrackData : public ParsedTrackPrivData { public: MovParsedAudioTrackData(MovDemuxer* demuxer, MOVStreamContext* sc) - : ParsedTrackPrivData(), m_demuxer(demuxer), m_sc(sc), m_buff(), m_size(0) + : ParsedTrackPrivData(), m_buff(), m_size(0), m_demuxer(demuxer), m_sc(sc), m_aacRaw() { isAAC = false; } @@ -207,7 +207,6 @@ class MovParsedAudioTrackData : public ParsedTrackPrivData } int newBufferSize(uint8_t* buff, int size) override { - int frameCnt = 0; int left = size; int i = 0; for (; left > 4; ++i) @@ -390,7 +389,7 @@ class MovParsedSRTTrackData : public ParsedTrackPrivData { public: MovParsedSRTTrackData(MovDemuxer* demuxer, MOVStreamContext* sc) - : ParsedTrackPrivData(), m_demuxer(demuxer), m_sc(sc), m_buff(), m_size(0), sttsCnt(0) + : ParsedTrackPrivData(), m_buff(), m_size(0), m_demuxer(demuxer), m_sc(sc), sttsCnt(0) { m_packetCnt = 0; sttsPos = 0; @@ -562,7 +561,7 @@ const MovDemuxer::MOVParseTableEntry MovDemuxer::mov_default_parse_table[] = { {0, 0}}; MovDemuxer::MovDemuxer(const BufferedReaderManager& readManager) - : IOContextDemuxer(readManager), fragment(), m_fileSize(0), m_mdat_size(0) + : IOContextDemuxer(readManager), m_mdat_size(0), m_fileSize(0), fragment() { found_moov = 0; found_moof = false; @@ -599,7 +598,6 @@ void MovDemuxer::openFile(const std::string& streamName) readClose(); - BufferedFileReader* fileReader = dynamic_cast(m_bufferedReader); if (!m_bufferedReader->openStream(m_readerID, streamName.c_str())) THROW(ERR_FILE_NOT_FOUND, "Can't open stream " << streamName); @@ -659,7 +657,6 @@ int MovDemuxer::simpleDemuxBlock(DemuxedData& demuxedData, const PIDSet& accepte { for (std::set::const_iterator itr = acceptedPIDs.begin(); itr != acceptedPIDs.end(); ++itr) demuxedData[*itr]; - uint32_t demuxedSize = 0; discardSize = m_firstHeaderSize; m_firstHeaderSize = 0; if (m_firstDemux) @@ -757,7 +754,6 @@ int MovDemuxer::simpleDemuxBlock(DemuxedData& demuxedData, const PIDSet& accepte else { vect.grow(chunkSize); - uint8_t* dst = vect.data() + oldSize; int readed = get_buffer(vect.data() + oldSize, chunkSize); if (readed < chunkSize) { @@ -1372,7 +1368,7 @@ int MovDemuxer::mov_read_stsd(MOVAtom atom) st->channels = get_be32(); get_be32(); // always 0x7F000000 st->bits_per_coded_sample = get_be32(); // bits per channel if sound is uncompressed - int flags = get_be32(); // lcpm format specific flag + get_be32(); // lcpm format specific flag st->bytes_per_frame = get_be32(); // bytes per audio packet if constant st->samples_per_frame = get_be32(); // lpcm frames per audio packet if constant // if (format == MKTAG('l','p','c','m')) @@ -1487,18 +1483,15 @@ int MovDemuxer::mov_read_glbl(MOVAtom atom) int MovDemuxer::mov_read_hdlr(MOVAtom atom) { - MOVStreamContext* st = (MOVStreamContext*)tracks[num_tracks - 1]; - get_byte(); // version get_be24(); // flags // component type int ctype = get_le32(); - int type = get_le32(); // component subtype - if (!ctype) isom = 1; + get_le32(); // component subtype get_be32(); // component manufacture get_be32(); // component flags get_be32(); // component flags mask @@ -1544,7 +1537,7 @@ int MovDemuxer::mov_read_esds(MOVAtom atom) len = mp4_read_descr(&tag); if (tag == MP4DecConfigDescrTag) { - int object_type_id = get_byte(); + get_byte(); // object_type_id get_byte(); // stream type get_be24(); // buffer size db get_be32(); // max bitrate @@ -1612,7 +1605,6 @@ int MovDemuxer::mov_read_smi(MOVAtom atom) { return 0; } int MovDemuxer::mov_read_wave(MOVAtom atom) { - MOVStreamContext* st = (MOVStreamContext*)tracks[num_tracks - 1]; if ((uint64_t)atom.size > (1 << 30)) return -1; /* @@ -1645,9 +1637,9 @@ int MovDemuxer::mov_read_elst(MOVAtom atom) for (int i = 0; i < edit_count; i++) { - uint32_t duration = get_be32(); // Track duration - int time = get_be32(); // Media time - int rate = get_be32(); // Media rate + get_be32(); // Track duration + int time = get_be32(); // Media time + get_be32(); // Media rate if (i == 0 && time != -1) { st->time_offset = time; diff --git a/tsMuxer/mp3Codec.cpp b/tsMuxer/mp3Codec.cpp index dde81df..e786fbe 100644 --- a/tsMuxer/mp3Codec.cpp +++ b/tsMuxer/mp3Codec.cpp @@ -10,9 +10,9 @@ const uint16_t ff_mpa_bitrate_tab[2][3][15] = {{{0, 32, 64, 96, 128, 160, 192, 2 const uint16_t ff_mpa_freq_tab[3] = {44100, 48000, 32000}; -const static int MPA_STEREO = 0; -const static int MPA_JSTEREO = 1; -const static int MPA_DUAL = 2; +// const static int MPA_STEREO = 0; +// const static int MPA_JSTEREO = 1; +// const static int MPA_DUAL = 2; const static int MPA_MONO = 3; uint8_t* MP3Codec::mp3FindFrame(uint8_t* buff, uint8_t* end) @@ -43,7 +43,7 @@ int MP3Codec::mp3DecodeFrame(uint8_t* buff, uint8_t* end) { // int sample_rate, frame_size, mpeg25, padding; // int sample_rate_index, bitrate_index; - int mpeg25, padding, error_protection, lsf; + int mpeg25, padding, lsf; if (end - buff < 4) return 0; uint32_t header = my_ntohl(*((uint32_t*)buff)); @@ -67,7 +67,7 @@ int MP3Codec::mp3DecodeFrame(uint8_t* buff, uint8_t* end) return 0; // invalid sample rate m_sample_rate = ff_mpa_freq_tab[m_sample_rate_index] >> (lsf + mpeg25); m_sample_rate_index += 3 * (lsf + mpeg25); - error_protection = ((header >> 16) & 1) ^ 1; + // error_protection = ((header >> 16) & 1) ^ 1; m_bitrate_index = (header >> 12) & 0xf; if (m_bitrate_index == 15) diff --git a/tsMuxer/mpeg2StreamReader.cpp b/tsMuxer/mpeg2StreamReader.cpp index c060877..9d64d98 100644 --- a/tsMuxer/mpeg2StreamReader.cpp +++ b/tsMuxer/mpeg2StreamReader.cpp @@ -68,7 +68,6 @@ CheckStreamRez MPEG2StreamReader::checkStream(uint8_t* buffer, int len) BitStreamReader bitReader{}; uint8_t* nextNal = 0; bool spsFound = false; - bool iFrameFound = false; bool gopFound = false; bool sliceFound = false; bool seqExtFound = false; diff --git a/tsMuxer/mpegAudioStreamReader.cpp b/tsMuxer/mpegAudioStreamReader.cpp index dc46530..ec187ce 100644 --- a/tsMuxer/mpegAudioStreamReader.cpp +++ b/tsMuxer/mpegAudioStreamReader.cpp @@ -10,7 +10,7 @@ int MpegAudioStreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bo return 0; int skipBytes = 0; int skipBeforeBytes = 0; - int len = decodeFrame(frame, m_bufEnd, skipBytes, skipBeforeBytes); + decodeFrame(frame, m_bufEnd, skipBytes, skipBeforeBytes); return 0; } diff --git a/tsMuxer/mpegStreamReader.h b/tsMuxer/mpegStreamReader.h index 5068926..33b6bb2 100644 --- a/tsMuxer/mpegStreamReader.h +++ b/tsMuxer/mpegStreamReader.h @@ -101,7 +101,6 @@ class MPEGStreamReader : public AbstractStreamReader int bufFromNAL(); virtual int decodeNal(uint8_t* buff); void storeBufferRest(); - uint8_t* m_frameStart; }; #endif diff --git a/tsMuxer/mpegVideo.cpp b/tsMuxer/mpegVideo.cpp index 9e9921f..288c6f5 100644 --- a/tsMuxer/mpegVideo.cpp +++ b/tsMuxer/mpegVideo.cpp @@ -56,29 +56,30 @@ bool MPEGRawDataHeader::addRawData(uint8_t* buffer, int len, bool headerIncluded MPEGSequenceHeader::MPEGSequenceHeader(int bufferSize) : MPEGRawDataHeader(bufferSize), - aspect_ratio_info(0), - bit_rate(0), - bit_rate_ext(0), - chroma_format(0), - color_primaries(0), - constParameterFlag(0), - frame_rate_index(0), + width(0), height(0), - horiz_size_ext(0), - intra_matrix(), + aspect_ratio_info(0), + frame_rate_index(0), + bit_rate(0), + rc_buffer_size(0), + vbv_buffer_size(0), + constParameterFlag(0), load_intra_matrix(false), load_non_intra_matrix(false), - low_delay(0), - matrix_coefficients(0), + intra_matrix(), non_intra_matrix(), - pan_scan_height(0), - pan_scan_width(0), - rc_buffer_size(0), - transfer_characteristics(0), - vbv_buffer_size(0), + chroma_format(0), + horiz_size_ext(0), vert_size_ext(0), + bit_rate_ext(0), + low_delay(0), + frame_rate_ext(), video_format(0), - width(0) + color_primaries(0), + transfer_characteristics(0), + matrix_coefficients(0), + pan_scan_width(0), + pan_scan_height(0) { progressive_sequence = false; profile = -1; @@ -270,13 +271,13 @@ void MPEGSequenceHeader::setAspectRatio(uint8_t* buff, VideoAspectRatio ar) MPEGGOPHeader::MPEGGOPHeader() : MPEGHeader(), - time_code_pictures(0), + drop_frame_flag(0), time_code_hours(0), time_code_minutes(0), time_code_seconds(0), - broken_link(0), + time_code_pictures(0), close_gop(0), - drop_frame_flag(0) + broken_link(0) { } @@ -330,34 +331,34 @@ uint32_t MPEGGOPHeader::serialize(uint8_t* buffer) MPEGPictureHeader::MPEGPictureHeader(int bufferSize) : MPEGRawDataHeader(bufferSize), + ref(0), + pict_type(PictureCodingType::FORBIDDEN), + vbv_delay(0), + full_pel(), + f_code(0), + extra_bit(0), + mpeg_f_code(), + intra_dc_precision(0), + picture_structure(0), + top_field_first(0), + frame_pred_frame_dct(0), + concealment_motion_vectors(0), + q_scale_type(0), + intra_vlc_format(0), + alternate_scan(0), + chroma_420_type(0), + progressive_frame(0), + composite_display_flag(0), + v_axis(0), + field_sequence(0), + sub_carrier(0), + burst_amplitude(0), + sub_carrier_phase(0), + horizontal_offset(0), + vertical_offset(0), m_headerSize(0), m_picture_data_len(0), - alternate_scan(0), - bitReader(), - burst_amplitude(0), - chroma_420_type(0), - composite_display_flag(0), - concealment_motion_vectors(0), - extra_bit(0), - f_code(0), - field_sequence(0), - frame_pred_frame_dct(0), - full_pel(), - horizontal_offset(0), - intra_dc_precision(0), - intra_vlc_format(0), - mpeg_f_code(), - pict_type(PictureCodingType::FORBIDDEN), - picture_structure(0), - progressive_frame(0), - q_scale_type(0), - ref(0), - sub_carrier(0), - sub_carrier_phase(0), - top_field_first(0), - v_axis(0), - vbv_delay(0), - vertical_offset(0) + bitReader() { repeat_first_field = 0; repeat_first_field_bitpos = 0; diff --git a/tsMuxer/muxerManager.cpp b/tsMuxer/muxerManager.cpp index fdf6f19..6c30789 100644 --- a/tsMuxer/muxerManager.cpp +++ b/tsMuxer/muxerManager.cpp @@ -347,7 +347,7 @@ void MuxerManager::parseMuxOpt(const string& opts) string postfix; for (auto i : paramPair[1]) { - if (!(i >= '0' && i <= '9' || i == '.')) + if (!((i >= '0' && i <= '9') || i == '.')) postfix += i; } diff --git a/tsMuxer/nalUnits.cpp b/tsMuxer/nalUnits.cpp index d04fc70..80b000f 100644 --- a/tsMuxer/nalUnits.cpp +++ b/tsMuxer/nalUnits.cpp @@ -9,8 +9,6 @@ #include "bitStream.h" #include "vod_common.h" -static const double FRAME_RATE_EPS = 3e-5; - uint8_t BDROM_METADATA_GUID[] = "\x17\xee\x8c\x60\xf8\x4d\x11\xd9\x8c\xd6\x08\x00\x20\x0c\x9a\x66"; void NALUnit::write_rbsp_trailing_bits(BitStreamWriter& writer) @@ -554,7 +552,7 @@ int SPSUnit::deserialize() } num_ref_frames = extractUEGolombCode(); - int gaps_in_frame_num_value_allowed_flag = bitReader.getBit(); + bitReader.skipBit(); // gaps_in_frame_num_value_allowed_flag pic_width_in_mbs = extractUEGolombCode() + 1; pic_height_in_map_units = extractUEGolombCode() + 1; frame_mbs_only_flag = bitReader.getBit(); @@ -672,7 +670,7 @@ int SPSUnit::deserializeVuiParameters() pic_struct_present_flag = bitReader.getBit(); if (bitReader.getBit()) // bitstream_restriction_flag { - int motion_vectors_over_pic_boundaries_flag = bitReader.getBit(); + bitReader.skipBit(); // motion_vectors_over_pic_boundaries_flag if (extractUEGolombCode() > 16) // max_bytes_per_pic_denom return 1; if (extractUEGolombCode() > 16) // max_bits_per_mb_denom @@ -1188,19 +1186,19 @@ int SPSUnit::mvc_vui_parameters_extension() SliceUnit::SliceUnit() : NALUnit(), - anchor_pic_flag(0), - bottom_field_flag(0), - first_mb_in_slice(0), - frame_num(0), m_field_pic_flag(0), - memory_management_control_operation(0), non_idr_flag(0), + memory_management_control_operation(0), + first_mb_in_slice(0), + slice_type(0), orig_slice_type(0), - pic_order_cnt_lsb(0), pic_parameter_set_id(0), + frame_num(0), + bottom_field_flag(0), + pic_order_cnt_lsb(0), + anchor_pic_flag(0), pps(), - sps(), - slice_type(0) + sps() { } @@ -1220,7 +1218,7 @@ void SliceUnit::nal_unit_header_mvc_extension() bool SliceUnit::isIDR() const { - return nal_unit_type == NALType::nuSliceIDR || nal_unit_type == NALType::nuSliceExt && !non_idr_flag; + return nal_unit_type == NALType::nuSliceIDR || (nal_unit_type == NALType::nuSliceExt && !non_idr_flag); } bool SliceUnit::isIFrame() const @@ -1634,7 +1632,6 @@ void SEIUnit::serialize_pic_timing_message(const SPSUnit& sps, BitStreamWriter& writer.putBits(8, SEI_MSG_PIC_TIMING); } writer.putBits(8, 0); - int beforeMessageLen = writer.getBitsCount(); // pic timing if (sps.nalHrdParams.isPresent || sps.vclHrdParams.isPresent) { @@ -1664,7 +1661,6 @@ void SEIUnit::serialize_buffering_period_message(const SPSUnit& sps, BitStreamWr writer.putBits(8, SEI_MSG_BUFFERING_PERIOD); } writer.putBits(8, 0); - int beforeMessageLen = writer.getBitsCount(); // buffering period writeUEGolombCode(writer, sps.seq_parameter_set_id); if (sps.nalHrdParams.isPresent) diff --git a/tsMuxer/nalUnits.h b/tsMuxer/nalUnits.h index a4f9864..3463413 100644 --- a/tsMuxer/nalUnits.h +++ b/tsMuxer/nalUnits.h @@ -20,19 +20,6 @@ const static int SEI_MSG_BUFFERING_PERIOD = 0; const static int SEI_MSG_PIC_TIMING = 1; const static int SEI_MSG_MVC_SCALABLE_NESTING = 37; -#if 0 -const static char* NALUnitDescr[30] = - {"nuUnspecified", "nuSliceNonIDR", "nuSliceA", "nuSliceB", "nuSliceC", - "nuSliceIDR","nuSEI","nuSPS","nuPPS","nuAUD", - "nuEOSeq","nuEOStream","nuFillerData","nuSPSExt","nuReserved1", - "nuReserved2","nuReserved3","nuReserved4","nuReserved5","nuSliceWithoutPartitioning", - "nuReserved6","nuReserved7","nuReserved8"," nuReserved9", - // ------------------- additional RTP nal units ------------- - "STAP-A","STAP-B","MTAP16","MTAP24","FU-A","FU-B" - }; - -#endif - class NALUnit { public: diff --git a/tsMuxer/programStreamDemuxer.cpp b/tsMuxer/programStreamDemuxer.cpp index 8bbb21f..8f5198c 100644 --- a/tsMuxer/programStreamDemuxer.cpp +++ b/tsMuxer/programStreamDemuxer.cpp @@ -187,8 +187,8 @@ void ProgramStreamDemuxer::getTrackList(std::map& trackList bool ProgramStreamDemuxer::isVideoPID(uint32_t pid) { - return pid >= 0x55 && pid <= 0x5f || // vc1 - pid >= 0xe0 && pid <= 0xef || // mpeg video + return (pid >= 0x55 && pid <= 0x5f) || // vc1 + (pid >= 0xe0 && pid <= 0xef) || // mpeg video m_psm_es_type[pid & 0xff] == (int)StreamType::VIDEO_H264 || m_psm_es_type[pid & 0xff] == (int)StreamType::VIDEO_MVC || m_psm_es_type[pid & 0xff] == (int)StreamType::VIDEO_H265 || @@ -206,7 +206,7 @@ int ProgramStreamDemuxer::simpleDemuxBlock(DemuxedData& demuxedData, const PIDSe m_lastReadRez = readRez; return BufferedFileReader::DATA_NOT_READY; } - if (readedBytes + m_tmpBufferLen == 0 || readedBytes == 0 && m_lastReadRez == BufferedReader::DATA_EOF) + if (readedBytes + m_tmpBufferLen == 0 || (readedBytes == 0 && m_lastReadRez == BufferedReader::DATA_EOF)) { m_lastReadRez = readRez; return BufferedReader::DATA_EOF; diff --git a/tsMuxer/simplePacketizerReader.cpp b/tsMuxer/simplePacketizerReader.cpp index 6b80d8a..b104f7a 100644 --- a/tsMuxer/simplePacketizerReader.cpp +++ b/tsMuxer/simplePacketizerReader.cpp @@ -111,7 +111,6 @@ int SimplePacketizerReader::readPacket(AVPacket& avPacket) assert(m_curPos <= m_bufEnd); if (m_curPos == m_bufEnd) return NEED_MORE_DATA; - uint8_t* prevPos = m_curPos; int skipBytes = 0; int skipBeforeBytes = 0; if (m_needSync) @@ -274,7 +273,7 @@ CheckStreamRez SimplePacketizerReader::checkStream(uint8_t* buffer, int len, Con for (int i = 0; i < CHECK_FRAMES_COUNT && frame < end;) { int frameLen = decodeFrame(frame, end, skipBytes, skipBeforeBytes); - if (frameLen <= 0 || getFreq() != freq || firstStep && frameLen > end - frame) + if (frameLen <= 0 || getFreq() != freq || (firstStep && frameLen > end - frame)) { setTestMode(false); return rez; diff --git a/tsMuxer/srtStreamReader.cpp b/tsMuxer/srtStreamReader.cpp index 7280db5..93690c1 100644 --- a/tsMuxer/srtStreamReader.cpp +++ b/tsMuxer/srtStreamReader.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace text_subtitles; -SRTStreamReader::SRTStreamReader() : m_lastBlock(false), m_long_N(0), m_long_R(0), m_short_N(0), m_short_R(0) +SRTStreamReader::SRTStreamReader() : m_lastBlock(false), m_short_R(0), m_short_N(0), m_long_R(0), m_long_N(0) { // in future version here must be case for destination subtitle format (DVB sub, DVD sub e.t.c) m_dstSubCodec = new PGSStreamReader(); @@ -125,13 +125,13 @@ int SRTStreamReader::parseText(uint8_t* dataStart, int len) for (; cur < end; cur += m_charSize) { // if (cur[m_splitterOfs] == '\n') - if (m_charSize == 1 && *cur == '\n' || m_charSize == 2 && *((uint16_t*)cur) == m_short_N || - m_charSize == 4 && *((uint32_t*)cur) == m_long_N) + if ((m_charSize == 1 && *cur == '\n') || (m_charSize == 2 && *((uint16_t*)cur) == m_short_N) || + (m_charSize == 4 && *((uint32_t*)cur) == m_long_N)) { int32_t x = 0; if (cur >= m_charSize + lastProcessedLine) - if (m_charSize == 1 && cur[-1] == '\r' || m_charSize == 2 && ((uint16_t*)cur)[-1] == m_short_R || - m_charSize == 4 && ((uint32_t*)cur)[-1] == m_long_R) + if ((m_charSize == 1 && cur[-1] == '\r') || (m_charSize == 2 && ((uint16_t*)cur)[-1] == m_short_R) || + (m_charSize == 4 && ((uint32_t*)cur)[-1] == m_long_R)) x = m_charSize; m_sourceText.emplace(UtfConverter::toUtf8(lastProcessedLine, cur - lastProcessedLine - x, m_srcFormat)); @@ -278,8 +278,8 @@ CheckStreamRez SRTStreamReader::checkStream(uint8_t* buffer, int len, ContainerT int containerDataType, int containerStreamIndex) { CheckStreamRez rez; - if ((containerType == ContainerType::ctMKV || containerType == ContainerType::ctMOV) && - containerDataType == TRACKTYPE_SRT || + if (((containerType == ContainerType::ctMKV || containerType == ContainerType::ctMOV) && + containerDataType == TRACKTYPE_SRT) || containerType == ContainerType::ctSRT) { rez.codecInfo = srtCodecInfo; diff --git a/tsMuxer/textSubtitles.cpp b/tsMuxer/textSubtitles.cpp index 8b57cda..d5ae3e5 100644 --- a/tsMuxer/textSubtitles.cpp +++ b/tsMuxer/textSubtitles.cpp @@ -30,12 +30,13 @@ static const int PG_BUFFER_SIZE = 1024 * 1024 * 2; /////////////////////////////////////////// TextToPGSConverter::TextToPGSConverter(bool sourceIsText) - : /*TextSubtitlesRenderWin32(), */ m_composition_number(0), - m_imageBuffer(), + : /* TextSubtitlesRenderWin32(), */ m_rleLen(0), - m_videoFps(0), + m_composition_number(0), + m_videoWidth(0), m_videoHeight(0), - m_videoWidth(0) + m_videoFps(0), + m_imageBuffer() { m_bottomOffset = 0; m_renderedData = 0; @@ -227,11 +228,6 @@ bool TextToPGSConverter::rlePack(uint32_t colorMask) { int repCnt = getRepeatCnt(srcData, srcLineEnd, colorMask); - if (y > 435 && srcLineEnd - srcData == 412) - { - int gg = 4; - } - if (repCnt == m_videoWidth) { isEmptyLine = true; @@ -567,7 +563,6 @@ long TextToPGSConverter::composeObjectDefinition(uint8_t* buff, int64_t pts, int std::vector seqPos; const uint8_t* srcData = m_renderedData; - bool first = true; int srcProcessed = 0; int blocks = 0; uint8_t* curPos = buff; diff --git a/tsMuxer/tsDemuxer.cpp b/tsMuxer/tsDemuxer.cpp index 361b24a..26aa663 100644 --- a/tsMuxer/tsDemuxer.cpp +++ b/tsMuxer/tsDemuxer.cpp @@ -9,10 +9,6 @@ using namespace std; -const static uint64_t TS_FREQ_TO_INT_FREQ_COEFF = INTERNAL_PTS_FREQ / PCR_FREQUENCY; - -const static int64_t MAX_PTS_DIFF = 90000ll * 15ll; - bool isM2TSExt(const std::string& streamName) { string sName = strToLowerCase(unquoteStr(streamName)); @@ -218,7 +214,7 @@ int TSDemuxer::simpleDemuxBlock(DemuxedData& demuxedData, const PIDSet& accepted m_lastReadRez = readRez; return BufferedFileReader::DATA_NOT_READY; } - if (readedBytes + m_tmpBufferLen == 0 || readedBytes == 0 && m_lastReadRez == BufferedReader::DATA_EOF) + if (readedBytes + m_tmpBufferLen == 0 || (readedBytes == 0 && m_lastReadRez == BufferedReader::DATA_EOF)) { m_lastReadRez = readRez; return BufferedReader::DATA_EOF; @@ -352,34 +348,10 @@ int TSDemuxer::simpleDemuxBlock(DemuxedData& demuxedData, const PIDSet& accepted if (pesStartCode) { PESPacket* pesPacket = (PESPacket*)frameData; - int payloadLen = pesPacket->getPacketLength() - pesPacket->getHeaderLength(); - PIDListMap::iterator streamInfo = m_pmt.pidList.find(pid); if ((pesPacket->flagsLo & 0x80) == 0x80) - { // 2880 - ac3 frame len - - /* - if (pid == 4114 || pid == 4113) - { - static int64_t prevDts = 0; - - uint64_t tmpDts = ((pesPacket->flagsLo & 0xc0) == 0xc0) ? pesPacket->getDts() : - pesPacket->getPts(); - int32_t dtsDif = (int64_t)tmpDts - prevDts; - uint8_t* afterPesData = frameData + pesPacket->getHeaderLength() - 1; - LTRACE(LT_INFO, 2, "PID=" << pid << " PTS: " << pesPacket->getPts() << - " DTS:" << tmpDts << " dtsDif:" << dtsDif); - - prevDts = tmpDts; - static int lastPid; - if (lastPid != pid) - { - lastPid = pid; - } - } -*/ - + { int64_t curPts = pesPacket->getPts(); int64_t curDts = curPts; @@ -474,8 +446,6 @@ void TSDemuxer::openFile(const std::string& streamName) m_m2tsMode = isM2TSExt(streamName); - BufferedFileReader* fileReader = dynamic_cast(m_bufferedReader); - if (!m_bufferedReader->openStream(m_readerID, m_streamName.c_str())) THROW(ERR_FILE_NOT_FOUND, "Can't open stream " << m_streamName); diff --git a/tsMuxer/tsMuxer.cpp b/tsMuxer/tsMuxer.cpp index 208d08f..b079332 100644 --- a/tsMuxer/tsMuxer.cpp +++ b/tsMuxer/tsMuxer.cpp @@ -1,10 +1,9 @@ #include "tsMuxer.h" +#include #include "pesPacket.h" #include "tsPacket.h" -//#include "tsEncoder.h" -#include #include "ac3StreamReader.h" #include "avCodecs.h" @@ -283,15 +282,12 @@ void TSMuxer::intAddStream(const std::string& streamName, const std::string& cod if (codecName == "V_MPEG4/ISO/AVC") { - H264StreamReader* h264Reader = (H264StreamReader*)codecReader; - // h264Reader->setH264SPSCont(m_h264SPSCont); m_pmt.pidList.insert( std::make_pair(tsStreamIndex, PMTStreamInfo(StreamType::VIDEO_H264, tsStreamIndex, descrBuffer, descriptorLen, codecReader, lang, isSecondary))); } else if (codecName == "V_MPEG4/ISO/MVC") { - H264StreamReader* h264Reader = (H264StreamReader*)codecReader; m_pmt.pidList.insert( std::make_pair(tsStreamIndex, PMTStreamInfo(StreamType::VIDEO_MVC, tsStreamIndex, descrBuffer, descriptorLen, codecReader, lang, isSecondary))); @@ -1025,7 +1021,7 @@ bool TSMuxer::muxPacket(AVPacket& avPacket) finishFileBlock(avPacket.pts, newPCR, true); // goto next file } else if (newPES && m_interliaveBlockSize > 0 && m_canSwithBlock && - (blockFull() || m_sublingMuxer && m_sublingMuxer->blockFull())) + (blockFull() || (m_sublingMuxer && m_sublingMuxer->blockFull()))) { finishFileBlock(avPacket.pts, newPCR, false); // interleave SSIF here } @@ -1381,7 +1377,7 @@ void TSMuxer::parseMuxOpt(const std::string& opts) uint64_t coeff = 1; string postfix; for (auto& j : paramPair[1]) - if (!(j >= '0' && j <= '9' || j == '.')) + if (!((j >= '0' && j <= '9') || j == '.')) postfix += j; postfix = strToUpperCase(postfix); if (postfix == "GB") diff --git a/tsMuxer/vc1Parser.h b/tsMuxer/vc1Parser.h index e1531b3..1b2ed49 100644 --- a/tsMuxer/vc1Parser.h +++ b/tsMuxer/vc1Parser.h @@ -68,7 +68,6 @@ class VC1Unit inline static bool isMarker(uint8_t* ptr) { return ptr[0] == ptr[1] == 0 && ptr[2] == 1; } inline static uint8_t* findNextMarker(uint8_t* buffer, uint8_t* end) { - uint8_t* bufStart = buffer; for (buffer += 2; buffer < end;) { if (*buffer > 1) diff --git a/tsMuxer/vvc.cpp b/tsMuxer/vvc.cpp index 8d92e76..10b976a 100644 --- a/tsMuxer/vvc.cpp +++ b/tsMuxer/vvc.cpp @@ -367,7 +367,7 @@ int VvcVpsUnit::deserialize() for (int i = 1; i < TotalNumOlss; i++) { - int NumLayersInOls; + int NumLayersInOls = 0; if (vps_each_layer_is_an_ols_flag) NumLayersInOls = 1; else if (vps_ols_mode_idc == 0 || vps_ols_mode_idc == 1) @@ -492,11 +492,11 @@ VvcSpsUnit::VvcSpsUnit() transfer_characteristics(2), matrix_coeffs(2), // 2 = unspecified full_range_flag(0), - inter_layer_prediction_enabled_flag(0), - long_term_ref_pics_flag(0), sps_num_ref_pic_lists(0), weighted_pred_flag(0), - weighted_bipred_flag(0) + weighted_bipred_flag(0), + long_term_ref_pics_flag(0), + inter_layer_prediction_enabled_flag(0) { } @@ -603,7 +603,6 @@ int VvcSpsUnit::deserialize() if (sps_log2_min_luma_coding_block_size_minus2 > (unsigned)min(4, (int)sps_log2_ctu_size_minus5 + 3)) return 1; unsigned MinCbLog2SizeY = sps_log2_min_luma_coding_block_size_minus2 + 2; - unsigned MinCbSizeY = 1 << MinCbLog2SizeY; m_reader.skipBit(); // sps_partition_constraints_override_enabled_flag unsigned sps_log2_diff_min_qt_min_cb_intra_slice_luma = extractUEGolombCode(); if (sps_log2_diff_min_qt_min_cb_intra_slice_luma > min(6, CtbLog2SizeY) - MinCbLog2SizeY) @@ -957,12 +956,12 @@ int VvcPpsUnit::deserialize() // ----------------------- VvcHrdUnit ------------------------ VvcHrdUnit::VvcHrdUnit() - : general_nal_hrd_params_present_flag(0), - general_du_hrd_params_present_flag(0), + : num_units_in_tick(0), + time_scale(0), + general_nal_hrd_params_present_flag(0), general_vcl_hrd_params_present_flag(0), - hrd_cpb_cnt_minus1(0), - num_units_in_tick(0), - time_scale(0) + general_du_hrd_params_present_flag(0), + hrd_cpb_cnt_minus1(0) { } @@ -1086,7 +1085,7 @@ vector> vvc_extract_priv_data(const uint8_t* buff, int size, int { if (src + 3 > end) THROW(ERR_MOV_PARSE, "Invalid VVC extra data format"); - int type = *src++; + src++; // type int cnt = AV_RB16(src); src += 2; diff --git a/tsMuxer/vvcStreamReader.cpp b/tsMuxer/vvcStreamReader.cpp index d257084..0e8827e 100644 --- a/tsMuxer/vvcStreamReader.cpp +++ b/tsMuxer/vvcStreamReader.cpp @@ -21,11 +21,10 @@ VVCStreamReader::VVCStreamReader() m_firstFrame(true), m_frameNum(0), m_fullPicOrder(0), + m_picOrderBase(0), m_frameDepth(1), - m_picOrderMsb(0), m_prevPicOrder(0), - m_picOrderBase(0), m_lastIFrame(false), m_firstFileFrame(false), m_vpsCounter(0), @@ -300,7 +299,6 @@ int VVCStreamReader::intDecodeNAL(uint8_t* buff) uint8_t* curPos = buff; uint8_t* nextNal = NALUnit::findNextNAL(curPos, m_bufEnd); uint8_t* nextNalWithStartCode; - long oldSpsLen = 0; if (!m_eof && nextNal == m_bufEnd) return NOT_ENOUGH_BUFFER;