2013-09-12 22:41:09 +02:00
|
|
|
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style license
|
|
|
|
// that can be found in the COPYING file in the root of the source
|
|
|
|
// tree. An additional intellectual property rights grant can be found
|
|
|
|
// in the file PATENTS. All contributing project authors may
|
|
|
|
// be found in the AUTHORS file in the root of the source tree.
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Helper structs and methods for gif2webp tool.
|
|
|
|
//
|
|
|
|
// Author: Urvang (urvang@google.com)
|
|
|
|
|
|
|
|
#ifndef WEBP_EXAMPLES_GIF2WEBP_UTIL_H_
|
|
|
|
#define WEBP_EXAMPLES_GIF2WEBP_UTIL_H_
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "webp/mux.h"
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-10-14 23:39:46 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Helper utilities.
|
|
|
|
|
|
|
|
#define WEBP_UTIL_TRANSPARENT_COLOR 0x00ffffff
|
|
|
|
|
|
|
|
struct WebPPicture;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int x_offset, y_offset, width, height;
|
|
|
|
} WebPFrameRect;
|
|
|
|
|
|
|
|
// Clear pixels in 'picture' within given 'rect' to transparent color.
|
|
|
|
void WebPUtilClearPic(struct WebPPicture* const picture,
|
|
|
|
const WebPFrameRect* const rect);
|
|
|
|
|
2013-09-12 22:41:09 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Frame cache.
|
|
|
|
|
|
|
|
typedef struct WebPFrameCache WebPFrameCache;
|
|
|
|
|
|
|
|
// Given the minimum distance between key frames 'kmin' and maximum distance
|
|
|
|
// between key frames 'kmax', returns an appropriately allocated cache object.
|
|
|
|
// Use WebPFrameCacheDelete() to deallocate the 'cache'.
|
2013-10-14 23:39:46 +02:00
|
|
|
WebPFrameCache* WebPFrameCacheNew(int width, int height,
|
|
|
|
size_t kmin, size_t kmax);
|
2013-09-12 22:41:09 +02:00
|
|
|
|
|
|
|
// Release all the frame data from 'cache' and free 'cache'.
|
|
|
|
void WebPFrameCacheDelete(WebPFrameCache* const cache);
|
|
|
|
|
2013-10-14 23:39:46 +02:00
|
|
|
// Given an image described by 'frame', 'info' and 'orig_rect', optimize it for
|
|
|
|
// WebP, encode it and add it to 'cache'.
|
|
|
|
// This takes care of frame disposal too, according to 'info->dispose_method'.
|
2013-09-12 22:41:09 +02:00
|
|
|
int WebPFrameCacheAddFrame(WebPFrameCache* const cache,
|
|
|
|
const WebPConfig* const config,
|
2013-10-14 23:39:46 +02:00
|
|
|
const WebPFrameRect* const orig_rect,
|
|
|
|
WebPPicture* const frame,
|
|
|
|
WebPMuxFrameInfo* const info);
|
2013-09-12 22:41:09 +02:00
|
|
|
|
|
|
|
// Flush the *ready* frames from cache and add them to 'mux'. If 'verbose' is
|
|
|
|
// true, prints the information about these frames.
|
|
|
|
WebPMuxError WebPFrameCacheFlush(WebPFrameCache* const cache, int verbose,
|
|
|
|
WebPMux* const mux);
|
|
|
|
|
|
|
|
// Similar to 'WebPFrameCacheFlushFrames()', but flushes *all* the frames.
|
|
|
|
WebPMuxError WebPFrameCacheFlushAll(WebPFrameCache* const cache, int verbose,
|
|
|
|
WebPMux* const mux);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // WEBP_EXAMPLES_GIF2WEBP_UTIL_H_
|