diff --git a/examples/cwebp.c b/examples/cwebp.c index d94ac531..da138c9a 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -64,13 +64,13 @@ extern void* VP8GetCPUInfo; // opaque forward declaration. static int verbose = 0; static int ReadYUV(FILE* in_file, WebPPicture* const pic) { - const int use_argb_input = pic->use_argb_input; + const int use_argb = pic->use_argb; const int uv_width = (pic->width + 1) / 2; const int uv_height = (pic->height + 1) / 2; int y; int ok = 0; - pic->use_argb_input = 0; + pic->use_argb = 0; if (!WebPPictureAlloc(pic)) return ok; for (y = 0; y < pic->height; ++y) { @@ -87,7 +87,7 @@ static int ReadYUV(FILE* in_file, WebPPicture* const pic) { goto End; } ok = 1; - if (use_argb_input) ok = WebPPictureYUVAToARGB(pic); + if (use_argb) ok = WebPPictureYUVAToARGB(pic); End: return ok; @@ -943,7 +943,7 @@ int main(int argc, const char *argv[]) { keep_alpha = 0; } else if (!strcmp(argv[c], "-lossless")) { config.lossless = 1; - picture.use_argb_input = 1; + picture.use_argb = 1; } else if (!strcmp(argv[c], "-hint") && c < argc - 1) { ++c; if (!strcmp(argv[c], "photo")) { @@ -1143,7 +1143,7 @@ int main(int argc, const char *argv[]) { // Write info if (dump_file) { - if (picture.use_argb_input) { + if (picture.use_argb) { fprintf(stderr, "Warning: can't dump file (-d option) in lossless mode."); } else if (!DumpPicture(&picture, dump_file)) { fprintf(stderr, "Warning, couldn't dump picture %s\n", dump_file); diff --git a/src/enc/alpha.c b/src/enc/alpha.c index 52bc1d39..b31cee8c 100644 --- a/src/enc/alpha.c +++ b/src/enc/alpha.c @@ -62,7 +62,7 @@ static int EncodeLossless(const uint8_t* data, int width, int height, WebPPictureInit(&picture); picture.width = width; picture.height = height; - picture.use_argb_input = 1; + picture.use_argb = 1; if (!WebPPictureAlloc(&picture)) return 0; // Transfer the alpha values to the green channel. diff --git a/src/enc/picture.c b/src/enc/picture.c index fae22930..f8ca19db 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -41,7 +41,7 @@ int WebPPictureAlloc(WebPPicture* picture) { const int width = picture->width; const int height = picture->height; - if (!picture->use_argb_input) { + if (!picture->use_argb) { const int y_stride = width; const int uv_width = HALVE(width); const int uv_height = HALVE(height); @@ -172,7 +172,7 @@ static int PictureAllocARGB(WebPPicture* const picture) { WebPPicture tmp; free(picture->memory_argb_); PictureResetARGB(picture); - picture->use_argb_input = 1; + picture->use_argb = 1; WebPPictureGrabSpecs(picture, &tmp); if (!WebPPictureAlloc(&tmp)) { return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); @@ -209,7 +209,7 @@ static void CopyPlane(const uint8_t* src, int src_stride, // Adjust top-left corner to chroma sample position. static void SnapTopLeftPosition(const WebPPicture* const pic, int* const left, int* const top) { - if (!pic->use_argb_input) { + 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; @@ -237,7 +237,7 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) { WebPPictureGrabSpecs(src, dst); if (!WebPPictureAlloc(dst)) return 0; - if (!src->use_argb_input) { + if (!src->use_argb) { CopyPlane(src->y, src->y_stride, dst->y, dst->y_stride, dst->width, dst->height); CopyPlane(src->u, src->uv_stride, @@ -270,7 +270,7 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) { int WebPPictureIsView(const WebPPicture* picture) { if (picture == NULL) return 0; - if (picture->use_argb_input) { + if (picture->use_argb) { return (picture->memory_argb_ == NULL); } return (picture->memory_ == NULL); @@ -289,7 +289,7 @@ int WebPPictureView(const WebPPicture* src, } dst->width = width; dst->height = height; - if (!src->use_argb_input) { + if (!src->use_argb) { dst->y = src->y + top * src->y_stride + left; dst->u = src->u + (top >> 1) * src->uv_stride + (left >> 1); dst->v = src->v + (top >> 1) * src->uv_stride + (left >> 1); @@ -325,7 +325,7 @@ int WebPPictureCrop(WebPPicture* pic, tmp.height = height; if (!WebPPictureAlloc(&tmp)) return 0; - if (!pic->use_argb_input) { + if (!pic->use_argb) { const int y_offset = top * pic->y_stride + left; const int uv_offset = (top / 2) * pic->uv_stride + left / 2; CopyPlane(pic->y + y_offset, pic->y_stride, @@ -415,7 +415,7 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) { tmp.height = height; if (!WebPPictureAlloc(&tmp)) return 0; - if (!pic->use_argb_input) { + if (!pic->use_argb) { work = (int32_t*)malloc(2 * width * sizeof(*work)); if (work == NULL) { WebPPictureFree(&tmp); @@ -528,7 +528,7 @@ static int CheckNonOpaque(const uint8_t* alpha, int width, int height, // Checking for the presence of non-opaque alpha. int WebPPictureHasTransparency(const WebPPicture* picture) { if (picture == NULL) return 0; - if (!picture->use_argb_input) { + if (!picture->use_argb) { return CheckNonOpaque(picture->a, picture->width, picture->height, 1, picture->a_stride); } else { @@ -625,7 +625,7 @@ static int ImportYUVAFromRGBA(const uint8_t* const r_ptr, const int has_alpha = CheckNonOpaque(a_ptr, width, height, step, rgb_stride); picture->colorspace = uv_csp; - picture->use_argb_input = 0; + picture->use_argb = 0; if (has_alpha) { picture->colorspace |= WEBP_CSP_ALPHA_BIT; } @@ -704,7 +704,7 @@ static int Import(WebPPicture* const picture, const int width = picture->width; const int height = picture->height; - if (!picture->use_argb_input) { + if (!picture->use_argb) { return ImportYUVAFromRGBA(r_ptr, g_ptr, b_ptr, a_ptr, step, rgb_stride, picture); } @@ -856,7 +856,7 @@ int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) { // would be calling WebPPictureFree(picture) otherwise. WebPPicture tmp = *picture; PictureResetARGB(&tmp); // reset ARGB buffer so that it's not free()'d. - tmp.use_argb_input = 0; + tmp.use_argb = 0; tmp.colorspace = colorspace & WEBP_CSP_UV_MASK; if (!ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride, &tmp)) { return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); @@ -957,8 +957,7 @@ int WebPPictureDistortion(const WebPPicture* pic1, const WebPPicture* pic2, return 0; } // TODO(skal): provide distortion for ARGB too. - if (pic1->use_argb_input == 1 || - pic1->use_argb_input != pic2->use_argb_input) { + if (pic1->use_argb == 1 || pic1->use_argb != pic2->use_argb) { return 0; } @@ -1020,7 +1019,7 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride, } config.lossless = !!lossless; - pic.use_argb_input = !!lossless; + pic.use_argb = !!lossless; pic.width = width; pic.height = height; pic.writer = WebPMemoryWrite; diff --git a/src/webp/encode.h b/src/webp/encode.h index 6450c196..e9d6fbe1 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -246,7 +246,7 @@ struct WebPPicture { // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. - int use_argb_input; + int use_argb; // YUV input (mostly used for input to lossy compression) WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). @@ -399,15 +399,15 @@ WEBP_EXTERN(int) WebPPictureImportBGRX( WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); // Converts picture->argb data to the YUVA format specified by 'colorspace'. -// Upon return, picture->use_argb_input is set to false. The presence of -// real non-opaque transparent values is detected, and 'colorspace' will be +// Upon return, picture->use_argb is set to false. The presence of real +// non-opaque transparent values is detected, and 'colorspace' will be // adjusted accordingly. Note that this method is lossy. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace); -// Converts picture->yuv to picture->argb and sets picture->use_argb_input -// to true. The input format must be YUV_420 or YUV_420A. +// Converts picture->yuv to picture->argb and sets picture->use_argb to true. +// The input format must be YUV_420 or YUV_420A. // Note that the use of this method is discouraged if one has access to the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // conversion from YUV420 to ARGB incurs a small loss too. @@ -433,8 +433,8 @@ WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending -// on the value of 'picture->use_argb_input'. It is highly recommended to -// use the former for lossy encoding, and the latter for lossless encoding +// on the value of 'picture->use_argb'. It is highly recommended to use +// the former for lossy encoding, and the latter for lossless encoding // (when config.lossless is true). Automatic conversion from one format to // another is provided but they both incur some loss. WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture);