libs: small refactors to enhance the code style
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 3 Feb 2016 10:04:15 +0000 (11:04 +0100)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 3 Feb 2016 19:03:47 +0000 (20:03 +0100)
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>
gst-libs/gst/vaapi/gstvaapicontext.c
gst-libs/gst/vaapi/gstvaapidecoder_vp9.c
gst-libs/gst/vaapi/gstvaapidisplay_egl.c
gst-libs/gst/vaapi/gstvaapidisplay_wayland.c
gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
gst/vaapi/gstvaapivideomemory.c

index 36fc18a..000c713 100644 (file)
@@ -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;
index bb13e96..ecb4491 100644 (file)
@@ -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;
   }
 }
 
index 4d995eb..3d7ec20 100644 (file)
@@ -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
index 71c4909..8b8e8cb 100644 (file)
@@ -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
index 9747ae1..0620d9f 100644 (file)
@@ -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;
index 3cf4746..00f6a85 100644 (file)
@@ -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);