Webp-cwebp.c详解

一、入口文件

cwebp.c

 

二、入口函数

640行

int main(int argc, const char *argv[]) {

//定义有符号整形返回值,默认-1

int return_value = -1;

//三个字符串文件地址.in_file:输入文件地址,out_file:输出文件地址,dump_file:打印文件 地址

  const char *in_file = NULL, *out_file = NULL, *dump_file = NULL;

//输出文件指针

  FILE *out = NULL;

  int c;

//简要输出

  int short_output = 0;

//静默

  int quiet = 0;

//保持alpha

  int keep_alpha = 1;

//混合alpha

  int blend_alpha = 0;

//背景颜色

  uint32_t background_color = 0xffffffu;

//坐标

  int crop = 0, crop_x = 0, crop_y = 0, crop_w = 0, crop_h = 0;

//调整的宽度和高度

  int resize_w = 0, resize_h = 0;

//无损的预置模式

  int lossless_preset = 6;

//使用无损的预置模式

  int use_lossless_preset = -1;  // -1=unset, 0=don’t use, 1=use it

//显示进度

  int show_progress = 0;

//保持元数据

  int keep_metadata = 0;

//元数据写入

  int metadata_written = 0;

//WebPPicture结构体

  WebPPicture picture;

//打印失真

  int print_distortion = -1;        // -1=off, 0=PSNR, 1=SSIM, 2=LSIM

//WebPPicture原始图片

  WebPPicture original_picture;    // when PSNR or SSIM is requested

//WebPConfig结构体配置文件

  WebPConfig config;

//WebPAuxStats结构体状态

  WebPAuxStats stats;

//WebPMemoryWriter结构体内存写入器

  WebPMemoryWriter memory_writer;

//元数据

  Metadata metadata;

//停止监听架构体

  Stopwatch stop_watch;

//初始化元数据metadata

MetadataInit(&metadata);

  WebPMemoryWriterInit(&memory_writer);

  if (!WebPPictureInit(&picture) ||

      !WebPPictureInit(&original_picture) ||

      !WebPConfigInit(&config)) {

    fprintf(stderr, “Error! Version mismatch!\n”);

    return -1;

  }

Leave a Comment