added settings for waveform/thumbnail resolution

This commit is contained in:
itsmattkc
2019-02-01 18:39:26 +11:00
parent a34b446302
commit 2da663d057
5 changed files with 152 additions and 57 deletions
+17 -7
View File
@@ -48,7 +48,9 @@ Config::Config()
seek_also_selects(false),
effect_textbox_lines(3),
use_software_fallback(false),
center_timeline_timecodes(true)
center_timeline_timecodes(true),
waveform_resolution(64),
thumbnail_resolution(120)
{}
void Config::load(QString path) {
@@ -179,10 +181,16 @@ void Config::load(QString path) {
} else if (stream.name() == "PreferredAudioInput") {
stream.readNext();
preferred_audio_input = stream.text().toString();
} else if (stream.name() == "LanguageFile") {
stream.readNext();
language_file = stream.text().toString();
}
} else if (stream.name() == "LanguageFile") {
stream.readNext();
language_file = stream.text().toString();
} else if (stream.name() == "ThumbnailResolution") {
stream.readNext();
thumbnail_resolution = stream.text().toInt();
} else if (stream.name() == "WaveformResolution") {
stream.readNext();
waveform_resolution = stream.text().toInt();
}
}
}
if (stream.hasError()) {
@@ -245,8 +253,10 @@ void Config::save(QString path) {
stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback));
stream.writeTextElement("CenterTimelineTimecodes", QString::number(center_timeline_timecodes));
stream.writeTextElement("PreferredAudioOutput", preferred_audio_output);
stream.writeTextElement("PreferredAudioInput", preferred_audio_input);
stream.writeTextElement("LanguageFile", language_file);
stream.writeTextElement("PreferredAudioInput", preferred_audio_input);
stream.writeTextElement("LanguageFile", language_file);
stream.writeTextElement("ThumbnailResolution", QString::number(thumbnail_resolution));
stream.writeTextElement("WaveformResolution", QString::number(waveform_resolution));
stream.writeEndElement(); // configuration
stream.writeEndDocument(); // doc
+3 -1
View File
@@ -66,7 +66,9 @@ struct Config {
bool center_timeline_timecodes;
QString preferred_audio_output;
QString preferred_audio_input;
QString language_file;
QString language_file;
int waveform_resolution;
int thumbnail_resolution;
void load(QString path);
void save(QString path);
+2 -5
View File
@@ -18,9 +18,6 @@
#include <QDir>
#include <QDateTime>
#define WAVEFORM_RESOLUTION 64
#define THUMBNAIL_RESOLUTION 120
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
@@ -278,7 +275,7 @@ void PreviewGenerator::generate_waveform() {
if (s != nullptr) {
if (fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!s->preview_done) {
int dstH = THUMBNAIL_RESOLUTION;
int dstH = config.thumbnail_resolution;
int dstW = qRound(dstH * (float(temp_frame->width)/float(temp_frame->height)));
uint8_t* data = new uint8_t[size_t(dstW*dstH*4)];
@@ -317,7 +314,7 @@ void PreviewGenerator::generate_waveform() {
}
media_lengths[packet->stream_index]++;
} else if (fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
int interval = qFloor((temp_frame->sample_rate/WAVEFORM_RESOLUTION)/4)*4;
int interval = qFloor((temp_frame->sample_rate/config.waveform_resolution)/4)*4;
AVFrame* swr_frame = av_frame_alloc();
swr_frame->channel_layout = temp_frame->channel_layout;