merged trilinear fixes
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
uniform sampler2D image;
|
||||
|
||||
//uniform float radius;
|
||||
>>>>>>> master
|
||||
uniform float sigma;
|
||||
uniform vec2 resolution;
|
||||
uniform bool horiz_blur;
|
||||
@@ -15,13 +21,13 @@ float gaussian2(float x, float y, float sigma) {
|
||||
}
|
||||
|
||||
vec4 process(vec4 col) {
|
||||
float rad = ceil(sigma);
|
||||
float rad = ceil(3.0 * sigma);
|
||||
|
||||
float sum = 0.0;
|
||||
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
bool radius_is_zero = (rad == 0.0);
|
||||
bool radius_is_zero = (rad == 0.0 || sigma == 0.0);
|
||||
|
||||
if (!radius_is_zero) {
|
||||
for (float x=-rad+0.5;x<=rad;x+=2.0) {
|
||||
|
||||
@@ -21,5 +21,6 @@ vec4 process(vec4 col) {
|
||||
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
|
||||
}
|
||||
tc += center;
|
||||
|
||||
return texture2D(texture, tc / resolution);
|
||||
}
|
||||
+13
-27
@@ -70,7 +70,7 @@ ExportThread::ExportThread(const ExportParams ¶ms,
|
||||
surface.create();
|
||||
}
|
||||
|
||||
bool ExportThread::Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale) {
|
||||
bool ExportThread::Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream) {
|
||||
ret = avcodec_send_frame(codec_ctx, frame);
|
||||
if (ret < 0) {
|
||||
qCritical() << "Failed to send frame to encoder." << ret;
|
||||
@@ -91,18 +91,9 @@ bool ExportThread::Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx,
|
||||
}
|
||||
|
||||
packet->stream_index = stream->index;
|
||||
if (rescale) {
|
||||
if (packet->pts != AV_NOPTS_VALUE) {
|
||||
packet->pts = qRound(packet->pts * av_q2d(codec_ctx->time_base) / av_q2d(stream->time_base));
|
||||
}
|
||||
if (packet->dts != AV_NOPTS_VALUE) {
|
||||
packet->dts = qRound(packet->dts * av_q2d(codec_ctx->time_base) / av_q2d(stream->time_base));
|
||||
}
|
||||
if (packet->duration > 0) {
|
||||
packet->duration = qRound(packet->duration * av_q2d(codec_ctx->time_base) / av_q2d(stream->time_base));
|
||||
}
|
||||
//av_packet_rescale_ts(packet, codec_ctx->time_base, stream->time_base);
|
||||
}
|
||||
|
||||
av_packet_rescale_ts(packet, codec_ctx->time_base, stream->time_base);
|
||||
|
||||
av_interleaved_write_frame(ofmt_ctx, packet);
|
||||
av_packet_unref(packet);
|
||||
}
|
||||
@@ -482,7 +473,7 @@ void ExportThread::Export()
|
||||
sws_frame->pts = qRound(timecode_secs/av_q2d(vcodec_ctx->time_base));
|
||||
|
||||
// Send frame to encoder
|
||||
if (!Encode(fmt_ctx, vcodec_ctx, sws_frame, &video_pkt, video_stream, true)) {
|
||||
if (!Encode(fmt_ctx, vcodec_ctx, sws_frame, &video_pkt, video_stream)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -520,7 +511,7 @@ void ExportThread::Export()
|
||||
swr_frame->pts = file_audio_samples;
|
||||
|
||||
// Send frame to encoder
|
||||
if (!Encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) {
|
||||
if (!Encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -569,7 +560,7 @@ void ExportThread::Export()
|
||||
swr_convert_frame(swr_ctx, swr_frame, nullptr);
|
||||
if (swr_frame->nb_samples == 0) break;
|
||||
swr_frame->pts = file_audio_samples;
|
||||
if (!Encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) {
|
||||
if (!Encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream)) {
|
||||
return;
|
||||
}
|
||||
file_audio_samples += swr_frame->nb_samples;
|
||||
@@ -582,17 +573,12 @@ void ExportThread::Export()
|
||||
return;
|
||||
}
|
||||
|
||||
bool continueVideo = params_.video_enabled;
|
||||
bool continueAudio = params_.audio_enabled;
|
||||
|
||||
// Flush remaining packets out of video and audio encoders
|
||||
while (continueVideo && continueAudio) {
|
||||
if (continueVideo) {
|
||||
continueVideo = Encode(fmt_ctx, vcodec_ctx, nullptr, &video_pkt, video_stream, true);
|
||||
}
|
||||
if (continueAudio) {
|
||||
continueAudio = Encode(fmt_ctx, acodec_ctx, nullptr, &audio_pkt, audio_stream, true);
|
||||
}
|
||||
// Flush remaining packets out of video and audio encoders by sending a null frame
|
||||
if (params_.video_enabled) {
|
||||
Encode(fmt_ctx, vcodec_ctx, nullptr, &video_pkt, video_stream);
|
||||
}
|
||||
if (params_.audio_enabled) {
|
||||
Encode(fmt_ctx, acodec_ctx, nullptr, &audio_pkt, audio_stream);
|
||||
}
|
||||
|
||||
// Write container trailer
|
||||
|
||||
@@ -83,7 +83,7 @@ signals:
|
||||
public slots:
|
||||
void Interrupt();
|
||||
private:
|
||||
bool Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale);
|
||||
bool Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream);
|
||||
bool SetupVideo();
|
||||
bool SetupAudio();
|
||||
bool SetupContainer();
|
||||
|
||||
@@ -52,17 +52,19 @@ void FramebufferObject::Create(QOpenGLContext *ctx, int width, int height)
|
||||
// set context to new context provided
|
||||
ctx_ = ctx;
|
||||
|
||||
QOpenGLFunctions* f = ctx->functions();
|
||||
|
||||
// create framebuffer object
|
||||
ctx->functions()->glGenFramebuffers(1, &buffer_);
|
||||
f->glGenFramebuffers(1, &buffer_);
|
||||
|
||||
// create texture
|
||||
ctx->functions()->glGenTextures(1, &texture_);
|
||||
f->glGenTextures(1, &texture_);
|
||||
|
||||
// bind framebuffer for attaching
|
||||
ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer_);
|
||||
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer_);
|
||||
|
||||
// bind texture
|
||||
ctx->functions()->glBindTexture(GL_TEXTURE_2D, texture_);
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture_);
|
||||
|
||||
// allocate storage for texture
|
||||
const olive::PixelFormatInfo& bit_depth = olive::pixel_formats.at(olive::Global->is_exporting() ?
|
||||
@@ -82,8 +84,8 @@ void FramebufferObject::Create(QOpenGLContext *ctx, int width, int height)
|
||||
);
|
||||
|
||||
// set texture filtering to bilinear
|
||||
ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// attach texture to framebuffer
|
||||
ctx->extraFunctions()->glFramebufferTexture2D(
|
||||
@@ -95,10 +97,10 @@ void FramebufferObject::Create(QOpenGLContext *ctx, int width, int height)
|
||||
ctx->functions()->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// release texture
|
||||
ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
f->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// release framebuffer
|
||||
ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void FramebufferObject::Destroy()
|
||||
|
||||
@@ -76,8 +76,19 @@ GLfloat olive::rendering::flipped_blit_texcoords[] = {
|
||||
1.0, 0.0
|
||||
};
|
||||
|
||||
void PrepareToDraw(QOpenGLFunctions* f) {
|
||||
f->glGenerateMipmap(GL_TEXTURE_2D);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
}
|
||||
|
||||
void olive::rendering::Blit(QOpenGLShaderProgram* pipeline, bool flipped, QMatrix4x4 matrix) {
|
||||
|
||||
QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions();
|
||||
PrepareToDraw(func);
|
||||
|
||||
QOpenGLVertexArrayObject m_vao;
|
||||
m_vao.create();
|
||||
m_vao.bind();
|
||||
@@ -94,8 +105,6 @@ void olive::rendering::Blit(QOpenGLShaderProgram* pipeline, bool flipped, QMatri
|
||||
m_vbo2.allocate(flipped ? flipped_blit_texcoords : blit_texcoords, 12 * sizeof(GLfloat));
|
||||
m_vbo2.release();
|
||||
|
||||
QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions();
|
||||
|
||||
pipeline->bind();
|
||||
|
||||
pipeline->setUniformValue("mvp_matrix", matrix);
|
||||
@@ -586,9 +595,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, textureID);
|
||||
|
||||
// set texture filter to bilinear
|
||||
params.ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D);
|
||||
params.ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
params.ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
PrepareToDraw(params.ctx->functions());
|
||||
|
||||
// draw clip on screen according to gl coordinates
|
||||
params.pipeline->bind();
|
||||
|
||||
+1
-1
@@ -570,7 +570,7 @@ bool Clip::Retrieve()
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
// set texture filtering to bilinear
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// set texture wrapping to clamp
|
||||
|
||||
+10
-7
@@ -1097,13 +1097,16 @@ void MainWindow::maximize_panel() {
|
||||
// store the current state of panels
|
||||
temp_panel_state = saveState();
|
||||
|
||||
// remove all dock widgets (kind of painful having to do each individually)
|
||||
if (focused_panel != panel_project) removeDockWidget(panel_project);
|
||||
if (focused_panel != panel_effect_controls) removeDockWidget(panel_effect_controls);
|
||||
if (focused_panel != panel_timeline) removeDockWidget(panel_timeline);
|
||||
if (focused_panel != panel_sequence_viewer) removeDockWidget(panel_sequence_viewer);
|
||||
if (focused_panel != panel_footage_viewer) removeDockWidget(panel_footage_viewer);
|
||||
if (focused_panel != panel_graph_editor) removeDockWidget(panel_graph_editor);
|
||||
// remove all dock widgets that aren't the hovered panel
|
||||
for (int i=0;i<olive::panels.size();i++) {
|
||||
if (olive::panels.at(i) != focused_panel) {
|
||||
// hide the panel
|
||||
olive::panels.at(i)->setVisible(false);
|
||||
|
||||
// set it to floating
|
||||
olive::panels.at(i)->setFloating(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// we must be maximized, restore previous state
|
||||
|
||||
@@ -117,7 +117,6 @@ void ViewerWindow::paintGL() {
|
||||
if (texture_ > 0) {
|
||||
if (mutex_ != nullptr) mutex_->lock();
|
||||
|
||||
|
||||
QOpenGLFunctions* f = context()->functions();
|
||||
//QOpenGLExtraFunctions* xf = context()->extraFunctions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user