Fixes video playback when gralloc0 and software video decoder are used.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I676060021806186bb3c23928d0d54af4add5120a
* found in the LICENSE file.
*/
+#include "../../helpers.h"
#include "../../util.h"
#include "../cros_gralloc_driver.h"
break;
case GRALLOC_DRM_GET_BUFFER_INFO:
info = va_arg(args, struct cros_gralloc0_buffer_info *);
- info->drm_fourcc = hnd->format;
+ info->drm_fourcc = drv_get_standard_fourcc(hnd->format);
info->num_fds = hnd->num_planes;
info->modifier = hnd->format_modifier;
for (uint32_t i = 0; i < hnd->num_planes; i++) {
PixelFormat pixelFormat = static_cast<PixelFormat>(crosHandle->droid_format);
status = android::gralloc4::encodePixelFormatRequested(pixelFormat, &encodedMetadata);
} else if (metadataType == android::gralloc4::MetadataType_PixelFormatFourCC) {
- uint32_t format = crosHandle->format;
- // Map internal fourcc codes back to standard fourcc codes.
- if (format == DRM_FORMAT_YVU420_ANDROID) {
- format = DRM_FORMAT_YVU420;
- }
- status = android::gralloc4::encodePixelFormatFourCC(format, &encodedMetadata);
+ status = android::gralloc4::encodePixelFormatFourCC(
+ drv_get_standard_fourcc(crosHandle->format), &encodedMetadata);
} else if (metadataType == android::gralloc4::MetadataType_PixelFormatModifier) {
status = android::gralloc4::encodePixelFormatModifier(crosHandle->format_modifier,
&encodedMetadata);
hidlCb(Error::BAD_VALUE, encodedMetadata);
return Void();
}
- status = android::gralloc4::encodePixelFormatFourCC(drmFormat, &encodedMetadata);
+ status = android::gralloc4::encodePixelFormatFourCC(drv_get_standard_fourcc(drmFormat),
+ &encodedMetadata);
} else if (metadataType == android::gralloc4::MetadataType_Usage) {
status = android::gralloc4::encodeUsage(descriptor.usage, &encodedMetadata);
} else if (metadataType == android::gralloc4::MetadataType_ProtectedContent) {
// clang-format off
bo->priv = dri->image_extension->createImageFromDmaBufs2(dri->device, data->width, data->height,
- data->format,
+ drv_get_standard_fourcc(data->format),
data->format_modifiers[0],
data->fds,
bo->meta.num_planes,
} else {
// clang-format off
bo->priv = dri->image_extension->createImageFromFds(dri->device, data->width, data->height,
- data->format, data->fds,
+ drv_get_standard_fourcc(data->format), data->fds,
bo->meta.num_planes,
(int *)data->strides,
(int *)data->offsets, NULL);
return false;
}
+
+/*
+ * Map internal fourcc codes back to standard fourcc codes.
+ */
+uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal)
+{
+ return (fourcc_internal == DRM_FORMAT_YVU420_ANDROID) ? DRM_FORMAT_YVU420 : fourcc_internal;
+}
#ifndef HELPERS_H
#define HELPERS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdbool.h>
#include "drv.h"
uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
const uint64_t *modifier_order, uint32_t order_count);
bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier);
+uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif