Skip to content

Commit a69596c

Browse files
authored
Merge pull request #535 from ElderOrb/yaxis
Scriptable min/max for y-axis
2 parents cc4e181 + 1f15222 commit a69596c

19 files changed

+237
-115
lines changed

Source/Core/AudioCore.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct per_group AudioPerGroup [Group_AudioMax]=
1212
{
1313
//R128
1414
{
15-
Item_R128M, 1, -70, 0, 3, "R.128", false,
15+
Item_R128M, 1, "-70", "0", 3, "R.128", false,
1616
"R 128 refers to a European Broadcasting Union (EBU) specification\n"
1717
"document governing several loudness parameters, including momentary,\n"
1818
"integrated, and short-term loudness. QCTools specifically examines momentary\n"
@@ -23,15 +23,15 @@ struct per_group AudioPerGroup [Group_AudioMax]=
2323
},
2424
//aphasemeter
2525
{
26-
Item_aphasemeter, 1, -1, 1, 3, "Audio Phase", false,
26+
Item_aphasemeter, 1, "-1", "1", 3, "Audio Phase", false,
2727
"The audio phase value represents the mean phase of current audio frame. Value is\n"
2828
"in range [-1, 1]. The -1 means left and right channels are completely out of\n"
2929
"phase and 1 means channels are in phase.",
3030
ActiveFilter_Audio_aphasemeter,
3131
},
3232
//astats levels
3333
{
34-
Item_DC_offset, 3, -1, 1, 3, "Levels", true,
34+
Item_DC_offset, 3, "-1", "1", 3, "Levels", true,
3535
"For selected audio tracks this graph plots the DC offset (mean\n"
3636
"amplitude displacement from zero), minimal sample level, and \n"
3737
"maximum sample level. Note that this value is plotted per audio\n"
@@ -40,7 +40,7 @@ struct per_group AudioPerGroup [Group_AudioMax]=
4040
},
4141
//astats diff
4242
{
43-
Item_Min_difference, 3, 0, 1, 3, "Aud Diffs", false,
43+
Item_Min_difference, 3, "0", "1", 3, "Aud Diffs", false,
4444
"For selected audio tracks this graph plots the minimal difference\n"
4545
"between two consecutive samples, maximal difference between two\n"
4646
"consecutive samples. and the mean difference between two consecutive\n"
@@ -52,7 +52,7 @@ struct per_group AudioPerGroup [Group_AudioMax]=
5252
},
5353
//astats rms
5454
{
55-
Item_Peak_level, 3, -70, 0, 3, "RMS", false,
55+
Item_Peak_level, 3, "-70", "0", 3, "RMS", false,
5656
"For selected audio tracks this graph plots the Standard peak and RMS\n"
5757
"level measured in dBFS and the Peak and trough values for RMS level\n"
5858
"measured over a short window. Note that this value is plotted per\n"

Source/Core/AudioStreamStats.cpp

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ using namespace tinyxml2;
3535
AudioStreamStats::AudioStreamStats(XMLElement *streamElement) : CommonStreamStats(streamElement),
3636
sample_rate(0),
3737
channels(0),
38-
bits_per_sample(0),
39-
bits_per_raw_sample(0)
38+
bits_per_sample(0)
4039
{
4140
codec_type = "audio";
41+
stream_type = AVMEDIA_TYPE_AUDIO;
4242

4343
const char* sample_fmt_value = streamElement->Attribute("sample_fmt");
44-
if(sample_fmt_value)
45-
sample_fmt = sample_fmt_value;
44+
if(sample_fmt_value) {
45+
sample_fmt = av_get_sample_fmt(sample_fmt_value);
46+
sample_fmt_string = sample_fmt_value;
47+
}
4648

4749
const char* sample_rate_value = streamElement->Attribute("sample_rate");
4850
if(sample_rate_value)
@@ -59,31 +61,28 @@ AudioStreamStats::AudioStreamStats(XMLElement *streamElement) : CommonStreamStat
5961
const char* bits_per_sample_value = streamElement->Attribute("bits_per_sample");
6062
if(bits_per_sample_value)
6163
bits_per_sample = std::stoi(bits_per_sample_value);
62-
63-
const char* bits_per_raw_sample_value = streamElement->Attribute("bits_per_raw_sample");
64-
if(bits_per_raw_sample_value)
65-
bits_per_raw_sample = std::stoi(bits_per_raw_sample_value);
6664
}
6765

6866
AudioStreamStats::AudioStreamStats(AVStream* stream, AVFormatContext *context) : CommonStreamStats(stream),
69-
sample_fmt(""),
67+
sample_fmt_string(""),
7068
sample_rate(stream != NULL ? stream->codecpar->sample_rate : 0),
7169
channels(stream != NULL ? stream->codecpar->channels : 0),
7270
channel_layout(""),
73-
bits_per_sample(stream != NULL ? av_get_bits_per_sample(stream->codecpar->codec_id) : 0),
74-
bits_per_raw_sample(stream != NULL ? stream->codecpar->bits_per_raw_sample : 0)
71+
bits_per_sample(stream != NULL ? av_get_bits_per_sample(stream->codecpar->codec_id) : 0)
7572
{
7673
Q_UNUSED(context);
7774

7875
codec_type = "audio";
76+
stream_type = AVMEDIA_TYPE_AUDIO;
7977

8078
if(stream)
8179
{
82-
const char* s = av_get_sample_fmt_name((AVSampleFormat) stream->codecpar->format);
80+
sample_fmt = stream->codecpar->format;
81+
const char* s = av_get_sample_fmt_name((AVSampleFormat) sample_fmt);
8382
if (s)
84-
sample_fmt = s;
83+
sample_fmt_string = s;
8584
else
86-
sample_fmt = "unknown";
85+
sample_fmt_string = "unknown";
8786

8887
AVBPrint pbuf;
8988
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
@@ -106,7 +105,7 @@ void AudioStreamStats::writeStreamInfoToXML(QXmlStreamWriter *writer)
106105

107106
assert(writer);
108107

109-
writer->writeAttribute("sample_fmt", QString::fromStdString(getSample_fmt()));
108+
writer->writeAttribute("sample_fmt", QString::fromStdString(getSample_fmt_string()));
110109
writer->writeAttribute("sample_rate", QString::number(getSample_rate()));
111110
writer->writeAttribute("channels", QString::number(getChannels()));
112111
writer->writeAttribute("channel_layout", QString::fromStdString(getChannel_layout()));
@@ -116,20 +115,24 @@ void AudioStreamStats::writeStreamInfoToXML(QXmlStreamWriter *writer)
116115
writer->writeAttribute("time_base", QString::fromStdString(getTime_base()));
117116
writer->writeAttribute("start_pts", QString::fromStdString(getStart_pts()));
118117
writer->writeAttribute("start_time", QString::fromStdString(getStart_time()));
119-
writer->writeAttribute("bits_per_raw_sample", QString::number(getBits_per_raw_sample()));
120118

121119
CommonStreamStats::writeDispositionInfoToXML(writer);
122120
CommonStreamStats::writeMetadataToXML(writer);
123121
}
124122

125-
std::string AudioStreamStats::getSample_fmt() const
123+
int AudioStreamStats::getSample_fmt() const
126124
{
127125
return sample_fmt;
128126
}
129127

130-
void AudioStreamStats::setSample_fmt(const std::string &value)
128+
std::string AudioStreamStats::getSample_fmt_string() const
129+
{
130+
return sample_fmt_string;
131+
}
132+
133+
void AudioStreamStats::setSample_fmt_string(const std::string &value)
131134
{
132-
sample_fmt = value;
135+
sample_fmt_string = value;
133136
}
134137

135138
int AudioStreamStats::getSample_rate() const
@@ -171,13 +174,3 @@ void AudioStreamStats::setBits_per_sample(int value)
171174
{
172175
bits_per_sample = value;
173176
}
174-
175-
int AudioStreamStats::getBits_per_raw_sample() const
176-
{
177-
return bits_per_raw_sample;
178-
}
179-
180-
void AudioStreamStats::setBits_per_raw_sample(int value)
181-
{
182-
bits_per_raw_sample = value;
183-
}

Source/Core/AudioStreamStats.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ class AudioStreamStats : public CommonStreamStats
2626

2727
virtual void writeStreamInfoToXML(QXmlStreamWriter* writer);
2828

29-
std::string getSample_fmt() const;
30-
void setSample_fmt(const std::string &value);
29+
int getSample_fmt() const;
30+
31+
std::string getSample_fmt_string() const;
32+
void setSample_fmt_string(const std::string &value);
3133

3234
int getSample_rate() const;
3335
void setSample_rate(const int &value);
@@ -41,16 +43,13 @@ class AudioStreamStats : public CommonStreamStats
4143
int getBits_per_sample() const;
4244
void setBits_per_sample(int value);
4345

44-
int getBits_per_raw_sample() const;
45-
void setBits_per_raw_sample(int value);
46-
4746
private:
48-
std::string sample_fmt;
47+
std::string sample_fmt_string;
48+
int sample_fmt;
4949
int sample_rate;
5050
int channels;
5151
std::string channel_layout;
5252
int bits_per_sample;
53-
int bits_per_raw_sample;
5453
};
5554

5655
#endif // AudioStreamStats_H

Source/Core/CommonStreamStats.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ std::string CommonStreamStats::getCodec_Type() const
207207
return codec_type;
208208
}
209209

210+
int CommonStreamStats::getType() const
211+
{
212+
return stream_type;
213+
}
214+
210215
std::string CommonStreamStats::getCodec_Time_Base() const
211216
{
212217
return codec_time_base;

Source/Core/CommonStreamStats.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CommonStreamStats
3333
std::string getCodec_Name() const;
3434
std::string getCodec_Long_Name() const;
3535
std::string getCodec_Type() const;
36+
int getType() const;
3637
std::string getCodec_Time_Base() const;
3738
std::string getCodec_TagString() const;
3839

@@ -75,6 +76,7 @@ class CommonStreamStats
7576
std::string codec_name;
7677
std::string codec_long_name;
7778
std::string codec_type;
79+
int stream_type;
7880
std::string codec_time_base;
7981
int codec_tag;
8082

Source/Core/Core.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,15 @@ struct per_group
4141
{
4242
const std::size_t Start; //Item
4343
const std::size_t Count;
44-
const double Min;
45-
const double Max;
44+
const char* MinFormula;
45+
const char* MaxFormula;
4646
const double StepsCount;
4747
const char* Name;
4848
const bool CheckedByDefault;
4949
const char* Description;
5050
activefilter ActiveFilterGroup;
51-
52-
void setMax(double value) {
53-
(const_cast<double&> (Max)) = value;
54-
}
5551
};
52+
5653
struct per_item
5754
{
5855
const std::size_t Group1; //Group

Source/Core/FFmpeg_Glue.cpp

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,11 +2408,11 @@ string FFmpeg_Glue::ColorRange_Get()
24082408
}
24092409
}
24102410

2411-
int FFmpeg_Glue::BitsPerRawSample_Get()
2411+
int FFmpeg_Glue::BitsPerRawSample_Get(int streamType)
24122412
{
24132413
inputdata* InputData=NULL;
24142414
for (size_t Pos=0; Pos<InputDatas.size(); Pos++)
2415-
if (InputDatas[Pos] && InputDatas[Pos]->Type==AVMEDIA_TYPE_VIDEO)
2415+
if (InputDatas[Pos] && InputDatas[Pos]->Type==streamType)
24162416
{
24172417
InputData=InputDatas[Pos];
24182418
break;
@@ -2470,7 +2470,23 @@ string FFmpeg_Glue::SampleFormat_Get()
24702470
case AV_SAMPLE_FMT_NB: return "number of sample formats";
24712471
default: return string();
24722472
}
2473-
}
2473+
}
2474+
2475+
int FFmpeg_Glue::sampleFormat()
2476+
{
2477+
inputdata* InputData=NULL;
2478+
for (size_t Pos=0; Pos<InputDatas.size(); Pos++)
2479+
if (InputDatas[Pos] && InputDatas[Pos]->Type==AVMEDIA_TYPE_AUDIO)
2480+
{
2481+
InputData=InputDatas[Pos];
2482+
break;
2483+
}
2484+
2485+
if (InputData==NULL || InputData->Stream==NULL || InputData->Stream->codec==NULL)
2486+
return AV_SAMPLE_FMT_NONE;
2487+
2488+
return InputData->Stream->codec->sample_fmt;
2489+
}
24742490

24752491
//---------------------------------------------------------------------------
24762492
int FFmpeg_Glue::SamplingRate_Get()
@@ -2775,6 +2791,35 @@ int FFmpeg_Glue::guessBitsPerRawSampleFromFormat(int pixelFormat)
27752791
}
27762792
}
27772793

2794+
int FFmpeg_Glue::bitsPerAudioSample(int audioFormat)
2795+
{
2796+
return av_get_bytes_per_sample((AVSampleFormat) audioFormat);
2797+
}
2798+
2799+
bool FFmpeg_Glue::isFloatAudioSampleFormat(int audioFormat)
2800+
{
2801+
return audioFormat == AV_SAMPLE_FMT_FLT
2802+
|| audioFormat == AV_SAMPLE_FMT_FLTP
2803+
|| audioFormat == AV_SAMPLE_FMT_DBL
2804+
|| audioFormat == AV_SAMPLE_FMT_DBLP;
2805+
}
2806+
2807+
bool FFmpeg_Glue::isSignedAudioSampleFormat(int audioFormat)
2808+
{
2809+
return audioFormat == AV_SAMPLE_FMT_S16
2810+
|| audioFormat == AV_SAMPLE_FMT_S16P
2811+
|| audioFormat == AV_SAMPLE_FMT_S32
2812+
|| audioFormat == AV_SAMPLE_FMT_S32P
2813+
|| audioFormat == AV_SAMPLE_FMT_S64
2814+
|| audioFormat == AV_SAMPLE_FMT_S64P;
2815+
}
2816+
2817+
bool FFmpeg_Glue::isUnsignedAudioSampleFormat(int audioFormat)
2818+
{
2819+
return audioFormat == AV_SAMPLE_FMT_U8
2820+
|| audioFormat == AV_SAMPLE_FMT_U8P;
2821+
}
2822+
27782823
FFmpeg_Glue::Image::Image()
27792824
{
27802825

Source/Core/FFmpeg_Glue.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ class FFmpeg_Glue
135135
string PixFormat_Get();
136136
string ColorSpace_Get();
137137
string ColorRange_Get();
138-
int BitsPerRawSample_Get();
138+
int BitsPerRawSample_Get(int streamType = Type_Video);
139139

140140
// Audio information
141141
string AudioFormat_Get();
142142
string SampleFormat_Get();
143+
int sampleFormat();
143144
int SamplingRate_Get();
144145
string ChannelLayout_Get();
145146
int ABitDepth_Get();
@@ -153,6 +154,10 @@ class FFmpeg_Glue
153154

154155
static QByteArray getAttachment(const QString& fileName, QString& attachmentFileName);
155156
static int guessBitsPerRawSampleFromFormat(int pixelFormat);
157+
static int bitsPerAudioSample(int audioFormat);
158+
static bool isFloatAudioSampleFormat(int audioFormat);
159+
static bool isSignedAudioSampleFormat(int audioFormat);
160+
static bool isUnsignedAudioSampleFormat(int audioFormat);
156161

157162
// Actions
158163
void AddInput_Video(size_t FrameCount, int time_base_num, int time_base_den, int Width, int Height, int BitDepth, bool Compression, int TimecodeBCD=-1);

0 commit comments

Comments
 (0)