From 11714ff1583e438352e31cf432a975d91cb69a4d Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 15 Dec 2015 13:02:32 -0800 Subject: [PATCH 1/5] demux: remove WebPDemuxSelectFragment this never had any affect, fragments were an abandoned experiment Change-Id: Ifef15486a04cdb58f89f7faf56c31fd0a06e44ab --- src/demux/demux.c | 11 ----------- src/webp/demux.h | 9 ++------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/demux/demux.c b/src/demux/demux.c index e8e5418e..c098119a 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -859,17 +859,6 @@ int WebPDemuxPrevFrame(WebPIterator* iter) { return SetFrame(iter->frame_num - 1, iter); } -int WebPDemuxSelectFragment(WebPIterator* iter, int fragment_num) { - if (iter != NULL && iter->private_ != NULL && fragment_num > 0) { - const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_; - const Frame* const frame = GetFrame(dmux, iter->frame_num); - if (frame == NULL) return 0; - - return SynthesizeFrame(dmux, frame, fragment_num, iter); - } - return 0; -} - void WebPDemuxReleaseIterator(WebPIterator* iter) { (void)iter; } diff --git a/src/webp/demux.h b/src/webp/demux.h index 6fbe7758..f90e2354 100644 --- a/src/webp/demux.h +++ b/src/webp/demux.h @@ -55,7 +55,7 @@ extern "C" { #endif -#define WEBP_DEMUX_ABI_VERSION 0x0105 // MAJOR(8b) + MINOR(8b) +#define WEBP_DEMUX_ABI_VERSION 0x0106 // MAJOR(8b) + MINOR(8b) // Note: forward declaring enumerations is not allowed in (strict) C and C++, // the types are left here for reference. @@ -155,8 +155,7 @@ struct WebPIterator { }; // Retrieves frame 'frame_number' from 'dmux'. -// 'iter->fragment' points to the first fragment on return from this function. -// Individual fragments may be extracted using WebPDemuxSelectFragment(). +// 'iter->fragment' points to the frame on return from this function. // Setting 'frame_number' equal to 0 will return the last frame of the image. // Returns false if 'dmux' is NULL or frame 'frame_number' is not present. // Call WebPDemuxReleaseIterator() when use of the iterator is complete. @@ -170,10 +169,6 @@ WEBP_EXTERN(int) WebPDemuxGetFrame( WEBP_EXTERN(int) WebPDemuxNextFrame(WebPIterator* iter); WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* iter); -// Sets 'iter->fragment' to reflect fragment number 'fragment_num'. -// Returns true if fragment 'fragment_num' is present, false otherwise. -WEBP_EXTERN(int) WebPDemuxSelectFragment(WebPIterator* iter, int fragment_num); - // Releases any memory associated with 'iter'. // Must be called before any subsequent calls to WebPDemuxGetChunk() on the same // iter. Also, must be called before destroying the associated WebPDemuxer with From 466c92e829977e4064302a47d26bd6b1cb47d315 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 15 Dec 2015 14:05:21 -0800 Subject: [PATCH 2/5] demux,WebPIterator: remove fragment_num/num_fragments these are remnants of an unused experiment Change-Id: Ia08f9e6a895d5afff41a49f6e680fd76f024a5ee --- src/demux/demux.c | 3 +-- src/webp/demux.h | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/demux/demux.c b/src/demux/demux.c index c098119a..d716f10f 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -757,6 +757,7 @@ static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { } // Returns fragment 'fragment_num' and the total count. +// TODO(jzern): this function is no longer necessary. static const Frame* GetFragment( const Frame* const frame_set, int fragment_num, int* const count) { const int this_frame = frame_set->frame_num_; @@ -811,8 +812,6 @@ static int SynthesizeFrame(const WebPDemuxer* const dmux, iter->frame_num = first_frame->frame_num_; iter->num_frames = dmux->num_frames_; - iter->fragment_num = fragment_num; - iter->num_fragments = num_fragments; iter->x_offset = fragment->x_offset_; iter->y_offset = fragment->y_offset_; iter->width = fragment->width_; diff --git a/src/webp/demux.h b/src/webp/demux.h index f90e2354..b4ed19d5 100644 --- a/src/webp/demux.h +++ b/src/webp/demux.h @@ -55,7 +55,7 @@ extern "C" { #endif -#define WEBP_DEMUX_ABI_VERSION 0x0106 // MAJOR(8b) + MINOR(8b) +#define WEBP_DEMUX_ABI_VERSION 0x0107 // MAJOR(8b) + MINOR(8b) // Note: forward declaring enumerations is not allowed in (strict) C and C++, // the types are left here for reference. @@ -137,17 +137,15 @@ WEBP_EXTERN(uint32_t) WebPDemuxGetI( struct WebPIterator { int frame_num; int num_frames; // equivalent to WEBP_FF_FRAME_COUNT. - int fragment_num; - int num_fragments; int x_offset, y_offset; // offset relative to the canvas. - int width, height; // dimensions of this frame or fragment. + int width, height; // dimensions of this frame. int duration; // display duration in milliseconds. WebPMuxAnimDispose dispose_method; // dispose method for the frame. int complete; // true if 'fragment' contains a full frame. partial images // may still be decoded with the WebP incremental decoder. - WebPData fragment; // The frame or fragment given by 'frame_num' and - // 'fragment_num'. - int has_alpha; // True if the frame or fragment contains transparency. + WebPData fragment; // The frame given by 'frame_num'. Note for historical + // reasons this is called a fragment. + int has_alpha; // True if the frame contains transparency. WebPMuxAnimBlend blend_method; // Blend operation for the frame. uint32_t pad[2]; // padding for later use. From ab714b8ac445288ab26ab08b4eda5e843880ed30 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 15 Dec 2015 17:38:37 -0800 Subject: [PATCH 3/5] demux, Frame: remove is_fragment_ field this hasn't been set since parsing of the experimental chunk was removed. + cleanup IsValidExtendedFormat(). is_fragmented has caused immediate failure since: 4e2589f demux: restore strict fragment flag check Change-Id: If9ecfc19556297100a6d5de1ba2cffdcbdc6c8fd --- src/demux/demux.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/demux/demux.c b/src/demux/demux.c index d716f10f..e22fa121 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -47,7 +47,6 @@ typedef struct Frame { int duration_; WebPMuxAnimDispose dispose_method_; WebPMuxAnimBlend blend_method_; - int is_fragment_; // this is a frame fragment (and not a full frame). int frame_num_; // the referent frame number for use in assembling fragments. int complete_; // img_components_ contains a full image. ChunkData img_components_[2]; // 0=VP8{,L} 1=ALPH @@ -597,16 +596,13 @@ static int IsValidExtendedFormat(const WebPDemuxer* const dmux) { while (f != NULL) { const int cur_frame_set = f->frame_num_; - int frame_count = 0, fragment_count = 0; + int frame_count = 0; - // Check frame properties and if the image is composed of fragments that - // each fragment came from a fragment. + // Check frame properties. for (; f != NULL && f->frame_num_ == cur_frame_set; f = f->next_) { const ChunkData* const image = f->img_components_; const ChunkData* const alpha = f->img_components_ + 1; - if (is_fragmented && !f->is_fragment_) return 0; - if (!is_fragmented && f->is_fragment_) return 0; if (!is_animation && f->frame_num_ > 1) return 0; if (f->complete_) { @@ -631,16 +627,13 @@ static int IsValidExtendedFormat(const WebPDemuxer* const dmux) { } if (f->width_ > 0 && f->height_ > 0 && - !CheckFrameBounds(f, !(is_animation || is_fragmented), + !CheckFrameBounds(f, !is_animation, dmux->canvas_width_, dmux->canvas_height_)) { return 0; } - fragment_count += f->is_fragment_; ++frame_count; } - if (!is_fragmented && frame_count > 1) return 0; - if (fragment_count > 0 && frame_count != fragment_count) return 0; } return 1; } From d3cfb79ad68245d385f1ba7ff9433ff06108eba1 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 15 Dec 2015 17:34:35 -0800 Subject: [PATCH 4/5] demux: remove dead fragment related TODO Change-Id: Iea6bf4742f803af46cd18f5d26843548e1b5cf00 --- src/demux/demux.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/demux/demux.c b/src/demux/demux.c index e22fa121..57135832 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -563,8 +563,6 @@ static int IsValidSimpleFormat(const WebPDemuxer* const dmux) { // If 'exact' is true, check that the image resolution matches the canvas. // If 'exact' is false, check that the x/y offsets do not exceed the canvas. -// TODO(jzern): this is insufficient in the fragmented image case if the -// expectation is that the fragments completely cover the canvas. static int CheckFrameBounds(const Frame* const frame, int exact, int canvas_width, int canvas_height) { if (exact) { From 47399f92b050390d52cf23a45978b5235976693b Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 15 Dec 2015 18:53:01 -0800 Subject: [PATCH 5/5] demux: remove GetFragment() Change-Id: Ibea117b64ca91ccafde80411c10e0035dc3247f3 --- src/demux/demux.c | 54 ++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/src/demux/demux.c b/src/demux/demux.c index 57135832..86927343 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -47,7 +47,7 @@ typedef struct Frame { int duration_; WebPMuxAnimDispose dispose_method_; WebPMuxAnimBlend blend_method_; - int frame_num_; // the referent frame number for use in assembling fragments. + int frame_num_; int complete_; // img_components_ contains a full image. ChunkData img_components_[2]; // 0=VP8{,L} 1=ALPH struct Frame* next_; @@ -737,8 +737,6 @@ uint32_t WebPDemuxGetI(const WebPDemuxer* dmux, WebPFormatFeature feature) { // ----------------------------------------------------------------------------- // Frame iteration -// Find the first 'frame_num' frame. There may be multiple such frames in a -// fragmented frame. static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { const Frame* f; for (f = dmux->frames_; f != NULL; f = f->next_) { @@ -747,22 +745,6 @@ static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { return f; } -// Returns fragment 'fragment_num' and the total count. -// TODO(jzern): this function is no longer necessary. -static const Frame* GetFragment( - const Frame* const frame_set, int fragment_num, int* const count) { - const int this_frame = frame_set->frame_num_; - const Frame* f = frame_set; - const Frame* fragment = NULL; - int total; - - for (total = 0; f != NULL && f->frame_num_ == this_frame; f = f->next_) { - if (++total == fragment_num) fragment = f; - } - *count = total; - return fragment; -} - static const uint8_t* GetFramePayload(const uint8_t* const mem_buf, const Frame* const frame, size_t* const data_size) { @@ -789,29 +771,25 @@ static const uint8_t* GetFramePayload(const uint8_t* const mem_buf, // Create a whole 'frame' from VP8 (+ alpha) or lossless. static int SynthesizeFrame(const WebPDemuxer* const dmux, - const Frame* const first_frame, - int fragment_num, WebPIterator* const iter) { + const Frame* const frame, + WebPIterator* const iter) { const uint8_t* const mem_buf = dmux->mem_.buf_; - int num_fragments; size_t payload_size = 0; - const Frame* const fragment = - GetFragment(first_frame, fragment_num, &num_fragments); - const uint8_t* const payload = - GetFramePayload(mem_buf, fragment, &payload_size); + const uint8_t* const payload = GetFramePayload(mem_buf, frame, &payload_size); if (payload == NULL) return 0; - assert(first_frame != NULL); + assert(frame != NULL); - iter->frame_num = first_frame->frame_num_; + iter->frame_num = frame->frame_num_; iter->num_frames = dmux->num_frames_; - iter->x_offset = fragment->x_offset_; - iter->y_offset = fragment->y_offset_; - iter->width = fragment->width_; - iter->height = fragment->height_; - iter->has_alpha = fragment->has_alpha_; - iter->duration = fragment->duration_; - iter->dispose_method = fragment->dispose_method_; - iter->blend_method = fragment->blend_method_; - iter->complete = fragment->complete_; + iter->x_offset = frame->x_offset_; + iter->y_offset = frame->y_offset_; + iter->width = frame->width_; + iter->height = frame->height_; + iter->has_alpha = frame->has_alpha_; + iter->duration = frame->duration_; + iter->dispose_method = frame->dispose_method_; + iter->blend_method = frame->blend_method_; + iter->complete = frame->complete_; iter->fragment.bytes = payload; iter->fragment.size = payload_size; return 1; @@ -827,7 +805,7 @@ static int SetFrame(int frame_num, WebPIterator* const iter) { frame = GetFrame(dmux, frame_num); if (frame == NULL) return 0; - return SynthesizeFrame(dmux, frame, 1, iter); + return SynthesizeFrame(dmux, frame, iter); } int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {