This commit is contained in:
mapleyuan 2023-12-26 03:06:24 +00:00 committed by GitHub
commit 084f23eccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -442,8 +442,9 @@ absl::Status ScaleImageCalculator::ValidateImageFormats() const {
RET_CHECK(output_format_ == ImageFormat::SRGB ||
output_format_ == ImageFormat::SRGBA ||
(input_format_ == output_format_ &&
output_format_ == ImageFormat::YCBCR420P))
output_format_ == ImageFormat::YCBCR420P) || output_format_ == ImageFormat::SRGBA || output_format_ == ImageFormat::SBGRA || output_format_ == ImageFormat::GRAY8)
<< "Outputting YCbCr420P images from SRGB input is not yet supported";
RET_CHECK(input_format_ == output_format_ ||
(input_format_ == ImageFormat::YCBCR420P &&
output_format_ == ImageFormat::SRGB) ||
@ -705,11 +706,20 @@ absl::Status ScaleImageCalculator::Process(CalculatorContext* cc) {
} else {
// Upscale. If upscaling is disallowed, output_width_ and output_height_ are
// the same as the input/crop width and height.
image_frame_util::RescaleImageFrame(
*image_frame, output_width_, output_height_, alignment_boundary_,
interpolation_algorithm_, output_frame.get());
if(output_format_ == ImageFormat::SRGB || output_format_ == ImageFormat::YCBCR420P) {
image_frame_util::RescaleImageFrame(
*image_frame, output_width_, output_height_, alignment_boundary_,
interpolation_algorithm_, output_frame.get());
} else {
cv::Mat input_mat = ::upipe::formats::MatView(image_frame);
output_frame->Reset(image_frame->Format(), output_width_, output_height_,
alignment_boundary_);
cv::Mat output_mat = ::upipe::formats::MatView(output_frame.get());
cv::resize(input_mat, output_mat, cv::Size(output_width_, output_height_), 0.0, 0.0, interpolation_algorithm_);
}
if (interpolation_algorithm_ != -1) {
cc->GetCounter("Upscales")->Increment();
cc->GetCounter("Upscales")->Increment();
}
}