Core Audio / FFmpeg inputs: Change to correctly discern most lossy/lossless codecs
parent
9d1fd08574
commit
058614b6a0
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
BOOL _audioFile_opened;
|
BOOL _audioFile_opened;
|
||||||
BOOL _in_opened;
|
BOOL _in_opened;
|
||||||
|
BOOL _audioFile_is_lossy;
|
||||||
|
|
||||||
int bitrate;
|
int bitrate;
|
||||||
int bitsPerSample;
|
int bitsPerSample;
|
||||||
|
|
|
@ -212,6 +212,11 @@ static SInt64 getSizeProc(void* clientData) {
|
||||||
bitsPerSample = 32;
|
bitsPerSample = 32;
|
||||||
floatingPoint = YES;
|
floatingPoint = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_audioFile_is_lossy = NO;
|
||||||
|
|
||||||
|
if (floatingPoint || [[codec lowercaseString] containsString:@"adpcm"] || [[codec lowercaseString] containsString:@"gsm"])
|
||||||
|
_audioFile_is_lossy = YES;
|
||||||
|
|
||||||
// Set output format
|
// Set output format
|
||||||
AudioStreamBasicDescription result;
|
AudioStreamBasicDescription result;
|
||||||
|
@ -349,7 +354,7 @@ static SInt64 getSizeProc(void* clientData) {
|
||||||
[NSNumber numberWithBool:YES], @"seekable",
|
[NSNumber numberWithBool:YES], @"seekable",
|
||||||
codec, @"codec",
|
codec, @"codec",
|
||||||
floatingPoint ? @"host" : @"big", @"endian",
|
floatingPoint ? @"host" : @"big", @"endian",
|
||||||
floatingPoint ? @"lossy" : @"lossless", @"encoding",
|
_audioFile_is_lossy ? @"lossy" : @"lossless", @"encoding",
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
int channels;
|
int channels;
|
||||||
int bitsPerSample;
|
int bitsPerSample;
|
||||||
BOOL floatingPoint;
|
BOOL floatingPoint;
|
||||||
|
BOOL lossy;
|
||||||
float frequency;
|
float frequency;
|
||||||
long totalFrames;
|
long totalFrames;
|
||||||
long framesRead;
|
long framesRead;
|
||||||
|
|
|
@ -333,6 +333,100 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
return NO;
|
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);
|
//totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE);
|
||||||
AVRational tb = {.num = 1, .den = codecCtx->sample_rate};
|
AVRational tb = {.num = 1, .den = codecCtx->sample_rate};
|
||||||
totalFrames = av_rescale_q(stream->duration, stream->time_base, tb);
|
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",
|
[NSNumber numberWithBool:seekable], @"seekable",
|
||||||
[NSString stringWithUTF8String:avcodec_get_name(codecCtx->codec_id)], @"codec",
|
[NSString stringWithUTF8String:avcodec_get_name(codecCtx->codec_id)], @"codec",
|
||||||
@"host", @"endian",
|
@"host", @"endian",
|
||||||
floatingPoint ? @"lossy" : @"lossless", @"encoding",
|
lossy ? @"lossy" : @"lossless", @"encoding",
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue