godot/thirdparty/libwebp/src/dec/idec_dec.c

// Copyright 2011 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.
// -----------------------------------------------------------------------------
//
// Incremental decoding
//
// Author: [email protected] (Somnath Banerjee)

#include <assert.h>
#include <string.h>
#include <stdlib.h>

#include "src/dec/alphai_dec.h"
#include "src/dec/webpi_dec.h"
#include "src/dec/vp8_dec.h"
#include "src/dec/vp8i_dec.h"
#include "src/utils/utils.h"
#include "src/webp/decode.h"

// In append mode, buffer allocations increase as multiples of this value.
// Needs to be a power of 2.
#define CHUNK_SIZE
#define MAX_MB_SIZE

//------------------------------------------------------------------------------
// Data structures for memory and states

// Decoding states. State normally flows as:
// WEBP_HEADER->VP8_HEADER->VP8_PARTS0->VP8_DATA->DONE for a lossy image, and
// WEBP_HEADER->VP8L_HEADER->VP8L_DATA->DONE for a lossless image.
// If there is any error the decoder goes into state ERROR.
DecState;

// Operating state for the MemBuffer
MemBufferMode;

// storage for partition #0 and partial data (in a rolling fashion)
MemBuffer;

struct WebPIDecoder {};

// MB context to restore in case VP8DecodeMB() fails
MBContext;

//------------------------------------------------------------------------------
// MemBuffer: incoming data handling

static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) {}

// Check if we need to preserve the compressed alpha data, as it may not have
// been decoded yet.
static int NeedCompressedAlpha(const WebPIDecoder* const idec) {}

static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {}

// Appends data to the end of MemBuffer->buf_. It expands the allocated memory
// size if required and also updates VP8BitReader's if new memory is allocated.
WEBP_NODISCARD static int AppendToMemBuffer(WebPIDecoder* const idec,
                                            const uint8_t* const data,
                                            size_t data_size) {}

WEBP_NODISCARD static int RemapMemBuffer(WebPIDecoder* const idec,
                                         const uint8_t* const data,
                                         size_t data_size) {}

static void InitMemBuffer(MemBuffer* const mem) {}

static void ClearMemBuffer(MemBuffer* const mem) {}

WEBP_NODISCARD static int CheckMemBufferMode(MemBuffer* const mem,
                                             MemBufferMode expected) {}

// To be called last.
WEBP_NODISCARD static VP8StatusCode FinishDecoding(WebPIDecoder* const idec) {}

//------------------------------------------------------------------------------
// Macroblock-decoding contexts

static void SaveContext(const VP8Decoder* dec, const VP8BitReader* token_br,
                        MBContext* const context) {}

static void RestoreContext(const MBContext* context, VP8Decoder* const dec,
                           VP8BitReader* const token_br) {}

//------------------------------------------------------------------------------

static VP8StatusCode IDecError(WebPIDecoder* const idec, VP8StatusCode error) {}

static void ChangeState(WebPIDecoder* const idec, DecState new_state,
                        size_t consumed_bytes) {}

// Headers
static VP8StatusCode DecodeWebPHeaders(WebPIDecoder* const idec) {}

static VP8StatusCode DecodeVP8FrameHeader(WebPIDecoder* const idec) {}

// Partition #0
static VP8StatusCode CopyParts0Data(WebPIDecoder* const idec) {}

static VP8StatusCode DecodePartition0(WebPIDecoder* const idec) {}

// Remaining partitions
static VP8StatusCode DecodeRemaining(WebPIDecoder* const idec) {}

static VP8StatusCode ErrorStatusLossless(WebPIDecoder* const idec,
                                         VP8StatusCode status) {}

static VP8StatusCode DecodeVP8LHeader(WebPIDecoder* const idec) {}

static VP8StatusCode DecodeVP8LData(WebPIDecoder* const idec) {}

  // Main decoding loop
static VP8StatusCode IDecode(WebPIDecoder* idec) {}

//------------------------------------------------------------------------------
// Internal constructor

WEBP_NODISCARD static WebPIDecoder* NewDecoder(
    WebPDecBuffer* const output_buffer,
    const WebPBitstreamFeatures* const features) {}

//------------------------------------------------------------------------------
// Public functions

WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer) {}

WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size,
                          WebPDecoderConfig* config) {}

void WebPIDelete(WebPIDecoder* idec) {}

//------------------------------------------------------------------------------
// Wrapper toward WebPINewDecoder

WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE csp, uint8_t* output_buffer,
                          size_t output_buffer_size, int output_stride) {}

WebPIDecoder* WebPINewYUVA(uint8_t* luma, size_t luma_size, int luma_stride,
                           uint8_t* u, size_t u_size, int u_stride,
                           uint8_t* v, size_t v_size, int v_stride,
                           uint8_t* a, size_t a_size, int a_stride) {}

WebPIDecoder* WebPINewYUV(uint8_t* luma, size_t luma_size, int luma_stride,
                          uint8_t* u, size_t u_size, int u_stride,
                          uint8_t* v, size_t v_size, int v_stride) {}

//------------------------------------------------------------------------------

static VP8StatusCode IDecCheckStatus(const WebPIDecoder* const idec) {}

VP8StatusCode WebPIAppend(WebPIDecoder* idec,
                          const uint8_t* data, size_t data_size) {}

VP8StatusCode WebPIUpdate(WebPIDecoder* idec,
                          const uint8_t* data, size_t data_size) {}

//------------------------------------------------------------------------------

static const WebPDecBuffer* GetOutputBuffer(const WebPIDecoder* const idec) {}

const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* idec,
                                      int* left, int* top,
                                      int* width, int* height) {}

WEBP_NODISCARD uint8_t* WebPIDecGetRGB(const WebPIDecoder* idec, int* last_y,
                                       int* width, int* height, int* stride) {}

WEBP_NODISCARD uint8_t* WebPIDecGetYUVA(const WebPIDecoder* idec, int* last_y,
                                        uint8_t** u, uint8_t** v, uint8_t** a,
                                        int* width, int* height, int* stride,
                                        int* uv_stride, int* a_stride) {}

int WebPISetIOHooks(WebPIDecoder* const idec,
                    VP8IoPutHook put,
                    VP8IoSetupHook setup,
                    VP8IoTeardownHook teardown,
                    void* user_data) {}