Skip to content

Commit

Permalink
Remove y4m seek hack that is probably obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Apr 29, 2024
1 parent 9b7ac32 commit 72b5035
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
25 changes: 4 additions & 21 deletions src/core/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ int FFMS_VideoSource::Seek(int n) {
}

if (ret < 0 && Frames[n].FilePos >= 0) {
ret = av_seek_frame(FormatContext, VideoTrack, Frames[n].FilePos + PosOffset, AVSEEK_FLAG_BYTE);
ret = av_seek_frame(FormatContext, VideoTrack, Frames[n].FilePos, AVSEEK_FLAG_BYTE);
if (ret >= 0)
SeekByPos = true;
}
Expand All @@ -727,23 +727,6 @@ int FFMS_VideoSource::Seek(int n) {
return ret;
}

int FFMS_VideoSource::ReadFrame(AVPacket *pkt) {
int ret = av_read_frame(FormatContext, pkt);
if (ret >= 0 || ret == AVERROR(EOF)) return ret;

// Lavf reports the beginning of the actual video data as the packet's
// position, but the reader requires the header, so we end up seeking
// to the wrong position. Wait until a read actual fails to adjust the
// seek targets, so that if this ever gets fixed upstream our workaround
// doesn't re-break it.
if (strcmp(FormatContext->iformat->name, "yuv4mpegpipe") == 0) {
PosOffset = -6;
Seek(CurrentFrame);
return av_read_frame(FormatContext, pkt);
}
return ret;
}

void FFMS_VideoSource::Free() {
av_freep(&RPUBuffer);
av_freep(&HDR10PlusBuffer);
Expand Down Expand Up @@ -776,12 +759,12 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
av_packet_ref(Packet, StashedPacket);
av_packet_unref(StashedPacket);
} else {
ret = ReadFrame(Packet);
ret = av_read_frame(FormatContext, Packet);
}
while (ret >= 0) {
if (Packet->stream_index != VideoTrack) {
av_packet_unref(Packet);
ret = ReadFrame(Packet);
ret = av_read_frame(FormatContext, Packet);
continue;
}

Expand All @@ -805,7 +788,7 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
av_packet_ref(Packet, StashedPacket);
av_packet_unref(StashedPacket);
} else {
ret = ReadFrame(Packet);
ret = av_read_frame(FormatContext, Packet);
}
}
if (IsIOError(ret)) {
Expand Down
2 changes: 0 additions & 2 deletions src/core/videosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ struct FFMS_VideoSource {
AVFormatContext *FormatContext = nullptr;
int SeekMode;
bool SeekByPos = false;
int PosOffset = 0;
bool HaveSeenInterlacedFrame = false;

void ReAdjustOutputFormat(AVFrame *Frame);
Expand All @@ -127,7 +126,6 @@ struct FFMS_VideoSource {
void DecodeNextFrame(int64_t &PTS, int64_t &Pos);
bool SeekTo(int n, int SeekOffset);
int Seek(int n);
int ReadFrame(AVPacket *pkt);
void Free();
static void SanityCheckFrameForData(AVFrame *Frame);
public:
Expand Down

0 comments on commit 72b5035

Please sign in to comment.