mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-19 23:39:58 +02:00
Extract some useful functions around decoding buffer WebPDecParams.
This is to prepare for incremental decoding. Change-Id: Ibb1ac6c1f2d10e096c4fbcf0c06bce77b30ca457
This commit is contained in:
59
src/dec/webpi.h
Normal file
59
src/dec/webpi.h
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright 2011 Google Inc.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Internal header: WebP decoding parameters and custom IO on buffer
|
||||
//
|
||||
// Author: somnath@google.com (Somnath Banerjee)
|
||||
|
||||
#ifndef WEBP_DEC_WEBPI_H
|
||||
#define WEBP_DEC_WEBPI_H
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "webp/decode_vp8.h"
|
||||
|
||||
typedef enum { MODE_RGB = 0, MODE_RGBA = 1,
|
||||
MODE_BGR = 2, MODE_BGRA = 3,
|
||||
MODE_YUV = 4 } WEBP_CSP_MODE;
|
||||
|
||||
// Decoding output parameters.
|
||||
typedef struct {
|
||||
uint8_t* output; // rgb(a) or luma
|
||||
uint8_t *u, *v;
|
||||
uint8_t *top_y, *top_u, *top_v;
|
||||
int stride; // rgb(a) stride or luma stride
|
||||
int u_stride;
|
||||
int v_stride;
|
||||
WEBP_CSP_MODE mode;
|
||||
} WebPDecParams;
|
||||
|
||||
// If a RIFF container is detected, validate it and skip over it. Returns
|
||||
// VP8 bit-stream size if RIFF header is valid else returns 0
|
||||
uint32_t WebPCheckRIFFHeader(const uint8_t** data_ptr,
|
||||
uint32_t *data_size_ptr);
|
||||
|
||||
// Initializes VP8Io with custom setup, io and teardown functions
|
||||
void WebPInitCustomIo(VP8Io* const io);
|
||||
|
||||
// Initializes params_out by allocating output buffer and setting the
|
||||
// stride information. It also outputs width and height information of
|
||||
// the WebP image. Returns 1 if succeeds.
|
||||
int WebPInitDecParams(const uint8_t* data, uint32_t data_size, int* width,
|
||||
int* height, WebPDecParams* const params_out);
|
||||
|
||||
// Verifies various size configurations (e.g stride >= width, specified
|
||||
// output size <= stride * height etc.). Returns 0 if checks fail.
|
||||
int WebPCheckDecParams(const VP8Io* io, const WebPDecParams* params,
|
||||
int output_size, int output_u_size, int output_v_size);
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // WEBP_DEC_WEBPI_H
|
Reference in New Issue
Block a user