mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
ffmpeg: AAC cleanup and doc
This commit is contained in:
parent
4927761e52
commit
4a178e4e44
@ -572,7 +572,7 @@ STREAMFILE* ffmpeg_get_streamfile(ffmpeg_codec_data* data);
|
||||
/* ffmpeg_decoder_utils.c (helper-things) */
|
||||
ffmpeg_codec_data* init_ffmpeg_atrac3_raw(STREAMFILE* sf, off_t offset, size_t data_size, int sample_count, int channels, int sample_rate, int block_align, int encoder_delay);
|
||||
ffmpeg_codec_data* init_ffmpeg_atrac3_riff(STREAMFILE* sf, off_t offset, int* out_samples);
|
||||
ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size);
|
||||
ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size, int skip_samples);
|
||||
|
||||
|
||||
/* ffmpeg_decoder_custom_opus.c (helper-things) */
|
||||
|
@ -764,10 +764,8 @@ static ffmpeg_codec_data* init_ffmpeg_custom_opus_config(STREAMFILE* sf, off_t s
|
||||
|
||||
/* FFmpeg + libopus: skips samples, notifies skip in codecCtx->delay (not in stream->skip_samples)
|
||||
* FFmpeg + opus: *doesn't* skip, also notifies skip in codecCtx->delay, hurray (possibly fixed in recent versions)
|
||||
* FFmpeg + opus is audibly buggy with some low bitrate SSB Ultimate files too */
|
||||
//if (ffmpeg_data->skipSamples <= 0) {
|
||||
// ffmpeg_set_skip_samples(ffmpeg_data, skip);
|
||||
//}
|
||||
* FFmpeg + opus is audibly buggy with some low bitrate SSB Ultimate files */
|
||||
//ffmpeg_set_skip_samples(ffmpeg_data, skip);
|
||||
|
||||
close_streamfile(temp_sf);
|
||||
return ffmpeg_data;
|
||||
|
@ -187,7 +187,7 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size) {
|
||||
ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size, int skip_samples) {
|
||||
ffmpeg_codec_data* data = NULL;
|
||||
|
||||
data = init_ffmpeg_offset(sf, offset, size);
|
||||
@ -199,7 +199,7 @@ ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size) {
|
||||
/* raw AAC doesn't set this, while some decoders like FAAD remove 1024,
|
||||
* but should be handled in container as each encoder uses its own value
|
||||
* (Apple: 2112, FAAD: probably 1024, etc) */
|
||||
//ffmpeg_set_skip_samples(data, 1024);
|
||||
ffmpeg_set_skip_samples(data, skip_samples);
|
||||
|
||||
return data;
|
||||
fail:
|
||||
|
@ -82,6 +82,9 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
|
||||
* .mus: Marc Ecko's Getting Up (PC) */
|
||||
if (!num_samples && check_extensions(sf, "mp3,lmp3,mus")) {
|
||||
num_samples = mpeg_get_samples(sf, 0x00, get_streamfile_size(sf));
|
||||
|
||||
/* this seems correct thankfully */
|
||||
//ffmpeg_set_skip_samples(data, encoder_delay);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
VGMSTREAM* init_vgmstream_naac(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channels;
|
||||
int loop_flag, channels, skip_samples;
|
||||
size_t data_size;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ VGMSTREAM* init_vgmstream_naac(STREAMFILE* sf) {
|
||||
start_offset = 0x1000;
|
||||
loop_flag = (read_s32le(0x18,sf) != 0);
|
||||
channels = read_s32le(0x08,sf);
|
||||
skip_samples = 1024; /* raw AAC doesn't set this */
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
@ -42,15 +43,14 @@ VGMSTREAM* init_vgmstream_naac(STREAMFILE* sf) {
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
{
|
||||
vgmstream->codec_data = init_ffmpeg_aac(sf, start_offset, data_size);
|
||||
vgmstream->codec_data = init_ffmpeg_aac(sf, start_offset, data_size, skip_samples);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
/* observed default, some files start without silence though seems correct when loop_start=0 */
|
||||
ffmpeg_set_skip_samples(vgmstream->codec_data, 1024); /* raw AAC doesn't set this */
|
||||
vgmstream->num_samples -= 1024;
|
||||
vgmstream->loop_end_sample -= 1024;
|
||||
vgmstream->num_samples -= skip_samples;
|
||||
vgmstream->loop_end_sample -= skip_samples;
|
||||
/* for some reason last frame is ignored/bugged in various decoders (gives EOF errors) */
|
||||
}
|
||||
#else
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
/* .STRM - from Abylight 3DS games [Cursed Castilla (3DS)] */
|
||||
VGMSTREAM* init_vgmstream_strm_abylight(STREAMFILE* sf) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, sample_rate;
|
||||
int loop_flag, channel_count, sample_rate, skip_samples;
|
||||
size_t data_size;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ VGMSTREAM* init_vgmstream_strm_abylight(STREAMFILE* sf) {
|
||||
loop_flag = 0;
|
||||
channel_count = 2; /* there are various possible fields but all files are stereo */
|
||||
sample_rate = read_32bitLE(0x08,sf);
|
||||
skip_samples = 1024; /* assumed, maybe a bit more */
|
||||
|
||||
start_offset = 0x1e;
|
||||
data_size = read_32bitLE(0x10,sf);
|
||||
@ -42,14 +43,12 @@ VGMSTREAM* init_vgmstream_strm_abylight(STREAMFILE* sf) {
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
{
|
||||
vgmstream->codec_data = init_ffmpeg_aac(sf, start_offset, data_size);
|
||||
vgmstream->codec_data = init_ffmpeg_aac(sf, start_offset, data_size, skip_samples);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
/* assumed, maybe a bit more */
|
||||
ffmpeg_set_skip_samples(vgmstream->codec_data, 1024);
|
||||
vgmstream->num_samples -= 1024;
|
||||
vgmstream->num_samples -= skip_samples;
|
||||
}
|
||||
#else
|
||||
goto fail;
|
||||
|
@ -486,7 +486,7 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
|
||||
vgmstream->num_samples = ffmpeg_data->totalSamples; /* sometimes works */
|
||||
}
|
||||
else if (txth.codec == AAC) {
|
||||
ffmpeg_data = init_ffmpeg_aac(txth.sf_body, txth.start_offset, txth.data_size);
|
||||
ffmpeg_data = init_ffmpeg_aac(txth.sf_body, txth.start_offset, txth.data_size, 0);
|
||||
if (!ffmpeg_data) goto fail;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user