// Get the canvas width, height and flags after validating that VP8X/VP8/VP8L // chunk and canvas size are valid. static WebPMuxError MuxGetCanvasInfo(const WebPMux* const mux, int* width, int* height, uint32_t* flags) { int w, h; uint32_t f = 0; WebPData data; assert(mux != NULL); // Check if VP8X chunk is present. if (MuxGet(mux, IDX_VP8X, 1, &data) == WEBP_MUX_OK) { if (data.size < VP8X_CHUNK_SIZE) return WEBP_MUX_BAD_DATA; f = GetLE32(data.bytes + 0); w = GetLE24(data.bytes + 4) + 1; h = GetLE24(data.bytes + 7) + 1; } else { const WebPMuxImage* const wpi = mux->images_; // Grab user-forced canvas size as default. w = mux->canvas_width_; h = mux->canvas_height_; if (w == 0 && h == 0 && ValidateForSingleImage(mux) == WEBP_MUX_OK) { // single image and not forced canvas size => use dimension of first frame assert(wpi != NULL); w = wpi->width_; h = wpi->height_; } if (wpi != NULL) { if (wpi->has_alpha_) f |= ALPHA_FLAG; } } if (w * (uint64_t)h >= MAX_IMAGE_AREA) return WEBP_MUX_BAD_DATA; if (width != NULL) *width = w; if (height != NULL) *height = h; if (flags != NULL) *flags = f; return WEBP_MUX_OK; }
// Get the canvas width, height and flags after validating that VP8X/VP8/VP8L // chunk and canvas size are valid. static WebPMuxError MuxGetCanvasInfo(const WebPMux* const mux, int* width, int* height, uint32_t* flags) { int w, h; uint32_t f = 0; WebPData data; assert(mux != NULL); // Check if VP8X chunk is present. if (MuxGet(mux, IDX_VP8X, 1, &data) == WEBP_MUX_OK) { if (data.size < VP8X_CHUNK_SIZE) return WEBP_MUX_BAD_DATA; f = GetLE32(data.bytes + 0); w = GetLE24(data.bytes + 4) + 1; h = GetLE24(data.bytes + 7) + 1; } else { // Single image case. const WebPMuxImage* const wpi = mux->images_; WebPMuxError err = ValidateForSingleImage(mux); if (err != WEBP_MUX_OK) return err; assert(wpi != NULL); w = wpi->width_; h = wpi->height_; if (wpi->has_alpha_) f |= ALPHA_FLAG; } if (w * (uint64_t)h >= MAX_IMAGE_AREA) return WEBP_MUX_BAD_DATA; if (width != NULL) *width = w; if (height != NULL) *height = h; if (flags != NULL) *flags = f; return WEBP_MUX_OK; }