mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-28 06:43:18 +01:00
Merge "WebPGetFeatures() out of if condition for clarity."
This commit is contained in:
commit
7368b8cbb2
@ -234,19 +234,22 @@ static ParseStatus StoreFrame(int frame_num, uint32_t min_size,
|
|||||||
case MKFOURCC('V', 'P', '8', ' '):
|
case MKFOURCC('V', 'P', '8', ' '):
|
||||||
case MKFOURCC('V', 'P', '8', 'L'):
|
case MKFOURCC('V', 'P', '8', 'L'):
|
||||||
if (image_chunks == 0) {
|
if (image_chunks == 0) {
|
||||||
|
// Extract the bitstream features, tolerating failures when the data
|
||||||
|
// is incomplete.
|
||||||
WebPBitstreamFeatures features;
|
WebPBitstreamFeatures features;
|
||||||
ChunkData* const image = frame->img_components_;
|
const VP8StatusCode vp8_status =
|
||||||
++image_chunks;
|
WebPGetFeatures(mem->buf_ + chunk_start_offset, chunk_size,
|
||||||
image->offset_ = chunk_start_offset;
|
&features);
|
||||||
image->size_ = chunk_size;
|
if (status == PARSE_NEED_MORE_DATA &&
|
||||||
// Extract the width and height from the bitstream, tolerating
|
vp8_status == VP8_STATUS_NOT_ENOUGH_DATA) {
|
||||||
// failures when the data is incomplete.
|
return PARSE_NEED_MORE_DATA;
|
||||||
if ((WebPGetFeatures(mem->buf_ + image->offset_, image->size_,
|
} else if (vp8_status != VP8_STATUS_OK) {
|
||||||
&features) != VP8_STATUS_OK) &&
|
// We have enough data, and yet WebPGetFeatures() failed.
|
||||||
status != PARSE_NEED_MORE_DATA) {
|
|
||||||
return PARSE_ERROR;
|
return PARSE_ERROR;
|
||||||
}
|
}
|
||||||
|
++image_chunks;
|
||||||
|
frame->img_components_[0].offset_ = chunk_start_offset;
|
||||||
|
frame->img_components_[0].size_ = chunk_size;
|
||||||
frame->width_ = features.width;
|
frame->width_ = features.width;
|
||||||
frame->height_ = features.height;
|
frame->height_ = features.height;
|
||||||
if (has_vp8l_alpha != NULL) *has_vp8l_alpha = features.has_alpha;
|
if (has_vp8l_alpha != NULL) *has_vp8l_alpha = features.has_alpha;
|
||||||
|
@ -412,8 +412,8 @@ WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
|
|||||||
// Retrieve features from the bitstream. The *features structure is filled
|
// Retrieve features from the bitstream. The *features structure is filled
|
||||||
// with information gathered from the bitstream.
|
// with information gathered from the bitstream.
|
||||||
// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
|
// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
|
||||||
// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieved the
|
// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the
|
||||||
// features. Returns error in other cases.
|
// features from headers. Returns error in other cases.
|
||||||
static WEBP_INLINE VP8StatusCode WebPGetFeatures(
|
static WEBP_INLINE VP8StatusCode WebPGetFeatures(
|
||||||
const uint8_t* data, size_t data_size,
|
const uint8_t* data, size_t data_size,
|
||||||
WebPBitstreamFeatures* features) {
|
WebPBitstreamFeatures* features) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user