#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "webp/config.h"
#endif
#include "../examples/example_util.h"
#include "../imageio/image_dec.h"
#include "../imageio/imageio_util.h"
#include "../imageio/webpdec.h"
#include "./stopwatch.h"
#include "./unicode.h"
#include "sharpyuv/sharpyuv.h"
#include "webp/encode.h"
#ifndef WEBP_DLL
#ifdef __cplusplus
extern "C" {
#endif
extern void* VP8GetCPUInfo;
#ifdef __cplusplus
}
#endif
#endif
static int verbose = …;
static int ReadYUV(const uint8_t* const data, size_t data_size,
WebPPicture* const pic) { … }
#ifdef HAVE_WINCODEC_H
static int ReadPicture(const char* const filename, WebPPicture* const pic,
int keep_alpha, Metadata* const metadata) {
int ok = 0;
const uint8_t* data = NULL;
size_t data_size = 0;
if (pic->width != 0 && pic->height != 0) {
ok = ImgIoUtilReadFile(filename, &data, &data_size);
ok = ok && ReadYUV(data, data_size, pic);
} else {
ok = ReadPictureWithWIC(filename, pic, keep_alpha, metadata);
if (!ok) {
ok = ImgIoUtilReadFile(filename, &data, &data_size);
ok = ok && ReadWebP(data, data_size, pic, keep_alpha, metadata);
}
}
if (!ok) {
WFPRINTF(stderr, "Error! Could not process file %s\n",
(const W_CHAR*)filename);
}
WebPFree((void*)data);
return ok;
}
#else
static int ReadPicture(const char* const filename, WebPPicture* const pic,
int keep_alpha, Metadata* const metadata) { … }
#endif
static void AllocExtraInfo(WebPPicture* const pic) { … }
static void PrintByteCount(const int bytes[4], int total_size,
int* const totals) { … }
static void PrintPercents(const int counts[4]) { … }
static void PrintValues(const int values[4]) { … }
static void PrintFullLosslessInfo(const WebPAuxStats* const stats,
const char* const description) { … }
static void PrintExtraInfoLossless(const WebPPicture* const pic,
int short_output,
const char* const file_name) { … }
static void PrintExtraInfoLossy(const WebPPicture* const pic, int short_output,
int full_details,
const char* const file_name) { … }
static void PrintMapInfo(const WebPPicture* const pic) { … }
static int MyWriter(const uint8_t* data, size_t data_size,
const WebPPicture* const pic) { … }
static int DumpPicture(const WebPPicture* const picture, const char* PGM_name) { … }
enum { … };
static const int kChunkHeaderSize = …;
static const int kTagSize = …;
static void PrintMetadataInfo(const Metadata* const metadata,
int metadata_written) { … }
static int WriteLE(FILE* const out, uint32_t val, int num) { … }
static int WriteLE24(FILE* const out, uint32_t val) { … }
static int WriteLE32(FILE* const out, uint32_t val) { … }
static int WriteMetadataChunk(FILE* const out, const char fourcc[4],
const MetadataPayload* const payload) { … }
static int UpdateFlagsAndSize(const MetadataPayload* const payload,
int keep, int flag,
uint32_t* vp8x_flags, uint64_t* metadata_size) { … }
static int WriteWebPWithMetadata(FILE* const out,
const WebPPicture* const picture,
const WebPMemoryWriter* const memory_writer,
const Metadata* const metadata,
int keep_metadata,
int* const metadata_written) { … }
static int ProgressReport(int percent, const WebPPicture* const picture) { … }
static void HelpShort(void) { … }
static void HelpLong(void) { … }
static const char* const kErrorMessages[VP8_ENC_ERROR_LAST] = …;
int main(int argc, const char* argv[]) { … }