mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
webp_quality: detect lossless format and features
lossless bitstream are returned as quality 101 Change-Id: I8b28287169b710ecf8d4d694abbf0cedc6447908
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
|
||||
#include "./extras.h"
|
||||
#include "webp/decode.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@ -46,9 +47,16 @@ int VP8EstimateQuality(const uint8_t* const data, size_t size) {
|
||||
uint64_t sig = 0x00;
|
||||
int ok = 0;
|
||||
int Q = -1;
|
||||
WebPBitstreamFeatures features;
|
||||
|
||||
if (data == NULL) return -1;
|
||||
|
||||
if (WebPGetFeatures(data, size, &features) != VP8_STATUS_OK) {
|
||||
return -1; // invalid file
|
||||
}
|
||||
if (features.format == 2) return 101; // lossless
|
||||
if (features.format == 0 || features.has_animation) return -1; // mixed
|
||||
|
||||
while (pos < size) {
|
||||
sig = (sig >> 8) | ((uint64_t)data[pos++] << 40);
|
||||
if ((sig >> 24) == 0x2a019dull) {
|
||||
|
Reference in New Issue
Block a user