summaryrefslogtreecommitdiff
path: root/src/i965_decoder_utils.c
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-05-09 18:52:00 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-06-02 19:30:43 +0200
commite9c2a677a04e911529966cccf71eb3a9ae59e6c3 (patch)
tree2c76af05e86408ceb6c1c827c9795b3a5e2ae008 /src/i965_decoder_utils.c
parent6d76944605a75872714744262ce0370581de9225 (diff)
downloadlibva-intel-driver-e9c2a677a04e911529966cccf71eb3a9ae59e6c3.tar.gz
libva-intel-driver-e9c2a677a04e911529966cccf71eb3a9ae59e6c3.tar.bz2
libva-intel-driver-e9c2a677a04e911529966cccf71eb3a9ae59e6c3.zip
decoder: h264: optimize support for grayscale surfaces.
Optimize support for grayscale surfaces in two aspects: (i) space by only allocating the luminance component ; (ii) speed by avoiding initialization of the (now inexistent) chrominance planes. Keep backward compatibility with older codec layers that only supported YUV 4:2:0 and not grayscale formats properly. v2: fix check for extra H.264 chroma formats [Haihao] Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'src/i965_decoder_utils.c')
-rw-r--r--src/i965_decoder_utils.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/i965_decoder_utils.c b/src/i965_decoder_utils.c
index 18704fe..9a5092e 100644
--- a/src/i965_decoder_utils.c
+++ b/src/i965_decoder_utils.c
@@ -185,25 +185,40 @@ avc_ensure_surface_bo(
)
{
VAStatus va_status;
- uint32_t hw_fourcc, fourcc, subsample;
+ uint32_t hw_fourcc, fourcc, subsample, chroma_format;
/* Validate chroma format */
switch (pic_param->seq_fields.bits.chroma_format_idc) {
case 0: // Grayscale
fourcc = VA_FOURCC_Y800;
subsample = SUBSAMPLE_YUV400;
+ chroma_format = VA_RT_FORMAT_YUV400;
break;
case 1: // YUV 4:2:0
fourcc = VA_FOURCC_NV12;
subsample = SUBSAMPLE_YUV420;
+ chroma_format = VA_RT_FORMAT_YUV420;
break;
default:
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
}
- /* XXX: always allocate NV12 (YUV 4:2:0) surfaces for now */
- hw_fourcc = VA_FOURCC_NV12;
- subsample = SUBSAMPLE_YUV420;
+ /* Determine the HW surface format, bound to VA config needs */
+ if ((decode_state->base.chroma_formats & chroma_format) == chroma_format)
+ hw_fourcc = fourcc;
+ else {
+ hw_fourcc = 0;
+ switch (fourcc) {
+ case VA_FOURCC_Y800: // Implement with an NV12 surface
+ if (decode_state->base.chroma_formats & VA_RT_FORMAT_YUV420) {
+ hw_fourcc = VA_FOURCC_NV12;
+ subsample = SUBSAMPLE_YUV420;
+ }
+ break;
+ }
+ }
+ if (!hw_fourcc)
+ return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
/* (Re-)allocate the underlying surface buffer store, if necessary */
if (!obj_surface->bo || obj_surface->fourcc != hw_fourcc) {