mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-20 06:08:14 +00:00
vaapiconvert: fix direct-rendering mode.
This commit is contained in:
parent
e00ec1f576
commit
8589e8279c
2 changed files with 41 additions and 21 deletions
1
NEWS
1
NEWS
|
@ -5,6 +5,7 @@ Copyright (C) 2011 Intel Corporation
|
||||||
Version 0.2.7 - DD.Jul.2011
|
Version 0.2.7 - DD.Jul.2011
|
||||||
* Fix MPEG-2 TS decoding
|
* Fix MPEG-2 TS decoding
|
||||||
* Fix build with newer versions of FFmpeg
|
* Fix build with newer versions of FFmpeg
|
||||||
|
* Fix vaapiconvert direct-rendering modes
|
||||||
|
|
||||||
Version 0.2.6 - 14.Jun.2011
|
Version 0.2.6 - 14.Jun.2011
|
||||||
* Fix licensing terms (LGPL v2.1)
|
* Fix licensing terms (LGPL v2.1)
|
||||||
|
|
|
@ -77,6 +77,12 @@ GST_BOILERPLATE(
|
||||||
GstBaseTransform,
|
GstBaseTransform,
|
||||||
GST_TYPE_BASE_TRANSFORM);
|
GST_TYPE_BASE_TRANSFORM);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Direct rendering levels (direct-rendering)
|
||||||
|
* 0: upstream allocated YUV pixels
|
||||||
|
* 1: vaapiconvert allocated YUV pixels (mapped from VA image)
|
||||||
|
* 2: vaapiconvert allocated YUV pixels (mapped from VA surface)
|
||||||
|
*/
|
||||||
#define DIRECT_RENDERING_DEFAULT 2
|
#define DIRECT_RENDERING_DEFAULT 2
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -334,10 +340,11 @@ gst_vaapiconvert_transform(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans);
|
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans);
|
||||||
GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(outbuf);
|
GstVaapiVideoBuffer *vbuffer;
|
||||||
GstVaapiSurface *surface;
|
GstVaapiSurface *surface;
|
||||||
GstVaapiImage *image;
|
GstVaapiImage *image;
|
||||||
|
|
||||||
|
vbuffer = GST_VAAPI_VIDEO_BUFFER(outbuf);
|
||||||
surface = gst_vaapi_video_buffer_get_surface(vbuffer);
|
surface = gst_vaapi_video_buffer_get_surface(vbuffer);
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
|
@ -347,12 +354,9 @@ gst_vaapiconvert_transform(
|
||||||
GST_DEBUG("GstVaapiVideoBuffer was expected");
|
GST_DEBUG("GstVaapiVideoBuffer was expected");
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
}
|
}
|
||||||
if (inbuf != outbuf) {
|
|
||||||
GST_DEBUG("same GstVaapiVideoBuffer was expected on both pads");
|
|
||||||
return GST_FLOW_UNEXPECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
image = gst_vaapi_video_buffer_get_image(vbuffer);
|
vbuffer = GST_VAAPI_VIDEO_BUFFER(inbuf);
|
||||||
|
image = gst_vaapi_video_buffer_get_image(vbuffer);
|
||||||
if (!image)
|
if (!image)
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
if (!gst_vaapi_image_unmap(image))
|
if (!gst_vaapi_image_unmap(image))
|
||||||
|
@ -571,6 +575,8 @@ gst_vaapiconvert_buffer_alloc(
|
||||||
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans);
|
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans);
|
||||||
GstBuffer *buffer = NULL;
|
GstBuffer *buffer = NULL;
|
||||||
GstVaapiImage *image = NULL;
|
GstVaapiImage *image = NULL;
|
||||||
|
GstVaapiSurface *surface = NULL;
|
||||||
|
GstVaapiVideoBuffer *vbuffer;
|
||||||
|
|
||||||
/* Check if we can use direct-rendering */
|
/* Check if we can use direct-rendering */
|
||||||
if (!gst_vaapiconvert_negotiate_buffers(convert, caps, caps))
|
if (!gst_vaapiconvert_negotiate_buffers(convert, caps, caps))
|
||||||
|
@ -578,26 +584,32 @@ gst_vaapiconvert_buffer_alloc(
|
||||||
if (!convert->direct_rendering)
|
if (!convert->direct_rendering)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
buffer = gst_vaapi_video_buffer_new_from_pool(convert->surfaces);
|
|
||||||
if (!buffer)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
|
|
||||||
GstVaapiSurface *surface;
|
|
||||||
switch (convert->direct_rendering) {
|
switch (convert->direct_rendering) {
|
||||||
case 2:
|
case 2:
|
||||||
|
buffer = gst_vaapi_video_buffer_new_from_pool(convert->surfaces);
|
||||||
|
if (!buffer)
|
||||||
|
goto error;
|
||||||
|
vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
|
||||||
|
|
||||||
surface = gst_vaapi_video_buffer_get_surface(vbuffer);
|
surface = gst_vaapi_video_buffer_get_surface(vbuffer);
|
||||||
image = gst_vaapi_surface_derive_image(surface);
|
image = gst_vaapi_surface_derive_image(surface);
|
||||||
if (image) {
|
if (image) {
|
||||||
gst_vaapi_video_buffer_set_image(vbuffer, image);
|
gst_vaapi_video_buffer_set_image(vbuffer, image);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can't use the derive-image optimization. Disable it. */
|
/* We can't use the derive-image optimization. Disable it. */
|
||||||
convert->direct_rendering = 1;
|
convert->direct_rendering = 1;
|
||||||
|
gst_buffer_unref(buffer);
|
||||||
|
buffer = NULL;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (!gst_vaapi_video_buffer_set_image_from_pool(vbuffer, convert->images))
|
buffer = gst_vaapi_video_buffer_new_from_pool(convert->images);
|
||||||
|
if (!buffer)
|
||||||
goto error;
|
goto error;
|
||||||
image = gst_vaapi_video_buffer_get_image(vbuffer);
|
vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
|
||||||
|
|
||||||
|
image = gst_vaapi_video_buffer_get_image(vbuffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_assert(image);
|
g_assert(image);
|
||||||
|
@ -614,6 +626,7 @@ gst_vaapiconvert_buffer_alloc(
|
||||||
|
|
||||||
error:
|
error:
|
||||||
/* We can't use the inout-buffers optimization. Disable it. */
|
/* We can't use the inout-buffers optimization. Disable it. */
|
||||||
|
GST_DEBUG("disable in/out buffer optimization");
|
||||||
if (buffer)
|
if (buffer)
|
||||||
gst_buffer_unref(buffer);
|
gst_buffer_unref(buffer);
|
||||||
convert->direct_rendering = 0;
|
convert->direct_rendering = 0;
|
||||||
|
@ -651,15 +664,21 @@ gst_vaapiconvert_prepare_output_buffer(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans);
|
GstVaapiConvert * const convert = GST_VAAPICONVERT(trans);
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer = NULL;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
if (GST_VAAPI_IS_VIDEO_BUFFER(inbuf))
|
if (convert->direct_rendering == 2) {
|
||||||
buffer = gst_buffer_ref(inbuf);
|
if (GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) {
|
||||||
else {
|
buffer = gst_vaapi_video_buffer_new_from_buffer(inbuf);
|
||||||
if (convert->direct_rendering) {
|
GST_BUFFER_SIZE(buffer) = size;
|
||||||
GST_DEBUG("upstream element destroyed our inout buffer");
|
|
||||||
convert->direct_rendering = 0;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
GST_DEBUG("upstream element destroyed our in/out buffer");
|
||||||
|
convert->direct_rendering = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buffer) {
|
||||||
buffer = gst_vaapi_video_buffer_new_from_pool(convert->surfaces);
|
buffer = gst_vaapi_video_buffer_new_from_pool(convert->surfaces);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
|
|
Loading…
Reference in a new issue