cloud-game/pkg/encoder/yuv/yuv.h
sergystepanov f4c3a8cfef
Add new YUV converter with avg color calc (#287)
Add new YUV converter with 2x2 pixel matrix YUV color estimation.

The new YUV color converter, as opposed to the original one, uses more precise color calculations based on four neighboring pixels' average color values which helps a great deal with image aliasing / shimmering artifacts.
By default, it runs in the multithreaded mode with the game frames sliced between 2*(CPU cores) goroutines.
In case if this estimation mode doesn't work as expected it is possible to switch back to the original mode.

The default encoder is switched to x264 since it's faster now.
2021-03-07 18:17:52 +03:00

24 lines
992 B
C
Vendored

typedef enum {
// It will take each TL pixel for chroma values.
// XO X XO X
// X X X X
TOP_LEFT = 0,
// It will take an average color from the 2x2 pixel group for chroma values.
// X X X X
// O O
// X X X X
BETWEEN_FOUR = 1
} chromaPos;
// Converts RGBA image to YUV (I420) with BT.601 studio color range.
void rgbaToYuv(void *destination, void *source, int width, int height, chromaPos chroma);
// Converts RGBA image chunk to YUV (I420) chroma with BT.601 studio color range.
// pos contains a shift value for chunks.
// deu, dev contains constant shifts for U, V planes in the resulting array.
// chroma (0, 1) selects chroma estimation algorithm.
void chroma(void *destination, void *source, int pos, int deu, int dev, int width, int height, chromaPos chroma);
// Converts RGBA image chunk to YUV (I420) luma with BT.601 studio color range.
void luma(void *destination, void *source, int pos, int width, int height);