![]() |
tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
|
The transform IR, the rewrites that run over it, and the executor. More...
Go to the source code of this file.
Classes | |
| struct | TinyPlanOp |
| One operation and its operands. More... | |
| struct | TinyPlan |
| A sequence of operations over one source, and the source itself. More... | |
| struct | TinyPlanResolution |
| What the planner decided, before any pixel is touched. More... | |
| struct | TinyColorStage |
| One collapsed color operation. More... | |
Macros | |
| #define | TINYIMG_PLAN_MAX_OPS 32 |
| How many operations one plan holds. | |
Typedefs | |
| typedef enum TinyPlanOpKind | TinyPlanOpKind |
| The operations a plan can hold. | |
| typedef enum TinyCurveKind | TinyCurveKind |
| The tone curves TINYIMG_OP_CURVE can carry. | |
| typedef enum TinyEffectKind | TinyEffectKind |
| The neighborhood effects TINYIMG_OP_EFFECT can carry. | |
| typedef enum TinyPlanOpClass | TinyPlanOpClass |
| What the planner needs to know about an operation to place it. | |
| typedef enum TinyResampleFilter | TinyResampleFilter |
| Which weights the resampler reads a source pixel through. | |
| typedef enum TinyPlanKernel | TinyPlanKernel |
| Special cases the planner took, reported as a bitmask. | |
| typedef enum TinyPlanField | TinyPlanField |
| A field of a TinyPlanResolution, named rather than offset. | |
Functions | |
| uint32_t | tiny_plan_sizeof (void) |
| Size of a TinyPlan, for a host allocating one across the wasm boundary. | |
| uint32_t | tiny_plan_resolution_sizeof (void) |
| Size of a TinyPlanResolution, for the same reason. | |
| int | tiny_plan_init (TinyPlan *plan, const uint8_t *buffer, size_t size) |
| Starts a plan over encoded bytes. | |
| int | tiny_plan_init_image (TinyPlan *plan, const TinyImage *image) |
| Starts a plan over pixels that are already decoded. | |
| int | tiny_plan_set_fusion (TinyPlan *plan, int enabled) |
| Chooses whether the plan fuses. | |
| int | tiny_plan_set_effort (TinyPlan *plan, uint8_t effort) |
| Chooses how much work the plan's decode may spend. | |
| int | tiny_plan_background (TinyPlan *plan, const uint8_t *color) |
| Sets what padding is filled with. | |
| int | tiny_plan_crop (TinyPlan *plan, uint32_t x, uint32_t y, uint32_t width, uint32_t height) |
| Appends a crop. | |
| int | tiny_plan_resize (TinyPlan *plan, uint32_t width, uint32_t height) |
| Appends a resize with the filter the planner would choose. | |
| int | tiny_plan_resize_with (TinyPlan *plan, uint32_t width, uint32_t height, TinyResampleFilter filter) |
| Appends a resize through a named filter. | |
| int | tiny_plan_fit (TinyPlan *plan, uint32_t width, uint32_t height, TinyImageFit mode, TinyImageGravity gravity) |
| Appends a fit, which resolves to a scale and a crop or a pad. | |
| int | tiny_plan_fit_with (TinyPlan *plan, uint32_t width, uint32_t height, TinyImageFit mode, TinyImageGravity gravity, TinyResampleFilter filter) |
| Appends a fit that samples through a named filter. | |
| int | tiny_plan_flip_horizontal (TinyPlan *plan) |
| Appends a horizontal flip. | |
| int | tiny_plan_flip_vertical (TinyPlan *plan) |
| Appends a vertical flip. | |
| int | tiny_plan_rotate (TinyPlan *plan, int32_t degrees) |
| Appends a turn. | |
| int | tiny_plan_brightness (TinyPlan *plan, float factor) |
| Appends a brightness change. | |
| int | tiny_plan_contrast (TinyPlan *plan, float factor) |
| Appends a contrast change. | |
| int | tiny_plan_saturation (TinyPlan *plan, float factor) |
| Appends a saturation change. | |
| int | tiny_plan_hue (TinyPlan *plan, float degrees) |
| Appends a hue rotation. | |
| int | tiny_plan_grayscale (TinyPlan *plan) |
| Appends a conversion to luminance. | |
| int | tiny_plan_invert (TinyPlan *plan) |
| Appends an inversion. | |
| int | tiny_plan_gamma (TinyPlan *plan, float gamma) |
| Appends a gamma correction. | |
| int | tiny_plan_blur (TinyPlan *plan, float radius) |
| Appends a box blur. | |
| int | tiny_plan_gaussian_blur (TinyPlan *plan, float sigma) |
| Appends a gaussian blur. | |
| int | tiny_plan_matrix (TinyPlan *plan, const float *matrix) |
| Appends a color matrix. | |
| int | tiny_plan_curve (TinyPlan *plan, TinyCurveKind kind, const float *params, uint8_t channels) |
| Appends a tone curve. | |
| int | tiny_plan_effect (TinyPlan *plan, TinyEffectKind kind, const float *params) |
| Appends a neighborhood effect. | |
| int | tiny_plan_effect_rect (TinyPlan *plan, TinyEffectKind kind, const float *params, uint32_t x, uint32_t y, uint32_t width, uint32_t height) |
| Appends a neighborhood effect confined to a rectangle. | |
| uint32_t | tiny_plan_count (const TinyPlan *plan) |
| How many operations a plan holds, before any rewrite. | |
| int | tiny_plan_op_at (const TinyPlan *plan, uint32_t index, TinyPlanOp *op) |
| Reads one appended operation out. | |
| TinyPlanOpClass | tiny_plan_op_class (TinyPlanOpKind kind) |
| What class the planner puts an operation in. | |
| uint32_t | tiny_plan_cost (const TinyPlan *plan) |
| What running this plan is expected to cost, in microseconds. | |
| uint32_t | tiny_encode_cost (TinyImageFormat format, uint32_t width, uint32_t height) |
| What encoding an image of this extent is expected to cost. | |
| uint32_t | tiny_plan_field (const TinyPlanResolution *resolution, TinyPlanField field) |
| Reads one named field of a resolution. | |
| int | tiny_plan_resolve (const TinyPlan *plan, TinyPlanResolution *resolution) |
| Runs the rewrites and the propagation, touching no pixels. | |
| int | tiny_plan_color_stages (const TinyPlanResolution *resolution, TinyColorStage *stages, uint32_t capacity, uint32_t *count) |
| Collapses a resolved plan's color operations into stages. | |
| int | tiny_plan_replace (TinyImage *image, TinyPlan *plan) |
| Runs a plan over an image and puts the result in its place. | |
| int | tiny_effect_apply (TinyImage *image, const TinyPlanOp *op) |
| Runs one TINYIMG_OP_EFFECT operation over a materialized image. | |
| int | tiny_plan_blur_box (TinyImage *image, uint32_t radius) |
| Blurs an image with one box pass of the given radius. | |
| int | tiny_plan_run (const TinyPlan *plan, TinyImage *out) |
| Runs the plan and produces the output image. | |
| int | tiny_plan_encode (const TinyPlan *plan, TinyImageFormat format, const TinyEncodeOpts *opts, TinyWriter *writer) |
| Runs the plan and encodes the result in one call. | |
The transform IR, the rewrites that run over it, and the executor.
| #define TINYIMG_PLAN_MAX_OPS 32 |
How many operations one plan holds.
A fixed capacity, so a TinyPlan is an ordinary structure a caller keeps on the stack and the planner never touches the allocator to build one. A chain longer than this is a caller that means to run two transforms.
| typedef enum TinyCurveKind TinyCurveKind |
The tone curves TINYIMG_OP_CURVE can carry.
A curve is named and parameterized rather than carried as a table, because a 768 byte table inline would make one operation larger than the whole rest of a plan and a plan is a structure a caller keeps on the stack. A caller's own table is still reachable: tiny_image_apply_lut takes one and runs it as a single pass, which is the escape hatch rather than the default.
| typedef enum TinyEffectKind TinyEffectKind |
The neighborhood effects TINYIMG_OP_EFFECT can carry.
Every one of these reads more than one pixel, so they share the class that ends a fused pass. What separates them is the kernel and the parameters, not anything the planner needs to know, which is why one operation kind carries them all.
| typedef enum TinyPlanField TinyPlanField |
A field of a TinyPlanResolution, named rather than offset.
TinyPlanResolution's layout is not part of the ABI, so a host that read it by computing offsets would be reading whatever the C compiler chose that day. The awkward part is not the prefix, which is fixed; it is that TinyPlanOp op[TINYIMG_PLAN_MAX_OPS] sits in the middle, so every counter after it moves whenever an operand grows. Naming the fields is what makes the decision readable from the outside without pinning the structure.
| typedef enum TinyPlanKernel TinyPlanKernel |
Special cases the planner took, reported as a bitmask.
Every bit is an assertion a test can make about a plan rather than about its pixels, which is the only way to tell a plan that was optimized from one that happened to produce the same image.
| typedef enum TinyPlanOpClass TinyPlanOpClass |
What the planner needs to know about an operation to place it.
The class is the whole contract for adding an operation: pick the one that describes how the operation reads its input, and every rewrite, the ROI walk and the executor already know what to do with it. Nothing else in the planner is written per operation.
| typedef enum TinyPlanOpKind TinyPlanOpKind |
The operations a plan can hold.
Appending to this enum is additive; the values are part of the ABI and are read by the host wrapper, so an operation is never renumbered.
| enum TinyCurveKind |
The tone curves TINYIMG_OP_CURVE can carry.
A curve is named and parameterized rather than carried as a table, because a 768 byte table inline would make one operation larger than the whole rest of a plan and a plan is a structure a caller keeps on the stack. A caller's own table is still reachable: tiny_image_apply_lut takes one and runs it as a single pass, which is the escape hatch rather than the default.
| enum TinyEffectKind |
The neighborhood effects TINYIMG_OP_EFFECT can carry.
Every one of these reads more than one pixel, so they share the class that ends a fused pass. What separates them is the kernel and the parameters, not anything the planner needs to know, which is why one operation kind carries them all.
| enum TinyPlanField |
A field of a TinyPlanResolution, named rather than offset.
TinyPlanResolution's layout is not part of the ABI, so a host that read it by computing offsets would be reading whatever the C compiler chose that day. The awkward part is not the prefix, which is fixed; it is that TinyPlanOp op[TINYIMG_PLAN_MAX_OPS] sits in the middle, so every counter after it moves whenever an operand grows. Naming the fields is what makes the decision readable from the outside without pinning the structure.
| Enumerator | |
|---|---|
| TINYIMG_FIELD_REGION_X | Left edge of the region the decoder is asked for, in source pixels. |
| TINYIMG_FIELD_REGION_Y | Top edge of that region. |
| TINYIMG_FIELD_REGION_WIDTH | Width of that region. |
| TINYIMG_FIELD_REGION_HEIGHT | Height of that region. |
| TINYIMG_FIELD_SCALE | Subsampling denominator the decoder is asked for: 1, 2, 4 or 8. |
| TINYIMG_FIELD_DECODE_WIDTH | Width the decode produces. |
| TINYIMG_FIELD_DECODE_HEIGHT | Height the decode produces. |
| TINYIMG_FIELD_WIDTH | Width of the final image. |
| TINYIMG_FIELD_HEIGHT | Height of the final image. |
| TINYIMG_FIELD_CHANNELS | Channels of the final image. |
| TINYIMG_FIELD_OPS | Operations left after the rewrites. |
| TINYIMG_FIELD_ELIMINATED | Operations an identity or annihilation rule removed. |
| TINYIMG_FIELD_COLLAPSED | Operations a pair rule merged into another. |
| TINYIMG_FIELD_COLOR_STAGES | Color stages the operations collapsed into. |
| TINYIMG_FIELD_PASSES | Fused passes tiny_plan_run will make. |
| TINYIMG_FIELD_KERNELS | A bitmask of TinyPlanKernel. |
| enum TinyPlanKernel |
Special cases the planner took, reported as a bitmask.
Every bit is an assertion a test can make about a plan rather than about its pixels, which is the only way to tell a plan that was optimized from one that happened to produce the same image.
| enum TinyPlanOpClass |
What the planner needs to know about an operation to place it.
The class is the whole contract for adding an operation: pick the one that describes how the operation reads its input, and every rewrite, the ROI walk and the executor already know what to do with it. Nothing else in the planner is written per operation.
| enum TinyPlanOpKind |
The operations a plan can hold.
Appending to this enum is additive; the values are part of the ABI and are read by the host wrapper, so an operation is never renumbered.
| Enumerator | |
|---|---|
| TINYIMG_OP_NONE | An empty slot, which a rewrite leaves behind and the resolved op list never contains. |
| TINYIMG_OP_CROP | Take a rectangle, in the coordinates the previous operation produced. |
| TINYIMG_OP_RESIZE | Resample to an extent. |
| TINYIMG_OP_FIT | Resample and crop or pad according to a TinyImageFit mode. |
| TINYIMG_OP_FLIP_H | Mirror along the vertical axis. |
| TINYIMG_OP_FLIP_V | Mirror along the horizontal axis. |
| TINYIMG_OP_ROTATE | Turn by a multiple of 90 degrees clockwise. |
| TINYIMG_OP_BRIGHTNESS | Scale every channel by a factor. |
| TINYIMG_OP_CONTRAST | Scale every channel about mid gray. |
| TINYIMG_OP_SATURATION | Move every channel toward or away from its luminance. |
| TINYIMG_OP_HUE | Rotate the hue by an angle in degrees. |
| TINYIMG_OP_GRAYSCALE | Replace every channel with the pixel's luminance. |
| TINYIMG_OP_INVERT | Subtract every channel from 255, leaving alpha alone. |
| TINYIMG_OP_GAMMA | Raise every channel to a power. |
| TINYIMG_OP_BLUR | Average each pixel with its neighbors. |
| TINYIMG_OP_MATRIX | Apply a caller-supplied 3x4 color matrix. |
| TINYIMG_OP_CURVE | Apply a named tone curve, per channel. |
| TINYIMG_OP_EFFECT | Apply a named neighborhood effect. |
| enum TinyResampleFilter |
Which weights the resampler reads a source pixel through.
| uint32_t tiny_encode_cost | ( | TinyImageFormat | format, |
| uint32_t | width, | ||
| uint32_t | height ) |
What encoding an image of this extent is expected to cost.
Separate from tiny_plan_cost so a caller choosing between formats can price each one without building a plan per candidate. The spread is the reason the function exists: at the rates measured, PNG costs 29 times JPEG per sample and WebP costs 4, so a request that does not fit as WebP may fit as JPEG.
| format | The format to write. |
| width | Output width. |
| height | Output height. |
| int tiny_plan_background | ( | TinyPlan * | plan, |
| const uint8_t * | color ) |
Sets what padding is filled with.
| plan | The plan. |
| color | As many channels as the output will have. NULL restores the default, which is transparent, or black when the output has no alpha. |
| int tiny_plan_blur | ( | TinyPlan * | plan, |
| float | radius ) |
Appends a box blur.
| plan | The plan. |
| radius | Pixels either side. Zero changes nothing and is eliminated. |
| int tiny_plan_brightness | ( | TinyPlan * | plan, |
| float | factor ) |
Appends a brightness change.
| plan | The plan. |
| factor | 1.0 changes nothing and is eliminated. |
| int tiny_plan_contrast | ( | TinyPlan * | plan, |
| float | factor ) |
Appends a contrast change.
| plan | The plan. |
| factor | 1.0 changes nothing and is eliminated. |
| uint32_t tiny_plan_cost | ( | const TinyPlan * | plan | ) |
What running this plan is expected to cost, in microseconds.
For deciding whether a request fits a CPU budget before spending any of it. The plan is resolved, which reads the source header and no pixels, so this costs about as much as tiny_plan_resolve and nothing like the plan itself.
This is an estimate and says so. The rates come from scripts/measure/calibrate.ts on one machine, and a machine of a different speed wants all of them scaled. Measured against real transforms it lands within about 20%, which is the accuracy a budget question needs when the question is whether 7 milliseconds of work will fit inside 10. It is not a substitute for measuring: a caller that needs to know what a request cost should read the work counters afterwards.
The encoder is not included, because a plan does not carry one. Add tiny_encode_cost for the format being written.
| plan | The plan to price. |
| uint32_t tiny_plan_count | ( | const TinyPlan * | plan | ) |
How many operations a plan holds, before any rewrite.
| plan | The plan. |
| int tiny_plan_crop | ( | TinyPlan * | plan, |
| uint32_t | x, | ||
| uint32_t | y, | ||
| uint32_t | width, | ||
| uint32_t | height ) |
Appends a crop.
The rectangle is in the coordinates the previous operation produces, not in source pixels, so a crop after a resize means what it reads like.
| plan | The plan. |
| x | Left edge. |
| y | Top edge. |
| width | Width; zero means to the right edge. |
| height | Height; zero means to the bottom edge. |
| int tiny_plan_curve | ( | TinyPlan * | plan, |
| TinyCurveKind | kind, | ||
| const float * | params, | ||
| uint8_t | channels ) |
Appends a tone curve.
The generic form of every color operation that is not affine. Adjacent curves compose through the table, so any number of them cost one table.
| plan | The plan. |
| kind | Which curve. |
| params | Its parameters, up to five, read according to kind. NULL is the same as all zero. |
| channels | Which channels to apply it to, bit 0 red through bit 2 blue; zero means all three. |
| int tiny_plan_effect | ( | TinyPlan * | plan, |
| TinyEffectKind | kind, | ||
| const float * | params ) |
Appends a neighborhood effect.
| plan | The plan. |
| kind | Which effect. |
| params | Its parameters, up to four. NULL is the same as all zero. |
| int tiny_plan_effect_rect | ( | TinyPlan * | plan, |
| TinyEffectKind | kind, | ||
| const float * | params, | ||
| uint32_t | x, | ||
| uint32_t | y, | ||
| uint32_t | width, | ||
| uint32_t | height ) |
Appends a neighborhood effect confined to a rectangle.
| plan | The plan. |
| kind | Which effect. |
| params | Its parameters, up to four. NULL is the same as all zero. |
| x | Left edge. |
| y | Top edge. |
| width | Width; zero means to the right edge. |
| height | Height; zero means to the bottom edge. |
| int tiny_plan_encode | ( | const TinyPlan * | plan, |
| TinyImageFormat | format, | ||
| const TinyEncodeOpts * | opts, | ||
| TinyWriter * | writer ) |
Runs the plan and encodes the result in one call.
| plan | The plan. |
| format | The container to write. |
| opts | Quality and related settings, or NULL for the defaults. |
| writer | An initialized TinyWriter to append to. |
| uint32_t tiny_plan_field | ( | const TinyPlanResolution * | resolution, |
| TinyPlanField | field ) |
Reads one named field of a resolution.
One accessor rather than sixteen, because every field a host wants is an unsigned integer and sixteen exports would cost more module bytes than the switch does.
| resolution | A resolution from tiny_plan_resolve. |
| field | Which field. |
| int tiny_plan_fit | ( | TinyPlan * | plan, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| TinyImageFit | mode, | ||
| TinyImageGravity | gravity ) |
Appends a fit, which resolves to a scale and a crop or a pad.
| plan | The plan. |
| width | Target width. |
| height | Target height. |
| mode | How the aspect mismatch is absorbed and how the scale is clamped; see TinyImageFit. |
| gravity | Which part of the image a crop keeps, or where a pad puts it. |
| int tiny_plan_fit_with | ( | TinyPlan * | plan, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| TinyImageFit | mode, | ||
| TinyImageGravity | gravity, | ||
| TinyResampleFilter | filter ) |
Appends a fit that samples through a named filter.
tiny_plan_fit leaves the filter to the planner, which is the right default and what almost every caller wants. This exists because a caller who names a filter for a resize has no way to name one for a fit, and an option that is accepted and then ignored is worse than one that does not exist.
| plan | The plan. |
| width | Target width. |
| height | Target height. |
| mode | How the aspect mismatch is absorbed and how the scale is clamped; see TinyImageFit. |
| gravity | Which part of the image a crop keeps, or where a pad puts it. |
| filter | The weights to sample through. TINYIMG_FILTER_AUTO is what tiny_plan_fit passes. |
| int tiny_plan_flip_horizontal | ( | TinyPlan * | plan | ) |
Appends a horizontal flip.
| plan | The plan. |
| int tiny_plan_flip_vertical | ( | TinyPlan * | plan | ) |
Appends a vertical flip.
| plan | The plan. |
| int tiny_plan_gamma | ( | TinyPlan * | plan, |
| float | gamma ) |
Appends a gamma correction.
| plan | The plan. |
| gamma | Above 1.0 darkens; 1.0 changes nothing and is eliminated. |
| int tiny_plan_gaussian_blur | ( | TinyPlan * | plan, |
| float | sigma ) |
Appends a gaussian blur.
Three box passes, which converge on a gaussian and cost the same as one regardless of sigma.
| plan | The plan. |
| sigma | Standard deviation in pixels. Zero changes nothing and is eliminated. |
| int tiny_plan_grayscale | ( | TinyPlan * | plan | ) |
Appends a conversion to luminance.
The output keeps its alpha channel and loses the other two, so an RGBA source becomes two channels and an RGB source becomes one.
| plan | The plan. |
| int tiny_plan_hue | ( | TinyPlan * | plan, |
| float | degrees ) |
Appends a hue rotation.
| plan | The plan. |
| degrees | Any angle; a multiple of 360 changes nothing and is eliminated. |
| int tiny_plan_init | ( | TinyPlan * | plan, |
| const uint8_t * | buffer, | ||
| size_t | size ) |
Starts a plan over encoded bytes.
Reads the header to learn the source's dimensions and nothing else; no pixel is decoded until tiny_plan_run, which is what lets the planner choose the decode. The buffer is borrowed and must outlive the plan.
| plan | The plan to initialize. |
| buffer | The encoded image. |
| size | Number of bytes. |
Starts a plan over pixels that are already decoded.
The escape hatch, and the form the eager operations in image.h are written in. There is no decode to choose, so the region and resolution propagation have nothing to do; every other rewrite still runs. The image is borrowed and is never written to.
| plan | The plan to initialize. |
| image | The source pixels. |
| int tiny_plan_invert | ( | TinyPlan * | plan | ) |
Appends an inversion.
| plan | The plan. |
| int tiny_plan_matrix | ( | TinyPlan * | plan, |
| const float * | matrix ) |
Appends a color matrix.
The generic form of every affine color operation in the library. Sepia, a channel mixer, a white balance and a colorblind simulation are all one of these, so they compose with each other and with brightness, contrast, saturation and hue into the single matrix the executor applies.
| plan | The plan. |
| matrix | Row major 3x4 applied to RGB, in the 0..255 range. The identity is eliminated. |
| int tiny_plan_op_at | ( | const TinyPlan * | plan, |
| uint32_t | index, | ||
| TinyPlanOp * | op ) |
Reads one appended operation out.
| plan | The plan. |
| index | Zero based, below tiny_plan_count. |
| op | Receives the operation. |
| TinyPlanOpClass tiny_plan_op_class | ( | TinyPlanOpKind | kind | ) |
What class the planner puts an operation in.
| kind | The operation. |
| int tiny_plan_resize | ( | TinyPlan * | plan, |
| uint32_t | width, | ||
| uint32_t | height ) |
Appends a resize with the filter the planner would choose.
| plan | The plan. |
| width | Target width. Zero keeps the aspect ratio against height. |
| height | Target height. Zero keeps the aspect ratio against width. |
| int tiny_plan_resize_with | ( | TinyPlan * | plan, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| TinyResampleFilter | filter ) |
Appends a resize through a named filter.
| plan | The plan. |
| width | Target width. Zero keeps the aspect ratio. |
| height | Target height. Zero keeps the aspect ratio. |
| filter | The weights to sample through. |
| uint32_t tiny_plan_resolution_sizeof | ( | void | ) |
Size of a TinyPlanResolution, for the same reason.
| int tiny_plan_resolve | ( | const TinyPlan * | plan, |
| TinyPlanResolution * | resolution ) |
Runs the rewrites and the propagation, touching no pixels.
Everything the planner decides is here: which operations survived, what rectangle of the source at what scale the decoder is asked for, the window and extent the resample works over, the composed orientation, and which special cases were taken. Calling it is free relative to a decode, so a caller that wants to log the saving can.
| plan | The plan. |
| resolution | Receives the decision. |
| int tiny_plan_rotate | ( | TinyPlan * | plan, |
| int32_t | degrees ) |
Appends a turn.
| plan | The plan. |
| degrees | Clockwise, and a multiple of 90. Negative and past 360 are both reduced. |
Runs the plan and produces the output image.
| plan | The plan. |
| out | Receives the output. Its previous contents are not freed. |
| int tiny_plan_saturation | ( | TinyPlan * | plan, |
| float | factor ) |
Appends a saturation change.
| plan | The plan. |
| factor | 1.0 changes nothing and is eliminated; 0.0 is a grayscale that keeps three channels. |
| int tiny_plan_set_effort | ( | TinyPlan * | plan, |
| uint8_t | effort ) |
Chooses how much work the plan's decode may spend.
TINYIMG_EFFORT_FANCY, the default, decodes to the bitstream's definition. TINYIMG_EFFORT_FAST lets a lossy decoder drop its smoothing pass: VP8 skips deblocking and JPEG replicates chroma rather than interpolating it. A lossless format has nothing to drop and is unaffected.
Separate from the encoder's effort, which is set on TinyEncodeOpts, because a request can want one and not the other: a thumbnail small enough to hide a decode approximation may still want a carefully searched encode.
| plan | The plan. |
| effort | A TinyEffort. |
| int tiny_plan_set_fusion | ( | TinyPlan * | plan, |
| int | enabled ) |
Chooses whether the plan fuses.
On, which is the default, the plan collapses into as few passes as the operations allow.
Off, nothing is rewritten, the source is decoded whole, and every operation as appended runs as its own pass over a materialized image. That is what the fused path is measured against, and it is the benchmark's planner-off arm. Both paths share one resampler, so a difference between them is a fault in the rewrites, the collapse or the region arithmetic, and cannot be a fault in the sampling.
| plan | The plan. |
| enabled | Non-zero to fuse. |
| uint32_t tiny_plan_sizeof | ( | void | ) |
Size of a TinyPlan, for a host allocating one across the wasm boundary.