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
+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;