From 1d530c9a7e1582ef97e35afffdf921affefd878d Mon Sep 17 00:00:00 2001
From: Urvang Joshi <urvang@google.com>
Date: Fri, 3 May 2013 13:58:53 -0700
Subject: [PATCH] Mux: make ValidateForSingleImage() method static

Change-Id: I96ac5e3be26b8e8ecd9f055501a5feb7710bc324
---
 src/mux/muxi.h        |  3 ---
 src/mux/muxinternal.c | 17 -----------------
 src/mux/muxread.c     | 23 ++++++++++++++++++++---
 3 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/src/mux/muxi.h b/src/mux/muxi.h
index bbdc60f6..23f6be53 100644
--- a/src/mux/muxi.h
+++ b/src/mux/muxi.h
@@ -233,9 +233,6 @@ uint8_t* MuxEmitRiffHeader(uint8_t* const data, size_t size);
 // or if 'id' is not known.
 WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id);
 
-// Validates that the given mux has a single image.
-WebPMuxError MuxValidateForImage(const WebPMux* const mux);
-
 // Get the canvas width and height after validating that VP8X/VP8/VP8L chunk and
 // canvas size are valid. This method can be used for validation-only purposes
 // by passing 'width' and 'height' to be NULL.
diff --git a/src/mux/muxinternal.c b/src/mux/muxinternal.c
index 573d3ac2..786357bf 100644
--- a/src/mux/muxinternal.c
+++ b/src/mux/muxinternal.c
@@ -443,23 +443,6 @@ WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id) {
   }
 }
 
-WebPMuxError MuxValidateForImage(const WebPMux* const mux) {
-  const int num_images = MuxImageCount(mux->images_, WEBP_CHUNK_IMAGE);
-  const int num_frames = MuxImageCount(mux->images_, WEBP_CHUNK_ANMF);
-  const int num_fragments = MuxImageCount(mux->images_, WEBP_CHUNK_FRGM);
-
-  if (num_images == 0) {
-    // No images in mux.
-    return WEBP_MUX_NOT_FOUND;
-  } else if (num_images == 1 && num_frames == 0 && num_fragments == 0) {
-    // Valid case (single image).
-    return WEBP_MUX_OK;
-  } else {
-    // Frame/Fragment case OR an invalid mux.
-    return WEBP_MUX_INVALID_ARGUMENT;
-  }
-}
-
 static int IsNotCompatible(int feature, int num_items) {
   return (feature != 0) != (num_items > 0);
 }
diff --git a/src/mux/muxread.c b/src/mux/muxread.c
index 1b5ac223..69cf0f18 100644
--- a/src/mux/muxread.c
+++ b/src/mux/muxread.c
@@ -260,6 +260,24 @@ WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
 //------------------------------------------------------------------------------
 // Get API(s).
 
+// Validates that the given mux has a single image.
+static WebPMuxError ValidateForSingleImage(const WebPMux* const mux) {
+  const int num_images = MuxImageCount(mux->images_, WEBP_CHUNK_IMAGE);
+  const int num_frames = MuxImageCount(mux->images_, WEBP_CHUNK_ANMF);
+  const int num_fragments = MuxImageCount(mux->images_, WEBP_CHUNK_FRGM);
+
+  if (num_images == 0) {
+    // No images in mux.
+    return WEBP_MUX_NOT_FOUND;
+  } else if (num_images == 1 && num_frames == 0 && num_fragments == 0) {
+    // Valid case (single image).
+    return WEBP_MUX_OK;
+  } else {
+    // Frame/Fragment case OR an invalid mux.
+    return WEBP_MUX_INVALID_ARGUMENT;
+  }
+}
+
 WebPMuxError MuxGetCanvasSize(const WebPMux* const mux, int* width,
                               int* height) {
   int w, h;
@@ -272,7 +290,7 @@ WebPMuxError MuxGetCanvasSize(const WebPMux* const mux, int* width,
     w = GetLE24(data.bytes + 4) + 1;
     h = GetLE24(data.bytes + 7) + 1;
   } else {  // Single image case.
-    WebPMuxError err = MuxValidateForImage(mux);
+    WebPMuxError err = ValidateForSingleImage(mux);
     if (err != WEBP_MUX_OK) return err;
     err = MuxGetImageWidthHeight(mux->images_->img_, &w, &h);
     if (err != WEBP_MUX_OK) return err;
@@ -291,7 +309,6 @@ WebPMuxError WebPMuxGetCanvasSize(const WebPMux* mux, int* width, int* height) {
   return MuxGetCanvasSize(mux, width, height);
 }
 
-
 WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) {
   WebPData data;
 
@@ -303,7 +320,7 @@ WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) {
     if (data.size < CHUNK_SIZE_BYTES) return WEBP_MUX_BAD_DATA;
     *flags = GetLE32(data.bytes);  // All OK. Fill up flags.
   } else {
-    WebPMuxError err = MuxValidateForImage(mux);  // Check for single image.
+    WebPMuxError err = ValidateForSingleImage(mux);  // Check for single image.
     if (err != WEBP_MUX_OK) return err;
     if (MuxHasLosslessImages(mux->images_)) {
       const WebPData* const vp8l_data = &mux->images_->img_->data_;