Beatmup
|
Resamples an image to a given resolution. More...
#include <resampler.h>
Public Types | |
enum class | Mode { NEAREST_NEIGHBOR , BOX , LINEAR , CUBIC , CONVNET } |
Resampling mode (algorithm) specification. More... | |
Public Types inherited from Beatmup::AbstractTask | |
enum class | TaskDeviceRequirement { CPU_ONLY , GPU_OR_CPU , GPU_ONLY } |
Specifies which device (CPU and/or GPU) is used to run the task. More... | |
Public Member Functions | |
BitmapResampler (Context &context) | |
Creates a resampler. More... | |
~BitmapResampler () | |
void | setInput (AbstractBitmap *input) |
Sets the image to process. More... | |
void | setOutput (AbstractBitmap *output) |
Sets the output image. More... | |
AbstractBitmap * | getInput () |
AbstractBitmap * | getOutput () |
void | setMode (Mode mode) |
Sets the resampling algorithm to use. More... | |
Mode | getMode () const |
Returns currently selected resampling algorithm. More... | |
void | setCubicParameter (float alpha) |
Sets cubic interpolation parameter ("alpha"). More... | |
float | getCubicParameter () const |
Returns cubic interpolation parameter ("alpha"). More... | |
void | setUsingEs31IfAvailable (bool useEs31) |
Defines OpenGL ES backend selection policy (2.0 vs 3.1) when applicable. More... | |
void | setInputRect (const IntRectangle &rect) |
Specifies a rectangular working area in the input bitmap. More... | |
void | setOutputRect (const IntRectangle &rect) |
Specifies a rectangular working area in the output bitmap. More... | |
IntRectangle | getInputRect () const |
IntRectangle | getOutputRect () const |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Static Public Attributes | |
static const float | DEFAULT_CUBIC_PARAMETER = -0.5f |
Protected Member Functions | |
virtual TaskDeviceRequirement | getUsedDevices () const |
Communicates devices (CPU and/or GPU) the task is run on. More... | |
virtual bool | process (TaskThread &thread) |
Executes the task on CPU within a given thread. More... | |
virtual bool | processOnGPU (GraphicPipeline &gpu, TaskThread &thread) |
Executes the task on GPU. More... | |
virtual void | beforeProcessing (ThreadIndex, ProcessingTarget target, GraphicPipeline *) |
Instruction called before the task is executed. More... | |
virtual void | afterProcessing (ThreadIndex, GraphicPipeline *, bool) |
Instruction called after the task is executed. More... | |
virtual ThreadIndex | getMaxThreads () const |
Gives the upper limint on the number of threads the task may be performed by. More... | |
Private Attributes | |
Context & | context |
a context managing intermediate bitmaps More... | |
AbstractBitmap * | input |
AbstractBitmap * | output |
input and output bitmaps More... | |
IntRectangle | srcRect |
IntRectangle | destRect |
Mode | mode |
float | cubicParameter |
X2UpsamplingNetwork * | convnet |
convnet instance More... | |
bool | isUsingEs31IfAvailable |
if true , uses OpenGL ES 3.1 backend when available instead ES 2.0 More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Beatmup::AbstractTask | |
static ThreadIndex | validThreadCount (int number) |
Valid thread count from a given integer value. More... | |
Private Member Functions inherited from Beatmup::BitmapContentLock | |
BitmapContentLock () | |
~BitmapContentLock () | |
void | readLock (GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target) |
Locks content of a bitmap for reading using a specific processing target device. More... | |
void | writeLock (GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target) |
Locks content of a bitmap for writing using a specific processing target device. More... | |
void | unlock (AbstractBitmap *bitmap) |
Drops a lock to the bitmap. More... | |
void | unlockAll () |
Unlocks all the locked bitmaps unconditionally. More... | |
template<const ProcessingTarget target> | |
void | lock (GraphicPipeline *gpu, AbstractBitmap *input, AbstractBitmap *output) |
void | lock (GraphicPipeline *gpu, ProcessingTarget target, AbstractBitmap *input, AbstractBitmap *output) |
template<const ProcessingTarget target> | |
void | lock (GraphicPipeline *gpu, std::initializer_list< AbstractBitmap * > read, std::initializer_list< AbstractBitmap * > write) |
template<typename ... Args> | |
void | unlock (AbstractBitmap *first, Args ... others) |
Resamples an image to a given resolution.
Implements different resampling approaches, including standard ones (bilinear, bicubic, etc.) and a neural network-based 2x upsampling approach dubbed as "x2".
Definition at line 33 of file resampler.h.
|
strong |
Resampling mode (algorithm) specification.
Definition at line 38 of file resampler.h.
BitmapResampler::BitmapResampler | ( | Context & | context | ) |
Creates a resampler.
context | A context instance used to manage resources required to run some of resampling algorithms. |
Definition at line 32 of file resampler.cpp.
BitmapResampler::~BitmapResampler | ( | ) |
Definition at line 39 of file resampler.cpp.
|
protectedvirtual |
Communicates devices (CPU and/or GPU) the task is run on.
Reimplemented from Beatmup::AbstractTask.
Definition at line 85 of file resampler.cpp.
|
protectedvirtual |
Executes the task on CPU within a given thread.
Generally called by multiple threads.
thread | associated task execution context |
true
if the execution is finished correctly, false
otherwise Implements Beatmup::AbstractTask.
Definition at line 137 of file resampler.cpp.
|
protectedvirtual |
Executes the task on GPU.
gpu | graphic pipeline instance |
thread | associated task execution context |
true
if the execution is finished correctly, false
otherwise Reimplemented from Beatmup::AbstractTask.
Definition at line 177 of file resampler.cpp.
|
protectedvirtual |
Instruction called before the task is executed.
threadCount | Number of threads used to perform the task |
target | Device used to perform the task |
gpu | A graphic pipeline instance; may be null. |
Reimplemented from Beatmup::AbstractTask.
Definition at line 90 of file resampler.cpp.
|
protectedvirtual |
Instruction called after the task is executed.
threadCount | Number of threads used to perform the task |
gpu | GPU to be used to execute the task; may be null. |
aborted | true if the task was aborted |
Reimplemented from Beatmup::AbstractTask.
Definition at line 132 of file resampler.cpp.
|
protectedvirtual |
Gives the upper limint on the number of threads the task may be performed by.
The actual number of threads running a specific task may be less or equal to the returned value, depending on the number of workers in ThreadPool running the task.
< minimum number of pixels per worker
Reimplemented from Beatmup::AbstractTask.
Definition at line 79 of file resampler.cpp.
void BitmapResampler::setInput | ( | AbstractBitmap * | input | ) |
Sets the image to process.
[in] | input | The input image |
Definition at line 45 of file resampler.cpp.
void BitmapResampler::setOutput | ( | AbstractBitmap * | output | ) |
Sets the output image.
The output image contains the resampled version of the input one once the task finishes.
[in] | output | The output image |
Definition at line 51 of file resampler.cpp.
|
inline |
Definition at line 86 of file resampler.h.
|
inline |
Definition at line 87 of file resampler.h.
void BitmapResampler::setMode | ( | Mode | mode | ) |
Sets the resampling algorithm to use.
[in] | mode | The algorithm to use |
Definition at line 59 of file resampler.cpp.
|
inline |
void BitmapResampler::setCubicParameter | ( | float | alpha | ) |
Sets cubic interpolation parameter ("alpha").
Has no impact if the resampling mode is different from cubic.
[in] | alpha | The alpha parameter value |
Definition at line 64 of file resampler.cpp.
|
inline |
|
inline |
Defines OpenGL ES backend selection policy (2.0 vs 3.1) when applicable.
[in] | useEs31 | If true , ES 3.1 backend will be used when available, otherwise ES 2.0 is used. |
Definition at line 116 of file resampler.h.
void BitmapResampler::setInputRect | ( | const IntRectangle & | rect | ) |
Specifies a rectangular working area in the input bitmap.
Pixels outside of this area are not used.
Definition at line 69 of file resampler.cpp.
void BitmapResampler::setOutputRect | ( | const IntRectangle & | rect | ) |
Specifies a rectangular working area in the output bitmap.
Pixels outside of this area are not affected.
Definition at line 74 of file resampler.cpp.
|
inline |
Definition at line 130 of file resampler.h.
|
inline |
Definition at line 131 of file resampler.h.
|
private |
a context managing intermediate bitmaps
Definition at line 46 of file resampler.h.
|
private |
Definition at line 47 of file resampler.h.
|
private |
input and output bitmaps
Definition at line 47 of file resampler.h.
|
private |
Definition at line 48 of file resampler.h.
|
private |
Definition at line 48 of file resampler.h.
|
private |
Definition at line 49 of file resampler.h.
|
private |
Definition at line 50 of file resampler.h.
|
private |
convnet instance
Definition at line 51 of file resampler.h.
|
private |
if true
, uses OpenGL ES 3.1 backend when available instead ES 2.0
Definition at line 52 of file resampler.h.
|
static |
Definition at line 63 of file resampler.h.