Add libwebp/src/mux/animi.h
Change-Id: I80ca2070d419acf6e8355a295ee965d2df5a4d8f
This commit is contained in:
parent
28ce304344
commit
68ae5b671f
@ -298,6 +298,7 @@ HDRS = \
|
||||
src/enc/histogram.h \
|
||||
src/enc/vp8enci.h \
|
||||
src/enc/vp8li.h \
|
||||
src/mux/animi.h \
|
||||
src/mux/muxi.h \
|
||||
src/utils/bit_reader.h \
|
||||
src/utils/bit_reader_inl.h \
|
||||
|
@ -2,6 +2,7 @@ lib_LTLIBRARIES = libwebpmux.la
|
||||
|
||||
libwebpmux_la_SOURCES =
|
||||
libwebpmux_la_SOURCES += anim_encode.c
|
||||
libwebpmux_la_SOURCES += animi.h
|
||||
libwebpmux_la_SOURCES += muxedit.c
|
||||
libwebpmux_la_SOURCES += muxi.h
|
||||
libwebpmux_la_SOURCES += muxinternal.c
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> // for abs()
|
||||
|
||||
#include "../mux/animi.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "../webp/decode.h"
|
||||
#include "../webp/encode.h"
|
||||
@ -586,6 +587,39 @@ static int GetSubRects(const WebPPicture* const prev_canvas,
|
||||
¶ms->rect_lossy_, ¶ms->sub_frame_lossy_);
|
||||
}
|
||||
|
||||
static WEBP_INLINE int clip(int v, int min_v, int max_v) {
|
||||
return (v < min_v) ? min_v : (v > max_v) ? max_v : v;
|
||||
}
|
||||
|
||||
int WebPAnimEncoderRefineRect(
|
||||
const WebPPicture* const prev_canvas, const WebPPicture* const curr_canvas,
|
||||
int is_lossless, float quality, int* const x_offset, int* const y_offset,
|
||||
int* const width, int* const height) {
|
||||
FrameRect rect;
|
||||
const int right = clip(*x_offset + *width, 0, curr_canvas->width);
|
||||
const int left = clip(*x_offset, 0, curr_canvas->width - 1);
|
||||
const int bottom = clip(*y_offset + *height, 0, curr_canvas->height);
|
||||
const int top = clip(*y_offset, 0, curr_canvas->height - 1);
|
||||
if (prev_canvas == NULL || curr_canvas == NULL ||
|
||||
prev_canvas->width != curr_canvas->width ||
|
||||
prev_canvas->height != curr_canvas->height ||
|
||||
!prev_canvas->use_argb || !curr_canvas->use_argb) {
|
||||
return 0;
|
||||
}
|
||||
rect.x_offset_ = left;
|
||||
rect.y_offset_ = top;
|
||||
rect.width_ = clip(right - left, 0, curr_canvas->width - rect.x_offset_);
|
||||
rect.height_ = clip(bottom - top, 0, curr_canvas->height - rect.y_offset_);
|
||||
MinimizeChangeRectangle(prev_canvas, curr_canvas, &rect, is_lossless,
|
||||
quality);
|
||||
SnapToEvenOffsets(&rect);
|
||||
*x_offset = rect.x_offset_;
|
||||
*y_offset = rect.y_offset_;
|
||||
*width = rect.width_;
|
||||
*height = rect.height_;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void DisposeFrameRectangle(int dispose_method,
|
||||
const FrameRect* const rect,
|
||||
WebPPicture* const curr_canvas) {
|
||||
|
43
src/mux/animi.h
Normal file
43
src/mux/animi.h
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright 2016 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.
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Internal header for animation related functions.
|
||||
//
|
||||
// Author: Hui Su (huisu@google.com)
|
||||
|
||||
#ifndef WEBP_MUX_ANIMI_H_
|
||||
#define WEBP_MUX_ANIMI_H_
|
||||
|
||||
#include "../webp/mux.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Picks the optimal rectangle between two pictures, starting with initial
|
||||
// values of offsets and dimensions that are passed in. The initial
|
||||
// values will be clipped, if necessary, to make sure the rectangle is
|
||||
// within the canvas. "use_argb" must be true for both pictures.
|
||||
// Parameters:
|
||||
// prev_canvas, curr_canvas - (in) two input pictures to compare.
|
||||
// is_lossless, quality - (in) encoding settings.
|
||||
// x_offset, y_offset, width, height - (in/out) rectangle between the two
|
||||
// input pictures.
|
||||
// Returns true on success.
|
||||
int WebPAnimEncoderRefineRect(
|
||||
const struct WebPPicture* const prev_canvas,
|
||||
const struct WebPPicture* const curr_canvas,
|
||||
int is_lossless, float quality, int* const x_offset, int* const y_offset,
|
||||
int* const width, int* const height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* WEBP_MUX_ANIMI_H_ */
|
Loading…
Reference in New Issue
Block a user