Commit 38d8ef17 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi_x11.c: Implement CopyPalette().

Create a palette for a VAImage when our region picture has one.
parent 2646cc96
......@@ -30,6 +30,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_es.h>
#include <vlc_picture.h>
#include <vlc_vout_display.h>
#include <vlc_vout_window.h>
......@@ -647,6 +648,48 @@ static VAStatus SubpictureUnlink( vlc_va_conn_t *p_connection, VASurfaceID surfa
return status;
}
static void CopyPalette(vout_display_t *vd, VAImage *image, video_palette_t *p_palette)
{
vout_display_sys_t *sys = vd->sys;
/* vaSetImagePalette
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
* in the palette is described by the component_order in VAImage struct
*/
uint8_t *palette = (uint8_t *) calloc(p_palette->i_entries, 4 * sizeof(uint8_t));
if (!palette)
return;
#define RED 0
#define BLUE 1
#define GREEN 2
#define ALPHA 3
int entries;
for (entries = 0; entries < p_palette->i_entries; entries++)
{
palette[RED] = p_palette->palette[entries][RED];
palette[BLUE] = p_palette->palette[entries][BLUE];
palette[GREEN] = p_palette->palette[entries][GREEN];
palette[ALPHA] = p_palette->palette[entries][ALPHA];
palette = palette + 4;
}
#undef RED
#undef BLUE
#undef GREEN
#undef ALPHA
image->num_palette_entries = entries;
image->entry_bytes = 4; /* RGBA has 4 components */
VAStatus status = vaSetImagePalette(sys->conn->p_display,
image->image_id, (unsigned char *)palette);
if (status != VA_STATUS_SUCCESS)
msg_Err(vd, "failed setting palette. (%d)", status);
}
static int CopyPictureToVAImage(vout_display_t *vd, picture_t *pic,
VAImage *image, VAImageFormat *fmt)
{
......@@ -770,6 +813,12 @@ static int RenderDirectSubpicture(vout_display_t *vd, picture_t *picture, subpic
image->format.blue_mask = region->p_picture->format.i_bmask;
image->format.green_mask = region->p_picture->format.i_gmask;
image->num_palette_entries = 0;
image->entry_bytes = 0;
if (region->p_picture->format.p_palette)
CopyPalette(vd, image, region->p_picture->format.p_palette);
/* Create Subpicture */
vasub_cache->i_id = SubpictureCreate(vd, subpicture, region,
image, sys->sflags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment