mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
tests: add basic support for video cropping.
Change generic decoder of sample I-frame to return a GstVaapiSurfaceProxy instead of a plain GstVaapiSurface. This means that we can now retrieve the frame cropping rectangle from the surface proxy, along with additional information if ever needed.
This commit is contained in:
parent
5bbab30859
commit
0829d94f38
4 changed files with 18 additions and 14 deletions
|
@ -171,10 +171,9 @@ decoder_put_buffers(GstVaapiDecoder *decoder)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
GstVaapiSurface *
|
||||
GstVaapiSurfaceProxy *
|
||||
decoder_get_surface(GstVaapiDecoder *decoder)
|
||||
{
|
||||
GstVaapiSurface *surface;
|
||||
GstVaapiSurfaceProxy *proxy;
|
||||
GstVaapiDecoderStatus status;
|
||||
|
||||
|
@ -185,12 +184,7 @@ decoder_get_surface(GstVaapiDecoder *decoder)
|
|||
GST_ERROR("failed to get decoded surface (decoder status %d)", status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Note: we only have a single I-frame to decode, so this is fine
|
||||
to just release the surface proxy right away */
|
||||
surface = gst_vaapi_surface_proxy_get_surface(proxy);
|
||||
gst_vaapi_surface_proxy_unref(proxy);
|
||||
return surface;
|
||||
return proxy;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
|
|
|
@ -30,7 +30,7 @@ decoder_new(GstVaapiDisplay *display, const gchar *codec_name);
|
|||
gboolean
|
||||
decoder_put_buffers(GstVaapiDecoder *decoder);
|
||||
|
||||
GstVaapiSurface *
|
||||
GstVaapiSurfaceProxy *
|
||||
decoder_get_surface(GstVaapiDecoder *decoder);
|
||||
|
||||
const gchar *
|
||||
|
|
|
@ -51,7 +51,9 @@ main(int argc, char *argv[])
|
|||
GstVaapiDisplay *display, *display2;
|
||||
GstVaapiWindow *window;
|
||||
GstVaapiDecoder *decoder;
|
||||
GstVaapiSurfaceProxy *proxy;
|
||||
GstVaapiSurface *surface;
|
||||
const GstVaapiRectangle *crop_rect;
|
||||
|
||||
static const guint win_width = 640;
|
||||
static const guint win_height = 480;
|
||||
|
@ -85,18 +87,22 @@ main(int argc, char *argv[])
|
|||
if (!decoder_put_buffers(decoder))
|
||||
g_error("could not fill decoder with sample data");
|
||||
|
||||
surface = decoder_get_surface(decoder);
|
||||
if (!surface)
|
||||
proxy = decoder_get_surface(decoder);
|
||||
if (!proxy)
|
||||
g_error("could not get decoded surface");
|
||||
|
||||
surface = gst_vaapi_surface_proxy_get_surface(proxy);
|
||||
crop_rect = gst_vaapi_surface_proxy_get_crop_rect(proxy);
|
||||
|
||||
gst_vaapi_window_show(window);
|
||||
|
||||
if (!gst_vaapi_window_put_surface(window, surface, NULL, NULL,
|
||||
if (!gst_vaapi_window_put_surface(window, surface, crop_rect, NULL,
|
||||
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
||||
g_error("could not render surface");
|
||||
|
||||
pause();
|
||||
|
||||
gst_vaapi_surface_proxy_unref(proxy);
|
||||
gst_vaapi_decoder_unref(decoder);
|
||||
gst_vaapi_window_unref(window);
|
||||
gst_vaapi_display_unref(display);
|
||||
|
|
|
@ -77,6 +77,7 @@ main(int argc, char *argv[])
|
|||
GstVaapiDisplay *display;
|
||||
GstVaapiWindow *window;
|
||||
GstVaapiDecoder *decoder;
|
||||
GstVaapiSurfaceProxy *proxy;
|
||||
GstVaapiSurface *surface;
|
||||
GstBuffer *buffer;
|
||||
VideoSubpictureInfo subinfo;
|
||||
|
@ -113,10 +114,12 @@ main(int argc, char *argv[])
|
|||
if (!decoder_put_buffers(decoder))
|
||||
g_error("could not fill decoder with sample data");
|
||||
|
||||
surface = decoder_get_surface(decoder);
|
||||
if (!surface)
|
||||
proxy = decoder_get_surface(decoder);
|
||||
if (!proxy)
|
||||
g_error("could not get decoded surface");
|
||||
|
||||
surface = gst_vaapi_surface_proxy_get_surface(proxy);
|
||||
|
||||
subpicture_get_info(&subinfo);
|
||||
buffer = gst_buffer_new_and_alloc(subinfo.data_size);
|
||||
upload_subpicture(buffer, &subinfo);
|
||||
|
@ -171,6 +174,7 @@ main(int argc, char *argv[])
|
|||
pause();
|
||||
|
||||
gst_video_overlay_composition_unref(compo);
|
||||
gst_vaapi_surface_proxy_unref(proxy);
|
||||
gst_vaapi_decoder_unref(decoder);
|
||||
gst_vaapi_window_unref(window);
|
||||
gst_vaapi_display_unref(display);
|
||||
|
|
Loading…
Reference in a new issue