Blame examples/anim_util.h

Packit 9c6abc
// Copyright 2015 Google Inc. All Rights Reserved.
Packit 9c6abc
//
Packit 9c6abc
// Use of this source code is governed by a BSD-style license
Packit 9c6abc
// that can be found in the COPYING file in the root of the source
Packit 9c6abc
// tree. An additional intellectual property rights grant can be found
Packit 9c6abc
// in the file PATENTS. All contributing project authors may
Packit 9c6abc
// be found in the AUTHORS file in the root of the source tree.
Packit 9c6abc
// -----------------------------------------------------------------------------
Packit 9c6abc
//
Packit 9c6abc
// Utilities for animated images
Packit 9c6abc
Packit 9c6abc
#ifndef WEBP_EXAMPLES_ANIM_UTIL_H_
Packit 9c6abc
#define WEBP_EXAMPLES_ANIM_UTIL_H_
Packit 9c6abc
Packit 9c6abc
#ifdef HAVE_CONFIG_H
Packit 9c6abc
#include "webp/config.h"
Packit 9c6abc
#endif
Packit 9c6abc
Packit 9c6abc
#include "webp/types.h"
Packit 9c6abc
Packit 9c6abc
#ifdef __cplusplus
Packit 9c6abc
extern "C" {
Packit 9c6abc
#endif
Packit 9c6abc
Packit 9c6abc
typedef struct {
Packit 9c6abc
  uint8_t* rgba;         // Decoded and reconstructed full frame.
Packit 9c6abc
  int duration;          // Frame duration in milliseconds.
Packit 9c6abc
  int is_key_frame;      // True if this frame is a key-frame.
Packit 9c6abc
} DecodedFrame;
Packit 9c6abc
Packit 9c6abc
typedef struct {
Packit 9c6abc
  uint32_t canvas_width;
Packit 9c6abc
  uint32_t canvas_height;
Packit 9c6abc
  uint32_t bgcolor;
Packit 9c6abc
  uint32_t loop_count;
Packit 9c6abc
  DecodedFrame* frames;
Packit 9c6abc
  uint32_t num_frames;
Packit 9c6abc
  void* raw_mem;
Packit 9c6abc
} AnimatedImage;
Packit 9c6abc
Packit 9c6abc
// Deallocate everything in 'image' (but not the object itself).
Packit 9c6abc
void ClearAnimatedImage(AnimatedImage* const image);
Packit 9c6abc
Packit 9c6abc
// Read animated image file into 'AnimatedImage' struct.
Packit 9c6abc
// If 'dump_frames' is true, dump frames to 'dump_folder'.
Packit 9c6abc
// Previous content of 'image' is obliterated.
Packit 9c6abc
// Upon successful return, content of 'image' must be deleted by
Packit 9c6abc
// calling 'ClearAnimatedImage'.
Packit 9c6abc
int ReadAnimatedImage(const char filename[], AnimatedImage* const image,
Packit 9c6abc
                      int dump_frames, const char dump_folder[]);
Packit 9c6abc
Packit 9c6abc
// Given two RGBA buffers, calculate max pixel difference and PSNR.
Packit 9c6abc
// If 'premultiply' is true, R/G/B values will be pre-multiplied by the
Packit 9c6abc
// transparency before comparison.
Packit 9c6abc
void GetDiffAndPSNR(const uint8_t rgba1[], const uint8_t rgba2[],
Packit 9c6abc
                    uint32_t width, uint32_t height, int premultiply,
Packit 9c6abc
                    int* const max_diff, double* const psnr);
Packit 9c6abc
Packit 9c6abc
// Return library versions used by anim_util.
Packit 9c6abc
void GetAnimatedImageVersions(int* const decoder_version,
Packit 9c6abc
                              int* const demux_version);
Packit 9c6abc
Packit 9c6abc
#ifdef __cplusplus
Packit 9c6abc
}    // extern "C"
Packit 9c6abc
#endif
Packit 9c6abc
Packit 9c6abc
#endif  // WEBP_EXAMPLES_ANIM_UTIL_H_