mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
38efdc2e9c
Specifically: - Merge OptimizeAndEncodeFrame with WebPFrameCacheAddFrame: they use the same if-else structure. - Move maintenance of 'prev_canvas' and 'curr_canvas' to util. - Move ReduceTransparency() and FlattenPixels() calls to SetFrame(): This is in preparation for the next patch: which will try try lossless encoding for each frame, even when '-lossy' option is given. - Make most methods static inside util. No changes to output expected. Change-Id: I1f65af25246665508cb20f0f6e338f9aaba9367b
79 lines
2.9 KiB
C
79 lines
2.9 KiB
C
// 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
|
|
|
|
//------------------------------------------------------------------------------
|
|
// 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);
|
|
|
|
//------------------------------------------------------------------------------
|
|
// 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'.
|
|
WebPFrameCache* WebPFrameCacheNew(int width, int height,
|
|
size_t kmin, size_t kmax);
|
|
|
|
// Release all the frame data from 'cache' and free 'cache'.
|
|
void WebPFrameCacheDelete(WebPFrameCache* const cache);
|
|
|
|
// 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'.
|
|
int WebPFrameCacheAddFrame(WebPFrameCache* const cache,
|
|
const WebPConfig* const config,
|
|
const WebPFrameRect* const orig_rect,
|
|
WebPPicture* const frame,
|
|
WebPMuxFrameInfo* const info);
|
|
|
|
// 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_
|