Fix MPC missing start samples

This commit is contained in:
bnnm 2019-10-13 20:13:15 +02:00
parent a05f8cbbec
commit d64f85a02e
3 changed files with 19 additions and 6 deletions

View File

@ -306,6 +306,7 @@ void ffmpeg_set_skip_samples(ffmpeg_codec_data * data, int skip_samples);
uint32_t ffmpeg_get_channel_layout(ffmpeg_codec_data * data);
void ffmpeg_set_channel_remapping(ffmpeg_codec_data * data, int *channels_remap);
const char* ffmpeg_get_codec_name(ffmpeg_codec_data * data);
void ffmpeg_set_force_seek(ffmpeg_codec_data * data);
/* ffmpeg_decoder_utils.c (helper-things) */

View File

@ -355,12 +355,8 @@ ffmpeg_codec_data * init_ffmpeg_header_offset_subsong(STREAMFILE *streamFile, ui
/* setup decent seeking for faulty formats */
errcode = init_seek(data);
if (errcode < 0) {
VGM_LOG("FFMPEG: can't init_seek, error=%i\n", errcode);
/* some formats like Smacker are so buggy that any seeking is impossible (even on video players)
* whatever, we'll just kill and reconstruct FFmpeg's config every time */
data->force_seek = 1;
reset_ffmpeg_internal(data); /* reset state from trying to seek */
//stream = data->formatCtx->streams[data->streamIndex];
VGM_LOG("FFMPEG: can't init_seek, error=%i (using force_seek)\n", errcode);
ffmpeg_set_force_seek(data);
}
return data;
@ -913,4 +909,14 @@ const char* ffmpeg_get_codec_name(ffmpeg_codec_data * data) {
return NULL;
}
void ffmpeg_set_force_seek(ffmpeg_codec_data * data) {
/* some formats like Smacker are so buggy that any seeking is impossible (even on video players),
* or MPC with an incorrectly parsed seek table (using as 0 some non-0 seek offset).
* whatever, we'll just kill and reconstruct FFmpeg's config every time */
;VGM_LOG("1\n");
data->force_seek = 1;
reset_ffmpeg_internal(data); /* reset state from trying to seek */
//stream = data->formatCtx->streams[data->streamIndex];
}
#endif

View File

@ -61,6 +61,12 @@ VGMSTREAM * init_vgmstream_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start,
num_samples = mpeg_get_samples(streamFile, 0x00, get_streamfile_size(streamFile));
}
/* hack for MPC, that seeks/resets incorrectly due to seek table shenanigans */
if (read_32bitBE(0x00, streamFile) == 0x4D502B07 || /* "MP+\7" (Musepack V7) */
read_32bitBE(0x00, streamFile) == 0x4D50434B) { /* "MPCK" (Musepack V8) */
ffmpeg_set_force_seek(data);
}
/* default but often inaccurate when calculated using bitrate (wrong for VBR) */
if (!num_samples) {
num_samples = data->totalSamples;