1 /* GStreamer Intel MSDK plugin
2 * Copyright (c) 2018, Intel Corporation
5 * Author: Sreerenj Balachaandran <sreerenj.balachandran@intel.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
17 * 3. Neither the name of the copyright holder nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #include "gstmsdkvpp.h"
41 #include "gstmsdkbufferpool.h"
42 #include "gstmsdkvideomemory.h"
43 #include "gstmsdksystemmemory.h"
44 #include "gstmsdkcontextutil.h"
45 #include "gstmsdkvpputil.h"
47 GST_DEBUG_CATEGORY_EXTERN (gst_msdkvpp_debug);
48 #define GST_CAT_DEFAULT gst_msdkvpp_debug
50 static GstStaticPadTemplate gst_msdkvpp_sink_factory =
51 GST_STATIC_PAD_TEMPLATE ("sink",
54 GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ NV12, I420, YUY2, UYVY, BGRA }")
55 ", " "interlace-mode = (string){ progressive, interleaved, mixed }"));
57 static GstStaticPadTemplate gst_msdkvpp_src_factory =
58 GST_STATIC_PAD_TEMPLATE ("src",
61 GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ NV12, BGRA }") ", "
62 "interlace-mode = (string){ progressive, interleaved, mixed }"));
71 PROP_DEINTERLACE_MODE,
72 PROP_DEINTERLACE_METHOD,
80 PROP_FORCE_ASPECT_RATIO,
85 #define PROP_HARDWARE_DEFAULT TRUE
86 #define PROP_ASYNC_DEPTH_DEFAULT 1
87 #define PROP_DENOISE_DEFAULT 0
88 #define PROP_ROTATION_DEFAULT MFX_ANGLE_0
89 #define PROP_DEINTERLACE_MODE_DEFAULT GST_MSDKVPP_DEINTERLACE_MODE_AUTO
90 #define PROP_DEINTERLACE_METHOD_DEFAULT MFX_DEINTERLACING_BOB
91 #define PROP_HUE_DEFAULT 0
92 #define PROP_SATURATION_DEFAULT 1
93 #define PROP_BRIGHTNESS_DEFAULT 0
94 #define PROP_CONTRAST_DEFAULT 1
95 #define PROP_DETAIL_DEFAULT 0
96 #define PROP_MIRRORING_DEFAULT MFX_MIRRORING_DISABLED
97 #define PROP_SCALING_MODE_DEFAULT MFX_SCALING_MODE_DEFAULT
98 #define PROP_FORCE_ASPECT_RATIO_DEFAULT TRUE
99 #define PROP_FRC_ALGORITHM_DEFAULT _MFX_FRC_ALGORITHM_NONE
101 #define gst_msdkvpp_parent_class parent_class
102 G_DEFINE_TYPE (GstMsdkVPP, gst_msdkvpp, GST_TYPE_BASE_TRANSFORM);
106 mfxFrameSurface1 *surface;
111 free_msdk_surface (MsdkSurface * surface)
114 gst_buffer_unref (surface->buf);
115 g_slice_free (MsdkSurface, surface);
119 gst_msdkvpp_add_extra_param (GstMsdkVPP * thiz, mfxExtBuffer * param)
121 if (thiz->num_extra_params < MAX_EXTRA_PARAMS) {
122 thiz->extra_params[thiz->num_extra_params] = param;
123 thiz->num_extra_params++;
128 ensure_context (GstBaseTransform * trans)
130 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
132 if (gst_msdk_context_prepare (GST_ELEMENT_CAST (thiz), &thiz->context)) {
133 GST_INFO_OBJECT (thiz, "Found context from neighbour %" GST_PTR_FORMAT,
136 if (gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_VPP) {
137 GstMsdkContext *parent_context;
139 parent_context = thiz->context;
140 thiz->context = gst_msdk_context_new_with_parent (parent_context);
141 gst_object_unref (parent_context);
143 GST_INFO_OBJECT (thiz,
144 "Creating new context %" GST_PTR_FORMAT " with joined session",
147 gst_msdk_context_add_job_type (thiz->context, GST_MSDK_JOB_VPP);
150 if (!gst_msdk_context_ensure_context (GST_ELEMENT_CAST (thiz),
151 thiz->hardware, GST_MSDK_JOB_VPP))
153 GST_INFO_OBJECT (thiz, "Creating new context %" GST_PTR_FORMAT,
157 gst_msdk_context_add_shared_async_depth (thiz->context, thiz->async_depth);
163 create_output_buffer (GstMsdkVPP * thiz)
167 GstBufferPool *pool = thiz->srcpad_buffer_pool;
169 g_return_val_if_fail (pool != NULL, NULL);
171 if (!gst_buffer_pool_is_active (pool) &&
172 !gst_buffer_pool_set_active (pool, TRUE))
173 goto error_activate_pool;
176 ret = gst_buffer_pool_acquire_buffer (pool, &outbuf, NULL);
177 if (ret != GST_FLOW_OK || !outbuf)
178 goto error_create_buffer;
185 GST_ERROR_OBJECT (thiz, "failed to activate output video buffer pool");
190 GST_ERROR_OBJECT (thiz, "failed to create output video buffer");
196 gst_msdkvpp_prepare_output_buffer (GstBaseTransform * trans,
197 GstBuffer * inbuf, GstBuffer ** outbuf_ptr)
199 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
201 if (gst_base_transform_is_passthrough (trans)) {
206 *outbuf_ptr = create_output_buffer (thiz);
207 return *outbuf_ptr ? GST_FLOW_OK : GST_FLOW_ERROR;
210 static GstBufferPool *
211 gst_msdkvpp_create_buffer_pool (GstMsdkVPP * thiz, GstPadDirection direction,
212 GstCaps * caps, guint min_num_buffers)
214 GstBufferPool *pool = NULL;
215 GstStructure *config;
216 GstAllocator *allocator = NULL;
218 GstVideoInfo *pool_info = NULL;
219 GstVideoAlignment align;
220 GstAllocationParams params = { 0, 31, 0, 0, };
221 mfxFrameAllocResponse *alloc_resp = NULL;
223 if (direction == GST_PAD_SINK) {
224 alloc_resp = &thiz->in_alloc_resp;
225 pool_info = &thiz->sinkpad_buffer_pool_info;
226 } else if (direction == GST_PAD_SRC) {
227 alloc_resp = &thiz->out_alloc_resp;
228 pool_info = &thiz->srcpad_buffer_pool_info;
231 pool = gst_msdk_buffer_pool_new (thiz->context, alloc_resp);
235 if (!gst_video_info_from_caps (&info, caps))
236 goto error_no_video_info;
238 gst_msdk_set_video_alignment (&info, &align);
239 gst_video_info_align (&info, &align);
241 if (thiz->use_video_memory)
242 allocator = gst_msdk_video_allocator_new (thiz->context, &info, alloc_resp);
244 allocator = gst_msdk_system_allocator_new (&info);
247 goto error_no_allocator;
249 config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
250 gst_buffer_pool_config_set_params (config, caps, info.size, min_num_buffers,
253 gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
254 gst_buffer_pool_config_add_option (config,
255 GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
256 if (thiz->use_video_memory)
257 gst_buffer_pool_config_add_option (config,
258 GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY);
260 gst_buffer_pool_config_set_video_alignment (config, &align);
261 gst_buffer_pool_config_set_allocator (config, allocator, ¶ms);
262 gst_object_unref (allocator);
264 if (!gst_buffer_pool_set_config (pool, config))
265 goto error_pool_config;
267 /* Updating pool_info with algined info of allocator */
274 GST_INFO_OBJECT (thiz, "Failed to create bufferpool");
279 GST_INFO_OBJECT (thiz, "Failed to get Video info from caps");
284 GST_INFO_OBJECT (thiz, "Failed to create allocator");
286 gst_object_unref (pool);
291 GST_INFO_OBJECT (thiz, "Failed to set config");
293 gst_object_unref (pool);
295 gst_object_unref (allocator);
301 gst_msdkvpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
303 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
305 GstBufferPool *pool = NULL;
306 GstStructure *config = NULL;
308 guint size = 0, min_buffers = 0, max_buffers = 0;
309 GstAllocator *allocator = NULL;
310 GstAllocationParams params;
311 gboolean update_pool = FALSE;
313 gst_query_parse_allocation (query, &caps, NULL);
315 GST_ERROR_OBJECT (thiz, "Failed to parse the decide_allocation caps");
318 if (!gst_video_info_from_caps (&info, caps)) {
319 GST_ERROR_OBJECT (thiz, "Failed to get video info");
323 if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL))
324 thiz->add_video_meta = TRUE;
326 thiz->add_video_meta = FALSE;
328 /* Check whether the query has pool */
329 if (gst_query_get_n_allocation_pools (query) > 0)
332 /* increase the min_buffers with number of concurrent vpp operations */
333 min_buffers += thiz->async_depth;
335 /* invalidate the cached pool if there is an allocation_query */
336 if (thiz->srcpad_buffer_pool)
337 gst_object_unref (thiz->srcpad_buffer_pool);
339 /* Always create a pool for vpp out buffers. Each of the msdk element
340 * has to create it's own mfxsurfacepool which is an msdk contraint.
341 * For eg: Each Msdk component (vpp, dec and enc) will invoke the external
342 * Frame allocator for video-memory usage.So sharing the pool between
343 * gst-msdk elements might not be a good idea, rather each element
344 * can check the buffer type (whether it is from msdk-buffer pool)
345 * to make sure there is no copy. Since we share the context between
346 * msdk elements, using buffers from one sdk's framealloator in another
347 * sdk-components is perfectly fine */
348 pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SRC, caps, min_buffers);
349 thiz->srcpad_buffer_pool = pool;
351 /* get the configured pool properties inorder to set in query */
352 config = gst_buffer_pool_get_config (pool);
353 gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
355 if (gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms))
356 gst_query_add_allocation_param (query, allocator, ¶ms);
357 gst_structure_free (config);
360 gst_query_set_nth_allocation_pool (query, 0, pool, size, min_buffers,
363 gst_query_add_allocation_pool (query, pool, size, min_buffers, max_buffers);
365 gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
367 /* Fixme if downstream doesn't have videometa support, msdkvpp should
368 * copy the output buffers */
374 gst_msdkvpp_propose_allocation (GstBaseTransform * trans,
375 GstQuery * decide_query, GstQuery * query)
377 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
379 GstBufferPool *pool = NULL;
380 GstAllocator *allocator = NULL;
382 GstStructure *config;
384 GstAllocationParams params;
386 guint min_buffers = thiz->async_depth + 1;
388 gst_query_parse_allocation (query, &caps, &need_pool);
390 GST_ERROR_OBJECT (thiz, "Failed to parse the allocation caps");
394 if (!gst_video_info_from_caps (&info, caps)) {
395 GST_ERROR_OBJECT (thiz, "Failed to get video info");
400 /* alwys provide a new pool for upstream to help re-negotiation
401 * more info here: https://bugzilla.gnome.org/show_bug.cgi?id=748344 */
402 pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps,
406 /* Update the internal pool if any allocation attribute changed */
407 if (!gst_video_info_is_equal (&thiz->sinkpad_buffer_pool_info, &info)) {
408 gst_object_unref (thiz->sinkpad_buffer_pool);
409 thiz->sinkpad_buffer_pool = gst_msdkvpp_create_buffer_pool (thiz,
410 GST_PAD_SINK, caps, min_buffers);
413 /* get the size and allocator params from configured pool and set it in query */
415 pool = gst_object_ref (thiz->sinkpad_buffer_pool);
416 config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
417 gst_buffer_pool_config_get_params (config, NULL, &size, NULL, NULL);
418 if (gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms))
419 gst_query_add_allocation_param (query, allocator, ¶ms);
420 gst_structure_free (config);
422 /* if upstream does't have a pool requirement, set only
423 * size, min_buffers and max_buffers in query */
424 gst_query_add_allocation_pool (query, need_pool ? pool : NULL, size,
426 gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
428 gst_object_unref (pool);
430 return GST_BASE_TRANSFORM_CLASS (parent_class)->propose_allocation (trans,
431 decide_query, query);
435 get_surface_from_pool (GstMsdkVPP * thiz, GstBufferPool * pool,
436 GstBufferPoolAcquireParams * params)
438 GstBuffer *new_buffer;
439 mfxFrameSurface1 *new_surface;
440 MsdkSurface *msdk_surface;
442 if (!gst_buffer_pool_is_active (pool) &&
443 !gst_buffer_pool_set_active (pool, TRUE)) {
444 GST_ERROR_OBJECT (pool, "failed to activate buffer pool");
448 if (gst_buffer_pool_acquire_buffer (pool, &new_buffer, params) != GST_FLOW_OK) {
449 GST_ERROR_OBJECT (pool, "failed to acquire a buffer from pool");
453 if (gst_msdk_is_msdk_buffer (new_buffer))
454 new_surface = gst_msdk_get_surface_from_buffer (new_buffer);
456 GST_ERROR_OBJECT (pool, "the acquired memory is not MSDK memory");
460 msdk_surface = g_slice_new0 (MsdkSurface);
461 msdk_surface->surface = new_surface;
462 msdk_surface->buf = new_buffer;
468 get_msdk_surface_from_input_buffer (GstMsdkVPP * thiz, GstBuffer * inbuf)
470 GstVideoFrame src_frame, out_frame;
471 MsdkSurface *msdk_surface;
473 if (gst_msdk_is_msdk_buffer (inbuf)) {
474 msdk_surface = g_slice_new0 (MsdkSurface);
475 msdk_surface->surface = gst_msdk_get_surface_from_buffer (inbuf);
476 msdk_surface->buf = gst_buffer_ref (inbuf);
480 /* If upstream hasn't accpeted the proposed msdk bufferpool,
481 * just copy frame to msdk buffer and take a surface from it.
484 get_surface_from_pool (thiz, thiz->sinkpad_buffer_pool, NULL)))
487 if (!gst_video_frame_map (&src_frame, &thiz->sinkpad_info, inbuf,
489 GST_ERROR_OBJECT (thiz, "failed to map the frame for source");
493 if (!gst_video_frame_map (&out_frame, &thiz->sinkpad_buffer_pool_info,
494 msdk_surface->buf, GST_MAP_WRITE)) {
495 GST_ERROR_OBJECT (thiz, "failed to map the frame for destination");
496 gst_video_frame_unmap (&src_frame);
500 if (!gst_video_frame_copy (&out_frame, &src_frame)) {
501 GST_ERROR_OBJECT (thiz, "failed to copy frame");
502 gst_video_frame_unmap (&out_frame);
503 gst_video_frame_unmap (&src_frame);
507 gst_video_frame_unmap (&out_frame);
508 gst_video_frame_unmap (&src_frame);
517 gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf,
520 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
521 GstClockTime timestamp;
522 GstFlowReturn ret = GST_FLOW_OK;
524 mfxSyncPoint sync_point = NULL;
526 MsdkSurface *in_surface = NULL;
527 MsdkSurface *out_surface = NULL;
529 timestamp = GST_BUFFER_TIMESTAMP (inbuf);
531 in_surface = get_msdk_surface_from_input_buffer (thiz, inbuf);
533 return GST_FLOW_ERROR;
535 if (gst_msdk_is_msdk_buffer (outbuf)) {
536 out_surface = g_slice_new0 (MsdkSurface);
537 out_surface->surface = gst_msdk_get_surface_from_buffer (outbuf);
539 GST_ERROR ("Failed to get msdk outsurface!");
540 return GST_FLOW_ERROR;
543 session = gst_msdk_context_get_session (thiz->context);
545 /* outer loop is for handling FrameRate Control and deinterlace use cases */
549 MFXVideoVPP_RunFrameVPPAsync (session, in_surface->surface,
550 out_surface->surface, NULL, &sync_point);
551 if (status != MFX_WRN_DEVICE_BUSY)
553 /* If device is busy, wait 1ms and retry, as per MSDK's recommendation */
557 if (status != MFX_ERR_NONE && status != MFX_ERR_MORE_DATA
558 && status != MFX_ERR_MORE_SURFACE)
561 /* No output generated */
562 if (status == MFX_ERR_MORE_DATA)
563 goto error_more_data;
566 MFXVideoCORE_SyncOperation (session, sync_point, 10000);
568 /* More than one output buffers are generated */
569 if (status == MFX_ERR_MORE_SURFACE) {
570 GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
571 GST_BUFFER_DURATION (outbuf) = thiz->buffer_duration;
572 timestamp += thiz->buffer_duration;
573 ret = gst_pad_push (GST_BASE_TRANSFORM_SRC_PAD (trans), outbuf);
574 if (ret != GST_FLOW_OK)
575 goto error_push_buffer;
576 outbuf = create_output_buffer (thiz);
578 GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
579 GST_BUFFER_DURATION (outbuf) = thiz->buffer_duration;
581 } while (status == MFX_ERR_MORE_SURFACE);
583 free_msdk_surface (in_surface);
587 GST_ERROR_OBJECT (thiz, "MSDK Failed to do VPP");
588 free_msdk_surface (in_surface);
589 free_msdk_surface (out_surface);
590 return GST_FLOW_ERROR;
593 GST_WARNING_OBJECT (thiz,
594 "MSDK Requries additional input for processing, "
595 "Retruning FLOW_DROPPED since no output buffer was generated");
596 free_msdk_surface (in_surface);
597 return GST_BASE_TRANSFORM_FLOW_DROPPED;
601 free_msdk_surface (in_surface);
602 free_msdk_surface (out_surface);
603 GST_DEBUG_OBJECT (thiz, "failed to push output buffer: %s",
604 gst_flow_get_name (ret));
610 gst_msdkvpp_close (GstMsdkVPP * thiz)
617 GST_DEBUG_OBJECT (thiz, "Closing VPP 0x%p", thiz->context);
618 status = MFXVideoVPP_Close (gst_msdk_context_get_session (thiz->context));
619 if (status != MFX_ERR_NONE && status != MFX_ERR_NOT_INITIALIZED) {
620 GST_WARNING_OBJECT (thiz, "Encoder close failed (%s)",
621 msdk_status_to_string (status));
625 gst_object_replace ((GstObject **) & thiz->context, NULL);
627 memset (&thiz->param, 0, sizeof (thiz->param));
629 if (thiz->sinkpad_buffer_pool)
630 gst_object_unref (thiz->sinkpad_buffer_pool);
631 thiz->sinkpad_buffer_pool = NULL;
632 if (thiz->srcpad_buffer_pool)
633 gst_object_unref (thiz->srcpad_buffer_pool);
634 thiz->srcpad_buffer_pool = NULL;
636 thiz->buffer_duration = GST_CLOCK_TIME_NONE;
637 gst_video_info_init (&thiz->sinkpad_info);
638 gst_video_info_init (&thiz->srcpad_info);
642 ensure_filters (GstMsdkVPP * thiz)
647 if (thiz->flags & GST_MSDK_FLAG_DENOISE) {
648 mfxExtVPPDenoise *mfx_denoise = &thiz->mfx_denoise;
649 mfx_denoise->Header.BufferId = MFX_EXTBUFF_VPP_DENOISE;
650 mfx_denoise->Header.BufferSz = sizeof (mfxExtVPPDenoise);
651 mfx_denoise->DenoiseFactor = thiz->denoise_factor;
652 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_denoise);
653 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_DENOISE;
658 if (thiz->flags & GST_MSDK_FLAG_ROTATION) {
659 mfxExtVPPRotation *mfx_rotation = &thiz->mfx_rotation;
660 mfx_rotation->Header.BufferId = MFX_EXTBUFF_VPP_ROTATION;
661 mfx_rotation->Header.BufferSz = sizeof (mfxExtVPPRotation);
662 mfx_rotation->Angle = thiz->rotation;
663 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_rotation);
664 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_ROTATION;
669 if (thiz->flags & GST_MSDK_FLAG_DEINTERLACE) {
670 mfxExtVPPDeinterlacing *mfx_deinterlace = &thiz->mfx_deinterlace;
671 mfx_deinterlace->Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING;
672 mfx_deinterlace->Header.BufferSz = sizeof (mfxExtVPPDeinterlacing);
673 mfx_deinterlace->Mode = thiz->deinterlace_method;
674 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_deinterlace);
675 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_DEINTERLACING;
679 /* Colorbalance(ProcAmp) */
680 if (thiz->flags & (GST_MSDK_FLAG_HUE | GST_MSDK_FLAG_SATURATION |
681 GST_MSDK_FLAG_BRIGHTNESS | GST_MSDK_FLAG_CONTRAST)) {
682 mfxExtVPPProcAmp *mfx_procamp = &thiz->mfx_procamp;
683 mfx_procamp->Header.BufferId = MFX_EXTBUFF_VPP_PROCAMP;
684 mfx_procamp->Header.BufferSz = sizeof (mfxExtVPPProcAmp);
685 mfx_procamp->Hue = thiz->hue;
686 mfx_procamp->Saturation = thiz->saturation;
687 mfx_procamp->Brightness = thiz->brightness;
688 mfx_procamp->Contrast = thiz->contrast;
689 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_procamp);
690 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_PROCAMP;
694 /* Detail/Edge enhancement */
695 if (thiz->flags & GST_MSDK_FLAG_DETAIL) {
696 mfxExtVPPDetail *mfx_detail = &thiz->mfx_detail;
697 mfx_detail->Header.BufferId = MFX_EXTBUFF_VPP_DETAIL;
698 mfx_detail->Header.BufferSz = sizeof (mfxExtVPPDetail);
699 mfx_detail->DetailFactor = thiz->detail;
700 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_detail);
701 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_DETAIL;
707 mfxExtVPPDoUse *mfx_vpp_douse = &thiz->mfx_vpp_douse;
708 mfx_vpp_douse->Header.BufferId = MFX_EXTBUFF_VPP_DOUSE;
709 mfx_vpp_douse->Header.BufferSz = sizeof (mfxExtVPPDoUse);
710 mfx_vpp_douse->NumAlg = n_filters;
711 mfx_vpp_douse->AlgList = thiz->max_filter_algorithms;
712 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_vpp_douse);
716 if (thiz->flags & GST_MSDK_FLAG_MIRRORING) {
717 mfxExtVPPMirroring *mfx_mirroring = &thiz->mfx_mirroring;
718 mfx_mirroring->Header.BufferId = MFX_EXTBUFF_VPP_MIRRORING;
719 mfx_mirroring->Header.BufferSz = sizeof (mfxExtVPPMirroring);
720 mfx_mirroring->Type = thiz->mirroring;
721 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_mirroring);
722 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_MIRRORING;
727 if (thiz->flags & GST_MSDK_FLAG_SCALING_MODE) {
728 mfxExtVPPScaling *mfx_scaling = &thiz->mfx_scaling;
729 mfx_scaling->Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
730 mfx_scaling->Header.BufferSz = sizeof (mfxExtVPPScaling);
731 mfx_scaling->ScalingMode = thiz->scaling_mode;
732 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_scaling);
733 thiz->max_filter_algorithms[n_filters] = MFX_EXTBUFF_VPP_SCALING;
738 if (thiz->flags & GST_MSDK_FLAG_FRC) {
739 mfxExtVPPFrameRateConversion *mfx_frc = &thiz->mfx_frc;
740 mfx_frc->Header.BufferId = MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION;
741 mfx_frc->Header.BufferSz = sizeof (mfxExtVPPFrameRateConversion);
742 mfx_frc->Algorithm = thiz->frc_algm;
743 gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_frc);
744 thiz->max_filter_algorithms[n_filters] =
745 MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION;
751 gst_msdkvpp_set_passthrough (GstMsdkVPP * thiz)
753 gboolean passthrough = TRUE;
755 /* no passthrough if any of the filter algorithm is enabled */
759 /* no passthrough if there is change in out width,height or format */
760 if (GST_VIDEO_INFO_WIDTH (&thiz->sinkpad_info) !=
761 GST_VIDEO_INFO_WIDTH (&thiz->srcpad_info)
762 || GST_VIDEO_INFO_HEIGHT (&thiz->sinkpad_info) !=
763 GST_VIDEO_INFO_HEIGHT (&thiz->srcpad_info)
764 || GST_VIDEO_INFO_FORMAT (&thiz->sinkpad_info) !=
765 GST_VIDEO_INFO_FORMAT (&thiz->srcpad_info))
768 GST_OBJECT_UNLOCK (thiz);
769 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (thiz), passthrough);
770 GST_OBJECT_LOCK (thiz);
774 gst_msdkvpp_initialize (GstMsdkVPP * thiz)
778 mfxFrameAllocRequest request[2];
780 if (!thiz->context) {
781 GST_WARNING_OBJECT (thiz, "No MSDK Context");
785 GST_OBJECT_LOCK (thiz);
786 session = gst_msdk_context_get_session (thiz->context);
788 if (thiz->use_video_memory) {
789 gst_msdk_set_frame_allocator (thiz->context);
790 thiz->param.IOPattern =
791 MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
793 thiz->param.IOPattern =
794 MFX_IOPATTERN_IN_SYSTEM_MEMORY | MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
797 /* update input video attributes */
798 gst_msdk_set_mfx_frame_info_from_video_info (&thiz->param.vpp.In,
799 &thiz->sinkpad_info);
801 /* update output video attributes, only CSC and Scaling are supported for now */
802 gst_msdk_set_mfx_frame_info_from_video_info (&thiz->param.vpp.Out,
805 /* use msdk frame rarte control if there is a mismatch in In & OUt fps */
806 if (GST_VIDEO_INFO_FPS_N (&thiz->srcpad_info) &&
807 (GST_VIDEO_INFO_FPS_N (&thiz->sinkpad_info) !=
808 GST_VIDEO_INFO_FPS_N (&thiz->srcpad_info)
809 || GST_VIDEO_INFO_FPS_D (&thiz->sinkpad_info) !=
810 GST_VIDEO_INFO_FPS_D (&thiz->srcpad_info))) {
811 thiz->flags |= GST_MSDK_FLAG_FRC;
812 /* So far this is the only algorithm which is working somewhat good */
813 thiz->frc_algm = MFX_FRCALGM_PRESERVE_TIMESTAMP;
816 /* work-around to avoid zero fps in msdk structure */
817 if (!thiz->param.vpp.In.FrameRateExtN)
818 thiz->param.vpp.In.FrameRateExtN = 30;
819 if (!thiz->param.vpp.Out.FrameRateExtN)
820 thiz->param.vpp.Out.FrameRateExtN = thiz->param.vpp.In.FrameRateExtN;
822 /* set vpp out picstruct as progressive if deinterlacing enabled */
823 if (thiz->flags & GST_MSDK_FLAG_DEINTERLACE)
824 thiz->param.vpp.Out.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
826 /* validate parameters and allow the Media SDK to make adjustments */
827 status = MFXVideoVPP_Query (session, &thiz->param, &thiz->param);
828 if (status < MFX_ERR_NONE) {
829 GST_ERROR_OBJECT (thiz, "Video VPP Query failed (%s)",
830 msdk_status_to_string (status));
832 } else if (status > MFX_ERR_NONE) {
833 GST_WARNING_OBJECT (thiz, "Video VPP Query returned: %s",
834 msdk_status_to_string (status));
837 /* Enable the required filters */
838 ensure_filters (thiz);
840 /* set passthrough according to filter operation change */
841 gst_msdkvpp_set_passthrough (thiz);
843 /* Add exteneded buffers */
844 if (thiz->num_extra_params) {
845 thiz->param.NumExtParam = thiz->num_extra_params;
846 thiz->param.ExtParam = thiz->extra_params;
849 status = MFXVideoVPP_QueryIOSurf (session, &thiz->param, request);
850 if (status < MFX_ERR_NONE) {
851 GST_ERROR_OBJECT (thiz, "VPP Query IO surfaces failed (%s)",
852 msdk_status_to_string (status));
854 } else if (status > MFX_ERR_NONE) {
855 GST_WARNING_OBJECT (thiz, "VPP Query IO surfaces returned: %s",
856 msdk_status_to_string (status));
859 if (thiz->use_video_memory) {
860 /* Input surface pool pre-allocation */
861 gst_msdk_frame_alloc (thiz->context, &(request[0]), &thiz->in_alloc_resp);
862 /* Output surface pool pre-allocation */
863 gst_msdk_frame_alloc (thiz->context, &(request[1]), &thiz->out_alloc_resp);
866 thiz->in_num_surfaces = request[0].NumFrameSuggested;
867 thiz->out_num_surfaces = request[1].NumFrameSuggested;
870 status = MFXVideoVPP_Init (session, &thiz->param);
871 if (status < MFX_ERR_NONE) {
872 GST_ERROR_OBJECT (thiz, "Init failed (%s)", msdk_status_to_string (status));
874 } else if (status > MFX_ERR_NONE) {
875 GST_WARNING_OBJECT (thiz, "Init returned: %s",
876 msdk_status_to_string (status));
879 GST_OBJECT_UNLOCK (thiz);
883 GST_OBJECT_UNLOCK (thiz);
885 gst_object_replace ((GstObject **) & thiz->context, NULL);
890 gst_msdkvpp_set_caps (GstBaseTransform * trans, GstCaps * caps,
893 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
894 GstVideoInfo in_info, out_info;
895 gboolean sinkpad_info_changed = FALSE;
896 gboolean srcpad_info_changed = FALSE;
897 gboolean deinterlace;
899 gst_video_info_from_caps (&in_info, caps);
900 gst_video_info_from_caps (&out_info, out_caps);
902 if (!gst_video_info_is_equal (&in_info, &thiz->sinkpad_info))
903 sinkpad_info_changed = TRUE;
904 if (!gst_video_info_is_equal (&out_info, &thiz->srcpad_info))
905 srcpad_info_changed = TRUE;
907 thiz->sinkpad_info = in_info;
908 thiz->srcpad_info = out_info;
910 thiz->use_video_memory = TRUE;
912 thiz->use_video_memory = FALSE;
915 if (!sinkpad_info_changed && !srcpad_info_changed)
918 /* check for deinterlace requirement */
919 deinterlace = gst_msdkvpp_is_deinterlace_enabled (thiz, &in_info);
921 thiz->flags |= GST_MSDK_FLAG_DEINTERLACE;
923 thiz->buffer_duration = GST_VIDEO_INFO_FPS_N (&out_info) > 0 ?
924 gst_util_uint64_scale (GST_SECOND, GST_VIDEO_INFO_FPS_D (&out_info),
925 GST_VIDEO_INFO_FPS_N (&out_info)) : 0;
927 if (!gst_msdkvpp_initialize (thiz))
930 /* Ensure sinkpad buffer pool */
931 thiz->sinkpad_buffer_pool =
932 gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps,
933 thiz->in_num_surfaces);
934 if (!thiz->sinkpad_buffer_pool) {
935 GST_ERROR_OBJECT (thiz, "Failed to ensure the sinkpad buffer pool");
938 /* Ensure a srcpad buffer pool */
939 thiz->srcpad_buffer_pool =
940 gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SRC, out_caps,
941 thiz->out_num_surfaces);
942 if (!thiz->srcpad_buffer_pool) {
943 GST_ERROR_OBJECT (thiz, "Failed to ensure the srcpad buffer pool");
951 gst_msdkvpp_fixate_caps (GstBaseTransform * trans,
952 GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
954 GstMsdkVPP *thiz = GST_MSDKVPP (trans);
955 GstCaps *result = NULL;
957 if (direction == GST_PAD_SRC)
958 result = gst_caps_fixate (result);
960 result = gst_msdkvpp_fixate_srccaps (thiz, caps, othercaps);
963 GST_DEBUG_OBJECT (trans, "fixated to %" GST_PTR_FORMAT, result);
964 gst_caps_unref (othercaps);
968 /* Generic code for now, requires changes in future when we
969 * add hardware query for supported formats, Framerate control etc */
971 gst_msdkvpp_transform_caps (GstBaseTransform * trans,
972 GstPadDirection direction, GstCaps * caps, GstCaps * filter)
976 GST_DEBUG_OBJECT (trans,
977 "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
978 (direction == GST_PAD_SINK) ? "sink" : "src");
980 if (direction == GST_PAD_SRC)
981 out_caps = gst_static_pad_template_get_caps (&gst_msdkvpp_sink_factory);
983 out_caps = gst_static_pad_template_get_caps (&gst_msdkvpp_src_factory);
985 if (out_caps && filter) {
986 GstCaps *intersection;
988 intersection = gst_caps_intersect_full (out_caps, filter,
989 GST_CAPS_INTERSECT_FIRST);
990 gst_caps_unref (out_caps);
991 out_caps = intersection;
994 GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, out_caps);
999 gst_msdkvpp_start (GstBaseTransform * trans)
1001 if (!ensure_context (trans))
1007 gst_msdkvpp_stop (GstBaseTransform * trans)
1009 gst_msdkvpp_close (GST_MSDKVPP (trans));
1014 gst_msdkvpp_set_property (GObject * object, guint prop_id,
1015 const GValue * value, GParamSpec * pspec)
1017 GstMsdkVPP *thiz = GST_MSDKVPP (object);
1021 thiz->hardware = g_value_get_boolean (value);
1023 case PROP_ASYNC_DEPTH:
1024 thiz->async_depth = g_value_get_uint (value);
1027 thiz->denoise_factor = g_value_get_uint (value);
1028 thiz->flags |= GST_MSDK_FLAG_DENOISE;
1031 thiz->rotation = g_value_get_enum (value);
1032 thiz->flags |= GST_MSDK_FLAG_ROTATION;
1034 case PROP_DEINTERLACE_MODE:
1035 thiz->deinterlace_mode = g_value_get_enum (value);
1037 case PROP_DEINTERLACE_METHOD:
1038 thiz->deinterlace_method = g_value_get_enum (value);
1041 thiz->hue = g_value_get_float (value);
1042 thiz->flags |= GST_MSDK_FLAG_HUE;
1044 case PROP_SATURATION:
1045 thiz->saturation = g_value_get_float (value);
1046 thiz->flags |= GST_MSDK_FLAG_SATURATION;
1048 case PROP_BRIGHTNESS:
1049 thiz->brightness = g_value_get_float (value);
1050 thiz->flags |= GST_MSDK_FLAG_BRIGHTNESS;
1053 thiz->contrast = g_value_get_float (value);
1054 thiz->flags |= GST_MSDK_FLAG_CONTRAST;
1057 thiz->detail = g_value_get_uint (value);
1058 thiz->flags |= GST_MSDK_FLAG_DETAIL;
1060 case PROP_MIRRORING:
1061 thiz->mirroring = g_value_get_enum (value);
1062 thiz->flags |= GST_MSDK_FLAG_MIRRORING;
1064 case PROP_SCALING_MODE:
1065 thiz->scaling_mode = g_value_get_enum (value);
1066 thiz->flags |= GST_MSDK_FLAG_SCALING_MODE;
1068 case PROP_FORCE_ASPECT_RATIO:
1069 thiz->keep_aspect = g_value_get_boolean (value);
1071 case PROP_FRC_ALGORITHM:
1072 thiz->frc_algm = g_value_get_enum (value);
1075 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1081 gst_msdkvpp_get_property (GObject * object, guint prop_id,
1082 GValue * value, GParamSpec * pspec)
1084 GstMsdkVPP *thiz = GST_MSDKVPP (object);
1088 g_value_set_boolean (value, thiz->hardware);
1090 case PROP_ASYNC_DEPTH:
1091 g_value_set_uint (value, thiz->async_depth);
1094 g_value_set_uint (value, thiz->denoise_factor);
1097 g_value_set_enum (value, thiz->rotation);
1099 case PROP_DEINTERLACE_MODE:
1100 g_value_set_enum (value, thiz->deinterlace_mode);
1102 case PROP_DEINTERLACE_METHOD:
1103 g_value_set_enum (value, thiz->deinterlace_method);
1106 g_value_set_float (value, thiz->hue);
1108 case PROP_SATURATION:
1109 g_value_set_float (value, thiz->saturation);
1111 case PROP_BRIGHTNESS:
1112 g_value_set_float (value, thiz->brightness);
1115 g_value_set_float (value, thiz->contrast);
1118 g_value_set_uint (value, thiz->detail);
1120 case PROP_MIRRORING:
1121 g_value_set_enum (value, thiz->mirroring);
1123 case PROP_SCALING_MODE:
1124 g_value_set_enum (value, thiz->scaling_mode);
1126 case PROP_FORCE_ASPECT_RATIO:
1127 g_value_set_boolean (value, thiz->keep_aspect);
1129 case PROP_FRC_ALGORITHM:
1130 g_value_set_enum (value, thiz->frc_algm);
1133 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1139 gst_msdkvpp_finalize (GObject * object)
1141 G_OBJECT_CLASS (parent_class)->finalize (object);
1145 gst_msdkvpp_set_context (GstElement * element, GstContext * context)
1147 GstMsdkContext *msdk_context = NULL;
1148 GstMsdkVPP *thiz = GST_MSDKVPP (element);
1150 if (gst_msdk_context_get_context (context, &msdk_context)) {
1151 gst_object_replace ((GstObject **) & thiz->context,
1152 (GstObject *) msdk_context);
1153 gst_object_unref (msdk_context);
1156 GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
1160 gst_msdkvpp_class_init (GstMsdkVPPClass * klass)
1162 GObjectClass *gobject_class;
1163 GstElementClass *element_class;
1164 GstBaseTransformClass *trans_class;
1165 GParamSpec *obj_properties[PROP_N] = { NULL, };
1167 gobject_class = G_OBJECT_CLASS (klass);
1168 element_class = GST_ELEMENT_CLASS (klass);
1169 trans_class = GST_BASE_TRANSFORM_CLASS (klass);
1171 gobject_class->set_property = gst_msdkvpp_set_property;
1172 gobject_class->get_property = gst_msdkvpp_get_property;
1173 gobject_class->finalize = gst_msdkvpp_finalize;
1175 element_class->set_context = gst_msdkvpp_set_context;
1177 gst_element_class_add_static_pad_template (element_class,
1178 &gst_msdkvpp_src_factory);
1179 gst_element_class_add_static_pad_template (element_class,
1180 &gst_msdkvpp_sink_factory);
1182 gst_element_class_set_static_metadata (element_class,
1183 "MSDK Video Postprocessor",
1184 "Filter/Converter/Video;Filter/Converter/Video/Scaler;"
1185 "Filter/Effect/Video;Filter/Effect/Video/Deinterlace",
1186 "A MediaSDK Video Postprocessing Filter",
1187 "Sreerenj Balachandrn <sreerenj.balachandran@intel.com>");
1189 trans_class->start = GST_DEBUG_FUNCPTR (gst_msdkvpp_start);
1190 trans_class->stop = GST_DEBUG_FUNCPTR (gst_msdkvpp_stop);
1191 trans_class->transform_caps = GST_DEBUG_FUNCPTR (gst_msdkvpp_transform_caps);
1192 trans_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_msdkvpp_fixate_caps);
1193 trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_msdkvpp_set_caps);
1194 trans_class->transform = GST_DEBUG_FUNCPTR (gst_msdkvpp_transform);
1195 trans_class->propose_allocation =
1196 GST_DEBUG_FUNCPTR (gst_msdkvpp_propose_allocation);
1197 trans_class->decide_allocation =
1198 GST_DEBUG_FUNCPTR (gst_msdkvpp_decide_allocation);
1199 trans_class->prepare_output_buffer =
1200 GST_DEBUG_FUNCPTR (gst_msdkvpp_prepare_output_buffer);
1202 obj_properties[PROP_HARDWARE] =
1203 g_param_spec_boolean ("hardware", "Hardware", "Enable hardware VPP",
1204 PROP_HARDWARE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1206 obj_properties[PROP_ASYNC_DEPTH] =
1207 g_param_spec_uint ("async-depth", "Async Depth",
1208 "Depth of asynchronous pipeline",
1209 1, 1, PROP_ASYNC_DEPTH_DEFAULT,
1210 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1212 obj_properties[PROP_DENOISE] =
1213 g_param_spec_uint ("denoise", "Denoising factor",
1215 0, 100, PROP_DENOISE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1217 obj_properties[PROP_ROTATION] =
1218 g_param_spec_enum ("rotation", "Rotation",
1219 "Rotation Angle", gst_msdkvpp_rotation_get_type (),
1220 PROP_ROTATION_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1222 obj_properties[PROP_DEINTERLACE_MODE] =
1223 g_param_spec_enum ("deinterlace-mode", "Deinterlace Mode",
1224 "Deinterlace mode to use", gst_msdkvpp_deinterlace_mode_get_type (),
1225 PROP_DEINTERLACE_MODE_DEFAULT,
1226 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1228 obj_properties[PROP_DEINTERLACE_METHOD] =
1229 g_param_spec_enum ("deinterlace-method", "Deinterlace Method",
1230 "Deinterlace method to use", gst_msdkvpp_deinterlace_method_get_type (),
1231 PROP_DEINTERLACE_METHOD_DEFAULT,
1232 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1234 obj_properties[PROP_HUE] =
1235 g_param_spec_float ("hue", "Hue",
1236 "The hue of the video",
1237 -180, 180, PROP_HUE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1239 obj_properties[PROP_SATURATION] =
1240 g_param_spec_float ("saturation", "Saturation",
1241 "The Saturation of the video",
1242 0, 10, PROP_SATURATION_DEFAULT,
1243 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1245 obj_properties[PROP_BRIGHTNESS] =
1246 g_param_spec_float ("brightness", "Brightness",
1247 "The Brightness of the video",
1248 -100, 100, PROP_BRIGHTNESS_DEFAULT,
1249 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1251 obj_properties[PROP_CONTRAST] =
1252 g_param_spec_float ("contrast", "Contrast",
1253 "The Contrast of the video",
1254 0, 10, PROP_CONTRAST_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1256 obj_properties[PROP_DETAIL] =
1257 g_param_spec_uint ("detail", "Detail",
1258 "The factor of detail/edge enhancement filter algorithm",
1259 0, 100, PROP_DETAIL_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1261 obj_properties[PROP_MIRRORING] =
1262 g_param_spec_enum ("mirroring", "Mirroring",
1263 "The Mirroring type", gst_msdkvpp_mirroring_get_type (),
1264 PROP_MIRRORING_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1266 obj_properties[PROP_SCALING_MODE] =
1267 g_param_spec_enum ("scaling-mode", "Scaling Mode",
1268 "The Scaling mode to use", gst_msdkvpp_scaling_mode_get_type (),
1269 PROP_SCALING_MODE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1271 obj_properties[PROP_FORCE_ASPECT_RATIO] =
1272 g_param_spec_boolean ("force-aspect-ratio", "Force Aspect Ratio",
1273 "When enabled, scaling will respect original aspect ratio",
1274 PROP_FORCE_ASPECT_RATIO_DEFAULT,
1275 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1277 obj_properties[PROP_FRC_ALGORITHM] =
1278 g_param_spec_enum ("frc-algorithm", "FrameRateControl Algorithm",
1279 "The Framerate Control Alogorithm to use",
1280 gst_msdkvpp_frc_algorithm_get_type (), PROP_FRC_ALGORITHM_DEFAULT,
1281 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
1283 g_object_class_install_properties (gobject_class, PROP_N, obj_properties);
1287 gst_msdkvpp_init (GstMsdkVPP * thiz)
1289 thiz->hardware = PROP_HARDWARE_DEFAULT;
1290 thiz->async_depth = PROP_ASYNC_DEPTH_DEFAULT;
1291 thiz->denoise_factor = PROP_DENOISE_DEFAULT;
1292 thiz->rotation = PROP_ROTATION_DEFAULT;
1293 thiz->deinterlace_mode = PROP_DEINTERLACE_MODE_DEFAULT;
1294 thiz->deinterlace_method = PROP_DEINTERLACE_METHOD_DEFAULT;
1295 thiz->buffer_duration = GST_CLOCK_TIME_NONE;
1296 thiz->hue = PROP_HUE_DEFAULT;
1297 thiz->saturation = PROP_SATURATION_DEFAULT;
1298 thiz->brightness = PROP_BRIGHTNESS_DEFAULT;
1299 thiz->contrast = PROP_CONTRAST_DEFAULT;
1300 thiz->detail = PROP_DETAIL_DEFAULT;
1301 thiz->mirroring = PROP_MIRRORING_DEFAULT;
1302 thiz->scaling_mode = PROP_SCALING_MODE_DEFAULT;
1303 thiz->keep_aspect = PROP_FORCE_ASPECT_RATIO_DEFAULT;
1304 thiz->frc_algm = PROP_FRC_ALGORITHM_DEFAULT;
1305 gst_video_info_init (&thiz->sinkpad_info);
1306 gst_video_info_init (&thiz->srcpad_info);