imageio_util: s/ExUtil/ImgIoUtil/

ExUtil(SetBinaryMode|ReadFile|ReadFromStdin|WriteFile|CopyPlane) ->
ImgIoUtil(SetBinaryMode|ReadFile|ReadFromStdin|WriteFile|CopyPlane)

Change-Id: I5497f8fe514347efeb83b8b8866ef334390fc18e
This commit is contained in:
James Zern 2016-07-21 15:36:29 -07:00
parent bdda5bd4bf
commit da573cf490
12 changed files with 49 additions and 49 deletions

View File

@ -688,7 +688,7 @@ int ReadAnimatedImage(const char filename[], AnimatedImage* const image,
WebPDataInit(&webp_data);
memset(image, 0, sizeof(*image));
if (!ExUtilReadFile(filename, &webp_data.bytes, &webp_data.size)) {
if (!ImgIoUtilReadFile(filename, &webp_data.bytes, &webp_data.size)) {
fprintf(stderr, "Error reading file: %s\n", filename);
return 0;
}

View File

@ -60,11 +60,11 @@ static int ReadYUV(const uint8_t* const data, size_t data_size,
pic->use_argb = 0;
if (!WebPPictureAlloc(pic)) return 0;
ExUtilCopyPlane(data, pic->width, pic->y, pic->y_stride,
ImgIoUtilCopyPlane(data, pic->width, pic->y, pic->y_stride,
pic->width, pic->height);
ExUtilCopyPlane(data + y_plane_size, uv_width,
ImgIoUtilCopyPlane(data + y_plane_size, uv_width,
pic->u, pic->uv_stride, uv_width, uv_height);
ExUtilCopyPlane(data + y_plane_size + uv_plane_size, uv_width,
ImgIoUtilCopyPlane(data + y_plane_size + uv_plane_size, uv_width,
pic->v, pic->uv_stride, uv_width, uv_height);
return use_argb ? WebPPictureYUVAToARGB(pic) : 1;
}
@ -77,13 +77,13 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic,
const uint8_t* data = NULL;
size_t data_size = 0;
if (pic->width != 0 && pic->height != 0) {
ok = ExUtilReadFile(filename, &data, &data_size);
ok = ImgIoUtilReadFile(filename, &data, &data_size);
ok = ok && ReadYUV(data, data_size, pic);
} else {
// If no size specified, try to decode it using WIC.
ok = ReadPictureWithWIC(filename, pic, keep_alpha, metadata);
if (!ok) {
ok = ExUtilReadFile(filename, &data, &data_size);
ok = ImgIoUtilReadFile(filename, &data, &data_size);
ok = ok && ReadWebP(data, data_size, pic, keep_alpha, metadata);
}
}
@ -102,7 +102,7 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic,
size_t data_size = 0;
int ok = 0;
ok = ExUtilReadFile(filename, &data, &data_size);
ok = ImgIoUtilReadFile(filename, &data, &data_size);
if (!ok) goto End;
if (pic->width == 0 || pic->height == 0) {
@ -958,7 +958,7 @@ int main(int argc, const char *argv[]) {
// Open the output
if (out_file != NULL) {
const int use_stdout = !strcmp(out_file, "-");
out = use_stdout ? ExUtilSetBinaryMode(stdout) : fopen(out_file, "wb");
out = use_stdout ? ImgIoUtilSetBinaryMode(stdout) : fopen(out_file, "wb");
if (out == NULL) {
fprintf(stderr, "Error! Cannot open output file '%s'\n", out_file);
goto Error;

View File

@ -505,7 +505,7 @@ static int SaveOutput(const WebPDecBuffer* const buffer,
#endif
if (needs_open_file) {
fout = use_stdout ? ExUtilSetBinaryMode(stdout) : fopen(out_file, "wb");
fout = use_stdout ? ImgIoUtilSetBinaryMode(stdout) : fopen(out_file, "wb");
if (fout == NULL) {
fprintf(stderr, "Error opening output file %s\n", out_file);
return 0;

View File

@ -500,7 +500,7 @@ int main(int argc, const char *argv[]) {
}
if (out_file != NULL) {
if (!ExUtilWriteFile(out_file, webp_data.bytes, webp_data.size)) {
if (!ImgIoUtilWriteFile(out_file, webp_data.bytes, webp_data.size)) {
fprintf(stderr, "Error writing output file: %s\n", out_file);
goto End;
}

View File

@ -469,7 +469,7 @@ int main(int argc, char *argv[]) {
return 0;
}
if (!ExUtilReadFile(kParams.file_name,
if (!ImgIoUtilReadFile(kParams.file_name,
&kParams.data.bytes, &kParams.data.size)) {
goto Error;
}

View File

@ -369,7 +369,7 @@ static int ReadFileToWebPData(const char* const filename,
WebPData* const webp_data) {
const uint8_t* data;
size_t size;
if (!ExUtilReadFile(filename, &data, &size)) return 0;
if (!ImgIoUtilReadFile(filename, &data, &size)) return 0;
webp_data->bytes = data;
webp_data->size = size;
return 1;
@ -389,7 +389,7 @@ static int CreateMux(const char* const filename, WebPMux** mux) {
static int WriteData(const char* filename, const WebPData* const webpdata) {
int ok = 0;
FILE* fout = strcmp(filename, "-") ? fopen(filename, "wb")
: ExUtilSetBinaryMode(stdout);
: ImgIoUtilSetBinaryMode(stdout);
if (fout == NULL) {
fprintf(stderr, "Error opening output WebP file %s!\n", filename);
return 0;

View File

@ -31,7 +31,7 @@ static size_t ReadPicture(const char* const filename, WebPPicture* const pic,
const uint8_t* data = NULL;
size_t data_size = 0;
WebPImageReader reader = NULL;
int ok = ExUtilReadFile(filename, &data, &data_size);
int ok = ImgIoUtilReadFile(filename, &data, &data_size);
if (!ok) goto Error;
pic->use_argb = 1; // force ARGB

View File

@ -29,7 +29,7 @@ int main(int argc, const char *argv[]) {
const uint8_t* data = NULL;
size_t data_size = 0;
int q;
const int ok = ExUtilReadFile(filename, &data, &data_size);
const int ok = ImgIoUtilReadFile(filename, &data, &data_size);
if (!ok) continue;
q = VP8EstimateQuality(data, data_size);
if (!quiet) printf("[%s] ", filename);

View File

@ -22,7 +22,7 @@
// -----------------------------------------------------------------------------
// File I/O
FILE* ExUtilSetBinaryMode(FILE* file) {
FILE* ImgIoUtilSetBinaryMode(FILE* file) {
#if defined(_WIN32)
if (_setmode(_fileno(file), _O_BINARY) == -1) {
fprintf(stderr, "Failed to reopen file in O_BINARY mode.\n");
@ -32,7 +32,7 @@ FILE* ExUtilSetBinaryMode(FILE* file) {
return file;
}
int ExUtilReadFromStdin(const uint8_t** data, size_t* data_size) {
int ImgIoUtilReadFromStdin(const uint8_t** data, size_t* data_size) {
static const size_t kBlockSize = 16384; // default initial size
size_t max_size = 0;
size_t size = 0;
@ -42,7 +42,7 @@ int ExUtilReadFromStdin(const uint8_t** data, size_t* data_size) {
*data = NULL;
*data_size = 0;
if (!ExUtilSetBinaryMode(stdin)) return 0;
if (!ImgIoUtilSetBinaryMode(stdin)) return 0;
while (!feof(stdin)) {
// We double the buffer size each time and read as much as possible.
@ -65,7 +65,7 @@ int ExUtilReadFromStdin(const uint8_t** data, size_t* data_size) {
return 0;
}
int ExUtilReadFile(const char* const file_name,
int ImgIoUtilReadFile(const char* const file_name,
const uint8_t** data, size_t* data_size) {
int ok;
void* file_data;
@ -73,7 +73,7 @@ int ExUtilReadFile(const char* const file_name,
FILE* in;
const int from_stdin = (file_name == NULL) || !strcmp(file_name, "-");
if (from_stdin) return ExUtilReadFromStdin(data, data_size);
if (from_stdin) return ImgIoUtilReadFromStdin(data, data_size);
if (data == NULL || data_size == NULL) return 0;
*data = NULL;
@ -103,7 +103,7 @@ int ExUtilReadFile(const char* const file_name,
return 1;
}
int ExUtilWriteFile(const char* const file_name,
int ImgIoUtilWriteFile(const char* const file_name,
const uint8_t* data, size_t data_size) {
int ok;
FILE* out;
@ -124,7 +124,7 @@ int ExUtilWriteFile(const char* const file_name,
// -----------------------------------------------------------------------------
void ExUtilCopyPlane(const uint8_t* src, int src_stride,
void ImgIoUtilCopyPlane(const uint8_t* src, int src_stride,
uint8_t* dst, int dst_stride, int width, int height) {
while (height-- > 0) {
memcpy(dst, src, width * sizeof(*dst));

View File

@ -25,28 +25,28 @@ extern "C" {
// Reopen file in binary (O_BINARY) mode.
// Returns 'file' on success, NULL otherwise.
FILE* ExUtilSetBinaryMode(FILE* file);
FILE* ImgIoUtilSetBinaryMode(FILE* file);
// Allocates storage for entire file 'file_name' and returns contents and size
// in 'data' and 'data_size'. Returns 1 on success, 0 otherwise. '*data' should
// be deleted using free().
// If 'file_name' is NULL or equal to "-", input is read from stdin by calling
// the function ExUtilReadFromStdin().
int ExUtilReadFile(const char* const file_name,
// the function ImgIoUtilReadFromStdin().
int ImgIoUtilReadFile(const char* const file_name,
const uint8_t** data, size_t* data_size);
// Same as ExUtilReadFile(), but reads until EOF from stdin instead.
int ExUtilReadFromStdin(const uint8_t** data, size_t* data_size);
// Same as ImgIoUtilReadFile(), but reads until EOF from stdin instead.
int ImgIoUtilReadFromStdin(const uint8_t** data, size_t* data_size);
// Write a data segment into a file named 'file_name'. Returns true if ok.
// If 'file_name' is NULL or equal to "-", output is written to stdout.
int ExUtilWriteFile(const char* const file_name,
int ImgIoUtilWriteFile(const char* const file_name,
const uint8_t* data, size_t data_size);
//------------------------------------------------------------------------------
// Copy width x height pixels from 'src' to 'dst' honoring the strides.
void ExUtilCopyPlane(const uint8_t* src, int src_stride,
void ImgIoUtilCopyPlane(const uint8_t* src, int src_stride,
uint8_t* dst, int dst_stride, int width, int height);
#ifdef __cplusplus

View File

@ -51,7 +51,7 @@ int ExUtilLoadWebP(const char* const in_file,
WebPBitstreamFeatures* bitstream) {
VP8StatusCode status;
WebPBitstreamFeatures local_features;
if (!ExUtilReadFile(in_file, data, data_size)) return 0;
if (!ImgIoUtilReadFile(in_file, data, data_size)) return 0;
if (bitstream == NULL) {
bitstream = &local_features;
@ -184,14 +184,14 @@ int ReadWebP(const uint8_t* const data, size_t data_size,
const WebPYUVABuffer* const yuva = &output_buffer->u.YUVA;
const int uv_width = (pic->width + 1) >> 1;
const int uv_height = (pic->height + 1) >> 1;
ExUtilCopyPlane(yuva->y, yuva->y_stride,
ImgIoUtilCopyPlane(yuva->y, yuva->y_stride,
pic->y, pic->y_stride, pic->width, pic->height);
ExUtilCopyPlane(yuva->u, yuva->u_stride,
ImgIoUtilCopyPlane(yuva->u, yuva->u_stride,
pic->u, pic->uv_stride, uv_width, uv_height);
ExUtilCopyPlane(yuva->v, yuva->v_stride,
ImgIoUtilCopyPlane(yuva->v, yuva->v_stride,
pic->v, pic->uv_stride, uv_width, uv_height);
if (has_alpha) {
ExUtilCopyPlane(yuva->a, yuva->a_stride,
ImgIoUtilCopyPlane(yuva->a, yuva->a_stride,
pic->a, pic->a_stride, pic->width, pic->height);
}
}

View File

@ -88,7 +88,7 @@ static HRESULT OpenInputStream(const char* filename, IStream** stream) {
if (!strcmp(filename, "-")) {
const uint8_t* data = NULL;
size_t data_size = 0;
const int ok = ExUtilReadFile(filename, &data, &data_size);
const int ok = ImgIoUtilReadFile(filename, &data, &data_size);
if (ok) {
HGLOBAL image = GlobalAlloc(GMEM_MOVEABLE, data_size);
if (image != NULL) {