pluginutil: add gst_video_info_force_nv12_if_encoded()

This lines repeat a couple times in the code, so it would be better to put it
a helper function.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-05-23 15:38:07 +02:00
parent 2562cd51be
commit 3d9f8dd41f
4 changed files with 25 additions and 14 deletions

View file

@ -524,11 +524,7 @@ ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
if (!gst_video_info_from_caps (&vi, caps))
goto error_invalid_caps;
if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) {
GST_DEBUG ("assume video buffer pool format is NV12");
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12,
GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi));
}
gst_video_info_force_nv12_if_encoded (&vi);
plugin->sinkpad_buffer_size = GST_VIDEO_INFO_SIZE (&vi);
config = gst_buffer_pool_get_config (pool);
@ -721,9 +717,7 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
if (!gst_video_info_from_caps (&vi, caps))
goto error_invalid_caps;
if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED)
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12,
GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi));
gst_video_info_force_nv12_if_encoded (&vi);
if (gst_query_get_n_allocation_pools (query) > 0) {
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);

View file

@ -692,6 +692,22 @@ gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new)
return FALSE;
}
/**
* gst_video_info_force_nv12_if_encoded:
* @vinfo: a #GstVideoInfo
*
* If the format of @vinfo is %GST_VIDEO_FORMAT_ENCODED it is changed
* to %GST_VIDEO_FORMAT_NV12.
**/
void
gst_video_info_force_nv12_if_encoded (GstVideoInfo * vinfo)
{
if (GST_VIDEO_INFO_FORMAT (vinfo) != GST_VIDEO_FORMAT_ENCODED)
return;
gst_video_info_set_format (vinfo, GST_VIDEO_FORMAT_NV12,
GST_VIDEO_INFO_WIDTH (vinfo), GST_VIDEO_INFO_HEIGHT (vinfo));
}
/**
* gst_vaapi_create_test_display:
*

View file

@ -127,6 +127,10 @@ G_GNUC_INTERNAL
gboolean
gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new);
G_GNUC_INTERNAL
void
gst_video_info_force_nv12_if_encoded (GstVideoInfo * vinfo);
G_GNUC_INTERNAL
GstVaapiDisplay *
gst_vaapi_create_test_display (void);

View file

@ -26,6 +26,7 @@
#include <gst/vaapi/gstvaapisurfacepool.h>
#include <gst/vaapi/gstvaapiimagepool.h>
#include "gstvaapivideomemory.h"
#include "gstvaapipluginutil.h"
GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapivideomemory);
#define GST_CAT_DEFAULT gst_debug_vaapivideomemory
@ -705,12 +706,8 @@ allocator_configure_image_info (GstVaapiDisplay * display,
}
vinfo = &allocator->video_info;
if (GST_VIDEO_INFO_FORMAT (vinfo) == GST_VIDEO_FORMAT_ENCODED)
gst_video_info_set_format (&allocator->image_info, GST_VIDEO_FORMAT_NV12,
GST_VIDEO_INFO_WIDTH (vinfo), GST_VIDEO_INFO_HEIGHT (vinfo));
else
allocator->image_info = *vinfo;
allocator->image_info = *vinfo;
gst_video_info_force_nv12_if_encoded (&allocator->image_info);
image = new_image (display, &allocator->image_info);
if (!image)