cosmetics: normalize fn proto & decl param names

BUG=webp:355

Change-Id: If020eb3b064cdb11853d1fa47058acae34752ce3
This commit is contained in:
James Zern 2017-08-26 14:17:31 -07:00
parent 869eb36983
commit f324b7f9ba
3 changed files with 25 additions and 22 deletions

View File

@ -542,22 +542,24 @@ int WebPWriteYUV(FILE* fout, const WebPDecBuffer* const buffer) {
// Generic top-level call // Generic top-level call
int WebPSaveImage(const WebPDecBuffer* const buffer, int WebPSaveImage(const WebPDecBuffer* const buffer,
WebPOutputFileFormat format, const char* const out_file) { WebPOutputFileFormat format,
const char* const out_file_name) {
FILE* fout = NULL; FILE* fout = NULL;
int needs_open_file = 1; int needs_open_file = 1;
const int use_stdout = (out_file != NULL) && !strcmp(out_file, "-"); const int use_stdout = (out_file_name != NULL) && !strcmp(out_file_name, "-");
int ok = 1; int ok = 1;
if (buffer == NULL || out_file == NULL) return 0; if (buffer == NULL || out_file_name == NULL) return 0;
#ifdef HAVE_WINCODEC_H #ifdef HAVE_WINCODEC_H
needs_open_file = (format != PNG); needs_open_file = (format != PNG);
#endif #endif
if (needs_open_file) { if (needs_open_file) {
fout = use_stdout ? ImgIoUtilSetBinaryMode(stdout) : fopen(out_file, "wb"); fout = use_stdout ? ImgIoUtilSetBinaryMode(stdout)
: fopen(out_file_name, "wb");
if (fout == NULL) { if (fout == NULL) {
fprintf(stderr, "Error opening output file %s\n", out_file); fprintf(stderr, "Error opening output file %s\n", out_file_name);
return 0; return 0;
} }
} }
@ -566,7 +568,7 @@ int WebPSaveImage(const WebPDecBuffer* const buffer,
format == RGBA || format == BGRA || format == ARGB || format == RGBA || format == BGRA || format == ARGB ||
format == rgbA || format == bgrA || format == Argb) { format == rgbA || format == bgrA || format == Argb) {
#ifdef HAVE_WINCODEC_H #ifdef HAVE_WINCODEC_H
ok &= WebPWritePNG(out_file, use_stdout, buffer); ok &= WebPWritePNG(out_file_name, use_stdout, buffer);
#else #else
ok &= WebPWritePNG(fout, buffer); ok &= WebPWritePNG(fout, buffer);
#endif #endif

View File

@ -169,11 +169,11 @@ VP8StatusCode WebPFlipBuffer(WebPDecBuffer* const buffer) {
return VP8_STATUS_OK; return VP8_STATUS_OK;
} }
VP8StatusCode WebPAllocateDecBuffer(int w, int h, VP8StatusCode WebPAllocateDecBuffer(int width, int height,
const WebPDecoderOptions* const options, const WebPDecoderOptions* const options,
WebPDecBuffer* const out) { WebPDecBuffer* const buffer) {
VP8StatusCode status; VP8StatusCode status;
if (out == NULL || w <= 0 || h <= 0) { if (buffer == NULL || width <= 0 || height <= 0) {
return VP8_STATUS_INVALID_PARAM; return VP8_STATUS_INVALID_PARAM;
} }
if (options != NULL) { // First, apply options if there is any. if (options != NULL) { // First, apply options if there is any.
@ -182,33 +182,34 @@ VP8StatusCode WebPAllocateDecBuffer(int w, int h,
const int ch = options->crop_height; const int ch = options->crop_height;
const int x = options->crop_left & ~1; const int x = options->crop_left & ~1;
const int y = options->crop_top & ~1; const int y = options->crop_top & ~1;
if (x < 0 || y < 0 || cw <= 0 || ch <= 0 || x + cw > w || y + ch > h) { if (x < 0 || y < 0 || cw <= 0 || ch <= 0 ||
x + cw > width || y + ch > height) {
return VP8_STATUS_INVALID_PARAM; // out of frame boundary. return VP8_STATUS_INVALID_PARAM; // out of frame boundary.
} }
w = cw; width = cw;
h = ch; height = ch;
} }
if (options->use_scaling) { if (options->use_scaling) {
int scaled_width = options->scaled_width; int scaled_width = options->scaled_width;
int scaled_height = options->scaled_height; int scaled_height = options->scaled_height;
if (!WebPRescalerGetScaledDimensions( if (!WebPRescalerGetScaledDimensions(
w, h, &scaled_width, &scaled_height)) { width, height, &scaled_width, &scaled_height)) {
return VP8_STATUS_INVALID_PARAM; return VP8_STATUS_INVALID_PARAM;
} }
w = scaled_width; width = scaled_width;
h = scaled_height; height = scaled_height;
} }
} }
out->width = w; buffer->width = width;
out->height = h; buffer->height = height;
// Then, allocate buffer for real. // Then, allocate buffer for real.
status = AllocateBuffer(out); status = AllocateBuffer(buffer);
if (status != VP8_STATUS_OK) return status; if (status != VP8_STATUS_OK) return status;
// Use the stride trick if vertical flip is needed. // Use the stride trick if vertical flip is needed.
if (options != NULL && options->flip) { if (options != NULL && options->flip) {
status = WebPFlipBuffer(out); status = WebPFlipBuffer(buffer);
} }
return status; return status;
} }

View File

@ -673,12 +673,12 @@ void WebPIDelete(WebPIDecoder* idec) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Wrapper toward WebPINewDecoder // Wrapper toward WebPINewDecoder
WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE mode, uint8_t* output_buffer, WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE csp, uint8_t* output_buffer,
size_t output_buffer_size, int output_stride) { size_t output_buffer_size, int output_stride) {
const int is_external_memory = (output_buffer != NULL) ? 1 : 0; const int is_external_memory = (output_buffer != NULL) ? 1 : 0;
WebPIDecoder* idec; WebPIDecoder* idec;
if (mode >= MODE_YUV) return NULL; if (csp >= MODE_YUV) return NULL;
if (is_external_memory == 0) { // Overwrite parameters to sane values. if (is_external_memory == 0) { // Overwrite parameters to sane values.
output_buffer_size = 0; output_buffer_size = 0;
output_stride = 0; output_stride = 0;
@ -689,7 +689,7 @@ WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE mode, uint8_t* output_buffer,
} }
idec = WebPINewDecoder(NULL); idec = WebPINewDecoder(NULL);
if (idec == NULL) return NULL; if (idec == NULL) return NULL;
idec->output_.colorspace = mode; idec->output_.colorspace = csp;
idec->output_.is_external_memory = is_external_memory; idec->output_.is_external_memory = is_external_memory;
idec->output_.u.RGBA.rgba = output_buffer; idec->output_.u.RGBA.rgba = output_buffer;
idec->output_.u.RGBA.stride = output_stride; idec->output_.u.RGBA.stride = output_stride;