Are my conversations correct?
C/C++ struct:
Code: Select all
// Signature for output function. Should return true if writing was successful.
// data/data_size is the segment of data to write, and 'picture' is for
// reference (and so one can make use of picture->custom_ptr).
typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
const WebPPicture* picture);
typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
// Color spaces.
typedef enum WebPEncCSP {
// chroma sampling
WEBP_YUV420 = 0, // 4:2:0
WEBP_YUV420A = 4, // alpha channel variant
WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors
WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present
} WebPEncCSP;
struct WebPAuxStats {
int coded_size; // final size
float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha
int block_count[3]; // number of intra4/intra16/skipped macroblocks
int header_bytes[2]; // approximate number of bytes spent for header
// and mode-partition #0
int residual_bytes[3][4]; // approximate number of bytes spent for
// DC/AC/uv coefficients for each (0..3) segments.
int segment_size[4]; // number of macroblocks in each segments
int segment_quant[4]; // quantizer values for each segments
int segment_level[4]; // filtering strength for each segments [0..63]
int alpha_data_size; // size of the transparency data
int layer_data_size; // size of the enhancement layer data
// lossless encoder statistics
uint32_t lossless_features; // bit0:predictor bit1:cross-color transform
// bit2:subtract-green bit3:color indexing
int histogram_bits; // number of precision bits of histogram
int transform_bits; // precision bits for transform
int cache_bits; // number of bits for color cache lookup
int palette_size; // number of color in palette, if used
int lossless_size; // final lossless size
int lossless_hdr_size; // lossless header (transform, huffman etc) size
int lossless_data_size; // lossless image data size
uint32_t pad[2]; // padding for later use
};
// Main exchange structure (input samples, output bytes, statistics)
struct WebPPicture {
// INPUT
//////////////
// Main flag for encoder selecting between ARGB or YUV input.
// It is recommended to use ARGB input (*argb, argb_stride) for lossless
// compression, and YUV input (*y, *u, *v, etc.) for lossy compression
// since these are the respective native colorspace for these formats.
int use_argb;
// YUV input (mostly used for input to lossy compression)
WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr).
int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION)
uint8_t *y, *u, *v; // pointers to luma/chroma planes.
int y_stride, uv_stride; // luma/chroma strides.
uint8_t* a; // pointer to the alpha plane
int a_stride; // stride of the alpha plane
uint32_t pad1[2]; // padding for later use
// ARGB input (mostly used for input to lossless compression)
uint32_t* argb; // Pointer to argb (32 bit) plane.
int argb_stride; // This is stride in pixels units, not bytes.
uint32_t pad2[3]; // padding for later use
// OUTPUT
///////////////
// Byte-emission hook, to store compressed bytes as they are ready.
WebPWriterFunction writer; // can be NULL
void* custom_ptr; // can be used by the writer.
// map for extra information (only for lossy compression mode)
int extra_info_type; // 1: intra type, 2: segment, 3: quant
// 4: intra-16 prediction mode,
// 5: chroma prediction mode,
// 6: bit cost, 7: distortion
uint8_t* extra_info; // if not NULL, points to an array of size
// ((width + 15) / 16) * ((height + 15) / 16) that
// will be filled with a macroblock map, depending
// on extra_info_type.
// STATS AND REPORTS
///////////////////////////
// Pointer to side statistics (updated only if not NULL)
WebPAuxStats* stats;
// Error code for the latest error encountered during encoding
WebPEncodingError error_code;
// If not NULL, report progress during encoding.
WebPProgressHook progress_hook;
void* user_data; // this field is free to be set to any value and
// used during callbacks (like progress-report e.g.).
uint32_t pad3[3]; // padding for later use
// Unused for now
uint8_t *pad4, *pad5;
uint32_t pad6[8]; // padding for later use
// PRIVATE FIELDS
////////////////////
void* memory_; // row chunk of memory for yuva planes
void* memory_argb_; // and for argb too.
void* pad7[2]; // padding for later use
};
FB Type Conversation:
Code: Select all
Type int8_t As Byte
Type int16_t As Short
Type int32_t As Long
Type int64_t As Longint
Type uint8_t As Ubyte
Type uint16_t as Ushort
Type uint32_t As Ulong
Type uint64_t As Ulongint
Enum WebPEncCSP
' chroma sampling
WEBP_YUV420 = 0, ' 4:2:0
WEBP_YUV420A = 4, ' alpha channel variant
WEBP_CSP_UV_MASK = 3, ' bit-mask to get the UV sampling factors
WEBP_CSP_ALPHA_BIT = 4 ' bit that is set if alpha is present
End Enum
Enum WebPEncodingError
VP8_ENC_OK = 0,
VP8_ENC_ERROR_OUT_OF_MEMORY, ' memory error allocating objects
VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, ' memory error while flushing bits
VP8_ENC_ERROR_NULL_PARAMETER, ' a pointer parameter is NULL
VP8_ENC_ERROR_INVALID_CONFIGURATION, ' configuration is invalid
VP8_ENC_ERROR_BAD_DIMENSION, ' picture has invalid width/height
VP8_ENC_ERROR_PARTITION0_OVERFLOW, ' partition is bigger than 512k
VP8_ENC_ERROR_PARTITION_OVERFLOW, ' partition is bigger than 16M
VP8_ENC_ERROR_BAD_WRITE, ' error while flushing bytes
VP8_ENC_ERROR_FILE_TOO_BIG, ' file is bigger than 4G
VP8_ENC_ERROR_USER_ABORT, ' abort request by user
VP8_ENC_ERROR_LAST ' list terminator. always last.
End Enum
Type tWebPAuxStats
As Long coded_size ' final size
' peak-signal-to-noise ratio for Y/U/V/All/Alpha
As Single PSNRY, PSNRU, PSNRV, PSNRALL, PSNRAlpha
' number of intra4/intra16/skipped macroblocks
As Long block_count_intra4, block_count_intra16, block_count_skipped
' approximate number of bytes spent for header and mode-partition #0
As Long header_bytes, mode_partition_0
' approximate number of bytes spent for
' DC/AC/uv coefficients for each (0..3) segments.
As Long residual_bytes_DC_segments0, residual_bytes_AC_segments0, residual_bytes_uv_segments0
As Long residual_bytes_DC_segments1, residual_bytes_AC_segments1, residual_bytes_uv_segments1
As Long residual_bytes_DC_segments2, residual_bytes_AC_segments2, residual_bytes_uv_segments2
As Long residual_bytes_DC_segments3, residual_bytes_AC_segments3, residual_bytes_uv_segments3
' number of macroblocks in each segments
As Long segment_size_segments0, segment_size_segments1, segment_size_segments2, segment_size_segments3
' quantizer values for each segments
As Long segment_quant0, segment_quant1, segment_quant2, segment_quant3
' filtering strength for each segments (0..63]
As Long segment_level_segments0, segment_level_segments1, segment_level_segments2, segment_level_segments3
As Long alpha_data_size ' size of the transparency data
As Long layer_data_size ' size of the enhancement layer data
' lossless encoder statistics
As uint32_t lossless_features ' bit0:predictor bit1:cross-color transform
' bit2:subtract-green bit3:color indexing
As Long histogram_bits ' number of precision bits of histogram
As Long transform_bits ' precision bits for transform
As Long cache_bits ' number of bits for color cache lookup
As Long palette_size ' number of color in palette, if used
As Long lossless_size ' final lossless size
As Long lossless_hdr_size ' lossless header (transform, huffman etc) size
As Long lossless_data_size ' lossless image data size
As uint32_t pad(2) ' padding for later use
End Type
Type tWebPPicture
' INPUT
' Main flag for encoder selecting between ARGB or YUV input.
' It is recommended to use ARGB input (*argb, argb_stride) for lossless
' compression, and YUV input (*y, *u, *v, etc.) for lossy compression
' since these are the respective native colorspace for these formats.
As Long use_argb
' YUV input (mostly used for input to lossy compression)
As WebPEncCSP colorspace ' colorspace: should be YUV420 for now (=Y'CbCr).
As Long width, height ' dimensions (less or equal to WEBP_MAX_DIMENSION)
As uint8_t Ptr y, u, v ' pointers to luma/chroma planes.
As Long y_stride, uv_stride ' luma/chroma strides.
As uint8_t Ptr a ' pointer to the alpha plane
As Long a_stride ' stride of the alpha plane
As uint32_t pad1(2) ' padding for later use
' ARGB input (mostly used for input to lossless compression)
As uint32_t Ptr argb ' Pointer to argb (32 bit) plane.
As Long argb_stride ' This is stride in pixels units, not bytes.
As uint32_t pad2(3) ' padding for later use
' OUTPUT
' Byte-emission hook, to store compressed bytes as they are ready.
As uint32_t Ptr writer ' WebPWriterFunction result can be NULL
As uint32_t Ptr custom_ptr ' can be used by the writer.
' map for extra information (only for lossy compression mode)
As Long extra_info_type ' 1: intra type, 2: segment, 3: quant
' 4: intra-16 prediction mode,
' 5: chroma prediction mode,
' 6: bit cost, 7: distortion
As uint8_t Ptr extra_info ' if not NULL, points to an array of size
' ((width + 15) / 16) * ((height + 15) / 16) that
' will be filled with a macroblock map, depending
' on extra_info_type.
' STATS AND REPORTS
' Pointer to side statistics (updated only if not NULL)
As tWebPAuxStats Ptr stats
' Error code for the latest error encountered during encoding
As WebPEncodingError error_code
' If not NULL, report progress during encoding.
As int32_t Ptr progress_hook ' WebPProgressHook result
As int32_t Ptr user_data ' this field is free to be set to any value and
' used during callbacks (like progress-report e.g.).
As uint32_t pad3(3) ' padding for later use
' Unused for now
As uint8_t Ptr pad4, pad5
As uint32_t pad6(8) ' padding for later use
' PRIVATE FIELDS
As int32_t Ptr memory_ ' row chunk of memory for yuva planes
As int32_t Ptr memory_argb_ ' and for argb too.
As int32_t Ptr pad7(2) ' padding for later use
End Type
Dim As tWebPPicture test
? Sizeof(test)
Sleep
Thx.