app: add option to vertically flip videos

This commit is contained in:
itsmattkc 2022-08-04 16:32:01 -07:00
parent 1b854d51c6
commit 80820263ac
2 changed files with 23 additions and 1 deletions

View file

@ -19,7 +19,8 @@ MediaPanel::MediaPanel(QWidget *parent) :
m_SwrCtx(nullptr),
m_IoCtx(nullptr),
m_AudioOutput(nullptr),
m_SliderPressed(false)
m_SliderPressed(false),
m_vflip(false)
{
int row = 0;
@ -28,6 +29,15 @@ MediaPanel::MediaPanel(QWidget *parent) :
auto preview_layout = new QVBoxLayout(wav_group);
m_vflipCheckbox = new QCheckBox(tr("Flip Vertically"));
connect(m_vflipCheckbox, &QCheckBox::toggled, this, [this](bool e){
m_vflip = e;
SliderMoved(m_PlayheadSlider->value());
});
m_vflipCheckbox->setVisible(false);
//vflip_checkbox->setAlignment(Qt::AlignCenter);
preview_layout->addWidget(m_vflipCheckbox);
m_ImgViewer = new QLabel();
m_ImgViewer->setAlignment(Qt::AlignCenter);
preview_layout->addWidget(m_ImgViewer);
@ -220,6 +230,7 @@ void MediaPanel::OnOpeningData(void *data)
}
if (m_VideoCodecCtx) {
m_vflipCheckbox->setVisible(true);
VideoUpdate(0);
}
}
@ -282,6 +293,9 @@ void MediaPanel::Close()
m_PlayheadSlider->setValue(0);
m_ImgViewer->setPixmap(QPixmap());
m_vflipCheckbox->setChecked(false);
m_vflipCheckbox->setVisible(false);
}
void MediaPanel::VideoUpdate(float t)
@ -350,6 +364,11 @@ void MediaPanel::VideoUpdate(float t)
m_SwsFrame->data, m_SwsFrame->linesize);
QImage img(m_SwsFrame->data[0], m_SwsFrame->width, m_SwsFrame->height, m_SwsFrame->linesize[0], QImage::Format_RGBA8888);
if (m_vflip) {
img = img.mirrored(false, true);
}
m_ImgViewer->setPixmap(QPixmap::fromImage(img));
}
}

View file

@ -10,6 +10,7 @@ extern "C" {
#include <file.h>
#include <QAudioOutput>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <QSlider>
@ -70,12 +71,14 @@ private:
QByteArray m_AudioBuffer;
AVSampleFormat m_AudioOutputSampleFmt;
QSlider *m_PlayheadSlider;
QCheckBox *m_vflipCheckbox;
QPushButton *m_PlayBtn;
QTimer *m_PlaybackTimer;
qint64 m_PlaybackStart;
float m_PlaybackOffset;
bool m_AudioFlushed;
bool m_SliderPressed;
bool m_vflip;
private slots:
void Play(bool e);