Commit 27c98933 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/chromeos/LibyuvIP: Compare fourccs by single-planar fourccs

LibyuvIP checks the configured fourcc is supported by comparing
the fourcc value. It causes the LibyuvIP supports single-planar
fourcc only. LibyuvIP is able to process multi-planar fourccs.
This fixes the bug by comparing the configured fourccs and
supported fourccs as single planar formats.

Bug: b:147411004
Test: image_processor_test on kevin
Test: media_unittests --gtest_filter=FourccTest on kevin
Change-Id: I7bbc6953bdf1bbd9c73deaf82beab743ce147cbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2016543
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735771}
parent f0a103c4
......@@ -269,6 +269,34 @@ base::Optional<uint32_t> Fourcc::ToVAFourCC() const {
#endif // BUILDFLAG(USE_VAAPI)
base::Optional<Fourcc> Fourcc::ToSinglePlanar() const {
switch (value_) {
case AR24:
case AB24:
case XR24:
case XB24:
case RGB4:
case YU12:
case YV12:
case YUYV:
case NV12:
case NV21:
return Fourcc(value_);
case YM12:
return Fourcc(YU12);
case YM21:
return Fourcc(YV12);
case NM12:
return Fourcc(NV12);
case NM21:
return Fourcc(NV21);
case YM16:
case MT21:
case MM21:
return base::nullopt;
}
}
bool operator!=(const Fourcc& lhs, const Fourcc& rhs) {
return !(lhs == rhs);
}
......
......@@ -155,6 +155,10 @@ class MEDIA_GPU_EXPORT Fourcc {
base::Optional<uint32_t> ToVAFourCC() const;
#endif // BUILDFLAG(USE_VAAPI)
// Returns the single-planar Fourcc of the value. If value is a single-planar,
// returns the same Fourcc. Returns nullopt if no mapping is found.
base::Optional<Fourcc> ToSinglePlanar() const;
// Returns whether |value_| is multi planar format.
bool IsMultiPlanar() const;
......
......@@ -179,4 +179,24 @@ TEST(FourccTest, VideoPixelFormatToVAFourCC) {
}
#endif // BUILDFLAG(USE_VAAPI)
TEST(FourccTest, FourccToSinglePlanar) {
EXPECT_EQ(Fourcc(Fourcc::AR24).ToSinglePlanar(), Fourcc(Fourcc::AR24));
EXPECT_EQ(Fourcc(Fourcc::AB24).ToSinglePlanar(), Fourcc(Fourcc::AB24));
EXPECT_EQ(Fourcc(Fourcc::XR24).ToSinglePlanar(), Fourcc(Fourcc::XR24));
EXPECT_EQ(Fourcc(Fourcc::XB24).ToSinglePlanar(), Fourcc(Fourcc::XB24));
EXPECT_EQ(Fourcc(Fourcc::RGB4).ToSinglePlanar(), Fourcc(Fourcc::RGB4));
EXPECT_EQ(Fourcc(Fourcc::YU12).ToSinglePlanar(), Fourcc(Fourcc::YU12));
EXPECT_EQ(Fourcc(Fourcc::YV12).ToSinglePlanar(), Fourcc(Fourcc::YV12));
EXPECT_EQ(Fourcc(Fourcc::YUYV).ToSinglePlanar(), Fourcc(Fourcc::YUYV));
EXPECT_EQ(Fourcc(Fourcc::NV12).ToSinglePlanar(), Fourcc(Fourcc::NV12));
EXPECT_EQ(Fourcc(Fourcc::NV21).ToSinglePlanar(), Fourcc(Fourcc::NV21));
EXPECT_EQ(Fourcc(Fourcc::YM12).ToSinglePlanar(),
Fourcc(Fourcc::YU12).ToSinglePlanar());
EXPECT_EQ(Fourcc(Fourcc::YM21).ToSinglePlanar(),
Fourcc(Fourcc::YV12).ToSinglePlanar());
EXPECT_EQ(Fourcc(Fourcc::NM12).ToSinglePlanar(),
Fourcc(Fourcc::NV12).ToSinglePlanar());
EXPECT_EQ(Fourcc(Fourcc::NM21).ToSinglePlanar(),
Fourcc(Fourcc::NV21).ToSinglePlanar());
}
} // namespace media
......@@ -34,14 +34,25 @@ SupportResult IsFormatSupported(Fourcc input_fourcc, Fourcc output_fourcc) {
{Fourcc::XB24, Fourcc::NV12, true},
};
const auto single_input_fourcc = input_fourcc.ToSinglePlanar();
const auto single_output_fourcc = output_fourcc.ToSinglePlanar();
if (!single_input_fourcc || !single_output_fourcc)
return SupportResult::Unsupported;
// Compare fourccs by formatting single planar formats because LibyuvIP can
// process either single- or multi-planar formats.
for (const auto& conv : kSupportFormatConversionArray) {
const auto conv_input_fourcc = Fourcc::FromUint32(conv.input);
const auto conv_output_fourcc = Fourcc::FromUint32(conv.output);
if (!conv_input_fourcc || !conv_output_fourcc)
return SupportResult::Unsupported;
if (*conv_input_fourcc == input_fourcc &&
*conv_output_fourcc == output_fourcc) {
continue;
const auto single_conv_input_fourcc = conv_input_fourcc->ToSinglePlanar();
const auto single_conv_output_fourcc = conv_output_fourcc->ToSinglePlanar();
if (!single_conv_input_fourcc || !single_conv_output_fourcc)
continue;
if (single_input_fourcc == single_conv_input_fourcc &&
single_output_fourcc == single_conv_output_fourcc) {
return conv.need_pivot ? SupportResult::SupportedWithPivot
: SupportResult::Supported;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment