mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
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:
parent
2562cd51be
commit
3d9f8dd41f
4 changed files with 25 additions and 14 deletions
|
@ -524,11 +524,7 @@ ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
|
||||||
|
|
||||||
if (!gst_video_info_from_caps (&vi, caps))
|
if (!gst_video_info_from_caps (&vi, caps))
|
||||||
goto error_invalid_caps;
|
goto error_invalid_caps;
|
||||||
if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) {
|
gst_video_info_force_nv12_if_encoded (&vi);
|
||||||
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));
|
|
||||||
}
|
|
||||||
plugin->sinkpad_buffer_size = GST_VIDEO_INFO_SIZE (&vi);
|
plugin->sinkpad_buffer_size = GST_VIDEO_INFO_SIZE (&vi);
|
||||||
|
|
||||||
config = gst_buffer_pool_get_config (pool);
|
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))
|
if (!gst_video_info_from_caps (&vi, caps))
|
||||||
goto error_invalid_caps;
|
goto error_invalid_caps;
|
||||||
if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED)
|
gst_video_info_force_nv12_if_encoded (&vi);
|
||||||
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12,
|
|
||||||
GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi));
|
|
||||||
|
|
||||||
if (gst_query_get_n_allocation_pools (query) > 0) {
|
if (gst_query_get_n_allocation_pools (query) > 0) {
|
||||||
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
|
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
|
||||||
|
|
|
@ -692,6 +692,22 @@ gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new)
|
||||||
return FALSE;
|
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:
|
* gst_vaapi_create_test_display:
|
||||||
*
|
*
|
||||||
|
|
|
@ -127,6 +127,10 @@ G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new);
|
gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_video_info_force_nv12_if_encoded (GstVideoInfo * vinfo);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
GstVaapiDisplay *
|
GstVaapiDisplay *
|
||||||
gst_vaapi_create_test_display (void);
|
gst_vaapi_create_test_display (void);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <gst/vaapi/gstvaapisurfacepool.h>
|
#include <gst/vaapi/gstvaapisurfacepool.h>
|
||||||
#include <gst/vaapi/gstvaapiimagepool.h>
|
#include <gst/vaapi/gstvaapiimagepool.h>
|
||||||
#include "gstvaapivideomemory.h"
|
#include "gstvaapivideomemory.h"
|
||||||
|
#include "gstvaapipluginutil.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapivideomemory);
|
GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapivideomemory);
|
||||||
#define GST_CAT_DEFAULT gst_debug_vaapivideomemory
|
#define GST_CAT_DEFAULT gst_debug_vaapivideomemory
|
||||||
|
@ -705,12 +706,8 @@ allocator_configure_image_info (GstVaapiDisplay * display,
|
||||||
}
|
}
|
||||||
|
|
||||||
vinfo = &allocator->video_info;
|
vinfo = &allocator->video_info;
|
||||||
|
allocator->image_info = *vinfo;
|
||||||
if (GST_VIDEO_INFO_FORMAT (vinfo) == GST_VIDEO_FORMAT_ENCODED)
|
gst_video_info_force_nv12_if_encoded (&allocator->image_info);
|
||||||
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;
|
|
||||||
|
|
||||||
image = new_image (display, &allocator->image_info);
|
image = new_image (display, &allocator->image_info);
|
||||||
if (!image)
|
if (!image)
|
||||||
|
|
Loading…
Reference in a new issue