Skip to content

Commit

Permalink
movDemuxer: change C cast to C++ cast
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdr428 committed Aug 9, 2023
1 parent d2ae282 commit 01c564e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tsMuxer/aac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool AACCodec::decodeFrame(uint8_t* buffer, uint8_t* end)
}
}

void AACCodec::buildADTSHeader(uint8_t* buffer, const int frameSize)
void AACCodec::buildADTSHeader(uint8_t* buffer, const unsigned frameSize)
{
BitStreamWriter writer{};
writer.setBuffer(buffer, buffer + AAC_HEADER_LEN);
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/aac.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AACCodec
static uint8_t* findAacFrame(uint8_t* buffer, uint8_t* end);
static int getFrameSize(uint8_t* buffer);
bool decodeFrame(uint8_t* buffer, uint8_t* end);
void buildADTSHeader(uint8_t* buffer, int frameSize);
void buildADTSHeader(uint8_t* buffer, unsigned frameSize);
inline void setSampleRate(int value) { m_sample_rate = value; }
void readConfig(uint8_t* buff, int size);

Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/ac3Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ AC3Codec::AC3ParseError AC3Codec::parseHeader(uint8_t *buf, uint8_t *end)
return AC3ParseError::SYNC;

// read ahead to bsid to make sure this is AC-3, not E-AC-3
const int id = buf[3] >> 3;
const uint8_t id = buf[3] >> 3;
if (id > 16)
return AC3ParseError::BSID;

Expand All @@ -99,7 +99,7 @@ AC3Codec::AC3ParseError AC3Codec::parseHeader(uint8_t *buf, uint8_t *end)
// ---------------------------------- EAC3 ------------------------------------------
if (m_bsid > 10)
{
m_frame_size = (((buf[0] & 0x07) << 8 | buf[1]) + 1) << 1;
m_frame_size = static_cast<uint8_t>((((buf[0] & 0x07) << 8 | buf[1]) + 1) << 1);
if (m_frame_size < AC3_HEADER_SIZE)
return AC3ParseError::FRAME_SIZE; // invalid header size

Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/ioContextDemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct Track
encodingAlgo = 0;
type = IOContextTrackType::UNDEFINED;
}
~Track()
virtual ~Track()
{
delete[] name;
delete[] codec_id;
Expand Down
41 changes: 21 additions & 20 deletions tsMuxer/movDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int ff_mov_lang_to_iso639(unsigned code, char* to)
{
for (int i = 2; i >= 0; i--)
{
to[i] = 0x60 + (code & 0x1f);
to[i] = static_cast<char>(0x60 + (code & 0x1f));
code >>= 5;
}
return 1;
Expand All @@ -87,7 +87,7 @@ int ff_mov_lang_to_iso639(unsigned code, char* to)
return 1;
}

struct MOVStreamContext : public Track
struct MOVStreamContext : Track
{
MOVStreamContext()
: m_indexCur(0),
Expand All @@ -114,7 +114,8 @@ struct MOVStreamContext : public Track
sample_rate(0)
{
}
virtual ~MOVStreamContext() {}

~MOVStreamContext() override {}

vector<uint64_t> chunk_offsets;
vector<uint32_t> m_index;
Expand Down Expand Up @@ -177,7 +178,7 @@ class MovParsedAudioTrackData : public ParsedTrackPrivData
const uint8_t* srcEnd = buff + size;
while (buff < srcEnd - 4)
{
int frameSize = m_sc->sample_size;
unsigned frameSize = m_sc->sample_size;
if (frameSize == 0)
frameSize = m_sc->m_index[m_sc->m_indexCur++];
if (isAAC)
Expand Down Expand Up @@ -728,15 +729,15 @@ void MovDemuxer::buildIndex()
m_curChunk = 0;
chunks.clear();

if (num_tracks == 1 && ((MOVStreamContext*)(tracks[0]))->chunk_offsets.empty())
if (num_tracks == 1 && (dynamic_cast<MOVStreamContext*>(tracks[0]))->chunk_offsets.empty())
{
chunks.push_back(make_pair(0, 0));
}
else
{
for (int i = 0; i < num_tracks; ++i)
{
const auto st = (MOVStreamContext*)(tracks[i]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[i]);
for (const auto& j : st->chunk_offsets)
{
if (!found_moof)
Expand Down Expand Up @@ -810,7 +811,7 @@ int MovDemuxer::simpleDemuxBlock(DemuxedData& demuxedData, const PIDSet& accepte
else if (chunkSize)
{
MemoryBlock& vect = demuxedData[trackId + 1ll];
const auto st = (MOVStreamContext*)(tracks[trackId]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[trackId]);
const int64_t oldSize = vect.size();
if (st->parsed_priv_data)
{
Expand Down Expand Up @@ -1084,7 +1085,7 @@ int MovDemuxer::mov_read_trun(MOVAtom atom)
if (!frag->track_id || frag->track_id > num_tracks)
return -1;
Track* st = tracks[frag->track_id - 1];
const auto sc = (MOVStreamContext*)(st);
const auto sc = dynamic_cast<MOVStreamContext*>(st);
if (sc->pseudo_stream_id + 1 != frag->stsd_id)
return 0;
get_byte(); // version
Expand Down Expand Up @@ -1135,7 +1136,7 @@ int MovDemuxer::mov_read_trex(MOVAtom atom)
MOVTrackExt& trex = trex_data[trex_data.size() - 1];
get_byte(); // version
get_be24(); // flags
trex.track_id = get_be32();
tr = get_be32();
trex.stsd_id = get_be32();
trex.duration = get_be32();
trex.size = get_be32();
Expand Down Expand Up @@ -1193,7 +1194,7 @@ int MovDemuxer::mov_read_tkhd(MOVAtom atom) { return 0; }

int MovDemuxer::mov_read_ctts(MOVAtom atom)
{
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
get_byte(); // version
get_be24(); // flags
const int entries = get_be32();
Expand All @@ -1209,7 +1210,7 @@ int MovDemuxer::mov_read_ctts(MOVAtom atom)

int MovDemuxer::mov_read_stts(MOVAtom atom)
{
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
get_byte(); // version
get_be24(); // flags
const int entries = get_be32();
Expand All @@ -1230,7 +1231,7 @@ int MovDemuxer::mov_read_stts(MOVAtom atom)

int MovDemuxer::mov_read_stsz(MOVAtom atom)
{
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
get_byte(); // version
get_be24(); // flags
st->sample_size = get_be32();
Expand All @@ -1245,7 +1246,7 @@ int MovDemuxer::mov_read_stsz(MOVAtom atom)

int MovDemuxer::mov_read_stss(MOVAtom atom)
{
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
get_byte(); // version
get_be24(); // flags

Expand Down Expand Up @@ -1339,7 +1340,7 @@ int MovDemuxer::mov_read_mdhd(MOVAtom atom)
{
if (num_tracks == -1)
return -1;
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
const int version = get_byte();
if (version > 1)
return -1; // unsupported
Expand Down Expand Up @@ -1371,7 +1372,7 @@ int MovDemuxer::mov_read_stsd(MOVAtom atom)
{
if (num_tracks == -1)
return -1;
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);

get_byte(); // version
get_be24(); // flags
Expand Down Expand Up @@ -1546,7 +1547,7 @@ if (bits_per_sample) {

int MovDemuxer::mov_read_stco(const MOVAtom atom)
{
const auto sc = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto sc = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);

get_byte(); // version
get_be24(); // flags
Expand Down Expand Up @@ -1628,7 +1629,7 @@ int MovDemuxer::mp4_read_descr(int* tag)

int MovDemuxer::mov_read_esds(MOVAtom atom)
{
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
get_be32(); // version + flags
int tag;
mp4_read_descr(&tag); // len
Expand Down Expand Up @@ -1666,7 +1667,7 @@ int MovDemuxer::mov_read_esds(MOVAtom atom)
int MovDemuxer::mov_read_dref(MOVAtom atom)
{
/*
MOVStreamContext* st = (MOVStreamContext*) tracks[num_tracks-1];
MOVStreamContext* st = dynamic_cast<MOVStreamContext*> tracks[num_tracks-1];
get_be32(); // version + flags
int entries = get_be32();
st->drefs.resize(entries);
Expand All @@ -1686,7 +1687,7 @@ for (int i = 0; i < entries; i++) {
}
int MovDemuxer::mov_read_stsc(MOVAtom atom)
{
const auto st = (MOVStreamContext*)(tracks[num_tracks - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[num_tracks - 1]);
get_byte(); // version
get_be24(); // flags

Expand Down Expand Up @@ -1758,7 +1759,7 @@ int MovDemuxer::mov_read_elst(MOVAtom atom)

double MovDemuxer::getTrackFps(const uint32_t trackId)
{
const auto st = (MOVStreamContext*)(tracks[trackId - 1]);
const auto st = dynamic_cast<MOVStreamContext*>(tracks[trackId - 1]);
return st->fps;
}

Expand Down

0 comments on commit 01c564e

Please sign in to comment.