mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
prepare experimentation with yuv444 / 422
+ add a simple rescaling function: WebPPictureRescale() for encoding + clean-up the memory managment around the alpha plane + fix some includes path by using "../webp/xxx.h" instead of "webp/xxx.h" New flags for 'cwebp': -resize <width> <height> -444 (no effect) -422 (no effect) -400 Change-Id: I25a95f901493f939c2dd789e658493b83bd1abfa
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
libwebpdecode_la_SOURCES = bits.h vp8i.h yuv.h bits.c dsp.c frame.c \
|
||||
quant.c tree.c vp8.c webp.c yuv.c idec.c alpha.c
|
||||
quant.c tree.c vp8.c webp.c yuv.c idec.c alpha.c \
|
||||
layer.c
|
||||
libwebpdecode_la_LDFLAGS = -version-info 0:0:0
|
||||
libwebpdecode_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE)
|
||||
libwebpdecodeinclude_HEADERS = ../webp/decode.h ../webp/decode_vp8.h ../webp/types.h
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define WEBP_DEC_BITS_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include "webp/decode_vp8.h"
|
||||
#include "../webp/decode_vp8.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
|
@ -10,7 +10,7 @@
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "vp8i.h"
|
||||
#include "./vp8i.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
|
34
src/dec/layer.c
Normal file
34
src/dec/layer.c
Normal file
@ -0,0 +1,34 @@
|
||||
// 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/
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Enhancement layer (for YUV444/422)
|
||||
//
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "vp8i.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int VP8DecodeLayer(VP8Decoder* const dec) {
|
||||
assert(dec);
|
||||
assert(dec->layer_data_size_ > 0);
|
||||
(void)dec;
|
||||
|
||||
// TODO: handle enhancement layer here.
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
} // extern "C"
|
||||
#endif
|
@ -375,26 +375,30 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
|
||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
||||
// Extensions
|
||||
if (dec->pic_hdr_.colorspace_) {
|
||||
const uint32_t EXT_SIZE = 4;
|
||||
uint32_t ext_size;
|
||||
uint8_t ext_bits;
|
||||
const uint8_t* ext_bytes_end = buf - EXT_SIZE;
|
||||
if (frm_hdr->partition_length_ <= EXT_SIZE) {
|
||||
const size_t kTrailerSize = 8;
|
||||
const uint8_t kTrailerMarker = 0x01;
|
||||
uint8_t* const ext_buf = buf - kTrailerSize;
|
||||
size_t size;
|
||||
|
||||
if (frm_hdr->partition_length_ < kTrailerSize ||
|
||||
ext_buf[kTrailerSize - 1] != kTrailerMarker) {
|
||||
Error:
|
||||
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
|
||||
"RIFF: Inconsistent extra information.");
|
||||
}
|
||||
ext_size = (ext_bytes_end[0] << 16) | (ext_bytes_end[1] << 8)
|
||||
| (ext_bytes_end[2]);
|
||||
ext_bits = ext_bytes_end[3];
|
||||
ext_bytes_end -= ext_size;
|
||||
if (!(ext_bits & 0x01) || (ext_size + EXT_SIZE > frm_hdr->partition_length_)) {
|
||||
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
|
||||
"RIFF: Inconsistent extra information.");
|
||||
}
|
||||
if (!!(ext_bits & 0x02)) { // has alpha data
|
||||
dec->alpha_data_size_ = ext_size;
|
||||
dec->alpha_data_ = ext_bytes_end;
|
||||
// Alpha
|
||||
size = (ext_buf[4] << 0) | (ext_buf[5] << 8) | (ext_buf[6] << 16);
|
||||
if (frm_hdr->partition_length_ < size + kTrailerSize) {
|
||||
goto Error;
|
||||
}
|
||||
dec->alpha_data_ = (size > 0) ? ext_buf - size : NULL;
|
||||
dec->alpha_data_size_ = size;
|
||||
|
||||
// Layer
|
||||
size = (ext_buf[0] << 0) | (ext_buf[1] << 8) | (ext_buf[2] << 16);
|
||||
dec->layer_data_size_ = size;
|
||||
dec->layer_data_ = NULL; // will be set later
|
||||
dec->layer_colorspace_ = ext_buf[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -651,6 +655,14 @@ static int ParseFrame(VP8Decoder* const dec, VP8Io* io) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
||||
if (dec->layer_data_size_ > 0) {
|
||||
if (!VP8DecodeLayer(dec)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -244,13 +244,17 @@ struct VP8Decoder {
|
||||
uint32_t non_zero_ac_;
|
||||
|
||||
// Filtering side-info
|
||||
int filter_type_; // 0=off, 1=simple, 2=complex
|
||||
int filter_type_; // 0=off, 1=simple, 2=complex
|
||||
uint8_t filter_levels_[NUM_MB_SEGMENTS]; // precalculated per-segment
|
||||
|
||||
// extensions
|
||||
const uint8_t* alpha_data_; // compressed alpha data (if present)
|
||||
size_t alpha_data_size_;
|
||||
uint8_t* alpha_plane_; // output
|
||||
|
||||
int layer_colorspace_;
|
||||
const uint8_t* layer_data_; // compressed layer data (if present)
|
||||
size_t layer_data_size_;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -283,6 +287,9 @@ int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br);
|
||||
const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
|
||||
int row, int num_rows);
|
||||
|
||||
// in layer.c
|
||||
int VP8DecodeLayer(VP8Decoder* const dec);
|
||||
|
||||
// in dsp.c
|
||||
typedef void (*VP8Idct)(const int16_t* coeffs, uint8_t* dst);
|
||||
extern VP8Idct VP8Transform;
|
||||
|
@ -16,7 +16,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "webp/decode_vp8.h"
|
||||
#include "../webp/decode_vp8.h"
|
||||
|
||||
// Decoding output parameters.
|
||||
typedef struct {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef WEBP_DEC_YUV_H_
|
||||
#define WEBP_DEC_YUV_H_
|
||||
|
||||
#include "webp/decode_vp8.h"
|
||||
#include "../webp/decode_vp8.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
|
Reference in New Issue
Block a user