diff options
author | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2016-02-03 11:04:15 +0100 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2016-02-03 20:03:47 +0100 |
commit | 4b5be5973ed7784a5099463de976e1fd118d6f57 (patch) | |
tree | 8a5ac3722437360a316550e2c8a69c8b082a3dc1 | |
parent | 28d01c08576933f1ccc41456f80730a689de0508 (diff) | |
download | gst-vaapi-4b5be5973ed7784a5099463de976e1fd118d6f57.tar.gz |
libs: small refactors to enhance the code style
As gst-indent generated ugly code in these cases, this patch changes the used
idiomatic into other one.
No functional changes were introduced.
Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapicontext.c | 5 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidecoder_vp9.c | 5 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay_egl.c | 8 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay_wayland.c | 6 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | 9 | ||||
-rw-r--r-- | gst/vaapi/gstvaapivideomemory.c | 14 |
6 files changed, 25 insertions, 22 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c index 36fc18af..000c7137 100644 --- a/gst-libs/gst/vaapi/gstvaapicontext.c +++ b/gst-libs/gst/vaapi/gstvaapicontext.c @@ -134,6 +134,7 @@ static gboolean context_create_surfaces (GstVaapiContext * context) { const GstVaapiContextInfo *const cip = &context->info; + GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (context); guint num_surfaces; if (!gst_vaapi_context_overlay_reset (context)) @@ -149,8 +150,8 @@ context_create_surfaces (GstVaapiContext * context) if (!context->surfaces_pool) { context->surfaces_pool = - gst_vaapi_surface_pool_new_with_chroma_type (GST_VAAPI_OBJECT_DISPLAY (context), - cip->chroma_type, cip->width, cip->height); + gst_vaapi_surface_pool_new_with_chroma_type (display, cip->chroma_type, + cip->width, cip->height); if (!context->surfaces_pool) return FALSE; diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c b/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c index bb13e961..ecb44914 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c @@ -236,9 +236,8 @@ vaapi_fill_ref_frames (GstVaapiDecoderVp9 * decoder, GstVaapiPicture * picture, frame_hdr->ref_frame_sign_bias[GST_VP9_REF_FRAME_ALTREF - 1]; } for (i = 0; i < G_N_ELEMENTS (priv->ref_frames); i++) { - pic_param->reference_frames[i] = - priv->ref_frames[i] ? priv-> - ref_frames[i]->surface_id : VA_INVALID_SURFACE; + pic_param->reference_frames[i] = priv->ref_frames[i] ? + priv->ref_frames[i]->surface_id : VA_INVALID_SURFACE; } } diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_egl.c b/gst-libs/gst/vaapi/gstvaapidisplay_egl.c index 4d995eb3..3d7ec20b 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_egl.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_egl.c @@ -464,10 +464,10 @@ static GstVaapiTexture * gst_vaapi_display_egl_create_texture (GstVaapiDisplay * display, GstVaapiID id, guint target, guint format, guint width, guint height) { - return id != GST_VAAPI_ID_INVALID ? - gst_vaapi_texture_egl_new_wrapped (display, id, target, format, - width, height) : - gst_vaapi_texture_egl_new (display, target, format, width, height); + if (id != GST_VAAPI_ID_INVALID) + return gst_vaapi_texture_egl_new_wrapped (display, id, target, format, + width, height); + return gst_vaapi_texture_egl_new (display, target, format, width, height); } static void diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c b/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c index 71c4909c..8b8e8cb3 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c @@ -330,9 +330,9 @@ static GstVaapiWindow * gst_vaapi_display_wayland_create_window (GstVaapiDisplay * display, GstVaapiID id, guint width, guint height) { - return id != GST_VAAPI_ID_INVALID ? - NULL : - gst_vaapi_window_wayland_new (display, width, height); + if (id != GST_VAAPI_ID_INVALID) + return NULL; + return gst_vaapi_window_wayland_new (display, width, height); } static void diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c index 9747ae1c..0620d9f9 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c @@ -880,17 +880,18 @@ static struct static int find_frame_rate_code (const VAEncSequenceParameterBufferMPEG2 * seq_param) { - unsigned int delta = -1; + unsigned int ndelta, delta = -1; int code = 1, i; float frame_rate_value = seq_param->frame_rate * (seq_param->sequence_extension.bits.frame_rate_extension_d + 1) / (seq_param->sequence_extension.bits.frame_rate_extension_n + 1); - for (i = 0; i < sizeof (frame_rate_tab) / sizeof (frame_rate_tab[0]); i++) { + for (i = 0; i < G_N_ELEMENTS (frame_rate_tab); i++) { - if (fabsf (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value) < delta) { + ndelta = fabsf (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value); + if (ndelta < delta) { code = frame_rate_tab[i].code; - delta = fabsf (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value); + delta = ndelta; } } return code; diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index 3cf4746b..00f6a85d 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -188,12 +188,13 @@ gboolean gst_video_meta_map_vaapi_memory (GstVideoMeta * meta, guint plane, GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags) { + GstAllocator *allocator; GstVaapiVideoMemory *const mem = GST_VAAPI_VIDEO_MEMORY_CAST (gst_buffer_peek_memory (meta->buffer, 0)); - g_return_val_if_fail (mem, FALSE); - g_return_val_if_fail (GST_VAAPI_IS_VIDEO_ALLOCATOR (mem->parent_instance. - allocator), FALSE); + + allocator = GST_MEMORY_CAST (mem)->allocator; + g_return_val_if_fail (GST_VAAPI_IS_VIDEO_ALLOCATOR (allocator), FALSE); g_return_val_if_fail (mem->meta, FALSE); if (mem->map_type && mem->map_type != GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_PLANAR) @@ -264,12 +265,13 @@ gboolean gst_video_meta_unmap_vaapi_memory (GstVideoMeta * meta, guint plane, GstMapInfo * info) { + GstAllocator *allocator; GstVaapiVideoMemory *const mem = GST_VAAPI_VIDEO_MEMORY_CAST (gst_buffer_peek_memory (meta->buffer, 0)); - g_return_val_if_fail (mem, FALSE); - g_return_val_if_fail (GST_VAAPI_IS_VIDEO_ALLOCATOR (mem->parent_instance. - allocator), FALSE); + + allocator = GST_MEMORY_CAST (mem)->allocator; + g_return_val_if_fail (GST_VAAPI_IS_VIDEO_ALLOCATOR (allocator), FALSE); g_return_val_if_fail (mem->meta, FALSE); g_return_val_if_fail (mem->surface, FALSE); g_return_val_if_fail (mem->image, FALSE); |