1 /*
2  *  gstvaapisurfaceproxy.c - VA surface proxy
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2011-2014 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24 
25 /**
26  * SECTION:gstvaapisurfaceproxy
27  * @short_description: VA surface proxy
28  */
29 
30 #include "sysdeps.h"
31 #include "gstvaapisurfaceproxy.h"
32 #include "gstvaapisurfaceproxy_priv.h"
33 #include "gstvaapivideopool_priv.h"
34 
35 #define DEBUG 1
36 #include "gstvaapidebug.h"
37 
38 static void
gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy * proxy)39 gst_vaapi_surface_proxy_finalize (GstVaapiSurfaceProxy * proxy)
40 {
41   if (proxy->surface) {
42     if (proxy->pool && !proxy->parent)
43       gst_vaapi_video_pool_put_object (proxy->pool, proxy->surface);
44     gst_vaapi_object_unref (proxy->surface);
45     proxy->surface = NULL;
46   }
47   gst_vaapi_video_pool_replace (&proxy->pool, NULL);
48   gst_vaapi_surface_proxy_replace (&proxy->parent, NULL);
49 
50   /* Notify the user function that the object is now destroyed */
51   if (proxy->destroy_func)
52     proxy->destroy_func (proxy->destroy_data);
53 
54 #if USE_H264_FEI_ENCODER
55   if (proxy->mvpred)
56     gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
57         proxy->mvpred, NULL);
58   if (proxy->mbcntrl)
59     gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
60         proxy->mbcntrl, NULL);
61   if (proxy->qp)
62     gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
63         proxy->qp, NULL);
64   if (proxy->mbcode)
65     gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
66         proxy->mbcode, NULL);
67   if (proxy->mv)
68     gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
69         proxy->mv, NULL);
70   if (proxy->dist)
71     gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
72         proxy->dist, NULL);
73 #endif
74 }
75 
76 static inline const GstVaapiMiniObjectClass *
gst_vaapi_surface_proxy_class(void)77 gst_vaapi_surface_proxy_class (void)
78 {
79   static const GstVaapiMiniObjectClass GstVaapiSurfaceProxyClass = {
80     sizeof (GstVaapiSurfaceProxy),
81     (GDestroyNotify) gst_vaapi_surface_proxy_finalize
82   };
83   return &GstVaapiSurfaceProxyClass;
84 }
85 
86 static void
gst_vaapi_surface_proxy_init_properties(GstVaapiSurfaceProxy * proxy)87 gst_vaapi_surface_proxy_init_properties (GstVaapiSurfaceProxy * proxy)
88 {
89   proxy->view_id = 0;
90   proxy->timestamp = GST_CLOCK_TIME_NONE;
91   proxy->duration = GST_CLOCK_TIME_NONE;
92   proxy->has_crop_rect = FALSE;
93 #if USE_H264_FEI_ENCODER
94   proxy->mvpred = NULL;
95   proxy->mbcntrl = NULL;
96   proxy->qp = NULL;
97   proxy->mbcode = NULL;
98   proxy->mv = NULL;
99   proxy->dist = NULL;
100 #endif
101 }
102 
103 /**
104  * gst_vaapi_surface_proxy_new:
105  * @surface: a #GstVaapiSurface
106  *
107  * Creates a new #GstVaapiSurfaceProxy with the specified
108  * surface. This allows for transporting additional information that
109  * are not to be attached to the @surface directly.
110  *
111  * Return value: the newly allocated #GstVaapiSurfaceProxy object
112  */
113 GstVaapiSurfaceProxy *
gst_vaapi_surface_proxy_new(GstVaapiSurface * surface)114 gst_vaapi_surface_proxy_new (GstVaapiSurface * surface)
115 {
116   GstVaapiSurfaceProxy *proxy;
117 
118   g_return_val_if_fail (surface != NULL, NULL);
119 
120   proxy = (GstVaapiSurfaceProxy *)
121       gst_vaapi_mini_object_new (gst_vaapi_surface_proxy_class ());
122   if (!proxy)
123     return NULL;
124 
125   proxy->parent = NULL;
126   proxy->destroy_func = NULL;
127   proxy->pool = NULL;
128   proxy->surface = gst_vaapi_object_ref (surface);
129   if (!proxy->surface)
130     goto error;
131   gst_vaapi_surface_proxy_init_properties (proxy);
132   return proxy;
133 
134   /* ERRORS */
135 error:
136   {
137     gst_vaapi_surface_proxy_unref (proxy);
138     return NULL;
139   }
140 }
141 
142 /**
143  * gst_vaapi_surface_proxy_new_from_pool:
144  * @pool: a #GstVaapiSurfacePool
145  *
146  * Allocates a new surface from the supplied surface @pool and creates
147  * the wrapped surface proxy object from it. When the last reference
148  * to the proxy object is released, then the underlying VA surface is
149  * pushed back to its parent pool.
150  *
151  * Returns: The same newly allocated @proxy object, or %NULL on error
152  */
153 GstVaapiSurfaceProxy *
gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool * pool)154 gst_vaapi_surface_proxy_new_from_pool (GstVaapiSurfacePool * pool)
155 {
156   GstVaapiSurfaceProxy *proxy;
157 
158   g_return_val_if_fail (pool != NULL, NULL);
159 
160   proxy = (GstVaapiSurfaceProxy *)
161       gst_vaapi_mini_object_new (gst_vaapi_surface_proxy_class ());
162   if (!proxy)
163     return NULL;
164 
165   proxy->parent = NULL;
166   proxy->destroy_func = NULL;
167   proxy->pool = gst_vaapi_video_pool_ref (GST_VAAPI_VIDEO_POOL (pool));
168   proxy->surface = gst_vaapi_video_pool_get_object (proxy->pool);
169   if (!proxy->surface)
170     goto error;
171   gst_vaapi_object_ref (proxy->surface);
172   gst_vaapi_surface_proxy_init_properties (proxy);
173   return proxy;
174 
175   /* ERRORS */
176 error:
177   {
178     gst_vaapi_surface_proxy_unref (proxy);
179     return NULL;
180   }
181 }
182 
183 /**
184  * gst_vaapi_surface_proxy_copy:
185  * @proxy: the parent #GstVaapiSurfaceProxy
186  *
187  * Creates are new VA surface proxy object from the supplied parent
188  * @proxy object with the same initial information, e.g. timestamp,
189  * duration.
190  *
191  * Note: the destroy notify function is not copied into the new
192  * surface proxy object.
193  *
194  * Returns: The same newly allocated @proxy object, or %NULL on error
195  */
196 GstVaapiSurfaceProxy *
gst_vaapi_surface_proxy_copy(GstVaapiSurfaceProxy * proxy)197 gst_vaapi_surface_proxy_copy (GstVaapiSurfaceProxy * proxy)
198 {
199   GstVaapiSurfaceProxy *copy;
200 
201   g_return_val_if_fail (proxy != NULL, NULL);
202 
203   copy = (GstVaapiSurfaceProxy *)
204       gst_vaapi_mini_object_new (gst_vaapi_surface_proxy_class ());
205   if (!copy)
206     return NULL;
207 
208   GST_VAAPI_SURFACE_PROXY_FLAGS (copy) = GST_VAAPI_SURFACE_PROXY_FLAGS (proxy);
209 
210   copy->parent = gst_vaapi_surface_proxy_ref (proxy->parent ?
211       proxy->parent : proxy);
212   copy->pool = proxy->pool ? gst_vaapi_video_pool_ref (proxy->pool) : NULL;
213   copy->surface = gst_vaapi_object_ref (proxy->surface);
214   copy->view_id = proxy->view_id;
215   copy->timestamp = proxy->timestamp;
216   copy->duration = proxy->duration;
217   copy->destroy_func = NULL;
218   copy->has_crop_rect = proxy->has_crop_rect;
219   if (copy->has_crop_rect)
220     copy->crop_rect = proxy->crop_rect;
221 
222 #if USE_H264_FEI_ENCODER
223 
224   if (proxy->mv)
225     copy->mv = (GstVaapiEncFeiMv *)
226         gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT (proxy->mv));
227   else
228     copy->mv = NULL;
229 
230   if (proxy->mbcode)
231     copy->mbcode = (GstVaapiEncFeiMbCode *)
232         gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
233         (proxy->mbcode));
234   else
235     copy->mbcode = NULL;
236 
237   if (proxy->mvpred)
238     copy->mvpred = (GstVaapiEncFeiMvPredictor *)
239         gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
240         (proxy->mvpred));
241   else
242     copy->mvpred = NULL;
243 
244   if (proxy->qp)
245     copy->qp = (GstVaapiEncFeiQp *)
246         gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT (proxy->qp));
247   else
248     copy->qp = NULL;
249 
250   if (proxy->mbcntrl)
251     copy->mbcntrl = (GstVaapiEncFeiMbControl *)
252         gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
253         (proxy->mbcntrl));
254   else
255     copy->mbcntrl = NULL;
256 
257   if (proxy->dist)
258     copy->dist = (GstVaapiEncFeiDistortion *)
259         gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
260         (proxy->dist));
261   else
262     copy->dist = NULL;
263 
264 
265 #endif
266 
267   return copy;
268 }
269 
270 /**
271  * gst_vaapi_surface_proxy_ref:
272  * @proxy: a #GstVaapiSurfaceProxy
273  *
274  * Atomically increases the reference count of the given @proxy by one.
275  *
276  * Returns: The same @proxy argument
277  */
278 GstVaapiSurfaceProxy *
gst_vaapi_surface_proxy_ref(GstVaapiSurfaceProxy * proxy)279 gst_vaapi_surface_proxy_ref (GstVaapiSurfaceProxy * proxy)
280 {
281   g_return_val_if_fail (proxy != NULL, NULL);
282 
283   return
284       GST_VAAPI_SURFACE_PROXY (gst_vaapi_mini_object_ref (GST_VAAPI_MINI_OBJECT
285           (proxy)));
286 }
287 
288 /**
289  * gst_vaapi_surface_proxy_unref:
290  * @proxy: a #GstVaapiSurfaceProxy
291  *
292  * Atomically decreases the reference count of the @proxy by one. If
293  * the reference count reaches zero, the object will be free'd.
294  */
295 void
gst_vaapi_surface_proxy_unref(GstVaapiSurfaceProxy * proxy)296 gst_vaapi_surface_proxy_unref (GstVaapiSurfaceProxy * proxy)
297 {
298   g_return_if_fail (proxy != NULL);
299 
300   gst_vaapi_mini_object_unref (GST_VAAPI_MINI_OBJECT (proxy));
301 }
302 
303 /**
304  * gst_vaapi_surface_proxy_replace:
305  * @old_proxy_ptr: a pointer to a #GstVaapiSurfaceProxy
306  * @new_proxy: a #GstVaapiSurfaceProxy
307  *
308  * Atomically replaces the proxy object held in @old_proxy_ptr with
309  * @new_proxy. This means that @old_proxy_ptr shall reference a valid
310  * object. However, @new_proxy can be NULL.
311  */
312 void
gst_vaapi_surface_proxy_replace(GstVaapiSurfaceProxy ** old_proxy_ptr,GstVaapiSurfaceProxy * new_proxy)313 gst_vaapi_surface_proxy_replace (GstVaapiSurfaceProxy ** old_proxy_ptr,
314     GstVaapiSurfaceProxy * new_proxy)
315 {
316   g_return_if_fail (old_proxy_ptr != NULL);
317 
318   gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) old_proxy_ptr,
319       GST_VAAPI_MINI_OBJECT (new_proxy));
320 }
321 
322 /**
323  * gst_vaapi_surface_proxy_get_surface:
324  * @proxy: a #GstVaapiSurfaceProxy
325  *
326  * Returns the #GstVaapiSurface stored in the @proxy.
327  *
328  * Return value: the #GstVaapiSurface
329  */
330 GstVaapiSurface *
gst_vaapi_surface_proxy_get_surface(GstVaapiSurfaceProxy * proxy)331 gst_vaapi_surface_proxy_get_surface (GstVaapiSurfaceProxy * proxy)
332 {
333   g_return_val_if_fail (proxy != NULL, NULL);
334 
335   return GST_VAAPI_SURFACE_PROXY_SURFACE (proxy);
336 }
337 
338 /**
339  * gst_vaapi_surface_proxy_get_flags:
340  * @proxy: a #GstVaapiSurfaceProxy
341  *
342  * Returns the #GstVaapiSurfaceProxyFlags associated with this surface
343  * @proxy.
344  *
345  * Return value: the set of #GstVaapiSurfaceProxyFlags
346  */
347 guint
gst_vaapi_surface_proxy_get_flags(GstVaapiSurfaceProxy * proxy)348 gst_vaapi_surface_proxy_get_flags (GstVaapiSurfaceProxy * proxy)
349 {
350   g_return_val_if_fail (proxy != NULL, 0);
351 
352   return GST_VAAPI_SURFACE_PROXY_FLAGS (proxy);
353 }
354 
355 /**
356  * gst_vaapi_surface_proxy_get_surface_id:
357  * @proxy: a #GstVaapiSurfaceProxy
358  *
359  * Returns the VA surface ID stored in the @proxy.
360  *
361  * Return value: the #GstVaapiID
362  */
363 GstVaapiID
gst_vaapi_surface_proxy_get_surface_id(GstVaapiSurfaceProxy * proxy)364 gst_vaapi_surface_proxy_get_surface_id (GstVaapiSurfaceProxy * proxy)
365 {
366   g_return_val_if_fail (proxy != NULL, VA_INVALID_ID);
367   g_return_val_if_fail (proxy->surface != NULL, VA_INVALID_ID);
368 
369   return GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy);
370 }
371 
372 /**
373  * gst_vaapi_surface_proxy_get_view_id:
374  * @proxy: a #GstVaapiSurfaceProxy
375  *
376  * Returns the decoded view-id stored in the @proxy.
377  *
378  * Return value: the #GstVaapiID
379  */
380 guintptr
gst_vaapi_surface_proxy_get_view_id(GstVaapiSurfaceProxy * proxy)381 gst_vaapi_surface_proxy_get_view_id (GstVaapiSurfaceProxy * proxy)
382 {
383   g_return_val_if_fail (proxy != NULL, 0);
384 
385   return GST_VAAPI_SURFACE_PROXY_VIEW_ID (proxy);
386 }
387 
388 /**
389  * gst_vaapi_surface_proxy_get_timestamp:
390  * @proxy: a #GstVaapiSurfaceProxy
391  *
392  * Returns the presentation timestamp for this surface @proxy.
393  *
394  * Return value: the presentation timestamp
395  */
396 GstClockTime
gst_vaapi_surface_proxy_get_timestamp(GstVaapiSurfaceProxy * proxy)397 gst_vaapi_surface_proxy_get_timestamp (GstVaapiSurfaceProxy * proxy)
398 {
399   g_return_val_if_fail (proxy != NULL, 0);
400 
401   return GST_VAAPI_SURFACE_PROXY_TIMESTAMP (proxy);
402 }
403 
404 /**
405  * gst_vaapi_surface_proxy_get_duration:
406  * @proxy: a #GstVaapiSurfaceProxy
407  *
408  * Returns the presentation duration for this surface @proxy.
409  *
410  * Return value: the presentation duration
411  */
412 GstClockTime
gst_vaapi_surface_proxy_get_duration(GstVaapiSurfaceProxy * proxy)413 gst_vaapi_surface_proxy_get_duration (GstVaapiSurfaceProxy * proxy)
414 {
415   g_return_val_if_fail (proxy != NULL, 0);
416 
417   return GST_VAAPI_SURFACE_PROXY_DURATION (proxy);
418 }
419 
420 /**
421  * gst_vaapi_surface_proxy_set_destroy_notify:
422  * @proxy: a @GstVaapiSurfaceProxy
423  * @destroy_func: a #GDestroyNotify function
424  * @user_data: some extra data to pass to the @destroy_func function
425  *
426  * Sets @destroy_func as the function to call when the surface @proxy
427  * was released. At this point, the proxy object is considered
428  * released, i.e. the underlying data storage is no longer valid and
429  * the callback function shall not expect anything from that.
430  */
431 void
gst_vaapi_surface_proxy_set_destroy_notify(GstVaapiSurfaceProxy * proxy,GDestroyNotify destroy_func,gpointer user_data)432 gst_vaapi_surface_proxy_set_destroy_notify (GstVaapiSurfaceProxy * proxy,
433     GDestroyNotify destroy_func, gpointer user_data)
434 {
435   g_return_if_fail (proxy != NULL);
436 
437   proxy->destroy_func = destroy_func;
438   proxy->destroy_data = user_data;
439 }
440 
441 /**
442  * gst_vaapi_surface_proxy_get_crop_rect:
443  * @proxy: a #GstVaapiSurfaceProxy
444  *
445  * Returns the #GstVaapiRectangle stored in the @proxy and that
446  * represents the cropping rectangle for the underlying surface to be
447  * used for rendering.
448  *
449  * If no cropping rectangle was associated with the @proxy, then this
450  * function returns %NULL.
451  *
452  * Return value: the #GstVaapiRectangle, or %NULL if none was
453  *   associated with the surface proxy
454  */
455 const GstVaapiRectangle *
gst_vaapi_surface_proxy_get_crop_rect(GstVaapiSurfaceProxy * proxy)456 gst_vaapi_surface_proxy_get_crop_rect (GstVaapiSurfaceProxy * proxy)
457 {
458   g_return_val_if_fail (proxy != NULL, NULL);
459 
460   return GST_VAAPI_SURFACE_PROXY_CROP_RECT (proxy);
461 }
462 
463 /**
464  * gst_vaapi_surface_proxy_set_crop_rect:
465  * @proxy: #GstVaapiSurfaceProxy
466  * @crop_rect: the #GstVaapiRectangle to be stored in @proxy
467  *
468  * Associates the @crop_rect with the @proxy
469  */
470 void
gst_vaapi_surface_proxy_set_crop_rect(GstVaapiSurfaceProxy * proxy,const GstVaapiRectangle * crop_rect)471 gst_vaapi_surface_proxy_set_crop_rect (GstVaapiSurfaceProxy * proxy,
472     const GstVaapiRectangle * crop_rect)
473 {
474   g_return_if_fail (proxy != NULL);
475 
476   proxy->has_crop_rect = crop_rect != NULL;
477   if (proxy->has_crop_rect)
478     proxy->crop_rect = *crop_rect;
479 }
480 
481 #if USE_H264_FEI_ENCODER
482 
483 /**
484  * gst_vaapi_surface_proxy_get_fei_mb_code:
485  * @proxy: a #GstVaapiSurfaceProxy
486  *
487  * Returns the #GstVaapiEncFeiMbCode stored in the @proxy
488  *
489  * Return value: the #GstVaapiEncFeiMbcode, or %NULL if none was
490  *   associated with the surface proxy
491  */
492 GstVaapiEncFeiMbCode *
gst_vaapi_surface_proxy_get_fei_mb_code(GstVaapiSurfaceProxy * proxy)493 gst_vaapi_surface_proxy_get_fei_mb_code (GstVaapiSurfaceProxy * proxy)
494 {
495   g_return_val_if_fail (proxy != NULL, NULL);
496   return proxy->mbcode;
497 }
498 
499 /**
500  * gst_vaapi_surface_proxy_get_fei_mv:
501  * @proxy: a #GstVaapiSurfaceProxy
502  *
503  * Returns the #GstVaapiEncFeiMv stored in the @proxy
504  *
505  * Return value: the #GstVaapiEncFeiMv, or %NULL if none was
506  *   associated with the surface proxy
507  */
508 GstVaapiEncFeiMv *
gst_vaapi_surface_proxy_get_fei_mv(GstVaapiSurfaceProxy * proxy)509 gst_vaapi_surface_proxy_get_fei_mv (GstVaapiSurfaceProxy * proxy)
510 {
511   g_return_val_if_fail (proxy != NULL, NULL);
512   return proxy->mv;
513 }
514 
515 /**
516  * gst_vaapi_surface_proxy_get_fei_distortion:
517  * @proxy: a #GstVaapiSurfaceProxy
518  *
519  * Returns the #GstVaapiEncFeiDistortion stored in the @proxy
520  *
521  * Return value: the #GstVaapiEncFeiDistortion, or %NULL if none was
522  *   associated with the surface proxy
523  */
524 GstVaapiEncFeiDistortion *
gst_vaapi_surface_proxy_get_fei_distortion(GstVaapiSurfaceProxy * proxy)525 gst_vaapi_surface_proxy_get_fei_distortion (GstVaapiSurfaceProxy * proxy)
526 {
527   g_return_val_if_fail (proxy != NULL, NULL);
528   return proxy->dist;
529 }
530 
531 /**
532  * gst_vaapi_surface_proxy_get_fei_qp:
533  * @proxy: a #GstVaapiSurfaceProxy
534  *
535  * Returns the #GstVaapiEncFeiQp stored in the @proxy
536  *
537  * Return value: the #GstVaapiEncFeiQp, or %NULL if none was
538  *   associated with the surface proxy
539  */
540 GstVaapiEncFeiQp *
gst_vaapi_surface_proxy_get_fei_qp(GstVaapiSurfaceProxy * proxy)541 gst_vaapi_surface_proxy_get_fei_qp (GstVaapiSurfaceProxy * proxy)
542 {
543   g_return_val_if_fail (proxy != NULL, NULL);
544   return proxy->qp;
545 }
546 
547 /**
548  * gst_vaapi_surface_proxy_get_fei_mv_predictor:
549  * @proxy: a #GstVaapiSurfaceProxy
550  *
551  * Returns the #GstVaapiEncFeiMvPredictor stored in the @proxy
552  *
553  * Return value: the #GstVaapiEncFeiMvPredictor, or %NULL if none was
554  *   associated with the surface proxy
555  */
556 GstVaapiEncFeiMvPredictor *
gst_vaapi_surface_proxy_get_fei_mv_predictor(GstVaapiSurfaceProxy * proxy)557 gst_vaapi_surface_proxy_get_fei_mv_predictor (GstVaapiSurfaceProxy * proxy)
558 {
559   g_return_val_if_fail (proxy != NULL, NULL);
560   return proxy->mvpred;
561 }
562 
563 /**
564  * gst_vaapi_surface_proxy_get_fei_mb_control:
565  * @proxy: a #GstVaapiSurfaceProxy
566  *
567  * Returns the #GstVaapiEncFeiMbControl stored in the @proxy
568  *
569  * Return value: the #GstVaapiEncFeiMbControl, or %NULL if none was
570  *   associated with the surface proxy
571  */
572 GstVaapiEncFeiMbControl *
gst_vaapi_surface_proxy_get_fei_mb_control(GstVaapiSurfaceProxy * proxy)573 gst_vaapi_surface_proxy_get_fei_mb_control (GstVaapiSurfaceProxy * proxy)
574 {
575   g_return_val_if_fail (proxy != NULL, NULL);
576   return proxy->mbcntrl;
577 }
578 
579 /**
580  * gst_vaapi_surface_proxy_set_fei_mb_code:
581  * @proxy: #GstVaapiSurfaceProxy
582  * @mbcode: the #GstVaapiEncFeiMbCode to be stored in @proxy
583  *
584  * Associates the @mbcode with the @proxy
585  */
586 void
gst_vaapi_surface_proxy_set_fei_mb_code(GstVaapiSurfaceProxy * proxy,GstVaapiEncFeiMbCode * mbcode)587 gst_vaapi_surface_proxy_set_fei_mb_code (GstVaapiSurfaceProxy * proxy,
588     GstVaapiEncFeiMbCode * mbcode)
589 {
590   g_return_if_fail (proxy != NULL);
591   gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
592       proxy->mbcode, (GstVaapiFeiCodecObject *) mbcode);
593 }
594 
595 /**
596  * gst_vaapi_surface_proxy_set_fei_mv:
597  * @proxy: #GstVaapiSurfaceProxy
598  * @mv: the #GstVaapiEncFeiMv to be stored in @proxy
599  *
600  * Associates the @mv with the @proxy
601  */
602 void
gst_vaapi_surface_proxy_set_fei_mv(GstVaapiSurfaceProxy * proxy,GstVaapiEncFeiMv * mv)603 gst_vaapi_surface_proxy_set_fei_mv (GstVaapiSurfaceProxy * proxy,
604     GstVaapiEncFeiMv * mv)
605 {
606   g_return_if_fail (proxy != NULL);
607   gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
608       proxy->mv, (GstVaapiFeiCodecObject *) mv);
609 }
610 
611 /**
612  * gst_vaapi_surface_proxy_set_fei_distortion:
613  * @proxy: #GstVaapiSurfaceProxy
614  * @dist: the #GstVaapiEncFeiDistortion to be stored in @proxy
615  *
616  * Associates the @dist with the @proxy
617  */
618 void
gst_vaapi_surface_proxy_set_fei_distortion(GstVaapiSurfaceProxy * proxy,GstVaapiEncFeiDistortion * dist)619 gst_vaapi_surface_proxy_set_fei_distortion (GstVaapiSurfaceProxy * proxy,
620     GstVaapiEncFeiDistortion * dist)
621 {
622   g_return_if_fail (proxy != NULL);
623   gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
624       proxy->dist, (GstVaapiFeiCodecObject *) dist);
625 }
626 
627 /**
628  * gst_vaapi_surface_proxy_set_fei_qp:
629  * @proxy: #GstVaapiSurfaceProxy
630  * @qp: the #GstVaapiEncFeiQp to be stored in @proxy
631  *
632  * Associates the @qp with the @proxy
633  */
634 void
gst_vaapi_surface_proxy_set_fei_qp(GstVaapiSurfaceProxy * proxy,GstVaapiEncFeiQp * qp)635 gst_vaapi_surface_proxy_set_fei_qp (GstVaapiSurfaceProxy * proxy,
636     GstVaapiEncFeiQp * qp)
637 {
638   g_return_if_fail (proxy != NULL);
639   gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
640       proxy->qp, (GstVaapiFeiCodecObject *) qp);
641 }
642 
643 /**
644  * gst_vaapi_surface_proxy_set_fei_mv_predictor:
645  * @proxy: #GstVaapiSurfaceProxy
646  * @mvpred: the #GstVaapiEncFeiMvPredictor to be stored in @proxy
647  *
648  * Associates the @mvpred with the @proxy
649  */
650 void
gst_vaapi_surface_proxy_set_fei_mv_predictor(GstVaapiSurfaceProxy * proxy,GstVaapiEncFeiMvPredictor * mvpred)651 gst_vaapi_surface_proxy_set_fei_mv_predictor (GstVaapiSurfaceProxy * proxy,
652     GstVaapiEncFeiMvPredictor * mvpred)
653 {
654   g_return_if_fail (proxy != NULL);
655   gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
656       proxy->mvpred, (GstVaapiFeiCodecObject *) mvpred);
657 }
658 
659 /**
660  * gst_vaapi_surface_proxy_set_fei_mb_control:
661  * @proxy: #GstVaapiSurfaceProxy
662  * @mbcntrl: the #GstVaapiEncFeiMbControl to be stored in @proxy
663  *
664  * Associates the @mbcntrl with the @proxy
665  */
666 void
gst_vaapi_surface_proxy_set_fei_mb_control(GstVaapiSurfaceProxy * proxy,GstVaapiEncFeiMbControl * mbcntrl)667 gst_vaapi_surface_proxy_set_fei_mb_control (GstVaapiSurfaceProxy * proxy,
668     GstVaapiEncFeiMbControl * mbcntrl)
669 {
670   g_return_if_fail (proxy != NULL);
671   gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
672       proxy->mbcntrl, (GstVaapiFeiCodecObject *) mbcntrl);
673 }
674 
675 #endif
676