mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-02 20:12:07 +08:00
replay: flush codec buffers after seeking (#34556)
* flush codec buffers after seeking * replace avio_seek with the higher-level avformat_seek_file * exit early
This commit is contained in:
@@ -177,7 +177,14 @@ bool VideoDecoder::decode(FrameReader *reader, int idx, VisionBuf *buf) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
avio_seek(reader->input_ctx->pb, reader->packets_info[from_idx].pos, SEEK_SET);
|
||||
|
||||
auto pos = reader->packets_info[from_idx].pos;
|
||||
int ret = avformat_seek_file(reader->input_ctx, 0, pos, pos, pos, AVSEEK_FLAG_BYTE);
|
||||
if (ret < 0) {
|
||||
rError("Failed to seek to byte position %lld: %d", pos, AVERROR(ret));
|
||||
return false;
|
||||
}
|
||||
avcodec_flush_buffers(decoder_ctx);
|
||||
}
|
||||
reader->prev_idx = idx;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user