// 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. // ----------------------------------------------------------------------------- // // WebPPicture class basis // // Author: Skal (pascal.massimino@gmail.com)
// Security and validation checks if (width <= 0 || height <= 0 || // luma/alpha param error
uv_width <= 0 || uv_height <= 0) { // u/v param error return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION);
} // allocate a new buffer.
mem = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*mem)); if (mem == NULL) { return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
}
// From now on, we're in the clear, we can no longer fail...
picture->memory_ = (void*)mem;
picture->y_stride = y_stride;
picture->uv_stride = uv_stride;
picture->a_stride = a_stride;
// TODO(skal): we could align the y/u/v planes and adjust stride.
picture->y = mem;
mem += y_size;
picture->u = mem;
mem += uv_size;
picture->v = mem;
mem += uv_size;
if (a_size > 0) {
picture->a = mem;
mem += a_size;
}
(void)mem; // makes the static analyzer happy return 1;
}
int WebPPictureAlloc(WebPPicture* picture) { if (picture != NULL) {
WebPPictureFree(picture); // erase previous buffer
static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
Importer import, float quality_factor, int lossless,
uint8_t** output) {
WebPPicture pic;
WebPConfig config;
WebPMemoryWriter wrt; int ok;
if (output == NULL) return 0;
if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality_factor) ||
!WebPPictureInit(&pic)) { return 0; // shouldn't happen, except if system installation is broken
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.