Skip to content

Commit

Permalink
Resolved issues in Mp4Reader regarding the gop changes being in abstr…
Browse files Browse the repository at this point in the history
…act class
  • Loading branch information
mohammedzakikochargi committed Jun 26, 2024
1 parent 77df71e commit 13053ca
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions base/src/Mp4ReaderSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Mp4ReaderDetailAbs
virtual void sendEndOfStream() = 0;
virtual bool produceFrames(frame_container& frames) = 0;
virtual int mp4Seek(mp4_demux* demux, uint64_t time_offset_usec, mp4_seek_method syncType, int& seekedToFrame) = 0;
virtual int getGop() = 0;

bool Init()
{
Expand Down Expand Up @@ -118,9 +119,13 @@ class Mp4ReaderDetailAbs
if (!props.parseFS && cof)
{
cof->clearCache();
if (tempVideoPath == mState.mVideoPath)
{
updateMstate(props, tempVideoPath);
return;
}
updateMstate(props, tempVideoPath);
initNewVideo();
return;
}

std::string tempSkipDir;
Expand Down Expand Up @@ -522,11 +527,14 @@ class Mp4ReaderDetailAbs
mFPS = mState.mFramesInVideo / mDurationInSecs;
// todo: Implement a way for mp4reader to update FPS when opening a new video in parseFS enabled mode. Must not set parseFS disabled in a loop.
mProps.fps = mFPS;
auto gop = mState.info.syncSampleEntries[2] - mState.info.syncSampleEntries[1];
auto gop = getGop();
mProps.fps = mFPS * playbackSpeed;
if(playbackSpeed == 8 || playbackSpeed == 16 || playbackSpeed == 32)
{
mProps.fps = mProps.fps/gop;
if (gop)
{
mProps.fps = mProps.fps / gop;
}
}
setMp4ReaderProps(mProps);
if (controlModule != nullptr)
Expand Down Expand Up @@ -1133,6 +1141,7 @@ class Mp4ReaderDetailJpeg : public Mp4ReaderDetailAbs
bool produceFrames(frame_container& frames);
void sendEndOfStream() {}
int mp4Seek(mp4_demux* demux, uint64_t time_offset_usec, mp4_seek_method syncType, int& seekedToFrame);
int getGop();
};

class Mp4ReaderDetailH264 : public Mp4ReaderDetailAbs
Expand All @@ -1148,6 +1157,7 @@ class Mp4ReaderDetailH264 : public Mp4ReaderDetailAbs
void prependSpsPps(uint8_t* iFrameBuffer);
void sendEndOfStream();
int mp4Seek(mp4_demux* demux, uint64_t time_offset_usec, mp4_seek_method syncType, int& seekedToFrame);
int getGop();
private:
uint8_t* sps = nullptr;
uint8_t* pps = nullptr;
Expand Down Expand Up @@ -1176,6 +1186,11 @@ int Mp4ReaderDetailJpeg::mp4Seek(mp4_demux* demux, uint64_t time_offset_usec, mp
return ret;
}

int Mp4ReaderDetailJpeg::getGop()
{
return 0;
}

bool Mp4ReaderDetailJpeg::produceFrames(frame_container& frames)
{
frame_sp imgFrame = makeFrame(mProps.biggerFrameSize, encodedImagePinId);
Expand Down Expand Up @@ -1286,6 +1301,12 @@ int Mp4ReaderDetailH264::mp4Seek(mp4_demux* demux, uint64_t time_offset_usec, mp
return ret;
}

int Mp4ReaderDetailH264::getGop()
{
int gop = mState.info.syncSampleEntries[2] - mState.info.syncSampleEntries[1];
return gop;
}

void Mp4ReaderDetailH264::sendEndOfStream()
{
auto frame = frame_sp(new EoSFrame(EoSFrame::EoSFrameType::MP4_SEEK_EOS, 0));
Expand Down

0 comments on commit 13053ca

Please sign in to comment.