Skip to content

Commit

Permalink
Do not advertise support for nonexistent alpha channels in
Browse files Browse the repository at this point in the history
 decode/encode

Change decode/encode in YUV 4:4:4 formats to only support surfaces with
no alpha channel, since there is no alpha support.

Signed-off-by: Mark Thompson <[email protected]>
  • Loading branch information
weizhu-intel committed May 29, 2020
1 parent b69d534 commit 9fdbb95
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 7 deletions.
38 changes: 34 additions & 4 deletions media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,16 @@ int32_t DdiMedia_MediaFormatToOsFormat(DDI_MEDIA_FORMAT format)
return VA_FOURCC_Y216;
case Media_Format_AYUV:
return VA_FOURCC_AYUV;
case Media_Format_XYUV:
return VA_FOURCC_XYUV;
case Media_Format_Y410:
return VA_FOURCC_Y410;
case Media_Format_XV30:
return VA_FOURCC_XV30;
case Media_Format_Y416:
return VA_FOURCC_Y416;
case Media_Format_XV48:
return VA_FOURCC_XV48;
case Media_Format_Y8:
return VA_FOURCC_Y8;
case Media_Format_Y16S:
Expand Down Expand Up @@ -588,10 +594,16 @@ DDI_MEDIA_FORMAT DdiMedia_OsFormatToMediaFormat(int32_t fourcc, int32_t rtformat
return Media_Format_Y216;
case VA_FOURCC_AYUV:
return Media_Format_AYUV;
case VA_FOURCC_XYUV:
return Media_Format_XYUV;
case VA_FOURCC_Y410:
return Media_Format_Y410;
case VA_FOURCC_XV30:
return Media_Format_XV30;
case VA_FOURCC_Y416:
return Media_Format_Y416;
case VA_FOURCC_XV48:
return Media_Format_XV48;
case VA_FOURCC_Y8:
return Media_Format_Y8;
case VA_FOURCC_Y16:
Expand Down Expand Up @@ -2266,6 +2278,9 @@ DdiMedia_CreateSurfaces2(
case VA_RT_FORMAT_YUV420:
expected_fourcc = VA_FOURCC_NV12;
break;
case VA_RT_FORMAT_YUV420_10:
expected_fourcc = VA_FOURCC_P010;
break;
case VA_RT_FORMAT_YUV420_12:
expected_fourcc = VA_FOURCC_P016;
break;
Expand All @@ -2282,17 +2297,17 @@ DdiMedia_CreateSurfaces2(
expected_fourcc = VA_FOURCC_444P;
break;
case VA_RT_FORMAT_YUV444_10:
expected_fourcc = VA_FOURCC_Y410;
expected_fourcc = VA_FOURCC_XV30;
break;
case VA_RT_FORMAT_YUV444_12:
expected_fourcc = VA_FOURCC_XV48;
break;
case VA_RT_FORMAT_YUV411:
expected_fourcc = VA_FOURCC_411P;
break;
case VA_RT_FORMAT_YUV400:
expected_fourcc = VA_FOURCC('4','0','0','P');
break;
case VA_RT_FORMAT_YUV420_10BPP:
expected_fourcc = VA_FOURCC_P010;
break;
case VA_RT_FORMAT_RGB16:
expected_fourcc = VA_FOURCC_R5G6B5;
break;
Expand Down Expand Up @@ -2362,12 +2377,21 @@ DdiMedia_CreateSurfaces2(
case VA_FOURCC_AYUV:
expected_fourcc = VA_FOURCC_AYUV;
break;
case VA_FOURCC_XYUV:
expected_fourcc = VA_FOURCC_XYUV;
break;
case VA_FOURCC_Y410:
expected_fourcc = VA_FOURCC_Y410;
break;
case VA_FOURCC_XV30:
expected_fourcc = VA_FOURCC_XV30;
break;
case VA_FOURCC_Y416:
expected_fourcc = VA_FOURCC_Y416;
break;
case VA_FOURCC_XV48:
expected_fourcc = VA_FOURCC_XV48;
break;
case VA_FOURCC_I420:
expected_fourcc = VA_FOURCC_I420;
break;
Expand Down Expand Up @@ -4110,10 +4134,13 @@ VAStatus DdiMedia_CreateImage(
case VA_FOURCC_VYUY:
case VA_FOURCC_YVYU:
case VA_FOURCC_AYUV:
case VA_FOURCC_XYUV:
case VA_FOURCC_Y210:
case VA_FOURCC_Y216:
case VA_FOURCC_Y410:
case VA_FOURCC_XV30:
case VA_FOURCC_Y416:
case VA_FOURCC_XV48:
case VA_FOURCC_Y800:
vaimg->num_planes = 1;
vaimg->pitches[0] = pitch;
Expand Down Expand Up @@ -4434,7 +4461,9 @@ VAStatus DdiMedia_DeriveImage (
vaimg->offsets[2] = vaimg->offsets[1] + 2;
break;
case Media_Format_Y410:
case Media_Format_XV30:
case Media_Format_AYUV:
case Media_Format_XYUV:
case Media_Format_Y210:
vaimg->format.bits_per_pixel = 32;
vaimg->data_size = mediaSurface->iPitch * mediaSurface->iHeight;
Expand All @@ -4443,6 +4472,7 @@ VAStatus DdiMedia_DeriveImage (
vaimg->offsets[0] = 0;
break;
case Media_Format_Y416:
case Media_Format_XV48:
vaimg->format.bits_per_pixel = 64; // packed format [alpha, Y, U, V], 16 bits per channel
vaimg->num_planes = 1;
vaimg->pitches[0] = mediaSurface->iPitch;
Expand Down
26 changes: 26 additions & 0 deletions media_driver/linux/common/ddi/media_libva_caps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,12 @@ VAStatus MediaLibvaCaps::QuerySurfaceAttributes(
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_AYUV;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XYUV;
i++;
}
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileVP9Profile3)
{
Expand All @@ -2679,13 +2685,25 @@ VAStatus MediaLibvaCaps::QuerySurfaceAttributes(
attribs[i].value.value.i = VA_FOURCC_Y410;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV30;
i++;

if(profile == VAProfileVP9Profile3)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV48;
i++;
}
}
else if(profile == VAProfileHEVCMain444_12)
Expand All @@ -2695,6 +2713,12 @@ VAStatus MediaLibvaCaps::QuerySurfaceAttributes(
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV48;
i++;
}
else if (profile == VAProfileJPEGBaseline)
{
Expand Down Expand Up @@ -3289,6 +3313,7 @@ GMM_RESOURCE_FORMAT MediaLibvaCaps::ConvertFourccToGmmFmt(uint32_t fourcc)
case VA_FOURCC_BGRP : return GMM_FORMAT_BGRP;
case VA_FOURCC_RGB565 : return GMM_FORMAT_B5G6R5_UNORM_TYPE;
case VA_FOURCC_AYUV : return GMM_FORMAT_AYUV_TYPE;
case VA_FOURCC_XYUV : return GMM_FORMAT_AYUV_TYPE;
case VA_FOURCC_NV12 : return GMM_FORMAT_NV12_TYPE;
case VA_FOURCC_NV21 : return GMM_FORMAT_NV21_TYPE;
case VA_FOURCC_YUY2 : return GMM_FORMAT_YUY2;
Expand All @@ -3306,6 +3331,7 @@ GMM_RESOURCE_FORMAT MediaLibvaCaps::ConvertFourccToGmmFmt(uint32_t fourcc)
case VA_FOURCC_P016 : return GMM_FORMAT_P016_TYPE;
case VA_FOURCC_Y210 : return GMM_FORMAT_Y210_TYPE;
case VA_FOURCC_Y410 : return GMM_FORMAT_Y410_TYPE;
case VA_FOURCC_XV30 : return GMM_FORMAT_Y410_TYPE;
case VA_FOURCC_Y800 : return GMM_FORMAT_GENERIC_8BIT;
case VA_FOURCC_A2R10G10B10 : return GMM_FORMAT_R10G10B10A2_UNORM_TYPE;
case VA_FOURCC_A2B10G10R10 : return GMM_FORMAT_B10G10R10A2_UNORM_TYPE;
Expand Down
3 changes: 3 additions & 0 deletions media_driver/linux/common/ddi/media_libva_common.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ typedef enum _DDI_MEDIA_FORMAT
Media_Format_Y210 ,
Media_Format_Y216 ,
Media_Format_AYUV ,
Media_Format_XYUV ,
Media_Format_Y410 ,
Media_Format_XV30 ,
Media_Format_Y416 ,
Media_Format_XV48 ,
Media_Format_Y8 ,
Media_Format_Y16S ,
Media_Format_Y16U ,
Expand Down
3 changes: 3 additions & 0 deletions media_driver/linux/common/ddi/media_libva_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ VAStatus DdiMediaUtil_AllocateSurface(
case Media_Format_Y210:
case Media_Format_Y216:
case Media_Format_AYUV:
case Media_Format_XYUV:
case Media_Format_Y410:
case Media_Format_XV30:
case Media_Format_Y416:
case Media_Format_XV48:
case Media_Format_Y8:
case Media_Format_Y16S:
case Media_Format_Y16U:
Expand Down
3 changes: 3 additions & 0 deletions media_driver/linux/common/os/mos_interface.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -902,12 +902,15 @@ MOS_STATUS MosInterface::ConvertResourceFromDdi(
resource->Format = Format_Y216;
break;
case Media_Format_AYUV:
case Media_Format_XYUV:
resource->Format = Format_AYUV;
break;
case Media_Format_Y410:
case Media_Format_XV30:
resource->Format = Format_Y410;
break;
case Media_Format_Y416:
case Media_Format_XV48:
resource->Format = Format_Y416;
break;
case Media_Format_Y8:
Expand Down
59 changes: 56 additions & 3 deletions media_driver/linux/gen11/ddi/media_libva_caps_g11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const VAImageFormat m_supportedImageformatsG11[] =
{VA_FOURCC_X2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0}, /* [31:0] X:B:G:R 2:10:10:10 little endian */
{VA_FOURCC_RGB565, VA_LSB_FIRST, 16, 16, 0xf800, 0x07e0, 0x001f, 0}, /* [15:0] R:G:B 5:6:5 little endian */
{VA_FOURCC_AYUV, VA_LSB_FIRST, 32, 0,0,0,0,0},
{VA_FOURCC_XYUV, VA_LSB_FIRST, 32, 0,0,0,0,0},
{VA_FOURCC_Y800, VA_LSB_FIRST, 8, 0,0,0,0,0},
{VA_FOURCC_NV12, VA_LSB_FIRST, 12, 0,0,0,0,0},
{VA_FOURCC_NV21, VA_LSB_FIRST, 12, 0,0,0,0,0},
Expand All @@ -63,7 +64,8 @@ const VAImageFormat m_supportedImageformatsG11[] =
{VA_FOURCC_IMC3, VA_LSB_FIRST, 16, 0,0,0,0,0},
{VA_FOURCC_P010, VA_LSB_FIRST, 24, 0,0,0,0,0},
{VA_FOURCC_Y210, VA_LSB_FIRST, 32, 0,0,0,0,0},
{VA_FOURCC_Y410, VA_LSB_FIRST, 32, 0,0,0,0,0}
{VA_FOURCC_Y410, VA_LSB_FIRST, 32, 0,0,0,0,0},
{VA_FOURCC_XV30, VA_LSB_FIRST, 32, 0,0,0,0,0}
};

const VAConfigAttribValEncRateControlExt MediaLibvaCapsG11::m_encVp9RateControlExt =
Expand Down Expand Up @@ -819,8 +821,11 @@ GMM_RESOURCE_FORMAT MediaLibvaCapsG11::ConvertMediaFmtToGmmFmt(
case Media_Format_B10G10R10X2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE;
case Media_Format_Y210 : return GMM_FORMAT_Y210_TYPE;
case Media_Format_AYUV : return GMM_FORMAT_AYUV_TYPE;
case Media_Format_XYUV : return GMM_FORMAT_AYUV_TYPE;
case Media_Format_Y410 : return GMM_FORMAT_Y410_TYPE;
case Media_Format_XV30 : return GMM_FORMAT_Y410_TYPE;
case Media_Format_Y416 : return GMM_FORMAT_Y416_TYPE;
case Media_Format_XV48 : return GMM_FORMAT_Y416_TYPE;
default : return GMM_FORMAT_INVALID;
}
}
Expand Down Expand Up @@ -969,6 +974,12 @@ VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes(
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_AYUV;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XYUV;
i++;
}
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileVP9Profile3)
{
Expand All @@ -978,13 +989,25 @@ VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes(
attribs[i].value.value.i = VA_FOURCC_Y410;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV30;
i++;

if(profile == VAProfileVP9Profile3)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV48;
i++;
}
}
else if(profile == VAProfileHEVCMain444_12)
Expand All @@ -994,6 +1017,12 @@ VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes(
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV48;
i++;
}
else if (profile == VAProfileJPEGBaseline)
{
Expand Down Expand Up @@ -1081,6 +1110,12 @@ VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes(
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_AYUV;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XYUV;
i++;
}
else if(profile == VAProfileHEVCMain444_10)
{
Expand All @@ -1089,6 +1124,12 @@ VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes(
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y410;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV30;
i++;
}
else if(profile == VAProfileHEVCMain422_10)
{
Expand All @@ -1109,15 +1150,27 @@ VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes(
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC('A', 'Y', 'U', 'V');
attribs[i].value.value.i = VA_FOURCC_AYUV;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XYUV;
i++;
}
else if (profile == VAProfileVP9Profile3)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC('Y', '4', '1', '6');
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_XV48;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
Expand Down
Loading

0 comments on commit 9fdbb95

Please sign in to comment.