<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 17 October 2015 at 00:25, Ilia Mirkin <span dir="ltr"><<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Not sure how VA specifies things, but if the RGBA8 stuff is supposed<br>
to be in CPU-endian as packed 32-bit ints, I think you're meant to use<br>
PIPE_FORMAT_RGBA8888_UNORM and so on. However if it's always supposed<br>
to be little-endian or array-based, then the way you have it is fine.<br></blockquote><div><br></div><div>Great question.<br></div><div><br></div><div>From what I can read, I think in VA there is no fixed assumption, for example VA_FOURCC('A','B','G','R') exists, I think currently mesa st/va just only supports VA_LSB_FIRST (but VA_MSB_FIRST exists in libva headers).<br></div><div>Initially I just extended existing code:<br><br>case VA_FOURCC('B','G','R','A'):<br> return PIPE_FORMAT_B8G8R8A8_UNORM;<br><br></div><div>I also compared with intel vaapi driver: <a href="http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c#n291" target="_blank">http://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_drv_video.c#n291</a><br></div><div>It seems they only use LSB case. Though MSB is handled in unmaintained vaapi driver bridge for vdpau: <a href="http://cgit.freedesktop.org/vaapi/vdpau-driver/tree/src/vdpau_image.c#n57" target="_blank">http://cgit.freedesktop.org/vaapi/vdpau-driver/tree/src/vdpau_image.c#n57</a><br></div><div><br></div><div>As you raised the question, I decided to ask on libva irc channel to poke some maintainers. But actually you replied to me :) (for the record, you replied there is not a ton of big endian intel cpu).<br><br></div><div>Well in any case libva defines for example VA_FOURCC('A','B','G','R') and VA_FOURCC('B','G','R','A'), so I guess it means I should not use PIPE_FORMAT_RGBA8888_UNORM-likes so I guess the patch is ok.</div><div><br></div><div>I think for now mesa st/va does not work on big endian cpu when it is about using "RGBs" formats. And after my patch it still does not.<br><br></div><div>Though I can add them if you want but it will be untested :)<br><br></div><div>Julien<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-ilia<br>
<div><div><br>
On Fri, Oct 16, 2015 at 7:14 PM, Julien Isorce <<a href="mailto:julien.isorce@gmail.com" target="_blank">julien.isorce@gmail.com</a>> wrote:<br>
> Also add RGBA, RGBX and BGRX.<br>
> Also extend ChromaToPipe and implement PipeToYCbCr.<br>
><br>
> Note that gstreamer-vaapi check all the VAImageFormat fields.<br>
><br>
> Signed-off-by: Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>><br>
> ---<br>
> src/gallium/state_trackers/va/image.c | 10 ++++++--<br>
> src/gallium/state_trackers/va/va_private.h | 38 +++++++++++++++++++++++++++++-<br>
> 2 files changed, 45 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c<br>
> index 022240d..c7fbe1a 100644<br>
> --- a/src/gallium/state_trackers/va/image.c<br>
> +++ b/src/gallium/state_trackers/va/image.c<br>
> @@ -44,7 +44,10 @@ static const VAImageFormat formats[VL_VA_MAX_IMAGE_FORMATS] =<br>
> {VA_FOURCC('Y','V','1','2')},<br>
> {VA_FOURCC('Y','U','Y','V')},<br>
> {VA_FOURCC('U','Y','V','Y')},<br>
> - {VA_FOURCC('B','G','R','A')}<br>
> + {.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000},<br>
> + {.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000},<br>
> + {.fourcc = VA_FOURCC('B','G','R','X'), .byte_order = VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000},<br>
> + {.fourcc = VA_FOURCC('R','G','B','X'), .byte_order = VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000}<br>
> };<br>
><br>
> static void<br>
> @@ -116,7 +119,7 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig<br>
> img->width = width;<br>
> img->height = height;<br>
> w = align(width, 2);<br>
> - h = align(width, 2);<br>
> + h = align(height, 2);<br>
><br>
> switch (format->fourcc) {<br>
> case VA_FOURCC('N','V','1','2'):<br>
> @@ -149,6 +152,9 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig<br>
> break;<br>
><br>
> case VA_FOURCC('B','G','R','A'):<br>
> + case VA_FOURCC('R','G','B','A'):<br>
> + case VA_FOURCC('B','G','R','X'):<br>
> + case VA_FOURCC('R','G','B','X'):<br>
> img->num_planes = 1;<br>
> img->pitches[0] = w * 4;<br>
> img->offsets[0] = 0;<br>
> diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h<br>
> index 1ea7be7..3479156 100644<br>
> --- a/src/gallium/state_trackers/va/va_private.h<br>
> +++ b/src/gallium/state_trackers/va/va_private.h<br>
> @@ -46,7 +46,7 @@<br>
> #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)<br>
> #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)<br>
><br>
> -#define VL_VA_MAX_IMAGE_FORMATS 6<br>
> +#define VL_VA_MAX_IMAGE_FORMATS 9<br>
><br>
> static inline enum pipe_video_chroma_format<br>
> ChromaToPipe(int format)<br>
> @@ -58,6 +58,8 @@ ChromaToPipe(int format)<br>
> return PIPE_VIDEO_CHROMA_FORMAT_422;<br>
> case VA_RT_FORMAT_YUV444:<br>
> return PIPE_VIDEO_CHROMA_FORMAT_444;<br>
> + case VA_RT_FORMAT_RGB32:<br>
> + return 0;<br>
> default:<br>
> assert(0);<br>
> return PIPE_VIDEO_CHROMA_FORMAT_420;<br>
> @@ -80,12 +82,46 @@ YCbCrToPipe(unsigned format)<br>
> return PIPE_FORMAT_UYVY;<br>
> case VA_FOURCC('B','G','R','A'):<br>
> return PIPE_FORMAT_B8G8R8A8_UNORM;<br>
> + case VA_FOURCC('R','G','B','A'):<br>
> + return PIPE_FORMAT_R8G8B8A8_UNORM;<br>
> + case VA_FOURCC('B','G','R','X'):<br>
> + return PIPE_FORMAT_B8G8R8X8_UNORM;<br>
> + case VA_FOURCC('R','G','B','X'):<br>
> + return PIPE_FORMAT_R8G8B8X8_UNORM;<br>
> default:<br>
> assert(0);<br>
> return PIPE_FORMAT_NONE;<br>
> }<br>
> }<br>
><br>
> +static inline unsigned<br>
> +PipeToYCbCr(enum pipe_format p_format)<br>
> +{<br>
> + switch (p_format) {<br>
> + case PIPE_FORMAT_NV12:<br>
> + return VA_FOURCC('N','V','1','2');<br>
> + case PIPE_FORMAT_IYUV:<br>
> + return VA_FOURCC('I','4','2','0');<br>
> + case PIPE_FORMAT_YV12:<br>
> + return VA_FOURCC('Y','V','1','2');<br>
> + case PIPE_FORMAT_UYVY:<br>
> + return VA_FOURCC('U','Y','V','Y');<br>
> + case PIPE_FORMAT_YUYV:<br>
> + return VA_FOURCC('Y','U','Y','V');<br>
> + case PIPE_FORMAT_B8G8R8A8_UNORM:<br>
> + return VA_FOURCC('B','G','R','A');<br>
> + case PIPE_FORMAT_R8G8B8A8_UNORM:<br>
> + return VA_FOURCC('R','G','B','A');<br>
> + case PIPE_FORMAT_B8G8R8X8_UNORM:<br>
> + return VA_FOURCC('B','G','R','X');<br>
> + case PIPE_FORMAT_R8G8B8X8_UNORM:<br>
> + return VA_FOURCC('R','G','B','X');<br>
> + default:<br>
> + assert(0);<br>
> + return -1;<br>
> + }<br>
> +}<br>
> +<br>
> static inline VAProfile<br>
> PipeToProfile(enum pipe_video_profile profile)<br>
> {<br>
> --<br>
> 1.9.1<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>