diff --git a/Plugins/CoreAudio/CoreAudioDecoder.h b/Plugins/CoreAudio/CoreAudioDecoder.h index a13d47e43..93ba337f4 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.h +++ b/Plugins/CoreAudio/CoreAudioDecoder.h @@ -37,6 +37,7 @@ BOOL _audioFile_opened; BOOL _in_opened; + BOOL _audioFile_is_lossy; int bitrate; int bitsPerSample; diff --git a/Plugins/CoreAudio/CoreAudioDecoder.m b/Plugins/CoreAudio/CoreAudioDecoder.m index ea83d2c1c..d48031e8e 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.m +++ b/Plugins/CoreAudio/CoreAudioDecoder.m @@ -212,6 +212,11 @@ static SInt64 getSizeProc(void* clientData) { bitsPerSample = 32; floatingPoint = YES; } + + _audioFile_is_lossy = NO; + + if (floatingPoint || [[codec lowercaseString] containsString:@"adpcm"] || [[codec lowercaseString] containsString:@"gsm"]) + _audioFile_is_lossy = YES; // Set output format AudioStreamBasicDescription result; @@ -349,7 +354,7 @@ static SInt64 getSizeProc(void* clientData) { [NSNumber numberWithBool:YES], @"seekable", codec, @"codec", floatingPoint ? @"host" : @"big", @"endian", - floatingPoint ? @"lossy" : @"lossless", @"encoding", + _audioFile_is_lossy ? @"lossy" : @"lossless", @"encoding", nil]; } diff --git a/Plugins/FFMPEG/FFMPEGDecoder.h b/Plugins/FFMPEG/FFMPEGDecoder.h index b80a54a25..d2ce701a6 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.h +++ b/Plugins/FFMPEG/FFMPEGDecoder.h @@ -19,6 +19,7 @@ int channels; int bitsPerSample; BOOL floatingPoint; + BOOL lossy; float frequency; long totalFrames; long framesRead; diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index 7e28104c7..bb22595c7 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -333,6 +333,100 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) return NO; } + lossy = NO; + if (floatingPoint) + lossy = YES; + + if (!floatingPoint) { + switch (codec_id) { + case AV_CODEC_ID_MP2: + case AV_CODEC_ID_MP3: + case AV_CODEC_ID_AAC: + case AV_CODEC_ID_AC3: + // case AV_CODEC_ID_DTS: // lossy will return float, caught above, lossless will be integer + case AV_CODEC_ID_VORBIS: + case AV_CODEC_ID_DVAUDIO: + case AV_CODEC_ID_WMAV1: + case AV_CODEC_ID_WMAV2: + case AV_CODEC_ID_MACE3: + case AV_CODEC_ID_MACE6: + case AV_CODEC_ID_VMDAUDIO: + case AV_CODEC_ID_MP3ADU: + case AV_CODEC_ID_MP3ON4: + case AV_CODEC_ID_WESTWOOD_SND1: + case AV_CODEC_ID_GSM: + case AV_CODEC_ID_QDM2: + case AV_CODEC_ID_COOK: + case AV_CODEC_ID_TRUESPEECH: + case AV_CODEC_ID_SMACKAUDIO: + case AV_CODEC_ID_QCELP: + case AV_CODEC_ID_DSICINAUDIO: + case AV_CODEC_ID_IMC: + case AV_CODEC_ID_MUSEPACK7: + case AV_CODEC_ID_MLP: + case AV_CODEC_ID_GSM_MS: + case AV_CODEC_ID_ATRAC3: + case AV_CODEC_ID_NELLYMOSER: + case AV_CODEC_ID_MUSEPACK8: + case AV_CODEC_ID_SPEEX: + case AV_CODEC_ID_WMAVOICE: + case AV_CODEC_ID_WMAPRO: + case AV_CODEC_ID_ATRAC3P: + case AV_CODEC_ID_EAC3: + case AV_CODEC_ID_SIPR: + case AV_CODEC_ID_MP1: + case AV_CODEC_ID_TWINVQ: + case AV_CODEC_ID_MP4ALS: + case AV_CODEC_ID_ATRAC1: + case AV_CODEC_ID_BINKAUDIO_RDFT: + case AV_CODEC_ID_BINKAUDIO_DCT: + case AV_CODEC_ID_AAC_LATM: + case AV_CODEC_ID_QDMC: + case AV_CODEC_ID_CELT: + case AV_CODEC_ID_G723_1: + case AV_CODEC_ID_G729: + case AV_CODEC_ID_8SVX_EXP: + case AV_CODEC_ID_8SVX_FIB: + case AV_CODEC_ID_BMV_AUDIO: + case AV_CODEC_ID_RALF: + case AV_CODEC_ID_IAC: + case AV_CODEC_ID_ILBC: + case AV_CODEC_ID_OPUS: + case AV_CODEC_ID_COMFORT_NOISE: + case AV_CODEC_ID_METASOUND: + case AV_CODEC_ID_PAF_AUDIO: + case AV_CODEC_ID_ON2AVC: + case AV_CODEC_ID_DSS_SP: + case AV_CODEC_ID_CODEC2: + case AV_CODEC_ID_FFWAVESYNTH: + case AV_CODEC_ID_SONIC: + case AV_CODEC_ID_SONIC_LS: + case AV_CODEC_ID_EVRC: + case AV_CODEC_ID_SMV: + case AV_CODEC_ID_4GV: + case AV_CODEC_ID_INTERPLAY_ACM: + case AV_CODEC_ID_XMA1: + case AV_CODEC_ID_XMA2: + case AV_CODEC_ID_ATRAC3AL: + case AV_CODEC_ID_ATRAC3PAL: + case AV_CODEC_ID_DOLBY_E: + case AV_CODEC_ID_APTX: + case AV_CODEC_ID_SBC: + case AV_CODEC_ID_ATRAC9: + case AV_CODEC_ID_HCOM: + case AV_CODEC_ID_ACELP_KELVIN: + case AV_CODEC_ID_MPEGH_3D_AUDIO: + case AV_CODEC_ID_SIREN: + case AV_CODEC_ID_HCA: + case AV_CODEC_ID_FASTAUDIO: + lossy = YES; + break; + + default: + break; + } + } + //totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE); AVRational tb = {.num = 1, .den = codecCtx->sample_rate}; totalFrames = av_rescale_q(stream->duration, stream->time_base, tb); @@ -580,7 +674,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) [NSNumber numberWithBool:seekable], @"seekable", [NSString stringWithUTF8String:avcodec_get_name(codecCtx->codec_id)], @"codec", @"host", @"endian", - floatingPoint ? @"lossy" : @"lossless", @"encoding", + lossy ? @"lossy" : @"lossless", @"encoding", nil]; }