Fixed reading duration + some code refactoring.
This commit is contained in:
parent
9b01f44804
commit
cde4d54680
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@ LameXP Audio-Encoder Front-End – Changelog
|
||||
* Updated LAME encoder to v3.100 Final (2017-10-13), compiled with ICL 18.0 and MSVC 14.1
|
||||
* Updated mpg123 decoder to v1.25.7 (2017-09-25), compiled with GCC 7.2.0
|
||||
* Updated Opus encoder/decoder libraries to v1.2.1 (2017-07-26) and Opus-Tools to v0.1.10 (2017-05-25)
|
||||
* Updated MediaInfo to v0.7.99 (2017-09-11), compiled with ICL 18.0 and MSVC 14.1
|
||||
* Updated MediaInfo to v17.10 (2017-11-02), compiled with ICL 18.0 and MSVC 14.1
|
||||
* Updated GnuPG to v1.4.22 (2017-07-19), compiled with GCC 7.2.0
|
||||
* Complete re-write of MediaInfo parsing code, now using XML-based MediaInfo output
|
||||
* Improved auto-detection of max. parallel instances on computers with SSD (or similar) drive
|
||||
|
@ -34,8 +34,8 @@
|
||||
#define VER_LAMEXP_MINOR_HI 1
|
||||
#define VER_LAMEXP_MINOR_LO 6
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 8
|
||||
#define VER_LAMEXP_BUILD 2050
|
||||
#define VER_LAMEXP_PATCH 9
|
||||
#define VER_LAMEXP_BUILD 2054
|
||||
#define VER_LAMEXP_CONFG 2002
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -71,7 +71,6 @@ while(0)
|
||||
} \
|
||||
while(0)
|
||||
|
||||
|
||||
#define SET_OPTIONAL(TYPE, IF_CMD, THEN_CMD) do \
|
||||
{ \
|
||||
TYPE _tmp;\
|
||||
@ -79,16 +78,15 @@ while(0)
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#define DIV_RND(A,B) (((A) + ((B) / 2U)) / (B))
|
||||
#define STRICMP(A,B) ((A).compare((B), Qt::CaseInsensitive) == 0)
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static initialization
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class AnalyzeTask_StaticInit_MediaInfoIdx : public MUtils::Lazy<const QMap<QPair<AnalyzeTask::MI_trackType_t, QString>, AnalyzeTask::MI_propertyId_t>>
|
||||
static MUtils::Lazy<const QMap<QPair<AnalyzeTask::MI_trackType_t, QString>, AnalyzeTask::MI_propertyId_t>> s_mediaInfoIdx([]
|
||||
{
|
||||
virtual QMap<QPair<AnalyzeTask::MI_trackType_t, QString>, AnalyzeTask::MI_propertyId_t> *create()
|
||||
{
|
||||
QMap<QPair<AnalyzeTask::MI_trackType_t, QString>, AnalyzeTask::MI_propertyId_t> *const builder = new QMap<QPair<AnalyzeTask::MI_trackType_t, QString>, AnalyzeTask::MI_propertyId_t>();
|
||||
ADD_PROPTERY_MAPPING_2(gen, format, container);
|
||||
ADD_PROPTERY_MAPPING_2(gen, format_profile, container_profile);
|
||||
@ -116,49 +114,35 @@ class AnalyzeTask_StaticInit_MediaInfoIdx : public MUtils::Lazy<const QMap<QPair
|
||||
ADD_PROPTERY_MAPPING_2(gen, cover_mime, cover_mime);
|
||||
ADD_PROPTERY_MAPPING_2(gen, cover_data, cover_data);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
s_mediaInfoIdx;
|
||||
});
|
||||
|
||||
class AnalyzeTask_StaticInit_AvisynthIdx : public MUtils::Lazy<const QMap<QString, AnalyzeTask::MI_propertyId_t>>
|
||||
static MUtils::Lazy<const QMap<QString, AnalyzeTask::MI_propertyId_t>> s_avisynthIdx([]
|
||||
{
|
||||
virtual QMap<QString, AnalyzeTask::MI_propertyId_t> *create()
|
||||
{
|
||||
QMap<QString, AnalyzeTask::MI_propertyId_t> *const builder = new QMap<QString, AnalyzeTask::MI_propertyId_t>();
|
||||
builder->insert(QLatin1String("totalseconds"), AnalyzeTask::propertyId_duration);
|
||||
builder->insert(QLatin1String("samplespersec"), AnalyzeTask::propertyId_samplingrate);
|
||||
builder->insert(QLatin1String("channels"), AnalyzeTask::propertyId_channel_s_);
|
||||
builder->insert(QLatin1String("bitspersample"), AnalyzeTask::propertyId_bitdepth);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
s_avisynthIdx;
|
||||
});
|
||||
|
||||
class AnalyzeTask_StaticInit_MimiTypes : public MUtils::Lazy<const QMap<QString, QString>>
|
||||
static MUtils::Lazy<const QMap<QString, QString>> s_mimeTypes([]
|
||||
{
|
||||
virtual QMap<QString, QString> *create()
|
||||
{
|
||||
QMap<QString, QString> *const builder = new QMap<QString, QString>();
|
||||
for (size_t i = 0U; MIME_TYPES[i].type; ++i)
|
||||
{
|
||||
builder->insert(QString::fromLatin1(MIME_TYPES[i].type), QString::fromLatin1(MIME_TYPES[i].ext[0]));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
s_mimeTypes;
|
||||
});
|
||||
|
||||
class AnalyzeTask_StaticInit_TrackTypes : public MUtils::Lazy<const QMap<QString, AnalyzeTask::MI_trackType_t>>
|
||||
static MUtils::Lazy<const QMap<QString, AnalyzeTask::MI_trackType_t>> s_trackTypes([]
|
||||
{
|
||||
virtual QMap<QString, AnalyzeTask::MI_trackType_t> *create()
|
||||
{
|
||||
QMap<QString, AnalyzeTask::MI_trackType_t> *const builder = new QMap<QString, AnalyzeTask::MI_trackType_t>();
|
||||
builder->insert("general", AnalyzeTask::trackType_gen);
|
||||
builder->insert("audio", AnalyzeTask::trackType_aud);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
s_trackTypes;
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -402,7 +386,6 @@ const AudioFileModel& AnalyzeTask::parseMediaInfo(const QByteArray &data, AudioF
|
||||
}
|
||||
while (findNextElement(QLatin1String("Media"), xmlStream))
|
||||
{
|
||||
qWarning("Found a media!");
|
||||
if (firstMediaFile || audioFile.techInfo().containerType().isEmpty() || audioFile.techInfo().audioType().isEmpty())
|
||||
{
|
||||
firstMediaFile = false;
|
||||
@ -453,7 +436,6 @@ void AnalyzeTask::parseFileInfo(QXmlStreamReader &xmlStream, AudioFileModel &aud
|
||||
MI_trackType_t trackType;
|
||||
while (findNextElement(QLatin1String("Track"), xmlStream))
|
||||
{
|
||||
qWarning("Found a track!");
|
||||
const QString typeString = findAttribute(QLatin1String("Type"), xmlStream.attributes());
|
||||
if ((trackType = m_trackTypes.value(typeString.toLower(), MI_trackType_t(-1))) != MI_trackType_t(-1))
|
||||
{
|
||||
@ -507,7 +489,7 @@ void AnalyzeTask::parseProperty(const QString &value, const MI_propertyId_t prop
|
||||
{
|
||||
case propertyId_container: audioFile.techInfo().setContainerType(value); return;
|
||||
case propertyId_container_profile: audioFile.techInfo().setContainerProfile(value); return;
|
||||
case propertyId_duration: SET_OPTIONAL(quint32, parseDuration(value, _tmp), audioFile.techInfo().setDuration(_tmp)); return;
|
||||
case propertyId_duration: SET_OPTIONAL(double, parseFloat(value, _tmp), audioFile.techInfo().setDuration(qRound(_tmp))); return;
|
||||
case propertyId_title: audioFile.metaInfo().setTitle(value); return;
|
||||
case propertyId_artist: audioFile.metaInfo().setArtist(value); return;
|
||||
case propertyId_album: audioFile.metaInfo().setAlbum(value); return;
|
||||
@ -521,7 +503,7 @@ void AnalyzeTask::parseProperty(const QString &value, const MI_propertyId_t prop
|
||||
case propertyId_channel_s_: SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioChannels(_tmp)); return;
|
||||
case propertyId_samplingrate: SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioSamplerate(_tmp)); return;
|
||||
case propertyId_bitdepth: SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioBitdepth(_tmp)); return;
|
||||
case propertyId_bitrate: SET_OPTIONAL(quint32, parseDuration(value, _tmp), audioFile.techInfo().setAudioBitrate(_tmp)); return;
|
||||
case propertyId_bitrate: SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioBitrate(DIV_RND(_tmp, 1000U))); return;
|
||||
case propertyId_bitrate_mode: SET_OPTIONAL(quint32, parseRCMode(value, _tmp), audioFile.techInfo().setAudioBitrateMode(_tmp)); return;
|
||||
case propertyId_encoded_library: audioFile.techInfo().setAudioEncodeLib(cleanAsciiStr(value)); return;
|
||||
case propertyId_cover_mime: coverMimeType = value; return;
|
||||
@ -684,14 +666,11 @@ bool AnalyzeTask::parseUnsigned(const QString &str, quint32 &value)
|
||||
value = str.toUInt(&okay);
|
||||
return okay;
|
||||
}
|
||||
bool AnalyzeTask::parseDuration(const QString &str, quint32 &value)
|
||||
bool AnalyzeTask::parseFloat(const QString &str, double &value)
|
||||
{
|
||||
if (parseUnsigned(str, value))
|
||||
{
|
||||
value = (value + 500U) / 1000U;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
bool okay = false;
|
||||
value = QLocale::c().toDouble(str, &okay);
|
||||
return okay;
|
||||
}
|
||||
|
||||
bool AnalyzeTask::parseYear(const QString &str, quint32 &value)
|
||||
|
@ -112,7 +112,7 @@ private:
|
||||
|
||||
static QString decodeStr(const QString &str, const QString &encoding);
|
||||
static bool parseUnsigned(const QString &str, quint32 &value);
|
||||
static bool parseDuration(const QString &str, quint32 &value);
|
||||
static bool parseFloat(const QString &str, double &value);
|
||||
static bool parseYear(const QString &st, quint32 &valuer);
|
||||
static bool parseRCMode(const QString &str, quint32 &value);
|
||||
static QString cleanAsciiStr(const QString &str);
|
||||
|
Loading…
Reference in New Issue
Block a user