add Advanced Decoding Interface

You can now use WebPDecBuffer, WebPBitstreamFeatures and WebPDecoderOptions
to have better control over the decoding process (and the speed/quality tradeoff).

WebPDecoderOptions allow to:
 - turn fancy upsampler on/off
 - turn in-loop filter on/off
 - perform on-the-fly cropping
 - perform on the-fly rescale
(and more to come. Not all features are implemented yet).

On-the-fly cropping and scaling allow to save quite some memory
(as the decoding operation will now scale with the output's size, not
the input's one). It saves some CPU too (since for instance,
in-loop filtering is partially turned off where it doesn't matter,
and some YUV->RGB conversion operations are ommitted too).

The scaler uses summed area, so is mainly meant to be used for
downscaling (like: for generating thumbnails or previews).

Incremental decoding works with these new options.
More doc to come soon.

dwebp is now using the new decoding interface, with the new flags:
  -nofancy
  -nofilter
  -crop top left width height
  -scale width height

Change-Id: I08baf2fa291941686f4ef70a9cc2e4137874e85e
This commit is contained in:
Pascal Massimino
2011-06-20 00:45:15 -07:00
parent bd2f65f67c
commit d260310511
19 changed files with 2052 additions and 788 deletions

View File

@ -184,6 +184,10 @@ struct VP8Decoder {
// dimension, in macroblock units.
int mb_w_, mb_h_;
// Macroblock to process/filter, depending on cropping and filter_type.
int tl_mb_x_, tl_mb_y_; // top-left MB that must be in-loop filtered
int br_mb_x_, br_mb_y_; // last bottom-right MB that must be decoded
// number of partitions.
int num_parts_;
// per-partition boolean decoders.
@ -212,8 +216,8 @@ struct VP8Decoder {
// Boundary data cache and persistent buffers.
uint8_t* intra_t_; // top intra modes values: 4 * mb_w_
uint8_t intra_l_[4]; // left intra modes values
uint8_t *y_t_; // top luma samples: 16 * mb_w_
uint8_t *u_t_, *v_t_; // top u/v samples: 8 * mb_w_ each
uint8_t* y_t_; // top luma samples: 16 * mb_w_
uint8_t* u_t_, *v_t_; // top u/v samples: 8 * mb_w_ each
VP8MB* mb_info_; // contextual macroblock infos (mb_w_ + 1)
uint8_t* yuv_b_; // main block for Y/U/V (size = YUV_SIZE)
@ -264,10 +268,12 @@ struct VP8Decoder {
int VP8SetError(VP8Decoder* const dec,
VP8StatusCode error, const char * const msg);
// Validates the VP8 data-header and retrieve basic header information viz width
// and height. Returns 0 in case of formatting error. *width/*height can be
// passed NULL.
int VP8GetInfo(const uint8_t* data, uint32_t data_size,
int *width, int *height);
// and height. Returns 0 in case of formatting error. *width/*height/*has_alpha
// can be passed NULL.
int VP8GetInfo(const uint8_t* data,
uint32_t data_size, // data available so far
uint32_t chunk_size, // total data size expect in the chunk
int *width, int *height, int *has_alpha);
// in tree.c
void VP8ResetProba(VP8Proba* const proba);
@ -281,10 +287,14 @@ void VP8ParseQuant(VP8Decoder* const dec);
int VP8InitFrame(VP8Decoder* const dec, VP8Io* io);
// Predict a block and add residual
void VP8ReconstructBlock(VP8Decoder* const dec);
// Call io->setup() and finish setting up scan parameters.
VP8StatusCode VP8FinishFrameSetup(VP8Decoder* const dec, VP8Io* const io);
// Filter the decoded macroblock row (if needed)
void VP8FilterRow(const VP8Decoder* const dec);
// Store a block, along with filtering params
void VP8StoreBlock(VP8Decoder* const dec);
// Finalize and transmit a complete row. Return false in case of user-abort.
int VP8FinishRow(VP8Decoder* const dec, VP8Io* io);
int VP8FinishRow(VP8Decoder* const dec, VP8Io* const io);
// Decode one macroblock. Returns false if there is not enough data.
int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br);
@ -307,7 +317,7 @@ extern void (*VP8TransformWHT)(const int16_t* in, int16_t* out);
// *dst is the destination block, with stride BPS. Boundary samples are
// assumed accessible when needed.
typedef void (*VP8PredFunc)(uint8_t *dst);
typedef void (*VP8PredFunc)(uint8_t* dst);
extern VP8PredFunc VP8PredLuma16[NUM_B_DC_MODES];
extern VP8PredFunc VP8PredChroma8[NUM_B_DC_MODES];
extern VP8PredFunc VP8PredLuma4[NUM_BMODES];