From 6b40a4ccf8cec58be2f64a74fa4bfb08481c32c6 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 26 Mar 2019 21:58:47 +1100 Subject: [PATCH] hdr video can be used in the pipeline without conversion to rgba8888 --- rendering/bitdepths.cpp | 8 ++++++-- rendering/bitdepths.h | 1 + rendering/framebufferobject.cpp | 2 -- timeline/clip.cpp | 6 ++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/rendering/bitdepths.cpp b/rendering/bitdepths.cpp index bad6dc6f7..f2a623088 100644 --- a/rendering/bitdepths.cpp +++ b/rendering/bitdepths.cpp @@ -35,21 +35,25 @@ void InitializeBitDepths() { bit_depths[PIX_FMT_RGBA8].internal_format = GL_RGBA8; bit_depths[PIX_FMT_RGBA8].pixel_format = GL_RGBA; bit_depths[PIX_FMT_RGBA8].pixel_type = GL_UNSIGNED_BYTE; + bit_depths[PIX_FMT_RGBA8].bytes_per_pixel = 4; bit_depths[PIX_FMT_RGBA16].name = QCoreApplication::translate("bitdepths", "16-bit Integer"); - bit_depths[PIX_FMT_RGBA16].internal_format = GL_RGBA16UI; - bit_depths[PIX_FMT_RGBA16].pixel_format = GL_RGBA_INTEGER; + bit_depths[PIX_FMT_RGBA16].internal_format = GL_RGBA16; + bit_depths[PIX_FMT_RGBA16].pixel_format = GL_RGBA; bit_depths[PIX_FMT_RGBA16].pixel_type = GL_UNSIGNED_SHORT; + bit_depths[PIX_FMT_RGBA16].bytes_per_pixel = 8; bit_depths[PIX_FMT_RGBA16F].name = QCoreApplication::translate("bitdepths", "Half-Float (16-bit)"); bit_depths[PIX_FMT_RGBA16F].internal_format = GL_RGBA16F; bit_depths[PIX_FMT_RGBA16F].pixel_format = GL_RGBA; bit_depths[PIX_FMT_RGBA16F].pixel_type = GL_HALF_FLOAT; + bit_depths[PIX_FMT_RGBA16F].bytes_per_pixel = 8; bit_depths[PIX_FMT_RGBA32F].name = QCoreApplication::translate("bitdepths", "Full-Float (32-bit)"); bit_depths[PIX_FMT_RGBA32F].internal_format = GL_RGBA32F; bit_depths[PIX_FMT_RGBA32F].pixel_format = GL_RGBA; bit_depths[PIX_FMT_RGBA32F].pixel_type = GL_FLOAT; + bit_depths[PIX_FMT_RGBA32F].bytes_per_pixel = 16; } diff --git a/rendering/bitdepths.h b/rendering/bitdepths.h index 67393440b..0cbd70bb5 100644 --- a/rendering/bitdepths.h +++ b/rendering/bitdepths.h @@ -33,6 +33,7 @@ struct BitDepthInfo { GLint internal_format; GLenum pixel_format; GLenum pixel_type; + int bytes_per_pixel; }; /** diff --git a/rendering/framebufferobject.cpp b/rendering/framebufferobject.cpp index 8f9eed3d7..00360ca8f 100644 --- a/rendering/framebufferobject.cpp +++ b/rendering/framebufferobject.cpp @@ -69,8 +69,6 @@ void FramebufferObject::Create(QOpenGLContext *ctx, int width, int height) olive::CurrentConfig.export_bit_depth : olive::CurrentConfig.playback_bit_depth); - qDebug() << "hello" << bit_depth.name; - ctx->functions()->glTexImage2D( GL_TEXTURE_2D, 0, diff --git a/timeline/clip.cpp b/timeline/clip.cpp index 36f5bec8c..3f0a6b516 100644 --- a/timeline/clip.cpp +++ b/timeline/clip.cpp @@ -37,8 +37,6 @@ #include "global/debug.h" #include "global/timing.h" -const int kRGBAComponentCount = 4; - Clip::Clip(Sequence* s) : sequence(s), cacher(this), @@ -584,13 +582,13 @@ bool Clip::Retrieve() } - f->glPixelStorei(GL_UNPACK_ROW_LENGTH, frame->linesize[0]/kRGBAComponentCount); - int video_width = cacher.media_width(); int video_height = cacher.media_height(); const olive::rendering::BitDepthInfo& bit_depth_info = olive::rendering::bit_depths.at(cacher.media_pixel_format()); + f->glPixelStorei(GL_UNPACK_ROW_LENGTH, frame->linesize[0]/bit_depth_info.bytes_per_pixel); + if (allocate_data) { // the raw frame size may differ from the one we're using (e.g. a lower resolution proxy), so we make sure