stagefright: MediaCodec buffer API revision
Bug: 136283874
Test: atest CtsMediaTestCases:MediaCodecBlockModelTest
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Change-Id: Idc02c7758da8b266099a4134b438e4478c38f912
diff --git a/media/codec2/sfplugin/utils/Codec2Mapper.cpp b/media/codec2/sfplugin/utils/Codec2Mapper.cpp
index 2f3d688..903db6c 100644
--- a/media/codec2/sfplugin/utils/Codec2Mapper.cpp
+++ b/media/codec2/sfplugin/utils/Codec2Mapper.cpp
@@ -949,3 +949,41 @@
bool C2Mapper::map(ColorAspects::Transfer from, C2Color::transfer_t *to) {
return sColorTransfersSf.map(from, to);
}
+
+// static
+bool C2Mapper::mapPixelFormatFrameworkToCodec(
+ int32_t frameworkValue, uint32_t *c2Value) {
+ switch (frameworkValue) {
+ case COLOR_FormatSurface:
+ *c2Value = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
+ return true;
+ case COLOR_FormatYUV420Flexible:
+ *c2Value = HAL_PIXEL_FORMAT_YCBCR_420_888;
+ return true;
+ case COLOR_FormatYUV420Planar:
+ case COLOR_FormatYUV420SemiPlanar:
+ case COLOR_FormatYUV420PackedPlanar:
+ case COLOR_FormatYUV420PackedSemiPlanar:
+ *c2Value = HAL_PIXEL_FORMAT_YV12;
+ return true;
+ default:
+ // TODO: support some sort of passthrough
+ return false;
+ }
+}
+
+// static
+bool C2Mapper::mapPixelFormatCodecToFramework(
+ uint32_t c2Value, int32_t *frameworkValue) {
+ switch (c2Value) {
+ case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
+ *frameworkValue = COLOR_FormatSurface;
+ return true;
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCBCR_420_888:
+ *frameworkValue = COLOR_FormatYUV420Flexible;
+ return true;
+ default:
+ return false;
+ }
+}
diff --git a/media/codec2/sfplugin/utils/Codec2Mapper.h b/media/codec2/sfplugin/utils/Codec2Mapper.h
index cec6f07..797c8a8 100644
--- a/media/codec2/sfplugin/utils/Codec2Mapper.h
+++ b/media/codec2/sfplugin/utils/Codec2Mapper.h
@@ -75,6 +75,11 @@
static bool map(ColorAspects::MatrixCoeffs, C2Color::matrix_t*);
static bool map(C2Color::transfer_t, ColorAspects::Transfer*);
static bool map(ColorAspects::Transfer, C2Color::transfer_t*);
+
+ static bool mapPixelFormatFrameworkToCodec(
+ int32_t frameworkValue, uint32_t *c2Value);
+ static bool mapPixelFormatCodecToFramework(
+ uint32_t c2Value, int32_t *frameworkValue);
};
}