Skip to content

Commit

Permalink
Copy JPEGData in local scope when used only for OutputJpeg().
Browse files Browse the repository at this point in the history
  • Loading branch information
szabadka authored and robryk committed Mar 29, 2017
1 parent 4ee841d commit 32a83cd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions guetzli/processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,12 @@ QuantData Processor::TryQuantMatrix(const JPEGData& jpg_in,
OutputImage img(jpg_in.width, jpg_in.height);
img.CopyFromJpegData(jpg_in);
img.ApplyGlobalQuantization(data.q);
JPEGData jpg_out = jpg_in;
img.SaveToJpegData(&jpg_out);
std::string encoded_jpg;
OutputJpeg(jpg_out, &encoded_jpg);
{
JPEGData jpg_out = jpg_in;
img.SaveToJpegData(&jpg_out);
OutputJpeg(jpg_out, &encoded_jpg);
}
GUETZLI_LOG(stats_, "Iter %2d: %s quantization matrix:\n",
stats_->counters[kNumItersCnt] + 1,
img.FrameTypeStr().c_str());
Expand Down Expand Up @@ -711,10 +713,12 @@ void Processor::SelectFrequencyMasking(const JPEGData& jpg, OutputImage* img,

++stats_->counters[kNumItersCnt];
++stats_->counters[direction > 0 ? kNumItersUpCnt : kNumItersDownCnt];
JPEGData jpg_out = jpg;
img->SaveToJpegData(&jpg_out);
std::string encoded_jpg;
OutputJpeg(jpg_out, &encoded_jpg);
{
JPEGData jpg_out = jpg;
img->SaveToJpegData(&jpg_out);
OutputJpeg(jpg_out, &encoded_jpg);
}
GUETZLI_LOG(stats_,
"Iter %2d: %s(%d) %s Coeffs[%d/%zd] "
"Blocks[%zd/%d/%d] ValThres[%.4f] Out[%7zd] EstErr[%.2f%%]",
Expand Down

0 comments on commit 32a83cd

Please sign in to comment.