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:
Gwenole Beauchesne 2013-07-08 17:01:21 +02:00
parent 5bbab30859
commit 0829d94f38
4 changed files with 18 additions and 14 deletions

View file

@ -171,10 +171,9 @@ decoder_put_buffers(GstVaapiDecoder *decoder)
return TRUE; return TRUE;
} }
GstVaapiSurface * GstVaapiSurfaceProxy *
decoder_get_surface(GstVaapiDecoder *decoder) decoder_get_surface(GstVaapiDecoder *decoder)
{ {
GstVaapiSurface *surface;
GstVaapiSurfaceProxy *proxy; GstVaapiSurfaceProxy *proxy;
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
@ -185,12 +184,7 @@ decoder_get_surface(GstVaapiDecoder *decoder)
GST_ERROR("failed to get decoded surface (decoder status %d)", status); GST_ERROR("failed to get decoded surface (decoder status %d)", status);
return NULL; return NULL;
} }
return proxy;
/* 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;
} }
const gchar * const gchar *

View file

@ -30,7 +30,7 @@ decoder_new(GstVaapiDisplay *display, const gchar *codec_name);
gboolean gboolean
decoder_put_buffers(GstVaapiDecoder *decoder); decoder_put_buffers(GstVaapiDecoder *decoder);
GstVaapiSurface * GstVaapiSurfaceProxy *
decoder_get_surface(GstVaapiDecoder *decoder); decoder_get_surface(GstVaapiDecoder *decoder);
const gchar * const gchar *

View file

@ -51,7 +51,9 @@ main(int argc, char *argv[])
GstVaapiDisplay *display, *display2; GstVaapiDisplay *display, *display2;
GstVaapiWindow *window; GstVaapiWindow *window;
GstVaapiDecoder *decoder; GstVaapiDecoder *decoder;
GstVaapiSurfaceProxy *proxy;
GstVaapiSurface *surface; GstVaapiSurface *surface;
const GstVaapiRectangle *crop_rect;
static const guint win_width = 640; static const guint win_width = 640;
static const guint win_height = 480; static const guint win_height = 480;
@ -85,18 +87,22 @@ main(int argc, char *argv[])
if (!decoder_put_buffers(decoder)) if (!decoder_put_buffers(decoder))
g_error("could not fill decoder with sample data"); g_error("could not fill decoder with sample data");
surface = decoder_get_surface(decoder); proxy = decoder_get_surface(decoder);
if (!surface) if (!proxy)
g_error("could not get decoded surface"); 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); 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)) GST_VAAPI_PICTURE_STRUCTURE_FRAME))
g_error("could not render surface"); g_error("could not render surface");
pause(); pause();
gst_vaapi_surface_proxy_unref(proxy);
gst_vaapi_decoder_unref(decoder); gst_vaapi_decoder_unref(decoder);
gst_vaapi_window_unref(window); gst_vaapi_window_unref(window);
gst_vaapi_display_unref(display); gst_vaapi_display_unref(display);

View file

@ -77,6 +77,7 @@ main(int argc, char *argv[])
GstVaapiDisplay *display; GstVaapiDisplay *display;
GstVaapiWindow *window; GstVaapiWindow *window;
GstVaapiDecoder *decoder; GstVaapiDecoder *decoder;
GstVaapiSurfaceProxy *proxy;
GstVaapiSurface *surface; GstVaapiSurface *surface;
GstBuffer *buffer; GstBuffer *buffer;
VideoSubpictureInfo subinfo; VideoSubpictureInfo subinfo;
@ -113,10 +114,12 @@ main(int argc, char *argv[])
if (!decoder_put_buffers(decoder)) if (!decoder_put_buffers(decoder))
g_error("could not fill decoder with sample data"); g_error("could not fill decoder with sample data");
surface = decoder_get_surface(decoder); proxy = decoder_get_surface(decoder);
if (!surface) if (!proxy)
g_error("could not get decoded surface"); g_error("could not get decoded surface");
surface = gst_vaapi_surface_proxy_get_surface(proxy);
subpicture_get_info(&subinfo); subpicture_get_info(&subinfo);
buffer = gst_buffer_new_and_alloc(subinfo.data_size); buffer = gst_buffer_new_and_alloc(subinfo.data_size);
upload_subpicture(buffer, &subinfo); upload_subpicture(buffer, &subinfo);
@ -171,6 +174,7 @@ main(int argc, char *argv[])
pause(); pause();
gst_video_overlay_composition_unref(compo); gst_video_overlay_composition_unref(compo);
gst_vaapi_surface_proxy_unref(proxy);
gst_vaapi_decoder_unref(decoder); gst_vaapi_decoder_unref(decoder);
gst_vaapi_window_unref(window); gst_vaapi_window_unref(window);
gst_vaapi_display_unref(display); gst_vaapi_display_unref(display);