From 3cb6aa45faa156fcb380aeacc13b03743bc471ec Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 21 Nov 2015 21:32:29 +0100 Subject: [PATCH] Allow setting width/height on FlatInput and YCbCrInput after instantiation. --- flat_input.h | 14 ++++++++++++++ util.cpp | 4 ++-- version.h | 2 +- ycbcr_input.cpp | 11 ++--------- ycbcr_input.h | 27 ++++++++++++++++++++++++++- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/flat_input.h b/flat_input.h index 14f8df1..d8b62b7 100644 --- a/flat_input.h +++ b/flat_input.h @@ -107,6 +107,20 @@ public: void invalidate_pixel_data(); + // Note: Sets pitch to width, so even if your pitch is unchanged, + // you will need to re-set it after this call. + void set_width(unsigned width) + { + this->pitch = this->width = width; + invalidate_pixel_data(); + } + + void set_height(unsigned height) + { + this->height = height; + invalidate_pixel_data(); + } + void set_pitch(unsigned pitch) { this->pitch = pitch; invalidate_pixel_data(); diff --git a/util.cpp b/util.cpp index 9c077e9..d500399 100644 --- a/util.cpp +++ b/util.cpp @@ -334,11 +334,11 @@ void *get_gl_context_identifier() #elif defined(WIN32) return (void *)wglGetCurrentContext(); #else - void *ret = (void *)glXGetCurrentContext(); + void *ret = (void *)eglGetCurrentContext(); if (ret != NULL) { return ret; } - return (void *)eglGetCurrentContext(); + return (void *)glXGetCurrentContext(); #endif } diff --git a/version.h b/version.h index c23d0e2..87be640 100644 --- a/version.h +++ b/version.h @@ -5,6 +5,6 @@ // changes, even within git versions. There is no specific version // documentation outside the regular changelogs, though. -#define MOVIT_VERSION 11 +#define MOVIT_VERSION 12 #endif // !defined(_MOVIT_VERSION_H) diff --git a/ycbcr_input.cpp b/ycbcr_input.cpp index 4c824c6..071ce13 100644 --- a/ycbcr_input.cpp +++ b/ycbcr_input.cpp @@ -30,15 +30,8 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format, pbos[0] = pbos[1] = pbos[2] = 0; texture_num[0] = texture_num[1] = texture_num[2] = 0; - assert(width % ycbcr_format.chroma_subsampling_x == 0); - pitch[0] = widths[0] = width; - pitch[1] = widths[1] = width / ycbcr_format.chroma_subsampling_x; - pitch[2] = widths[2] = width / ycbcr_format.chroma_subsampling_x; - - assert(height % ycbcr_format.chroma_subsampling_y == 0); - heights[0] = height; - heights[1] = height / ycbcr_format.chroma_subsampling_y; - heights[2] = height / ycbcr_format.chroma_subsampling_y; + set_width(width); + set_height(height); pixel_data[0] = pixel_data[1] = pixel_data[2] = NULL; owns_texture[0] = owns_texture[1] = owns_texture[2] = false; diff --git a/ycbcr_input.h b/ycbcr_input.h index 6f4b66d..3aed51b 100644 --- a/ycbcr_input.h +++ b/ycbcr_input.h @@ -79,7 +79,32 @@ public: void invalidate_pixel_data(); - void set_pitch(unsigned channel, unsigned pitch) { + // Note: Sets pitch to width, so even if your pitch is unchanged, + // you will need to re-set it after this call. + void set_width(unsigned width) + { + this->width = width; + + assert(width % ycbcr_format.chroma_subsampling_x == 0); + pitch[0] = widths[0] = width; + pitch[1] = widths[1] = width / ycbcr_format.chroma_subsampling_x; + pitch[2] = widths[2] = width / ycbcr_format.chroma_subsampling_x; + invalidate_pixel_data(); + } + + void set_height(unsigned height) + { + this->height = height; + + assert(height % ycbcr_format.chroma_subsampling_y == 0); + heights[0] = height; + heights[1] = height / ycbcr_format.chroma_subsampling_y; + heights[2] = height / ycbcr_format.chroma_subsampling_y; + invalidate_pixel_data(); + } + + void set_pitch(unsigned channel, unsigned pitch) + { assert(channel >= 0 && channel < num_channels); this->pitch[channel] = pitch; invalidate_pixel_data(); -- 2.39.2