mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
Move FFmpeg reset to ffmpeg_decoder (cleanup)
This commit is contained in:
parent
2754f05b11
commit
f5da8281e2
@ -109,11 +109,11 @@ void decode_at3plus(VGMSTREAM *vgmstream,
|
||||
#endif
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
void decode_ffmpeg(VGMSTREAM *stream,
|
||||
sample * outbuf, int32_t samples_to_do, int channels);
|
||||
void decode_ffmpeg(VGMSTREAM *stream, sample * outbuf, int32_t samples_to_do, int channels);
|
||||
|
||||
void reset_ffmpeg(VGMSTREAM *vgmstream);
|
||||
|
||||
void seek_ffmpeg(VGMSTREAM *vgmstream, int32_t num_sample);
|
||||
|
||||
#endif
|
||||
|
||||
void decode_acm(ACMStream * acm, sample * outbuf,
|
||||
|
@ -248,6 +248,24 @@ end:
|
||||
}
|
||||
|
||||
|
||||
void reset_ffmpeg(VGMSTREAM *vgmstream) {
|
||||
ffmpeg_codec_data *data = (ffmpeg_codec_data *) vgmstream->codec_data;
|
||||
|
||||
if (data->formatCtx) {
|
||||
avformat_seek_file(data->formatCtx, -1, 0, 0, 0, AVSEEK_FLAG_ANY);
|
||||
}
|
||||
if (data->codecCtx) {
|
||||
avcodec_flush_buffers(data->codecCtx);
|
||||
}
|
||||
data->readNextPacket = 1;
|
||||
data->bytesConsumedFromDecodedFrame = INT_MAX;
|
||||
data->framesRead = 0;
|
||||
data->endOfStream = 0;
|
||||
data->endOfAudio = 0;
|
||||
data->samplesToDiscard = 0;
|
||||
}
|
||||
|
||||
|
||||
void seek_ffmpeg(VGMSTREAM *vgmstream, int32_t num_sample) {
|
||||
ffmpeg_codec_data *data = (ffmpeg_codec_data *) vgmstream->codec_data;
|
||||
int64_t ts;
|
||||
|
@ -515,20 +515,7 @@ void reset_vgmstream(VGMSTREAM * vgmstream) {
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
if (vgmstream->coding_type==coding_FFmpeg) {
|
||||
ffmpeg_codec_data *data = (ffmpeg_codec_data *) vgmstream->codec_data;
|
||||
|
||||
if (data->formatCtx) {
|
||||
avformat_seek_file(data->formatCtx, -1, 0, 0, 0, AVSEEK_FLAG_ANY);
|
||||
}
|
||||
if (data->codecCtx) {
|
||||
avcodec_flush_buffers(data->codecCtx);
|
||||
}
|
||||
data->readNextPacket = 1;
|
||||
data->bytesConsumedFromDecodedFrame = INT_MAX;
|
||||
data->framesRead = 0;
|
||||
data->endOfStream = 0;
|
||||
data->endOfAudio = 0;
|
||||
data->samplesToDiscard = 0;
|
||||
reset_ffmpeg(vgmstream);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user