From 02dd37a2a3263dee4fa6490e4895824f6439c8d8 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 14 Jun 2012 16:59:58 -0700 Subject: [PATCH] demux: add {Next,Prev}Frame Replaces WebPDemuxSetFrame(). Change-Id: I38cef0ebeabb5c2f164322502abe1780f7a65e06 --- src/mux/demux.c | 10 ++++++++-- src/webp/mux.h | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mux/demux.c b/src/mux/demux.c index 411befd6..b578ac52 100644 --- a/src/mux/demux.c +++ b/src/mux/demux.c @@ -768,9 +768,15 @@ int WebPDemuxGetFrame(const WebPDemuxer* const dmux, return SetFrame(frame, iter); } -int WebPDemuxSetFrame(WebPIterator* const iter, int frame) { +int WebPDemuxNextFrame(WebPIterator* const iter) { if (iter == NULL) return 0; - return SetFrame(frame, iter); + return SetFrame(iter->frame_num_ + 1, iter); +} + +int WebPDemuxPrevFrame(WebPIterator* const iter) { + if (iter == NULL) return 0; + if (iter->frame_num_ <= 1) return 0; + return SetFrame(iter->frame_num_ - 1, iter); } int WebPDemuxSetTile(WebPIterator* const iter, int tile) { diff --git a/src/webp/mux.h b/src/webp/mux.h index ac2acf81..d21efa3a 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -546,9 +546,11 @@ typedef struct { WEBP_EXTERN(int) WebPDemuxGetFrame( const WebPDemuxer* const dmux, int frame_number, WebPIterator* const iter); -// Sets 'iter->tile_' to point to frame number 'frame_number'. +// Sets 'iter->tile_' to point to the next ('iter->frame_num_' + 1) or previous +// ('iter->frame_num_' - 1) frame. These functions do not loop. // Returns true on success, false otherwise. -WEBP_EXTERN(int) WebPDemuxSetFrame(WebPIterator* const iter, int frame_number); +WEBP_EXTERN(int) WebPDemuxNextFrame(WebPIterator* const iter); +WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* const iter); // Sets 'iter->tile_' to reflect tile number 'tile_number'. // Returns true if tile 'tile_number' is present, false otherwise.