Change in/out params in CBC_PDF417Writer::Encode to only out.

The value passed was always 0. This also prevented the scaling
from being executed, so that can be removed.

Change-Id: I143a9ed31b231d3b9fa297b0bf9dcc0fa6072889
Reviewed-on: https://pdfium-review.googlesource.com/40990
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fxbarcode/cbc_pdf417i.cpp b/fxbarcode/cbc_pdf417i.cpp
index 4e7e063..0bb632e 100644
--- a/fxbarcode/cbc_pdf417i.cpp
+++ b/fxbarcode/cbc_pdf417i.cpp
@@ -41,11 +41,11 @@
 }
 
 bool CBC_PDF417I::Encode(const WideStringView& contents) {
-  int32_t outWidth = 0;
-  int32_t outHeight = 0;
+  int32_t outWidth;
+  int32_t outHeight;
   auto* pWriter = GetPDF417Writer();
   std::unique_ptr<uint8_t, FxFreeDeleter> data(
-      pWriter->Encode(WideString(contents), outWidth, outHeight));
+      pWriter->Encode(WideString(contents), &outWidth, &outHeight));
   if (!data)
     return false;
   return pWriter->RenderResult(data.get(), outWidth, outHeight);
diff --git a/fxbarcode/pdf417/BC_PDF417Writer.cpp b/fxbarcode/pdf417/BC_PDF417Writer.cpp
index ca96f69..5cf9037 100644
--- a/fxbarcode/pdf417/BC_PDF417Writer.cpp
+++ b/fxbarcode/pdf417/BC_PDF417Writer.cpp
@@ -23,6 +23,7 @@
 #include "fxbarcode/pdf417/BC_PDF417Writer.h"
 
 #include <algorithm>
+#include <utility>
 
 #include "fxbarcode/BC_TwoDimWriter.h"
 #include "fxbarcode/common/BC_CommonBitArray.h"
@@ -49,8 +50,8 @@
 }
 
 uint8_t* CBC_PDF417Writer::Encode(const WideString& contents,
-                                  int32_t& outWidth,
-                                  int32_t& outHeight) {
+                                  int32_t* outWidth,
+                                  int32_t* outHeight) {
   CBC_PDF417 encoder;
   int32_t col = (m_Width / m_ModuleWidth - 69) / 17;
   int32_t row = m_Height / (m_ModuleWidth * 20);
@@ -64,34 +65,18 @@
     return nullptr;
 
   CBC_BarcodeMatrix* barcodeMatrix = encoder.getBarcodeMatrix();
-  std::vector<uint8_t> originalScale = barcodeMatrix->getMatrix();
-  int32_t width = outWidth;
-  int32_t height = outHeight;
-  outWidth = barcodeMatrix->getWidth();
-  outHeight = barcodeMatrix->getHeight();
+  std::vector<uint8_t> matrixData = barcodeMatrix->getMatrix();
+  int32_t matrixWidth = barcodeMatrix->getWidth();
+  int32_t matrixHeight = barcodeMatrix->getHeight();
 
-  bool rotated = false;
-  if ((height > width) ^ (outWidth < outHeight)) {
-    rotateArray(originalScale, outHeight, outWidth);
-    rotated = true;
-    int32_t temp = outHeight;
-    outHeight = outWidth;
-    outWidth = temp;
+  if (matrixWidth < matrixHeight) {
+    rotateArray(matrixData, matrixHeight, matrixWidth);
+    std::swap(matrixWidth, matrixHeight);
   }
-  int32_t scaleX = width / outWidth;
-  int32_t scaleY = height / outHeight;
-  int32_t scale = std::min(scaleX, scaleY);
-  if (scale > 1) {
-    originalScale = barcodeMatrix->getScaledMatrix(scale);
-    if (rotated) {
-      rotateArray(originalScale, outHeight, outWidth);
-      int32_t temp = outHeight;
-      outHeight = outWidth;
-      outWidth = temp;
-    }
-  }
-  uint8_t* result = FX_Alloc2D(uint8_t, outHeight, outWidth);
-  memcpy(result, originalScale.data(), outHeight * outWidth);
+  uint8_t* result = FX_Alloc2D(uint8_t, matrixHeight, matrixWidth);
+  memcpy(result, matrixData.data(), matrixHeight * matrixWidth);
+  *outWidth = matrixWidth;
+  *outHeight = matrixHeight;
   return result;
 }
 
diff --git a/fxbarcode/pdf417/BC_PDF417Writer.h b/fxbarcode/pdf417/BC_PDF417Writer.h
index ef59616..1bb3a27 100644
--- a/fxbarcode/pdf417/BC_PDF417Writer.h
+++ b/fxbarcode/pdf417/BC_PDF417Writer.h
@@ -19,8 +19,8 @@
   ~CBC_PDF417Writer() override;
 
   uint8_t* Encode(const WideString& contents,
-                  int32_t& outWidth,
-                  int32_t& outHeight);
+                  int32_t* outWidth,
+                  int32_t* outHeight);
 
   // CBC_TwoDimWriter
   bool SetErrorCorrectionLevel(int32_t level) override;