Remove avail_buf out argument from GetAvailInput() methods.

It's always passed as nullptr.  It's a good thing, too, since it looks
like some of the implementations are returning a wrong pointer.
Add some missing |const|s.

Change-Id: I768048fdfe4cdd1dc838fee26fec18e024e39920
Reviewed-on: https://pdfium-review.googlesource.com/41810
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
index a25afdf..de97c6d 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
@@ -663,19 +663,11 @@
   input_buffer_ = pdfium::MakeRetain<CFX_CodecMemory>(src_buf);
 }
 
-FX_FILESIZE CFX_BmpDecompressor::GetAvailInput(uint8_t** avail_buf) {
+FX_FILESIZE CFX_BmpDecompressor::GetAvailInput() const {
   if (!input_buffer_)
     return 0;
 
-  FX_FILESIZE available =
-      input_buffer_->GetSize() - input_buffer_->GetPosition();
-  if (avail_buf) {
-    *avail_buf = nullptr;
-    if (available > 0)
-      *avail_buf = input_buffer_->GetBuffer() + available;
-  }
-
-  return available;
+  return input_buffer_->GetSize() - input_buffer_->GetPosition();
 }
 
 void CFX_BmpDecompressor::SetHeight(int32_t signed_height) {
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.h b/core/fxcodec/bmp/cfx_bmpdecompressor.h
index ed013a2..331a634 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.h
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.h
@@ -28,7 +28,7 @@
   int32_t DecodeImage();
   int32_t ReadHeader();
   void SetInputBuffer(pdfium::span<uint8_t> src_buf);
-  FX_FILESIZE GetAvailInput(uint8_t** avail_buf);
+  FX_FILESIZE GetAvailInput() const;
 
   jmp_buf jmpbuf_;
   CFX_BmpContext* context_ptr_;
diff --git a/core/fxcodec/codec/ccodec_bmpmodule.cpp b/core/fxcodec/codec/ccodec_bmpmodule.cpp
index 75e59ed..ff4164c 100644
--- a/core/fxcodec/codec/ccodec_bmpmodule.cpp
+++ b/core/fxcodec/codec/ccodec_bmpmodule.cpp
@@ -63,10 +63,8 @@
   return ctx->m_Bmp.DecodeImage();
 }
 
-FX_FILESIZE CCodec_BmpModule::GetAvailInput(Context* pContext,
-                                            uint8_t** avail_buf_ptr) {
-  auto* ctx = static_cast<CFX_BmpContext*>(pContext);
-  return ctx->m_Bmp.GetAvailInput(avail_buf_ptr);
+FX_FILESIZE CCodec_BmpModule::GetAvailInput(Context* pContext) const {
+  return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.GetAvailInput();
 }
 
 void CCodec_BmpModule::Input(Context* pContext, pdfium::span<uint8_t> src_buf) {
diff --git a/core/fxcodec/codec/ccodec_bmpmodule.h b/core/fxcodec/codec/ccodec_bmpmodule.h
index 42d686e..6dc0ebd 100644
--- a/core/fxcodec/codec/ccodec_bmpmodule.h
+++ b/core/fxcodec/codec/ccodec_bmpmodule.h
@@ -34,7 +34,7 @@
   ~CCodec_BmpModule();
 
   std::unique_ptr<Context> Start(Delegate* pDelegate);
-  FX_FILESIZE GetAvailInput(Context* pContext, uint8_t** avail_buf_ptr);
+  FX_FILESIZE GetAvailInput(Context* pContext) const;
   void Input(Context* pContext, pdfium::span<uint8_t> src_buf);
   int32_t ReadHeader(Context* pContext,
                      int32_t* width,
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index 872d90f..a93cb27 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -66,10 +66,8 @@
   return CFX_GifDecodeStatus::Success;
 }
 
-uint32_t CCodec_GifModule::GetAvailInput(Context* pContext,
-                                         uint8_t** avail_buf_ptr) {
-  auto* context = static_cast<CFX_GifContext*>(pContext);
-  return context->GetAvailInput(avail_buf_ptr);
+uint32_t CCodec_GifModule::GetAvailInput(Context* pContext) const {
+  return static_cast<CFX_GifContext*>(pContext)->GetAvailInput();
 }
 
 void CCodec_GifModule::Input(Context* pContext, pdfium::span<uint8_t> src_buf) {
diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h
index f14665b..9529583 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.h
+++ b/core/fxcodec/codec/ccodec_gifmodule.h
@@ -43,7 +43,7 @@
   ~CCodec_GifModule();
 
   std::unique_ptr<Context> Start(Delegate* pDelegate);
-  uint32_t GetAvailInput(Context* context, uint8_t** avail_buf_ptr);
+  uint32_t GetAvailInput(Context* context) const;
   void Input(Context* context, pdfium::span<uint8_t> src_buf);
   CFX_GifDecodeStatus ReadHeader(Context* context,
                                  int* width,
diff --git a/core/fxcodec/codec/ccodec_jpegmodule.cpp b/core/fxcodec/codec/ccodec_jpegmodule.cpp
index e6aef3c..aaf16ae 100644
--- a/core/fxcodec/codec/ccodec_jpegmodule.cpp
+++ b/core/fxcodec/codec/ccodec_jpegmodule.cpp
@@ -464,15 +464,8 @@
   return nlines == 1;
 }
 
-uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext,
-                                          uint8_t** avail_buf_ptr) {
+uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext) const {
   auto* ctx = static_cast<CJpegContext*>(pContext);
-  if (avail_buf_ptr) {
-    *avail_buf_ptr = nullptr;
-    if (ctx->m_SrcMgr.bytes_in_buffer > 0) {
-      *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte;
-    }
-  }
   return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer;
 }
 
diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h
index fb116f5..2c72db3 100644
--- a/core/fxcodec/codec/ccodec_jpegmodule.h
+++ b/core/fxcodec/codec/ccodec_jpegmodule.h
@@ -56,7 +56,7 @@
 
   bool StartScanline(Context* pContext, int down_scale);
   bool ReadScanline(Context* pContext, uint8_t* dest_buf);
-  uint32_t GetAvailInput(Context* pContext, uint8_t** avail_buf_ptr);
+  uint32_t GetAvailInput(Context* pContext) const;
 
 #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
   static bool JpegEncode(const RetainPtr<CFX_DIBBase>& pSource,
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.cpp b/core/fxcodec/codec/ccodec_progressivedecoder.cpp
index 6faaaa1..280b647 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.cpp
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.cpp
@@ -418,7 +418,7 @@
 #ifdef PDF_ENABLE_XFA_GIF
 void CCodec_ProgressiveDecoder::GifRecordCurrentPosition(uint32_t& cur_pos) {
   uint32_t remain_size =
-      m_pCodecMgr->GetGifModule()->GetAvailInput(m_pGifContext.get(), nullptr);
+      m_pCodecMgr->GetGifModule()->GetAvailInput(m_pGifContext.get());
   cur_pos = m_offSet - remain_size;
 }
 
@@ -805,7 +805,7 @@
     return false;
 
   dwSize = dwSize - m_offSet;
-  FX_SAFE_UINT32 avail_input = pBmpModule->GetAvailInput(pBmpContext, nullptr);
+  FX_SAFE_UINT32 avail_input = pBmpModule->GetAvailInput(pBmpContext);
   if (!avail_input.IsValid())
     return false;
 
@@ -898,10 +898,9 @@
     return false;
 
   uint32_t dwFileRemaining = m_pFile->GetSize() - m_offSet;
-  uint32_t dwUnusedBuffer =
-      !m_InvalidateGifBuffer
-          ? pGifModule->GetAvailInput(m_pGifContext.get(), nullptr)
-          : 0;
+  uint32_t dwUnusedBuffer = !m_InvalidateGifBuffer
+                                ? pGifModule->GetAvailInput(m_pGifContext.get())
+                                : 0;
   uint32_t dwAmountToFetchFromFile = dwFileRemaining;
   if (dwUnusedBuffer == m_SrcSize) {
     if (dwFileRemaining > FXCODEC_BLOCK_SIZE)
@@ -1129,7 +1128,7 @@
     return false;
   }
   dwSize = dwSize - m_offSet;
-  uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext.get(), nullptr);
+  uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext.get());
   if (dwAvail == m_SrcSize) {
     if (dwSize > FXCODEC_BLOCK_SIZE) {
       dwSize = FXCODEC_BLOCK_SIZE;
diff --git a/core/fxcodec/gif/cfx_gifcontext.cpp b/core/fxcodec/gif/cfx_gifcontext.cpp
index f746bc1..8f48cfd 100644
--- a/core/fxcodec/gif/cfx_gifcontext.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext.cpp
@@ -346,19 +346,11 @@
   input_buffer_ = pdfium::MakeRetain<CFX_CodecMemory>(src_buf);
 }
 
-uint32_t CFX_GifContext::GetAvailInput(uint8_t** avail_buf) const {
+uint32_t CFX_GifContext::GetAvailInput() const {
   if (!input_buffer_)
     return 0;
 
-  FX_FILESIZE available_size =
-      input_buffer_->GetSize() - input_buffer_->GetPosition();
-  if (avail_buf) {
-    *avail_buf = nullptr;
-    if (available_size > 0)
-      *avail_buf = input_buffer_->GetBuffer() + available_size;
-  }
-
-  return available_size;
+  return input_buffer_->GetSize() - input_buffer_->GetPosition();
 }
 
 bool CFX_GifContext::ReadData(uint8_t* dest, uint32_t size) {
diff --git a/core/fxcodec/gif/cfx_gifcontext.h b/core/fxcodec/gif/cfx_gifcontext.h
index 90657b0..9cc7da9 100644
--- a/core/fxcodec/gif/cfx_gifcontext.h
+++ b/core/fxcodec/gif/cfx_gifcontext.h
@@ -42,7 +42,7 @@
   CFX_GifDecodeStatus GetFrame();
   CFX_GifDecodeStatus LoadFrame(int32_t frame_num);
   void SetInputBuffer(pdfium::span<uint8_t> src_buf);
-  uint32_t GetAvailInput(uint8_t** avail_buf) const;
+  uint32_t GetAvailInput() const;
   size_t GetFrameNum() const { return images_.size(); }
 
   UnownedPtr<CCodec_GifModule> gif_module_;