remove experimental YUV444 YUV422 and YUV400 code

(never used)

Change-Id: I12a886703592133939607df05132e9b498f916c1
This commit is contained in:
Pascal Massimino 2014-07-03 13:20:06 -07:00
parent 380cca4f2c
commit 257adfb0be
4 changed files with 27 additions and 162 deletions

View File

@ -597,9 +597,6 @@ static void HelpLong(void) {
printf(" -resize <w> <h> ........ resize picture (after any cropping)\n");
printf(" -mt .................... use multi-threading if available\n");
printf(" -low_memory ............ reduce memory usage (slower encoding)\n");
#ifdef WEBP_EXPERIMENTAL_FEATURES
printf(" -444 / -422 / -gray .... change colorspace\n");
#endif
printf(" -map <int> ............. print map of extra info\n");
printf(" -print_psnr ............ prints averaged PSNR distortion\n");
printf(" -print_ssim ............ prints averaged SSIM distortion\n");
@ -812,14 +809,6 @@ int main(int argc, const char *argv[]) {
config.partition_limit = strtol(argv[++c], NULL, 0);
} else if (!strcmp(argv[c], "-map") && c < argc - 1) {
picture.extra_info_type = strtol(argv[++c], NULL, 0);
#ifdef WEBP_EXPERIMENTAL_FEATURES
} else if (!strcmp(argv[c], "-444")) {
picture.colorspace = WEBP_YUV444;
} else if (!strcmp(argv[c], "-422")) {
picture.colorspace = WEBP_YUV422;
} else if (!strcmp(argv[c], "-gray")) {
picture.colorspace = WEBP_YUV400;
#endif
} else if (!strcmp(argv[c], "-crop") && c < argc - 4) {
crop = 1;
crop_x = strtol(argv[++c], NULL, 0);

View File

@ -788,9 +788,9 @@ int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
h = options->crop_height;
x = options->crop_left;
y = options->crop_top;
if (!WebPIsRGBMode(src_colorspace)) { // only snap for YUV420 or YUV422
if (!WebPIsRGBMode(src_colorspace)) { // only snap for YUV420
x &= ~1;
y &= ~1; // TODO(later): only for YUV420, not YUV422.
y &= ~1;
}
if (x < 0 || y < 0 || w <= 0 || h <= 0 || x + w > W || y + h > H) {
return 0; // out of frame boundary error

View File

@ -26,7 +26,6 @@
#define USE_GAMMA_COMPRESSION
#define HALVE(x) (((x) + 1) >> 1)
#define IS_YUV_CSP(csp, YUV_CSP) (((csp) & WEBP_CSP_UV_MASK) == (YUV_CSP))
static const union {
uint32_t argb;
@ -54,29 +53,17 @@ int WebPPictureAlloc(WebPPicture* picture) {
const int uv_width = HALVE(width);
const int uv_height = HALVE(height);
const int uv_stride = uv_width;
int uv0_stride = 0;
int a_width, a_stride;
uint64_t y_size, uv_size, uv0_size, a_size, total_size;
uint64_t y_size, uv_size, a_size, total_size;
uint8_t* mem;
// U/V
switch (uv_csp) {
case WEBP_YUV420:
break;
#ifdef WEBP_EXPERIMENTAL_FEATURES
case WEBP_YUV400: // for now, we'll just reset the U/V samples
break;
case WEBP_YUV422:
uv0_stride = uv_width;
break;
case WEBP_YUV444:
uv0_stride = width;
break;
#endif
default:
return 0;
}
uv0_size = height * uv0_stride;
// alpha
a_width = has_alpha ? width : 0;
@ -85,7 +72,7 @@ int WebPPictureAlloc(WebPPicture* picture) {
uv_size = (uint64_t)uv_stride * uv_height;
a_size = (uint64_t)a_stride * height;
total_size = y_size + a_size + 2 * uv_size + 2 * uv0_size;
total_size = y_size + a_size + 2 * uv_size;
// Security and validation checks
if (width <= 0 || height <= 0 || // luma/alpha param error
@ -102,7 +89,7 @@ int WebPPictureAlloc(WebPPicture* picture) {
picture->y_stride = y_stride;
picture->uv_stride = uv_stride;
picture->a_stride = a_stride;
picture->uv0_stride = uv0_stride;
// TODO(skal): we could align the y/u/v planes and adjust stride.
picture->y = mem;
mem += y_size;
@ -112,16 +99,10 @@ int WebPPictureAlloc(WebPPicture* picture) {
picture->v = mem;
mem += uv_size;
if (a_size) {
if (a_size > 0) {
picture->a = mem;
mem += a_size;
}
if (uv0_size) {
picture->u0 = mem;
mem += uv0_size;
picture->v0 = mem;
mem += uv0_size;
}
(void)mem; // makes the static analyzer happy
} else {
void* memory;
@ -154,10 +135,8 @@ static void PictureResetARGB(WebPPicture* const picture) {
static void PictureResetYUVA(WebPPicture* const picture) {
picture->memory_ = NULL;
picture->y = picture->u = picture->v = picture->a = NULL;
picture->u0 = picture->v0 = NULL;
picture->y_stride = picture->uv_stride = 0;
picture->a_stride = 0;
picture->uv0_stride = 0;
}
// Grab the 'specs' (writer, *opaque, width, height...) from 'src' and copy them
@ -214,11 +193,8 @@ static void CopyPlane(const uint8_t* src, int src_stride,
static void SnapTopLeftPosition(const WebPPicture* const pic,
int* const left, int* const top) {
if (!pic->use_argb) {
const int is_yuv422 = IS_YUV_CSP(pic->colorspace, WEBP_YUV422);
if (IS_YUV_CSP(pic->colorspace, WEBP_YUV420) || is_yuv422) {
*left &= ~1;
if (!is_yuv422) *top &= ~1;
}
*top &= ~1;
}
}
@ -252,18 +228,6 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
CopyPlane(src->a, src->a_stride,
dst->a, dst->a_stride, dst->width, dst->height);
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (dst->u0 != NULL) {
int uv0_width = src->width;
if (IS_YUV_CSP(dst->colorspace, WEBP_YUV422)) {
uv0_width = HALVE(uv0_width);
}
CopyPlane(src->u0, src->uv0_stride,
dst->u0, dst->uv0_stride, uv0_width, dst->height);
CopyPlane(src->v0, src->uv0_stride,
dst->v0, dst->uv0_stride, uv0_width, dst->height);
}
#endif
} else {
CopyPlane((const uint8_t*)src->argb, 4 * src->argb_stride,
(uint8_t*)dst->argb, 4 * dst->argb_stride,
@ -303,15 +267,6 @@ int WebPPictureView(const WebPPicture* src,
dst->a = src->a + top * src->a_stride + left;
dst->a_stride = src->a_stride;
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (src->u0 != NULL) {
const int left_pos =
IS_YUV_CSP(dst->colorspace, WEBP_YUV422) ? (left >> 1) : left;
dst->u0 = src->u0 + top * src->uv0_stride + left_pos;
dst->v0 = src->v0 + top * src->uv0_stride + left_pos;
dst->uv0_stride = src->uv0_stride;
}
#endif
} else {
dst->argb = src->argb + top * src->argb_stride + left;
dst->argb_stride = src->argb_stride;
@ -349,20 +304,6 @@ int WebPPictureCrop(WebPPicture* pic,
CopyPlane(pic->a + a_offset, pic->a_stride,
tmp.a, tmp.a_stride, width, height);
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (tmp.u0 != NULL) {
int w = width;
int left_pos = left;
if (IS_YUV_CSP(tmp.colorspace, WEBP_YUV422)) {
w = HALVE(w);
left_pos = HALVE(left_pos);
}
CopyPlane(pic->u0 + top * pic->uv0_stride + left_pos, pic->uv0_stride,
tmp.u0, tmp.uv0_stride, w, height);
CopyPlane(pic->v0 + top * pic->uv0_stride + left_pos, pic->uv0_stride,
tmp.v0, tmp.uv0_stride, w, height);
}
#endif
} else {
const uint8_t* const src =
(const uint8_t*)(pic->argb + top * pic->argb_stride + left);
@ -465,18 +406,6 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) {
HALVE(prev_width), HALVE(prev_height), pic->uv_stride,
tmp.v,
HALVE(width), HALVE(height), tmp.uv_stride, work, 1);
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (tmp.u0 != NULL) {
const int s = IS_YUV_CSP(tmp.colorspace, WEBP_YUV422) ? 2 : 1;
RescalePlane(
pic->u0, (prev_width + s / 2) / s, prev_height, pic->uv0_stride,
tmp.u0, (width + s / 2) / s, height, tmp.uv0_stride, work, 1);
RescalePlane(
pic->v0, (prev_width + s / 2) / s, prev_height, pic->uv0_stride,
tmp.v0, (width + s / 2) / s, height, tmp.uv0_stride, work, 1);
}
#endif
} else {
work = (int32_t*)WebPSafeMalloc(2ULL * width * 4, sizeof(*work));
if (work == NULL) {
@ -687,26 +616,6 @@ static WEBP_INLINE int LinearToGamma(uint32_t base_value, int shift) {
picture->v[dst] = RGBToV(r, g, b, &rg); \
}
#define RGB_TO_UV0(x_in, x_out, y, SUM) { \
const int src = (step * (x_in) + (y) * rgb_stride); \
const int dst = (x_out) + (y) * picture->uv0_stride; \
const int r = SUM(r_ptr + src); \
const int g = SUM(g_ptr + src); \
const int b = SUM(b_ptr + src); \
picture->u0[dst] = RGBToU(r, g, b, &rg); \
picture->v0[dst] = RGBToV(r, g, b, &rg); \
}
static void MakeGray(WebPPicture* const picture) {
int y;
const int uv_width = HALVE(picture->width);
const int uv_height = HALVE(picture->height);
for (y = 0; y < uv_height; ++y) {
memset(picture->u + y * picture->uv_stride, 128, uv_width);
memset(picture->v + y * picture->uv_stride, 128, uv_width);
}
}
static int ImportYUVAFromRGBA(const uint8_t* const r_ptr,
const uint8_t* const g_ptr,
const uint8_t* const b_ptr,
@ -742,7 +651,6 @@ static int ImportYUVAFromRGBA(const uint8_t* const r_ptr,
}
// Downsample U/V plane
if (uv_csp != WEBP_YUV400) {
for (y = 0; y < (height >> 1); ++y) {
for (x = 0; x < (width >> 1); ++x) {
RGB_TO_UV(x, y, SUM4);
@ -760,29 +668,6 @@ static int ImportYUVAFromRGBA(const uint8_t* const r_ptr,
}
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
// Store original U/V samples too
if (uv_csp == WEBP_YUV422) {
for (y = 0; y < height; ++y) {
for (x = 0; x < (width >> 1); ++x) {
RGB_TO_UV0(2 * x, x, y, SUM2H);
}
if (width & 1) {
RGB_TO_UV0(2 * x, x, y, SUM1);
}
}
} else if (uv_csp == WEBP_YUV444) {
for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) {
RGB_TO_UV0(x, x, y, SUM1);
}
}
}
#endif
} else {
MakeGray(picture);
}
if (has_alpha) {
assert(step >= 4);
assert(picture->a != NULL);

View File

@ -247,15 +247,8 @@ typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
typedef enum WebPEncCSP {
// chroma sampling
WEBP_YUV420 = 0, // 4:2:0
WEBP_YUV422 = 1, // 4:2:2
WEBP_YUV444 = 2, // 4:4:4
WEBP_YUV400 = 3, // grayscale
WEBP_YUV420A = 4, // alpha channel variant
WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors
// alpha channel variants
WEBP_YUV420A = 4,
WEBP_YUV422A = 5,
WEBP_YUV444A = 6,
WEBP_YUV400A = 7, // grayscale + alpha
WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present
} WebPEncCSP;
@ -334,17 +327,15 @@ struct WebPPicture {
uint32_t pad3[3]; // padding for later use
// Unused for now: original samples (for non-YUV420 modes)
uint8_t *u0, *v0;
int uv0_stride;
uint32_t pad4[7]; // padding for later use
// Unused for now
uint8_t *pad4, *pad5;
uint32_t pad6[8]; // padding for later use
// PRIVATE FIELDS
////////////////////
void* memory_; // row chunk of memory for yuva planes
void* memory_argb_; // and for argb too.
void* pad5[2]; // padding for later use
void* pad7[2]; // padding for later use
};
// Internal, version-checked, entry point