Corrected black surface for va-api.

This commit is contained in:
Antti Seppälä 2014-10-16 14:16:01 +02:00 committed by Johns
parent 0adc02dd78
commit 9f134c1b6d
2 changed files with 72 additions and 48 deletions

View File

@ -1,5 +1,10 @@
User Antti Seppälä
Date: Thu Oct 16 14:15:15 CEST 2014
Corrected black surface for va-api.
User johns User johns
Date: Date: Thu Oct 16 14:05:17 CEST 2014
Newer va-api intel drivers support PutImage. Newer va-api intel drivers support PutImage.
Use more portable fork for vfork. Use more portable fork for vfork.

113
video.c
View File

@ -3555,66 +3555,85 @@ static void VaapiBlackSurface(VaapiDecoder * decoder)
} }
if (decoder->BlackSurface == VA_INVALID_ID) { if (decoder->BlackSurface == VA_INVALID_ID) {
if (vaCreateSurfaces(decoder->VaDisplay, VA_RT_FORMAT_YUV420, uint8_t *va_image_data;
VideoWindowWidth, VideoWindowHeight, &decoder->BlackSurface, 1, unsigned u;
NULL, 0) != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't create a surface\n")); status =
vaCreateSurfaces(decoder->VaDisplay, VA_RT_FORMAT_YUV420,
VideoWindowWidth, VideoWindowHeight, &decoder->BlackSurface, 1,
NULL, 0);
if (status != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't create a surface: %s\n"),
vaErrorStr(status));
return; return;
} }
// full sized surface, no difference unscaled/scaled osd // full sized surface, no difference unscaled/scaled osd
if (vaAssociateSubpicture(decoder->VaDisplay, VaOsdSubpicture, status =
&decoder->BlackSurface, 1, 0, 0, VaOsdImage.width, vaAssociateSubpicture(decoder->VaDisplay, VaOsdSubpicture,
VaOsdImage.height, 0, 0, VideoWindowWidth, VideoWindowHeight, &decoder->BlackSurface, 1, 0, 0, VaOsdImage.width,
0) != VA_STATUS_SUCCESS) { VaOsdImage.height, 0, 0, VideoWindowWidth, VideoWindowHeight, 0);
Error(_("video/vaapi: can't associate subpicture\n")); if (status != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't associate subpicture: %s\n"),
vaErrorStr(status));
} }
Debug(3, "video/vaapi: associate %08x\n", decoder->BlackSurface); Debug(3, "video/vaapi: associate %08x\n", decoder->BlackSurface);
// FIXME: check if intel forgets this also
if (0 && decoder->Image->image_id == VA_INVALID_ID) { if (decoder->Image->image_id == VA_INVALID_ID) {
VAImageFormat format[1]; VAImageFormat format[1];
void *va_image_data;
int i;
printf("No image\n");
VaapiFindImageFormat(decoder, PIX_FMT_NV12, format); VaapiFindImageFormat(decoder, PIX_FMT_NV12, format);
if ((status = status =
vaDeriveImage(decoder->VaDisplay, decoder->BlackSurface, vaCreateImage(VaDisplay, format, VideoWindowWidth,
decoder->Image)) != VA_STATUS_SUCCESS) { VideoWindowHeight, decoder->Image);
Error(_("video/vaapi: vaDeriveImage failed %d\n"), status); if (status != VA_STATUS_SUCCESS) {
if (vaCreateImage(VaDisplay, format, VideoWindowWidth, Error(_("video/vaapi: can't create image: %s\n"),
VideoWindowHeight, vaErrorStr(status));
decoder->Image) != VA_STATUS_SUCCESS) { return;
Error(_("video/vaapi: can't create image!\n"));
}
}
if (vaMapBuffer(VaDisplay, decoder->Image->buf, &va_image_data)
!= VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't map the image!\n"));
}
for (i = 0; (unsigned)i < decoder->Image->data_size; i += 2) {
((uint8_t *) va_image_data)[i + 0] = 0xFF;
((uint8_t *) va_image_data)[i + 1] = 0xFF;
}
if (vaUnmapBuffer(VaDisplay,
decoder->Image->buf) != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't unmap the image!\n"));
}
if (vaDestroyImage(VaDisplay,
decoder->Image->image_id) != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't destroy image!\n"));
} }
} }
// FIXME: intel didn't support put image.
if (0 status =
&& vaPutImage(VaDisplay, decoder->BlackSurface, vaMapBuffer(VaDisplay, decoder->Image->buf,
(void **)&va_image_data);
if (status != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't map the image: %s\n"),
vaErrorStr(status));
return;
}
for (u = 0; u < decoder->Image->data_size; ++u) {
if (u < decoder->Image->offsets[1]) {
va_image_data[u] = 0x00; // Y
} else if (u % 2 == 0) {
va_image_data[u] = 0x80; // U
} else {
#ifdef DEBUG
// make black surface visible
va_image_data[u] = 0xFF; // V
#else
va_image_data[u] = 0x80; // V
#endif
}
}
if (vaUnmapBuffer(VaDisplay, decoder->Image->buf) != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't unmap the image!\n"));
}
if (decoder->GetPutImage) {
status =
vaPutImage(VaDisplay, decoder->BlackSurface,
decoder->Image->image_id, 0, 0, VideoWindowWidth, decoder->Image->image_id, 0, 0, VideoWindowWidth,
VideoWindowHeight, 0, 0, VideoWindowWidth, VideoWindowHeight) VideoWindowHeight, 0, 0, VideoWindowWidth, VideoWindowHeight);
!= VA_STATUS_SUCCESS) { if (status != VA_STATUS_SUCCESS) {
Error(_("video/vaapi: can't put image!\n")); Error(_("video/vaapi: can't put image!\n"));
}
} else {
// FIXME: PutImage isn't always supported
Debug(3,
"video/vaapi: put image not supported, alternative path not written\n");
} }
#ifdef DEBUG #ifdef DEBUG
start = GetMsTicks(); start = GetMsTicks();
#endif #endif