2018-03-06 13:51:05 +00:00
|
|
|
/* GStreamer Intel MSDK plugin
|
|
|
|
* Copyright (c) 2018, Intel Corporation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Sreerenj Balachaandran <sreerenj.balachandran@intel.com>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
|
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
doc: add the msdk elements
Supported elements:
msdkav1dec, msdkh264dec, msdkh264enc, msdkh265dec, msdkh265enc,
msdkmjpegdec, msdkmjpegenc, msdkmpeg2dec, msdkmpeg2enc, msdkvc1dec,
msdkvp8dec, msdkvp9dec, msdkvp9enc, msdkvpp.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2296>
2021-06-03 02:03:19 +00:00
|
|
|
/**
|
|
|
|
* SECTION: element-msdkvpp
|
|
|
|
* @title: msdkvpp
|
|
|
|
* @short_description: MSDK Video Postprocessor
|
|
|
|
*
|
|
|
|
* A MediaSDK Video Postprocessing Filter
|
|
|
|
*
|
|
|
|
* ## Example launch line
|
|
|
|
* ```
|
|
|
|
* gst-launch-1.0 videotestsrc ! msdkvpp ! glimagesink
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "gstmsdkvpp.h"
|
2023-02-22 02:26:38 +00:00
|
|
|
#include "gstmsdkcaps.h"
|
2018-03-06 13:51:05 +00:00
|
|
|
#include "gstmsdkcontextutil.h"
|
|
|
|
#include "gstmsdkvpputil.h"
|
2022-12-01 07:15:27 +00:00
|
|
|
#include "gstmsdkallocator.h"
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2018-05-31 00:24:24 +00:00
|
|
|
#ifndef _WIN32
|
2024-05-27 22:44:15 +00:00
|
|
|
#include <drm_fourcc.h>
|
2018-05-31 00:24:24 +00:00
|
|
|
#include "gstmsdkallocator_libva.h"
|
2022-06-08 04:31:56 +00:00
|
|
|
#include <gst/va/gstvaallocator.h>
|
2023-12-20 05:25:51 +00:00
|
|
|
#include <gst/va/gstvavideoformat.h>
|
2022-09-07 02:55:57 +00:00
|
|
|
#else
|
|
|
|
#include <gst/d3d11/gstd3d11.h>
|
2018-05-31 00:24:24 +00:00
|
|
|
#endif
|
|
|
|
|
2019-10-11 15:54:55 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (gst_msdkvpp_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_msdkvpp_debug
|
|
|
|
|
2023-03-20 12:42:41 +00:00
|
|
|
#define GST_MSDKVPP(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_FROM_INSTANCE (obj), GstMsdkVPP))
|
|
|
|
#define GST_MSDKVPP_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_FROM_CLASS (klass), GstMsdkVPPClass))
|
|
|
|
#define GST_IS_MSDKVPP(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_FROM_INSTANCE (obj)))
|
|
|
|
#define GST_IS_MSDKVPP_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_FROM_CLASS (klass)))
|
2019-07-18 09:27:55 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
enum
|
|
|
|
{
|
2018-03-06 13:51:32 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_HARDWARE,
|
|
|
|
PROP_ASYNC_DEPTH,
|
|
|
|
PROP_DENOISE,
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-06 13:51:32 +00:00
|
|
|
PROP_ROTATION,
|
2019-08-23 01:51:20 +00:00
|
|
|
#endif
|
2018-03-06 13:52:04 +00:00
|
|
|
PROP_DEINTERLACE_MODE,
|
|
|
|
PROP_DEINTERLACE_METHOD,
|
2018-03-21 14:45:35 +00:00
|
|
|
PROP_HUE,
|
|
|
|
PROP_SATURATION,
|
|
|
|
PROP_BRIGHTNESS,
|
|
|
|
PROP_CONTRAST,
|
2018-03-21 17:14:04 +00:00
|
|
|
PROP_DETAIL,
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-21 17:22:18 +00:00
|
|
|
PROP_MIRRORING,
|
2019-08-23 01:51:20 +00:00
|
|
|
#endif
|
2018-03-21 17:57:27 +00:00
|
|
|
PROP_SCALING_MODE,
|
2024-07-30 09:27:49 +00:00
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
PROP_INTERPOLATION_METHOD,
|
|
|
|
#endif
|
2018-03-21 18:17:11 +00:00
|
|
|
PROP_FORCE_ASPECT_RATIO,
|
2018-03-22 16:04:02 +00:00
|
|
|
PROP_FRC_ALGORITHM,
|
2019-08-23 01:51:20 +00:00
|
|
|
PROP_VIDEO_DIRECTION,
|
2019-10-16 18:59:32 +00:00
|
|
|
PROP_CROP_LEFT,
|
|
|
|
PROP_CROP_RIGHT,
|
|
|
|
PROP_CROP_TOP,
|
|
|
|
PROP_CROP_BOTTOM,
|
2023-08-11 07:20:30 +00:00
|
|
|
PROP_HDR_TONE_MAPPING,
|
2018-03-06 13:51:05 +00:00
|
|
|
PROP_N,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PROP_HARDWARE_DEFAULT TRUE
|
|
|
|
#define PROP_ASYNC_DEPTH_DEFAULT 1
|
2018-03-06 13:51:32 +00:00
|
|
|
#define PROP_DENOISE_DEFAULT 0
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-06 13:51:32 +00:00
|
|
|
#define PROP_ROTATION_DEFAULT MFX_ANGLE_0
|
2019-08-23 01:51:20 +00:00
|
|
|
#define PROP_MIRRORING_DEFAULT MFX_MIRRORING_DISABLED
|
|
|
|
#endif
|
2018-03-06 13:52:04 +00:00
|
|
|
#define PROP_DEINTERLACE_MODE_DEFAULT GST_MSDKVPP_DEINTERLACE_MODE_AUTO
|
|
|
|
#define PROP_DEINTERLACE_METHOD_DEFAULT MFX_DEINTERLACING_BOB
|
2018-03-21 14:45:35 +00:00
|
|
|
#define PROP_HUE_DEFAULT 0
|
|
|
|
#define PROP_SATURATION_DEFAULT 1
|
|
|
|
#define PROP_BRIGHTNESS_DEFAULT 0
|
|
|
|
#define PROP_CONTRAST_DEFAULT 1
|
2018-03-21 17:14:04 +00:00
|
|
|
#define PROP_DETAIL_DEFAULT 0
|
2018-03-21 17:57:27 +00:00
|
|
|
#define PROP_SCALING_MODE_DEFAULT MFX_SCALING_MODE_DEFAULT
|
2024-07-30 09:27:49 +00:00
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
#define PROP_INTERPOLATION_METHOD_DEFAULT \
|
|
|
|
MFX_INTERPOLATION_DEFAULT
|
|
|
|
#endif
|
2018-03-21 18:17:11 +00:00
|
|
|
#define PROP_FORCE_ASPECT_RATIO_DEFAULT TRUE
|
2018-03-22 16:04:02 +00:00
|
|
|
#define PROP_FRC_ALGORITHM_DEFAULT _MFX_FRC_ALGORITHM_NONE
|
2019-08-23 01:51:20 +00:00
|
|
|
#define PROP_VIDEO_DIRECTION_DEFAULT GST_VIDEO_ORIENTATION_IDENTITY
|
2019-10-16 18:59:32 +00:00
|
|
|
#define PROP_CROP_LEFT_DEFAULT 0
|
|
|
|
#define PROP_CROP_RIGHT_DEFAULT 0
|
|
|
|
#define PROP_CROP_TOP_DEFAULT 0
|
|
|
|
#define PROP_CROP_BOTTOM_DEFAULT 0
|
2023-08-11 07:20:30 +00:00
|
|
|
#define PROP_HDR_TONE_MAPPING_DEFAULT 0
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2020-05-19 06:59:25 +00:00
|
|
|
/* 8 should enough for a normal encoder */
|
|
|
|
#define SRC_POOL_SIZE_DEFAULT 8
|
|
|
|
|
2024-05-29 03:07:23 +00:00
|
|
|
/* It is used to compensate timestamp for input mfx surface */
|
|
|
|
#define PTS_OFFSET GST_SECOND * 60 * 60 * 1000
|
|
|
|
|
2023-03-20 12:42:41 +00:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
static const gchar *doc_sink_caps_str =
|
|
|
|
GST_VIDEO_CAPS_MAKE (
|
|
|
|
"{ NV12, YV12, I420, P010_10LE, YUY2, UYVY, BGRA, BGRx, RGB16, VUYA, "
|
|
|
|
"Y210, Y410, P012_LE, Y212_LE, Y412_LE }") " ;"
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:DMABuf",
|
|
|
|
"{ NV12, YV12, I420, P010_10LE, YUY2, UYVY, BGRA, BGRx, RGB16, VUYA, "
|
|
|
|
"Y210, Y410, P012_LE, Y212_LE, Y412_LE }") " ;"
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:VAMemory",
|
|
|
|
"{ NV12, VUYA, P010_10LE }") " ;"
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:D3D11Memory",
|
|
|
|
"{ NV12, VUYA, P010_10LE }");
|
|
|
|
|
|
|
|
static const gchar *doc_src_caps_str =
|
|
|
|
GST_VIDEO_CAPS_MAKE (
|
|
|
|
"{ NV12, BGRA, YUY2, UYVY, VUYA, BGRx, P010_10LE, BGR10A2_LE, YV12, "
|
|
|
|
"Y410, Y210, RGBP, BGRP, P012_LE, Y212_LE, Y412_LE }") " ;"
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:DMABuf",
|
|
|
|
"{ NV12, BGRA, YUY2, UYVY, VUYA, BGRx, P010_10LE, BGR10A2_LE, YV12, "
|
|
|
|
"Y410, Y210, RGBP, BGRP, P012_LE, Y212_LE, Y412_LE }") " ;"
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:VAMemory",
|
|
|
|
"{ NV12, VUYA, P010_10LE }") " ;"
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:D3D11Memory",
|
|
|
|
"{ NV12, VUYA, P010_10LE }");
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstCaps *sink_caps;
|
|
|
|
GstCaps *src_caps;
|
|
|
|
} MsdkVPPCData;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
static void
|
2020-05-19 07:14:34 +00:00
|
|
|
free_msdk_surface (gpointer p)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
2022-05-09 10:34:38 +00:00
|
|
|
GstMsdkSurface *surface = (GstMsdkSurface *) p;
|
2018-03-06 13:51:05 +00:00
|
|
|
if (surface->buf)
|
|
|
|
gst_buffer_unref (surface->buf);
|
2022-05-09 10:34:38 +00:00
|
|
|
g_slice_free (GstMsdkSurface, surface);
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 07:14:34 +00:00
|
|
|
static void
|
2022-05-09 10:34:38 +00:00
|
|
|
release_msdk_surface (GstMsdkVPP * thiz, GstMsdkSurface * surface,
|
|
|
|
GList ** list)
|
2020-05-19 07:14:34 +00:00
|
|
|
{
|
|
|
|
if (surface->surface) {
|
|
|
|
if (surface->surface->Data.Locked) {
|
2020-08-03 07:29:08 +00:00
|
|
|
*list = g_list_append (*list, surface);
|
2020-05-19 07:14:34 +00:00
|
|
|
} else {
|
|
|
|
free_msdk_surface (surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-05-09 10:34:38 +00:00
|
|
|
release_in_surface (GstMsdkVPP * thiz, GstMsdkSurface * surface,
|
2020-08-04 09:14:44 +00:00
|
|
|
gboolean locked_by_others)
|
2020-08-03 07:29:08 +00:00
|
|
|
{
|
2020-08-04 09:14:44 +00:00
|
|
|
if (locked_by_others) {
|
|
|
|
/* mfxFrameSurface1 locked by others, others will hold the surface->buf reference */
|
|
|
|
/* we are good to release it here */
|
|
|
|
free_msdk_surface (surface);
|
|
|
|
} else {
|
|
|
|
release_msdk_surface (thiz, surface, &thiz->locked_in_surfaces);
|
|
|
|
}
|
2020-08-03 07:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-05-09 10:34:38 +00:00
|
|
|
release_out_surface (GstMsdkVPP * thiz, GstMsdkSurface * surface)
|
2020-08-03 07:29:08 +00:00
|
|
|
{
|
|
|
|
release_msdk_surface (thiz, surface, &thiz->locked_out_surfaces);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_unlocked_msdk_surfaces_from_list (GstMsdkVPP * thiz, GList ** list)
|
2020-05-19 07:14:34 +00:00
|
|
|
{
|
|
|
|
GList *l;
|
2022-05-09 10:34:38 +00:00
|
|
|
GstMsdkSurface *surface;
|
2020-05-19 07:14:34 +00:00
|
|
|
|
2020-08-03 07:29:08 +00:00
|
|
|
for (l = *list; l;) {
|
2020-05-19 07:14:34 +00:00
|
|
|
GList *next = l->next;
|
|
|
|
surface = l->data;
|
|
|
|
if (surface->surface->Data.Locked == 0) {
|
|
|
|
free_msdk_surface (surface);
|
2020-08-03 07:29:08 +00:00
|
|
|
*list = g_list_delete_link (*list, l);
|
2020-05-19 07:14:34 +00:00
|
|
|
}
|
|
|
|
l = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 07:29:08 +00:00
|
|
|
static void
|
|
|
|
free_unlocked_msdk_surfaces (GstMsdkVPP * thiz)
|
|
|
|
{
|
|
|
|
free_unlocked_msdk_surfaces_from_list (thiz, &thiz->locked_in_surfaces);
|
|
|
|
free_unlocked_msdk_surfaces_from_list (thiz, &thiz->locked_out_surfaces);
|
|
|
|
}
|
|
|
|
|
2020-05-19 07:14:34 +00:00
|
|
|
static void
|
|
|
|
free_all_msdk_surfaces (GstMsdkVPP * thiz)
|
|
|
|
{
|
2020-08-03 07:29:08 +00:00
|
|
|
g_list_free_full (thiz->locked_in_surfaces, free_msdk_surface);
|
|
|
|
thiz->locked_in_surfaces = NULL;
|
|
|
|
g_list_free_full (thiz->locked_out_surfaces, free_msdk_surface);
|
|
|
|
thiz->locked_out_surfaces = NULL;
|
2020-05-19 07:14:34 +00:00
|
|
|
}
|
|
|
|
|
2018-03-06 13:51:32 +00:00
|
|
|
static void
|
|
|
|
gst_msdkvpp_add_extra_param (GstMsdkVPP * thiz, mfxExtBuffer * param)
|
|
|
|
{
|
|
|
|
if (thiz->num_extra_params < MAX_EXTRA_PARAMS) {
|
|
|
|
thiz->extra_params[thiz->num_extra_params] = param;
|
|
|
|
thiz->num_extra_params++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
static gboolean
|
2020-01-17 05:13:11 +00:00
|
|
|
gst_msdkvpp_context_prepare (GstMsdkVPP * thiz)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
2020-01-17 05:13:11 +00:00
|
|
|
/* Try to find an existing context from the pipeline. This may (indirectly)
|
|
|
|
* invoke gst_msdkvpp_set_context, which will set thiz->context. */
|
|
|
|
if (!gst_msdk_context_find (GST_ELEMENT_CAST (thiz), &thiz->context))
|
|
|
|
return FALSE;
|
|
|
|
|
2020-01-17 05:37:47 +00:00
|
|
|
if (thiz->context == thiz->old_context) {
|
|
|
|
GST_INFO_OBJECT (thiz, "Found old context %" GST_PTR_FORMAT
|
|
|
|
", reusing as-is", thiz->context);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-17 05:13:11 +00:00
|
|
|
GST_INFO_OBJECT (thiz, "Found context %" GST_PTR_FORMAT " from neighbour",
|
|
|
|
thiz->context);
|
|
|
|
|
|
|
|
/* Check GST_MSDK_JOB_VPP and GST_MSDK_JOB_ENCODER together to avoid sharing context
|
|
|
|
* between VPP and ENCODER
|
|
|
|
* Example:
|
|
|
|
* gst-launch-1.0 videotestsrc ! msdkvpp ! video/x-raw,format=YUY2 ! msdkh264enc ! fakesink
|
|
|
|
*/
|
2020-01-21 07:14:08 +00:00
|
|
|
if (!(gst_msdk_context_get_job_type (thiz->context) & (GST_MSDK_JOB_VPP |
|
|
|
|
GST_MSDK_JOB_ENCODER))) {
|
2020-01-17 05:13:11 +00:00
|
|
|
gst_msdk_context_add_job_type (thiz->context, GST_MSDK_JOB_VPP);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2020-01-17 05:13:11 +00:00
|
|
|
/* Found an existing context that's already being used as VPP, so clone the
|
|
|
|
* MFX session inside it to create a new one */
|
|
|
|
{
|
|
|
|
GstMsdkContext *parent_context, *msdk_context;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2020-01-17 05:13:11 +00:00
|
|
|
GST_INFO_OBJECT (thiz, "Creating new context %" GST_PTR_FORMAT " with "
|
|
|
|
"joined session", thiz->context);
|
|
|
|
parent_context = thiz->context;
|
|
|
|
msdk_context = gst_msdk_context_new_with_parent (parent_context);
|
|
|
|
|
|
|
|
if (!msdk_context) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to create a context with parent context "
|
|
|
|
"as %" GST_PTR_FORMAT, parent_context);
|
|
|
|
return FALSE;
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
2020-01-17 05:13:11 +00:00
|
|
|
|
|
|
|
thiz->context = msdk_context;
|
|
|
|
gst_object_unref (parent_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ensure_context (GstBaseTransform * trans)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
|
|
|
|
if (!gst_msdkvpp_context_prepare (thiz)) {
|
2021-08-17 13:51:58 +00:00
|
|
|
if (!gst_msdk_ensure_new_context (GST_ELEMENT_CAST (thiz),
|
|
|
|
thiz->hardware, GST_MSDK_JOB_VPP, &thiz->context))
|
2018-03-06 13:51:05 +00:00
|
|
|
return FALSE;
|
|
|
|
GST_INFO_OBJECT (thiz, "Creating new context %" GST_PTR_FORMAT,
|
|
|
|
thiz->context);
|
|
|
|
}
|
|
|
|
|
2020-01-17 05:37:47 +00:00
|
|
|
/* Save the current context in a separate field so that we know whether it
|
|
|
|
* has changed between calls to _start() */
|
|
|
|
gst_object_replace ((GstObject **) & thiz->old_context,
|
|
|
|
(GstObject *) thiz->context);
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
gst_msdk_context_add_shared_async_depth (thiz->context, thiz->async_depth);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
create_output_buffer (GstMsdkVPP * thiz)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstBufferPool *pool = thiz->srcpad_buffer_pool;
|
|
|
|
|
|
|
|
g_return_val_if_fail (pool != NULL, NULL);
|
|
|
|
|
|
|
|
if (!gst_buffer_pool_is_active (pool) &&
|
|
|
|
!gst_buffer_pool_set_active (pool, TRUE))
|
|
|
|
goto error_activate_pool;
|
|
|
|
|
|
|
|
outbuf = NULL;
|
|
|
|
ret = gst_buffer_pool_acquire_buffer (pool, &outbuf, NULL);
|
|
|
|
if (ret != GST_FLOW_OK || !outbuf)
|
|
|
|
goto error_create_buffer;
|
|
|
|
|
|
|
|
return outbuf;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
error_activate_pool:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (thiz, "failed to activate output video buffer pool");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
error_create_buffer:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (thiz, "failed to create output video buffer");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_msdkvpp_prepare_output_buffer (GstBaseTransform * trans,
|
|
|
|
GstBuffer * inbuf, GstBuffer ** outbuf_ptr)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
|
|
|
|
if (gst_base_transform_is_passthrough (trans)) {
|
|
|
|
*outbuf_ptr = inbuf;
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*outbuf_ptr = create_output_buffer (thiz);
|
|
|
|
return *outbuf_ptr ? GST_FLOW_OK : GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
static GstBufferPool *
|
2023-05-30 10:01:49 +00:00
|
|
|
gst_msdk_create_va_pool (GstMsdkVPP * thiz, GstVideoInfo * info,
|
|
|
|
GstMsdkContext * msdk_context, guint min_buffers, GstPadDirection direction)
|
2022-06-08 04:31:56 +00:00
|
|
|
{
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
GstAllocator *allocator;
|
|
|
|
GArray *formats = NULL;
|
|
|
|
GstAllocationParams alloc_params = { 0, 31, 0, 0 };
|
|
|
|
GstVaDisplay *display = NULL;
|
|
|
|
GstCaps *aligned_caps = NULL;
|
2023-05-30 10:01:49 +00:00
|
|
|
guint usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC;
|
|
|
|
gboolean use_dmabuf = FALSE;
|
|
|
|
guint64 modifier = DRM_FORMAT_MOD_INVALID;
|
2022-06-08 04:31:56 +00:00
|
|
|
|
2022-05-07 09:10:34 +00:00
|
|
|
display = (GstVaDisplay *) gst_msdk_context_get_va_display (msdk_context);
|
2022-06-08 04:31:56 +00:00
|
|
|
|
2023-05-30 10:01:49 +00:00
|
|
|
if (direction == GST_PAD_SINK) {
|
|
|
|
use_dmabuf = thiz->use_sinkpad_dmabuf;
|
|
|
|
modifier = thiz->sink_modifier;
|
|
|
|
} else if (direction == GST_PAD_SRC) {
|
|
|
|
use_dmabuf = thiz->use_srcpad_dmabuf;
|
|
|
|
modifier = thiz->src_modifier;
|
|
|
|
}
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
if (use_dmabuf)
|
|
|
|
allocator = gst_va_dmabuf_allocator_new (display);
|
|
|
|
else {
|
2023-03-09 09:18:16 +00:00
|
|
|
/* From attrib query, va surface format doesn't support RGB565, so leave
|
|
|
|
* the formats as NULL when creating va allocator for RGB565 */
|
|
|
|
if (GST_VIDEO_INFO_FORMAT (info) != GST_VIDEO_FORMAT_RGB16) {
|
|
|
|
formats = g_array_new (FALSE, FALSE, sizeof (GstVideoFormat));
|
|
|
|
g_array_append_val (formats, GST_VIDEO_INFO_FORMAT (info));
|
|
|
|
}
|
2022-06-08 04:31:56 +00:00
|
|
|
allocator = gst_va_allocator_new (display, formats);
|
|
|
|
}
|
2023-12-04 08:34:42 +00:00
|
|
|
|
|
|
|
gst_object_unref (display);
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
if (!allocator) {
|
|
|
|
GST_ERROR ("Failed to create allocator");
|
|
|
|
if (formats)
|
|
|
|
g_array_unref (formats);
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-05-30 10:01:49 +00:00
|
|
|
|
|
|
|
if (use_dmabuf && modifier != DRM_FORMAT_MOD_INVALID) {
|
|
|
|
aligned_caps = gst_msdkcaps_video_info_to_drm_caps (info, modifier);
|
|
|
|
usage_hint |= VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ |
|
|
|
|
VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE;
|
|
|
|
gst_caps_set_features (aligned_caps, 0,
|
|
|
|
gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_DMABUF, NULL));
|
|
|
|
} else
|
|
|
|
aligned_caps = gst_video_info_to_caps (info);
|
|
|
|
|
2023-12-13 09:20:33 +00:00
|
|
|
pool = gst_va_pool_new_with_config (aligned_caps, min_buffers, 0, usage_hint,
|
|
|
|
GST_VA_FEATURE_AUTO, allocator, &alloc_params);
|
2022-06-08 04:31:56 +00:00
|
|
|
|
|
|
|
gst_object_unref (allocator);
|
|
|
|
gst_caps_unref (aligned_caps);
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
2022-09-07 02:55:57 +00:00
|
|
|
#else
|
|
|
|
static GstBufferPool *
|
|
|
|
gst_msdk_create_d3d11_pool (GstMsdkVPP * thiz, GstVideoInfo * info,
|
|
|
|
guint num_buffers, gboolean propose)
|
|
|
|
{
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
GstD3D11Device *device;
|
|
|
|
GstStructure *config;
|
|
|
|
GstD3D11AllocationParams *params;
|
|
|
|
GstD3D11Format device_format;
|
|
|
|
guint bind_flags = 0;
|
|
|
|
GstCaps *aligned_caps = NULL;
|
|
|
|
GstVideoInfo aligned_info;
|
|
|
|
gint aligned_width;
|
|
|
|
gint aligned_height;
|
|
|
|
|
|
|
|
device = gst_msdk_context_get_d3d11_device (thiz->context);
|
|
|
|
|
|
|
|
aligned_width = GST_ROUND_UP_16 (info->width);
|
|
|
|
aligned_height = GST_ROUND_UP_32 (info->height);
|
|
|
|
|
|
|
|
gst_video_info_set_interlaced_format (&aligned_info,
|
|
|
|
GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_INTERLACE_MODE (info),
|
|
|
|
aligned_width, aligned_height);
|
|
|
|
|
|
|
|
gst_d3d11_device_get_format (device, GST_VIDEO_INFO_FORMAT (&aligned_info),
|
|
|
|
&device_format);
|
|
|
|
if (!propose
|
|
|
|
&& ((device_format.format_support[0] & D3D11_FORMAT_SUPPORT_RENDER_TARGET)
|
|
|
|
== D3D11_FORMAT_SUPPORT_RENDER_TARGET)) {
|
|
|
|
bind_flags = D3D11_BIND_RENDER_TARGET;
|
|
|
|
}
|
|
|
|
|
|
|
|
aligned_caps = gst_video_info_to_caps (&aligned_info);
|
|
|
|
|
|
|
|
pool = gst_d3d11_buffer_pool_new (device);
|
|
|
|
config = gst_buffer_pool_get_config (pool);
|
|
|
|
params = gst_d3d11_allocation_params_new (device, &aligned_info,
|
|
|
|
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags,
|
|
|
|
D3D11_RESOURCE_MISC_SHARED);
|
|
|
|
|
|
|
|
gst_buffer_pool_config_set_d3d11_allocation_params (config, params);
|
|
|
|
gst_d3d11_allocation_params_free (params);
|
|
|
|
gst_buffer_pool_config_set_params (config, aligned_caps,
|
|
|
|
GST_VIDEO_INFO_SIZE (&aligned_info), num_buffers, 0);
|
|
|
|
gst_buffer_pool_set_config (pool, config);
|
|
|
|
|
|
|
|
gst_caps_unref (aligned_caps);
|
|
|
|
GST_LOG_OBJECT (thiz, "Creating d3d11 pool");
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
2022-06-08 04:31:56 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
static GstBufferPool *
|
|
|
|
gst_msdkvpp_create_buffer_pool (GstMsdkVPP * thiz, GstPadDirection direction,
|
2022-09-07 02:55:57 +00:00
|
|
|
GstCaps * caps, guint min_num_buffers, gboolean propose)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
GstStructure *config;
|
|
|
|
GstVideoInfo info;
|
|
|
|
GstVideoInfo *pool_info = NULL;
|
|
|
|
GstVideoAlignment align;
|
|
|
|
|
|
|
|
if (direction == GST_PAD_SINK) {
|
|
|
|
pool_info = &thiz->sinkpad_buffer_pool_info;
|
|
|
|
} else if (direction == GST_PAD_SRC) {
|
|
|
|
pool_info = &thiz->srcpad_buffer_pool_info;
|
|
|
|
}
|
|
|
|
|
2023-05-30 10:01:49 +00:00
|
|
|
if (!gst_msdkcaps_video_info_from_caps (caps, &info, NULL)) {
|
2018-03-06 13:51:05 +00:00
|
|
|
goto error_no_video_info;
|
2022-06-08 04:31:56 +00:00
|
|
|
}
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2019-07-23 05:16:36 +00:00
|
|
|
gst_msdk_set_video_alignment (&info, 0, 0, &align);
|
2018-03-06 13:51:05 +00:00
|
|
|
gst_video_info_align (&info, &align);
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
#ifndef _WIN32
|
2023-05-30 10:01:49 +00:00
|
|
|
pool = gst_msdk_create_va_pool (thiz, &info, thiz->context, min_num_buffers,
|
|
|
|
direction);
|
2022-06-08 04:31:56 +00:00
|
|
|
#else
|
2022-09-07 02:55:57 +00:00
|
|
|
pool = gst_msdk_create_d3d11_pool (thiz, &info, min_num_buffers, propose);
|
|
|
|
#endif
|
2022-06-08 04:31:56 +00:00
|
|
|
if (!thiz->use_video_memory)
|
|
|
|
pool = gst_video_buffer_pool_new ();
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
if (!pool)
|
|
|
|
goto error_no_pool;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
gst_buffer_pool_config_set_params (config, caps,
|
|
|
|
GST_VIDEO_INFO_SIZE (&info), min_num_buffers, 0);
|
|
|
|
gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
|
|
|
|
gst_buffer_pool_config_add_option (config,
|
|
|
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
2018-03-06 13:51:05 +00:00
|
|
|
gst_buffer_pool_config_set_video_alignment (config, &align);
|
|
|
|
|
|
|
|
if (!gst_buffer_pool_set_config (pool, config))
|
|
|
|
goto error_pool_config;
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
/* Updating pool_info with info which used to config pool */
|
2018-03-06 13:51:05 +00:00
|
|
|
*pool_info = info;
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
|
|
|
|
error_no_pool:
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (thiz, "Failed to create bufferpool");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
error_no_video_info:
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (thiz, "Failed to get Video info from caps");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
error_pool_config:
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (thiz, "Failed to set config");
|
2019-01-09 00:58:00 +00:00
|
|
|
gst_object_unref (pool);
|
2018-03-06 13:51:05 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 06:59:25 +00:00
|
|
|
static GstBufferPool *
|
|
|
|
create_src_pool (GstMsdkVPP * thiz, GstQuery * query, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
guint size = 0, min_buffers = 0, max_buffers = 0;
|
|
|
|
gboolean update_pool = FALSE;
|
|
|
|
GstAllocator *allocator = NULL;
|
|
|
|
GstAllocationParams params;
|
|
|
|
mfxFrameAllocRequest request;
|
|
|
|
|
|
|
|
/* Check whether the query has pool */
|
|
|
|
if (gst_query_get_n_allocation_pools (query) > 0) {
|
|
|
|
update_pool = TRUE;
|
|
|
|
gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
if (pool) {
|
|
|
|
GstStructure *config = NULL;
|
|
|
|
/* get the configured pool properties inorder to set in query */
|
|
|
|
config = gst_buffer_pool_get_config (pool);
|
|
|
|
gst_object_unref (pool);
|
|
|
|
|
|
|
|
gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
|
|
|
|
&max_buffers);
|
|
|
|
if (gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms))
|
|
|
|
gst_query_add_allocation_param (query, allocator, ¶ms);
|
|
|
|
gst_structure_free (config);
|
|
|
|
} else {
|
|
|
|
/* if we have tee after msdkvpp, we will not have pool for src pad,
|
|
|
|
we need assign size for the internal pool
|
|
|
|
gst-launch-1.0 -v videotestsrc ! msdkvpp ! tee ! msdkh264enc ! fakesink silent=false
|
|
|
|
*/
|
|
|
|
min_buffers = SRC_POOL_SIZE_DEFAULT;
|
|
|
|
}
|
|
|
|
|
2022-06-08 04:31:56 +00:00
|
|
|
/* Always create a pool for vpp out buffers. For vpp, we don't use
|
|
|
|
* external mfxFrameAllocator for video-memory allocation. */
|
2020-05-19 06:59:25 +00:00
|
|
|
request = thiz->request[1];
|
|
|
|
min_buffers += thiz->async_depth + request.NumFrameSuggested;
|
|
|
|
request.NumFrameSuggested = min_buffers;
|
|
|
|
|
2022-09-07 02:55:57 +00:00
|
|
|
pool =
|
|
|
|
gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SRC, caps, min_buffers,
|
|
|
|
FALSE);
|
2020-05-19 06:59:25 +00:00
|
|
|
if (!pool)
|
|
|
|
return NULL;
|
|
|
|
/* we do not support dynamic buffer count change */
|
|
|
|
max_buffers = min_buffers;
|
|
|
|
if (update_pool)
|
|
|
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min_buffers,
|
|
|
|
max_buffers);
|
|
|
|
else
|
|
|
|
gst_query_add_allocation_pool (query, pool, size, min_buffers, max_buffers);
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_query_parse_allocation (query, &caps, NULL);
|
|
|
|
if (!caps) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to parse the decide_allocation caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2023-05-30 10:01:49 +00:00
|
|
|
|
2022-05-26 10:17:16 +00:00
|
|
|
/* We allocate the memory of type that downstream allocation requests */
|
|
|
|
#ifndef _WIN32
|
2023-02-22 02:26:38 +00:00
|
|
|
if (gst_msdkcaps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
2018-04-30 20:39:52 +00:00
|
|
|
GST_INFO_OBJECT (thiz, "MSDK VPP srcpad uses DMABuf memory");
|
|
|
|
thiz->use_srcpad_dmabuf = TRUE;
|
|
|
|
}
|
2022-05-26 10:17:16 +00:00
|
|
|
#endif
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL))
|
|
|
|
thiz->add_video_meta = TRUE;
|
|
|
|
else
|
|
|
|
thiz->add_video_meta = FALSE;
|
|
|
|
|
2020-05-19 06:59:25 +00:00
|
|
|
gst_clear_object (&thiz->srcpad_buffer_pool);
|
|
|
|
thiz->srcpad_buffer_pool = create_src_pool (thiz, query, caps);
|
|
|
|
if (!thiz->srcpad_buffer_pool)
|
|
|
|
return FALSE;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
|
|
|
|
|
|
|
/* Fixme if downstream doesn't have videometa support, msdkvpp should
|
|
|
|
* copy the output buffers */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_propose_allocation (GstBaseTransform * trans,
|
|
|
|
GstQuery * decide_query, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
GstVideoInfo info;
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
GstAllocator *allocator = NULL;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *config;
|
|
|
|
gboolean need_pool;
|
|
|
|
GstAllocationParams params;
|
2018-04-25 00:45:24 +00:00
|
|
|
guint size;
|
|
|
|
guint min_buffers = thiz->async_depth + 1;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
gst_query_parse_allocation (query, &caps, &need_pool);
|
|
|
|
if (!caps) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to parse the allocation caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-05-30 10:01:49 +00:00
|
|
|
if (!gst_msdkcaps_video_info_from_caps (caps, &info, NULL)) {
|
2018-03-06 13:51:05 +00:00
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to get video info");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-04-30 20:39:52 +00:00
|
|
|
/* if upstream allocation query supports dmabuf-capsfeatures,
|
|
|
|
* we do allocate dmabuf backed memory */
|
2023-02-22 02:26:38 +00:00
|
|
|
if (gst_msdkcaps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
2018-04-30 20:39:52 +00:00
|
|
|
GST_INFO_OBJECT (thiz, "MSDK VPP srcpad uses DMABuf memory");
|
|
|
|
thiz->use_sinkpad_dmabuf = TRUE;
|
|
|
|
}
|
|
|
|
|
2018-04-25 00:45:24 +00:00
|
|
|
if (need_pool) {
|
|
|
|
/* alwys provide a new pool for upstream to help re-negotiation
|
|
|
|
* more info here: https://bugzilla.gnome.org/show_bug.cgi?id=748344 */
|
|
|
|
pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps,
|
2022-09-07 02:55:57 +00:00
|
|
|
min_buffers, TRUE);
|
2018-04-25 00:45:24 +00:00
|
|
|
}
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2018-04-25 00:45:24 +00:00
|
|
|
/* Update the internal pool if any allocation attribute changed */
|
2018-03-06 13:51:05 +00:00
|
|
|
if (!gst_video_info_is_equal (&thiz->sinkpad_buffer_pool_info, &info)) {
|
|
|
|
gst_object_unref (thiz->sinkpad_buffer_pool);
|
2018-04-25 00:45:24 +00:00
|
|
|
thiz->sinkpad_buffer_pool = gst_msdkvpp_create_buffer_pool (thiz,
|
2022-09-07 02:55:57 +00:00
|
|
|
GST_PAD_SINK, caps, min_buffers, FALSE);
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 00:45:24 +00:00
|
|
|
/* get the size and allocator params from configured pool and set it in query */
|
|
|
|
if (!need_pool)
|
|
|
|
pool = gst_object_ref (thiz->sinkpad_buffer_pool);
|
2018-03-06 13:51:05 +00:00
|
|
|
config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
|
|
|
|
gst_buffer_pool_config_get_params (config, NULL, &size, NULL, NULL);
|
|
|
|
if (gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms))
|
|
|
|
gst_query_add_allocation_param (query, allocator, ¶ms);
|
|
|
|
gst_structure_free (config);
|
|
|
|
|
2019-09-02 19:08:44 +00:00
|
|
|
/* if upstream doesn't have a pool requirement, set only
|
2018-03-06 13:51:05 +00:00
|
|
|
* size, min_buffers and max_buffers in query */
|
2018-04-25 00:45:24 +00:00
|
|
|
gst_query_add_allocation_pool (query, need_pool ? pool : NULL, size,
|
|
|
|
min_buffers, 0);
|
2018-03-06 13:51:05 +00:00
|
|
|
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
|
|
|
|
2018-04-25 00:45:24 +00:00
|
|
|
gst_object_unref (pool);
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
return GST_BASE_TRANSFORM_CLASS (parent_class)->propose_allocation (trans,
|
|
|
|
decide_query, query);
|
|
|
|
}
|
|
|
|
|
2022-05-09 10:34:38 +00:00
|
|
|
static GstMsdkSurface *
|
2022-09-07 07:29:37 +00:00
|
|
|
gst_msdkvpp_get_surface_from_pool (GstMsdkVPP * thiz, GstBufferPool * pool,
|
|
|
|
GstBuffer * buf)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
2022-09-07 07:29:37 +00:00
|
|
|
GstBuffer *upload_buf;
|
2022-05-09 10:34:38 +00:00
|
|
|
GstMsdkSurface *msdk_surface = NULL;
|
2022-09-07 07:29:37 +00:00
|
|
|
GstVideoFrame src_frame, dst_frame;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
if (!gst_buffer_pool_is_active (pool) &&
|
|
|
|
!gst_buffer_pool_set_active (pool, TRUE)) {
|
|
|
|
GST_ERROR_OBJECT (pool, "failed to activate buffer pool");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-09-07 07:29:37 +00:00
|
|
|
if (gst_buffer_pool_acquire_buffer (pool, &upload_buf, NULL) != GST_FLOW_OK) {
|
2018-03-06 13:51:05 +00:00
|
|
|
GST_ERROR_OBJECT (pool, "failed to acquire a buffer from pool");
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-09-07 07:29:37 +00:00
|
|
|
|
|
|
|
if (!gst_video_frame_map (&src_frame, &thiz->sinkpad_info, buf, GST_MAP_READ)) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "failed to map the frame for source");
|
|
|
|
gst_buffer_unref (upload_buf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gst_video_frame_map (&dst_frame, &thiz->sinkpad_buffer_pool_info,
|
|
|
|
upload_buf, GST_MAP_WRITE)) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "failed to map the frame for destination");
|
|
|
|
gst_video_frame_unmap (&src_frame);
|
|
|
|
gst_buffer_unref (upload_buf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (guint i = 0; i < GST_VIDEO_FRAME_N_PLANES (&src_frame); i++) {
|
|
|
|
guint src_width_in_bytes, src_height;
|
|
|
|
guint dst_width_in_bytes, dst_height;
|
|
|
|
guint width_in_bytes, height;
|
|
|
|
guint src_stride, dst_stride;
|
|
|
|
guint8 *src_data, *dst_data;
|
|
|
|
|
|
|
|
src_width_in_bytes = GST_VIDEO_FRAME_COMP_WIDTH (&src_frame, i) *
|
|
|
|
GST_VIDEO_FRAME_COMP_PSTRIDE (&src_frame, i);
|
|
|
|
src_height = GST_VIDEO_FRAME_COMP_HEIGHT (&src_frame, i);
|
|
|
|
src_stride = GST_VIDEO_FRAME_COMP_STRIDE (&src_frame, i);
|
|
|
|
|
|
|
|
dst_width_in_bytes = GST_VIDEO_FRAME_COMP_WIDTH (&dst_frame, i) *
|
|
|
|
GST_VIDEO_FRAME_COMP_PSTRIDE (&src_frame, i);
|
|
|
|
dst_height = GST_VIDEO_FRAME_COMP_HEIGHT (&src_frame, i);
|
|
|
|
dst_stride = GST_VIDEO_FRAME_COMP_STRIDE (&dst_frame, i);
|
|
|
|
|
|
|
|
width_in_bytes = MIN (src_width_in_bytes, dst_width_in_bytes);
|
|
|
|
height = MIN (src_height, dst_height);
|
|
|
|
|
|
|
|
src_data = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&src_frame, i);
|
|
|
|
dst_data = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&dst_frame, i);
|
|
|
|
|
|
|
|
for (guint j = 0; j < height; j++) {
|
|
|
|
memcpy (dst_data, src_data, width_in_bytes);
|
|
|
|
dst_data += dst_stride;
|
|
|
|
src_data += src_stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_video_frame_unmap (&dst_frame);
|
|
|
|
gst_video_frame_unmap (&src_frame);
|
|
|
|
|
|
|
|
if (thiz->use_video_memory) {
|
|
|
|
msdk_surface = gst_msdk_import_to_msdk_surface (upload_buf, thiz->context,
|
|
|
|
&thiz->sinkpad_info, GST_MAP_READ);
|
|
|
|
} else {
|
|
|
|
msdk_surface =
|
|
|
|
gst_msdk_import_sys_mem_to_msdk_surface (upload_buf,
|
2022-12-21 08:32:10 +00:00
|
|
|
&thiz->sinkpad_buffer_pool_info);
|
2022-09-07 07:29:37 +00:00
|
|
|
}
|
2022-06-08 04:31:56 +00:00
|
|
|
|
|
|
|
if (msdk_surface)
|
2022-09-07 07:29:37 +00:00
|
|
|
msdk_surface->buf = upload_buf;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
return msdk_surface;
|
|
|
|
}
|
|
|
|
|
2022-05-09 10:34:38 +00:00
|
|
|
static GstMsdkSurface *
|
2018-03-06 13:51:05 +00:00
|
|
|
get_msdk_surface_from_input_buffer (GstMsdkVPP * thiz, GstBuffer * inbuf)
|
|
|
|
{
|
2022-05-09 10:34:38 +00:00
|
|
|
GstMsdkSurface *msdk_surface = NULL;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2022-05-09 10:34:38 +00:00
|
|
|
msdk_surface = gst_msdk_import_to_msdk_surface (inbuf, thiz->context,
|
2022-09-07 07:29:37 +00:00
|
|
|
&thiz->sinkpad_info, GST_MAP_READ);
|
2022-05-09 10:34:38 +00:00
|
|
|
if (msdk_surface) {
|
|
|
|
msdk_surface->buf = gst_buffer_ref (inbuf);
|
|
|
|
return msdk_surface;
|
|
|
|
}
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
/* If upstream hasn't accpeted the proposed msdk bufferpool,
|
2022-05-09 10:34:38 +00:00
|
|
|
* just copy frame to msdk buffer and take a surface from it.
|
|
|
|
*/
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2022-09-07 07:29:37 +00:00
|
|
|
return gst_msdkvpp_get_surface_from_pool (thiz, thiz->sinkpad_buffer_pool,
|
|
|
|
inbuf);
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|
|
|
GstBuffer * outbuf)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
2018-03-22 16:04:02 +00:00
|
|
|
GstClockTime timestamp;
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2018-03-06 13:51:05 +00:00
|
|
|
mfxSession session;
|
|
|
|
mfxSyncPoint sync_point = NULL;
|
|
|
|
mfxStatus status;
|
2019-10-16 18:59:32 +00:00
|
|
|
mfxFrameInfo *in_info = NULL;
|
2022-05-09 10:34:38 +00:00
|
|
|
GstMsdkSurface *in_surface = NULL;
|
|
|
|
GstMsdkSurface *out_surface = NULL;
|
2021-07-20 10:15:11 +00:00
|
|
|
GstBuffer *outbuf_new = NULL;
|
2020-08-04 09:14:44 +00:00
|
|
|
gboolean locked_by_others;
|
2021-07-20 10:15:11 +00:00
|
|
|
gboolean create_new_surface = FALSE;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2020-05-19 07:14:34 +00:00
|
|
|
free_unlocked_msdk_surfaces (thiz);
|
2018-03-22 16:04:02 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
in_surface = get_msdk_surface_from_input_buffer (thiz, inbuf);
|
|
|
|
if (!in_surface)
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
|
2019-12-06 05:19:13 +00:00
|
|
|
if (!in_surface->surface) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "mfx surface is NULL for the current input buffer");
|
|
|
|
free_msdk_surface (in_surface);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2020-08-04 09:14:44 +00:00
|
|
|
locked_by_others = !!in_surface->surface->Data.Locked;
|
2019-12-06 05:19:13 +00:00
|
|
|
|
2021-07-20 10:15:11 +00:00
|
|
|
/* always convert timestamp of input surface as msdk timestamp */
|
|
|
|
if (inbuf->pts == GST_CLOCK_TIME_NONE)
|
|
|
|
in_surface->surface->Data.TimeStamp = MFX_TIMESTAMP_UNKNOWN;
|
|
|
|
else
|
2024-05-29 03:07:23 +00:00
|
|
|
/* In the case of multi-channel transoding, for example:
|
|
|
|
* "gst-launch-1.0 -vf filesrc location=input.bin ! h265parse ! msdkh265dec !\
|
|
|
|
* tee name=t ! queue ! msdkh265enc ! h265parse ! filesink location=out.h265\
|
|
|
|
* t. ! queue ! msdkvpp denoise=10 ! fakesink",
|
|
|
|
* msdkenc and msdkvpp re-use surface from decoder and they both need to set
|
|
|
|
* timestamp for input mfx surface; but encoder use input frame->pts while vpp
|
|
|
|
* use input buffer->pts, and frame->pts has 1000h offset larger than inbuf->pts;
|
|
|
|
* It is very likely to cause conflict or mfx surface timestamp. So we add this
|
|
|
|
* PTS_OFFSET here to ensure enc and vpp set the same value to input mfx surface
|
|
|
|
* meanwhile does not break encoder's setting min_pts for dts protection.
|
|
|
|
*/
|
2021-07-20 10:15:11 +00:00
|
|
|
in_surface->surface->Data.TimeStamp =
|
2024-05-29 03:07:23 +00:00
|
|
|
gst_util_uint64_scale_round
|
|
|
|
(inbuf->pts + PTS_OFFSET, 90000, GST_SECOND);
|
2021-07-20 10:15:11 +00:00
|
|
|
|
2024-02-19 04:50:53 +00:00
|
|
|
if (thiz->use_video_memory) {
|
|
|
|
out_surface = gst_msdk_import_to_msdk_surface (outbuf, thiz->context,
|
|
|
|
&thiz->srcpad_info, GST_MAP_WRITE);
|
|
|
|
} else {
|
2022-12-01 06:53:21 +00:00
|
|
|
out_surface =
|
|
|
|
gst_msdk_import_sys_mem_to_msdk_surface (outbuf, &thiz->srcpad_info);
|
2024-02-19 04:50:53 +00:00
|
|
|
}
|
2022-12-01 06:53:21 +00:00
|
|
|
|
|
|
|
if (out_surface) {
|
|
|
|
out_surface->buf = gst_buffer_ref (outbuf);
|
2018-03-06 13:51:05 +00:00
|
|
|
} else {
|
2022-12-01 06:53:21 +00:00
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to get msdk outsurface!");
|
|
|
|
free_msdk_surface (in_surface);
|
|
|
|
return GST_FLOW_ERROR;
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 18:59:32 +00:00
|
|
|
/* update surface crop info (NOTE: msdk min frame size is 2x2) */
|
|
|
|
in_info = &in_surface->surface->Info;
|
|
|
|
if ((thiz->crop_left + thiz->crop_right >= in_info->CropW - 1)
|
|
|
|
|| (thiz->crop_top + thiz->crop_bottom >= in_info->CropH - 1)) {
|
|
|
|
GST_WARNING_OBJECT (thiz, "ignoring crop... cropping too much!");
|
2022-05-09 10:34:38 +00:00
|
|
|
} else if (!in_surface->from_qdata) {
|
|
|
|
/* We only fill crop info when it is a new surface.
|
|
|
|
* If the surface is a cached one, it already has crop info,
|
|
|
|
* and we should avoid updating again.
|
|
|
|
*/
|
2019-10-16 18:59:32 +00:00
|
|
|
in_info->CropX = thiz->crop_left;
|
|
|
|
in_info->CropY = thiz->crop_top;
|
|
|
|
in_info->CropW -= thiz->crop_left + thiz->crop_right;
|
|
|
|
in_info->CropH -= thiz->crop_top + thiz->crop_bottom;
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
session = gst_msdk_context_get_session (thiz->context);
|
|
|
|
|
2018-03-22 16:04:02 +00:00
|
|
|
/* outer loop is for handling FrameRate Control and deinterlace use cases */
|
|
|
|
do {
|
|
|
|
for (;;) {
|
|
|
|
status =
|
|
|
|
MFXVideoVPP_RunFrameVPPAsync (session, in_surface->surface,
|
|
|
|
out_surface->surface, NULL, &sync_point);
|
2021-07-20 10:15:11 +00:00
|
|
|
timestamp = out_surface->surface->Data.TimeStamp;
|
|
|
|
|
2018-03-22 16:04:02 +00:00
|
|
|
if (status != MFX_WRN_DEVICE_BUSY)
|
|
|
|
break;
|
|
|
|
/* If device is busy, wait 1ms and retry, as per MSDK's recommendation */
|
|
|
|
g_usleep (1000);
|
2021-07-20 10:15:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (timestamp == MFX_TIMESTAMP_UNKNOWN)
|
|
|
|
timestamp = GST_CLOCK_TIME_NONE;
|
|
|
|
else
|
2024-05-29 03:07:23 +00:00
|
|
|
/* We remove PTS_OFFSET here to avoid 1000h delay introduced earlier */
|
|
|
|
timestamp = gst_util_uint64_scale_round (timestamp, GST_SECOND, 90000)
|
|
|
|
- PTS_OFFSET;
|
2018-03-22 16:04:02 +00:00
|
|
|
|
2019-08-19 04:30:30 +00:00
|
|
|
if (status == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM)
|
|
|
|
GST_WARNING_OBJECT (thiz, "VPP returned: %s",
|
|
|
|
msdk_status_to_string (status));
|
|
|
|
else if (status != MFX_ERR_NONE && status != MFX_ERR_MORE_DATA
|
2018-03-22 16:04:02 +00:00
|
|
|
&& status != MFX_ERR_MORE_SURFACE)
|
|
|
|
goto vpp_error;
|
|
|
|
|
|
|
|
/* No output generated */
|
|
|
|
if (status == MFX_ERR_MORE_DATA)
|
|
|
|
goto error_more_data;
|
|
|
|
|
2018-12-12 07:24:18 +00:00
|
|
|
/* Wait for vpp operation to complete, the magic number 300000 below
|
|
|
|
* is used in MSDK samples
|
|
|
|
* #define MSDK_VPP_WAIT_INTERVAL 300000
|
|
|
|
*/
|
2019-01-09 04:19:50 +00:00
|
|
|
if (sync_point &&
|
|
|
|
MFXVideoCORE_SyncOperation (session, sync_point,
|
|
|
|
300000) != MFX_ERR_NONE)
|
|
|
|
GST_WARNING_OBJECT (thiz, "failed to do sync operation");
|
2021-07-20 10:15:11 +00:00
|
|
|
/* push new output buffer forward after sync operation */
|
|
|
|
if (create_new_surface) {
|
|
|
|
create_new_surface = FALSE;
|
|
|
|
ret = gst_pad_push (GST_BASE_TRANSFORM_SRC_PAD (trans), outbuf_new);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto error_push_buffer;
|
|
|
|
}
|
2018-03-22 16:04:02 +00:00
|
|
|
|
|
|
|
/* More than one output buffers are generated */
|
|
|
|
if (status == MFX_ERR_MORE_SURFACE) {
|
2021-07-20 10:15:11 +00:00
|
|
|
outbuf_new = create_output_buffer (thiz);
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf_new) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (outbuf_new) = thiz->buffer_duration;
|
|
|
|
|
2022-12-01 06:53:21 +00:00
|
|
|
release_out_surface (thiz, out_surface);
|
2024-02-19 04:50:53 +00:00
|
|
|
if (thiz->use_video_memory) {
|
|
|
|
out_surface =
|
|
|
|
gst_msdk_import_to_msdk_surface (outbuf_new, thiz->context,
|
|
|
|
&thiz->srcpad_buffer_pool_info, GST_MAP_WRITE);
|
|
|
|
} else {
|
2022-12-01 06:53:21 +00:00
|
|
|
out_surface =
|
|
|
|
gst_msdk_import_sys_mem_to_msdk_surface (outbuf_new,
|
|
|
|
&thiz->srcpad_buffer_pool_info);
|
2024-02-19 04:50:53 +00:00
|
|
|
}
|
2022-12-01 06:53:21 +00:00
|
|
|
|
|
|
|
if (out_surface) {
|
|
|
|
out_surface->buf = gst_buffer_ref (outbuf_new);
|
2021-07-20 10:15:11 +00:00
|
|
|
create_new_surface = TRUE;
|
|
|
|
} else {
|
2022-12-01 06:53:21 +00:00
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to get msdk outsurface!");
|
|
|
|
release_in_surface (thiz, in_surface, locked_by_others);
|
|
|
|
return GST_FLOW_ERROR;
|
2021-07-20 10:15:11 +00:00
|
|
|
}
|
2018-03-22 16:04:02 +00:00
|
|
|
} else {
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = thiz->buffer_duration;
|
|
|
|
}
|
|
|
|
} while (status == MFX_ERR_MORE_SURFACE);
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2019-08-29 01:31:22 +00:00
|
|
|
goto transform_end;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
vpp_error:
|
|
|
|
GST_ERROR_OBJECT (thiz, "MSDK Failed to do VPP");
|
2019-08-29 01:31:22 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto transform_end;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
error_more_data:
|
|
|
|
GST_WARNING_OBJECT (thiz,
|
2019-09-02 19:08:44 +00:00
|
|
|
"MSDK Requires additional input for processing, "
|
2018-03-06 13:51:05 +00:00
|
|
|
"Retruning FLOW_DROPPED since no output buffer was generated");
|
2019-08-29 01:31:22 +00:00
|
|
|
ret = GST_BASE_TRANSFORM_FLOW_DROPPED;
|
|
|
|
goto transform_end;
|
2018-03-22 16:04:02 +00:00
|
|
|
|
|
|
|
error_push_buffer:
|
2019-08-29 01:31:22 +00:00
|
|
|
GST_DEBUG_OBJECT (thiz, "failed to push output buffer: %s",
|
|
|
|
gst_flow_get_name (ret));
|
|
|
|
|
|
|
|
transform_end:
|
2020-08-04 09:14:44 +00:00
|
|
|
release_in_surface (thiz, in_surface, locked_by_others);
|
2020-08-03 07:29:08 +00:00
|
|
|
release_out_surface (thiz, out_surface);
|
2019-08-29 01:31:22 +00:00
|
|
|
|
|
|
|
return ret;
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_msdkvpp_close (GstMsdkVPP * thiz)
|
|
|
|
{
|
|
|
|
mfxStatus status;
|
|
|
|
|
|
|
|
if (!thiz->context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (thiz, "Closing VPP 0x%p", thiz->context);
|
|
|
|
status = MFXVideoVPP_Close (gst_msdk_context_get_session (thiz->context));
|
|
|
|
if (status != MFX_ERR_NONE && status != MFX_ERR_NOT_INITIALIZED) {
|
2018-12-12 05:45:34 +00:00
|
|
|
GST_WARNING_OBJECT (thiz, "VPP close failed (%s)",
|
2018-03-06 13:51:05 +00:00
|
|
|
msdk_status_to_string (status));
|
|
|
|
}
|
2020-05-19 07:14:34 +00:00
|
|
|
free_all_msdk_surfaces (thiz);
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2020-01-17 08:15:35 +00:00
|
|
|
gst_clear_object (&thiz->context);
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
memset (&thiz->param, 0, sizeof (thiz->param));
|
|
|
|
|
2020-01-17 08:15:35 +00:00
|
|
|
gst_clear_object (&thiz->sinkpad_buffer_pool);
|
|
|
|
gst_clear_object (&thiz->srcpad_buffer_pool);
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2018-03-22 16:04:02 +00:00
|
|
|
thiz->buffer_duration = GST_CLOCK_TIME_NONE;
|
2018-03-06 13:51:05 +00:00
|
|
|
gst_video_info_init (&thiz->sinkpad_info);
|
|
|
|
gst_video_info_init (&thiz->srcpad_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ensure_filters (GstMsdkVPP * thiz)
|
|
|
|
{
|
|
|
|
/* Denoise */
|
|
|
|
if (thiz->flags & GST_MSDK_FLAG_DENOISE) {
|
|
|
|
mfxExtVPPDenoise *mfx_denoise = &thiz->mfx_denoise;
|
|
|
|
mfx_denoise->Header.BufferId = MFX_EXTBUFF_VPP_DENOISE;
|
|
|
|
mfx_denoise->Header.BufferSz = sizeof (mfxExtVPPDenoise);
|
|
|
|
mfx_denoise->DenoiseFactor = thiz->denoise_factor;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_denoise);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Rotation */
|
2019-08-23 01:51:20 +00:00
|
|
|
if (thiz->rotation != MFX_ANGLE_0) {
|
2018-03-06 13:51:05 +00:00
|
|
|
mfxExtVPPRotation *mfx_rotation = &thiz->mfx_rotation;
|
|
|
|
mfx_rotation->Header.BufferId = MFX_EXTBUFF_VPP_ROTATION;
|
|
|
|
mfx_rotation->Header.BufferSz = sizeof (mfxExtVPPRotation);
|
|
|
|
mfx_rotation->Angle = thiz->rotation;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_rotation);
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:52:04 +00:00
|
|
|
/* Deinterlace */
|
|
|
|
if (thiz->flags & GST_MSDK_FLAG_DEINTERLACE) {
|
|
|
|
mfxExtVPPDeinterlacing *mfx_deinterlace = &thiz->mfx_deinterlace;
|
|
|
|
mfx_deinterlace->Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING;
|
|
|
|
mfx_deinterlace->Header.BufferSz = sizeof (mfxExtVPPDeinterlacing);
|
|
|
|
mfx_deinterlace->Mode = thiz->deinterlace_method;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_deinterlace);
|
|
|
|
}
|
|
|
|
|
2018-03-21 14:45:35 +00:00
|
|
|
/* Colorbalance(ProcAmp) */
|
|
|
|
if (thiz->flags & (GST_MSDK_FLAG_HUE | GST_MSDK_FLAG_SATURATION |
|
|
|
|
GST_MSDK_FLAG_BRIGHTNESS | GST_MSDK_FLAG_CONTRAST)) {
|
|
|
|
mfxExtVPPProcAmp *mfx_procamp = &thiz->mfx_procamp;
|
|
|
|
mfx_procamp->Header.BufferId = MFX_EXTBUFF_VPP_PROCAMP;
|
|
|
|
mfx_procamp->Header.BufferSz = sizeof (mfxExtVPPProcAmp);
|
|
|
|
mfx_procamp->Hue = thiz->hue;
|
|
|
|
mfx_procamp->Saturation = thiz->saturation;
|
|
|
|
mfx_procamp->Brightness = thiz->brightness;
|
|
|
|
mfx_procamp->Contrast = thiz->contrast;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_procamp);
|
|
|
|
}
|
|
|
|
|
2018-03-21 17:14:04 +00:00
|
|
|
/* Detail/Edge enhancement */
|
|
|
|
if (thiz->flags & GST_MSDK_FLAG_DETAIL) {
|
|
|
|
mfxExtVPPDetail *mfx_detail = &thiz->mfx_detail;
|
|
|
|
mfx_detail->Header.BufferId = MFX_EXTBUFF_VPP_DETAIL;
|
|
|
|
mfx_detail->Header.BufferSz = sizeof (mfxExtVPPDetail);
|
|
|
|
mfx_detail->DetailFactor = thiz->detail;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_detail);
|
|
|
|
}
|
|
|
|
|
2018-03-21 17:22:18 +00:00
|
|
|
/* Mirroring */
|
2019-08-23 01:51:20 +00:00
|
|
|
if (thiz->mirroring != MFX_MIRRORING_DISABLED) {
|
2018-03-21 17:22:18 +00:00
|
|
|
mfxExtVPPMirroring *mfx_mirroring = &thiz->mfx_mirroring;
|
|
|
|
mfx_mirroring->Header.BufferId = MFX_EXTBUFF_VPP_MIRRORING;
|
|
|
|
mfx_mirroring->Header.BufferSz = sizeof (mfxExtVPPMirroring);
|
|
|
|
mfx_mirroring->Type = thiz->mirroring;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_mirroring);
|
|
|
|
}
|
2018-03-21 17:57:27 +00:00
|
|
|
|
2024-07-30 09:27:49 +00:00
|
|
|
/* Scaling Mode & Interpolation Method */
|
|
|
|
if (thiz->flags & (GST_MSDK_FLAG_SCALING_MODE |
|
|
|
|
GST_MSDK_FLAG_INTERPOLATION_METHOD)) {
|
2023-07-20 07:46:32 +00:00
|
|
|
gboolean scaling_mode_is_compute = FALSE;
|
|
|
|
#if (MFX_VERSION >= 2007)
|
|
|
|
if (thiz->scaling_mode == MFX_SCALING_MODE_INTEL_GEN_COMPUTE)
|
|
|
|
scaling_mode_is_compute = TRUE;
|
|
|
|
#endif
|
|
|
|
if (MFX_RUNTIME_VERSION_ATLEAST (thiz->version, 2, 7) ||
|
|
|
|
!scaling_mode_is_compute) {
|
|
|
|
mfxExtVPPScaling *mfx_scaling = &thiz->mfx_scaling;
|
|
|
|
mfx_scaling->Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
|
|
|
|
mfx_scaling->Header.BufferSz = sizeof (mfxExtVPPScaling);
|
|
|
|
mfx_scaling->ScalingMode = thiz->scaling_mode;
|
2024-07-30 09:27:49 +00:00
|
|
|
if (MFX_RUNTIME_VERSION_ATLEAST (thiz->version, 1, 33)) {
|
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
mfx_scaling->InterpolationMethod = thiz->interpolation_method;
|
|
|
|
#endif
|
|
|
|
} else if (thiz->flags & GST_MSDK_FLAG_INTERPOLATION_METHOD) {
|
|
|
|
GST_WARNING_OBJECT (thiz,
|
|
|
|
"Interpolation method not supported, ignore it...");
|
|
|
|
}
|
2023-07-20 07:46:32 +00:00
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_scaling);
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (thiz,
|
|
|
|
"Compute scaling mode not supported, ignore it...");
|
|
|
|
}
|
2018-03-21 17:57:27 +00:00
|
|
|
}
|
2018-03-22 16:04:02 +00:00
|
|
|
|
|
|
|
/* FRC */
|
|
|
|
if (thiz->flags & GST_MSDK_FLAG_FRC) {
|
|
|
|
mfxExtVPPFrameRateConversion *mfx_frc = &thiz->mfx_frc;
|
|
|
|
mfx_frc->Header.BufferId = MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION;
|
|
|
|
mfx_frc->Header.BufferSz = sizeof (mfxExtVPPFrameRateConversion);
|
|
|
|
mfx_frc->Algorithm = thiz->frc_algm;
|
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mfx_frc);
|
2018-06-06 01:01:13 +00:00
|
|
|
}
|
2023-08-11 03:52:19 +00:00
|
|
|
|
|
|
|
/* Color properties */
|
|
|
|
#if (MFX_VERSION >= 2000)
|
|
|
|
if (MFX_RUNTIME_VERSION_ATLEAST (thiz->version, 2, 0)) {
|
|
|
|
GstVideoInfo *in_vinfo = &thiz->sinkpad_info;
|
|
|
|
GstVideoInfo *out_vinfo = &thiz->srcpad_info;
|
2023-09-21 12:34:02 +00:00
|
|
|
mfxExtVideoSignalInfo *in_vsi = &thiz->in_vsi;
|
|
|
|
mfxExtVideoSignalInfo *out_vsi = &thiz->out_vsi;
|
|
|
|
mfxExtMasteringDisplayColourVolume *mdcv = &thiz->mdcv;
|
|
|
|
mfxExtContentLightLevelInfo *cll = &thiz->cll;
|
2023-08-11 07:20:30 +00:00
|
|
|
const guint chroma_den = 50000;
|
|
|
|
const guint luma_den = 10000;
|
|
|
|
gint tmap = 0;
|
2023-08-11 03:52:19 +00:00
|
|
|
|
|
|
|
if (in_vinfo->colorimetry.primaries || in_vinfo->colorimetry.transfer
|
|
|
|
|| in_vinfo->colorimetry.matrix || in_vinfo->colorimetry.range) {
|
2023-09-21 12:34:02 +00:00
|
|
|
in_vsi->Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO_IN;
|
|
|
|
in_vsi->Header.BufferSz = sizeof (in_vsi);
|
|
|
|
in_vsi->ColourDescriptionPresent = 1;
|
|
|
|
in_vsi->VideoFullRange =
|
2023-08-11 03:52:19 +00:00
|
|
|
(in_vinfo->colorimetry.range == GST_VIDEO_COLOR_RANGE_0_255);
|
2023-09-21 12:34:02 +00:00
|
|
|
in_vsi->ColourPrimaries =
|
2023-08-11 03:52:19 +00:00
|
|
|
gst_video_color_primaries_to_iso (in_vinfo->colorimetry.primaries);
|
2023-09-21 12:34:02 +00:00
|
|
|
in_vsi->TransferCharacteristics =
|
2023-08-11 03:52:19 +00:00
|
|
|
gst_video_transfer_function_to_iso (in_vinfo->colorimetry.transfer);
|
2023-09-21 12:34:02 +00:00
|
|
|
in_vsi->MatrixCoefficients =
|
2023-08-11 03:52:19 +00:00
|
|
|
gst_video_color_matrix_to_iso (in_vinfo->colorimetry.matrix);
|
2023-09-21 12:34:02 +00:00
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) in_vsi);
|
2023-08-11 03:52:19 +00:00
|
|
|
}
|
|
|
|
|
2023-08-11 07:20:30 +00:00
|
|
|
if (thiz->hdr_tone_mapping) {
|
|
|
|
if (thiz->have_mdcv) {
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->Header.BufferId = MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME_IN;
|
|
|
|
mdcv->Header.BufferSz = sizeof (mfxExtMasteringDisplayColourVolume);
|
2023-08-11 07:20:30 +00:00
|
|
|
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->DisplayPrimariesX[0] =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.display_primaries[1].x * chroma_den),
|
|
|
|
chroma_den);
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->DisplayPrimariesY[0] =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.display_primaries[1].y * chroma_den),
|
|
|
|
chroma_den);
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->DisplayPrimariesX[1] =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.display_primaries[2].x * chroma_den),
|
|
|
|
chroma_den);
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->DisplayPrimariesY[1] =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.display_primaries[2].y * chroma_den),
|
|
|
|
chroma_den);
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->DisplayPrimariesX[2] =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.display_primaries[0].x * chroma_den),
|
|
|
|
chroma_den);
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->DisplayPrimariesY[2] =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.display_primaries[0].y * chroma_den),
|
|
|
|
chroma_den);
|
|
|
|
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->WhitePointX =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.white_point.x * chroma_den), chroma_den);
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->WhitePointY =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN ((thiz->mdcv_info.white_point.y * chroma_den), chroma_den);
|
|
|
|
|
|
|
|
/* From vpl spec, MaxDisplayMasteringLuminance is in the unit of 1 nits,
|
|
|
|
* MinDisplayMasteringLuminance is in the unit of 0.0001 nits.
|
|
|
|
*/
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->MaxDisplayMasteringLuminance =
|
2023-08-11 07:20:30 +00:00
|
|
|
thiz->mdcv_info.max_display_mastering_luminance;
|
2023-09-21 12:34:02 +00:00
|
|
|
mdcv->MinDisplayMasteringLuminance =
|
2023-08-11 07:20:30 +00:00
|
|
|
thiz->mdcv_info.min_display_mastering_luminance * luma_den;
|
|
|
|
|
2023-09-21 12:34:02 +00:00
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) mdcv);
|
2023-08-11 07:20:30 +00:00
|
|
|
tmap = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thiz->have_cll) {
|
2023-09-21 12:34:02 +00:00
|
|
|
cll->Header.BufferId = MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO;
|
|
|
|
cll->Header.BufferSz = sizeof (mfxExtContentLightLevelInfo);
|
2023-08-11 07:20:30 +00:00
|
|
|
|
2023-09-21 12:34:02 +00:00
|
|
|
cll->MaxContentLightLevel =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN (thiz->cll_info.max_content_light_level, 65535);
|
2023-09-21 12:34:02 +00:00
|
|
|
cll->MaxPicAverageLightLevel =
|
2023-08-11 07:20:30 +00:00
|
|
|
MIN (thiz->cll_info.max_frame_average_light_level, 65535);
|
|
|
|
|
2023-09-21 12:34:02 +00:00
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) cll);
|
2023-08-11 07:20:30 +00:00
|
|
|
tmap = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmap) {
|
|
|
|
out_vinfo->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
|
|
|
|
out_vinfo->colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
|
|
|
|
out_vinfo->colorimetry.range = GST_VIDEO_COLOR_RANGE_16_235;
|
|
|
|
out_vinfo->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT709;
|
|
|
|
}
|
|
|
|
|
2023-08-11 03:52:19 +00:00
|
|
|
if (out_vinfo->colorimetry.primaries || out_vinfo->colorimetry.transfer
|
|
|
|
|| out_vinfo->colorimetry.matrix || out_vinfo->colorimetry.range) {
|
2023-09-21 12:34:02 +00:00
|
|
|
out_vsi->Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO_OUT;
|
|
|
|
out_vsi->Header.BufferSz = sizeof (out_vsi);
|
|
|
|
out_vsi->ColourDescriptionPresent = 1;
|
|
|
|
out_vsi->VideoFullRange =
|
2023-08-11 03:52:19 +00:00
|
|
|
(out_vinfo->colorimetry.range == GST_VIDEO_COLOR_RANGE_0_255);
|
2023-09-21 12:34:02 +00:00
|
|
|
out_vsi->ColourPrimaries =
|
2023-08-11 03:52:19 +00:00
|
|
|
gst_video_color_primaries_to_iso (out_vinfo->colorimetry.primaries);
|
2023-09-21 12:34:02 +00:00
|
|
|
out_vsi->TransferCharacteristics =
|
2023-08-11 03:52:19 +00:00
|
|
|
gst_video_transfer_function_to_iso (out_vinfo->colorimetry.transfer);
|
2023-09-21 12:34:02 +00:00
|
|
|
out_vsi->MatrixCoefficients =
|
2023-08-11 03:52:19 +00:00
|
|
|
gst_video_color_matrix_to_iso (out_vinfo->colorimetry.matrix);
|
2023-09-21 12:34:02 +00:00
|
|
|
gst_msdkvpp_add_extra_param (thiz, (mfxExtBuffer *) out_vsi);
|
2023-08-11 03:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_msdkvpp_set_passthrough (GstMsdkVPP * thiz)
|
|
|
|
{
|
|
|
|
gboolean passthrough = TRUE;
|
|
|
|
|
|
|
|
/* no passthrough if any of the filter algorithm is enabled */
|
|
|
|
if (thiz->flags)
|
|
|
|
passthrough = FALSE;
|
|
|
|
|
2018-04-30 20:40:32 +00:00
|
|
|
/* vpp could be needed in some specific circumstances, for eg:
|
|
|
|
* input surface is dmabuf and output must be videomemory. So far
|
|
|
|
* the underline iHD driver doesn't seems to support dmabuf mapping,
|
|
|
|
* so we could explicitly ask msdkvpp to provide non-dambuf videomemory
|
|
|
|
* surfaces as output thourgh capsfileters */
|
|
|
|
if (thiz->need_vpp)
|
|
|
|
passthrough = FALSE;
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
/* no passthrough if there is change in out width,height or format */
|
|
|
|
if (GST_VIDEO_INFO_WIDTH (&thiz->sinkpad_info) !=
|
|
|
|
GST_VIDEO_INFO_WIDTH (&thiz->srcpad_info)
|
|
|
|
|| GST_VIDEO_INFO_HEIGHT (&thiz->sinkpad_info) !=
|
|
|
|
GST_VIDEO_INFO_HEIGHT (&thiz->srcpad_info)
|
|
|
|
|| GST_VIDEO_INFO_FORMAT (&thiz->sinkpad_info) !=
|
|
|
|
GST_VIDEO_INFO_FORMAT (&thiz->srcpad_info))
|
|
|
|
passthrough = FALSE;
|
|
|
|
|
|
|
|
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (thiz), passthrough);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_initialize (GstMsdkVPP * thiz)
|
|
|
|
{
|
|
|
|
mfxSession session;
|
|
|
|
mfxStatus status;
|
2020-05-19 06:59:25 +00:00
|
|
|
mfxFrameAllocRequest *request = &thiz->request[0];
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
if (!thiz->context) {
|
|
|
|
GST_WARNING_OBJECT (thiz, "No MSDK Context");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (thiz);
|
|
|
|
session = gst_msdk_context_get_session (thiz->context);
|
2023-08-11 03:52:19 +00:00
|
|
|
status = MFXQueryVersion (session, &thiz->version);
|
|
|
|
if (status != MFX_ERR_NONE) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "VPP failed to query version");
|
|
|
|
goto no_vpp;
|
|
|
|
}
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2018-12-14 02:18:25 +00:00
|
|
|
/* Close the current session if the session has been initialized,
|
|
|
|
* otherwise the subsequent function call of MFXVideoVPP_Init() will
|
|
|
|
* fail
|
|
|
|
*/
|
2019-08-21 04:45:37 +00:00
|
|
|
if (thiz->initialized) {
|
2018-12-14 02:18:25 +00:00
|
|
|
MFXVideoVPP_Close (session);
|
2020-04-02 02:44:31 +00:00
|
|
|
|
|
|
|
memset (&thiz->param, 0, sizeof (thiz->param));
|
|
|
|
memset (&thiz->extra_params, 0, sizeof (thiz->extra_params));
|
|
|
|
thiz->num_extra_params = 0;
|
2019-08-21 04:45:37 +00:00
|
|
|
}
|
2018-12-14 02:18:25 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
if (thiz->use_video_memory) {
|
|
|
|
gst_msdk_set_frame_allocator (thiz->context);
|
|
|
|
thiz->param.IOPattern =
|
|
|
|
MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
|
|
|
|
} else {
|
|
|
|
thiz->param.IOPattern =
|
|
|
|
MFX_IOPATTERN_IN_SYSTEM_MEMORY | MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update input video attributes */
|
|
|
|
gst_msdk_set_mfx_frame_info_from_video_info (&thiz->param.vpp.In,
|
|
|
|
&thiz->sinkpad_info);
|
|
|
|
|
|
|
|
/* update output video attributes, only CSC and Scaling are supported for now */
|
|
|
|
gst_msdk_set_mfx_frame_info_from_video_info (&thiz->param.vpp.Out,
|
|
|
|
&thiz->srcpad_info);
|
2018-03-22 16:04:02 +00:00
|
|
|
|
|
|
|
/* use msdk frame rarte control if there is a mismatch in In & OUt fps */
|
|
|
|
if (GST_VIDEO_INFO_FPS_N (&thiz->srcpad_info) &&
|
|
|
|
(GST_VIDEO_INFO_FPS_N (&thiz->sinkpad_info) !=
|
|
|
|
GST_VIDEO_INFO_FPS_N (&thiz->srcpad_info)
|
|
|
|
|| GST_VIDEO_INFO_FPS_D (&thiz->sinkpad_info) !=
|
|
|
|
GST_VIDEO_INFO_FPS_D (&thiz->srcpad_info))) {
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_FRC;
|
2021-07-20 10:15:11 +00:00
|
|
|
/* manually set distributed timestamp as frc algorithm
|
|
|
|
* as it is more resonable for framerate conversion
|
|
|
|
*/
|
|
|
|
thiz->frc_algm = MFX_FRCALGM_DISTRIBUTED_TIMESTAMP;
|
2018-03-22 16:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* work-around to avoid zero fps in msdk structure */
|
|
|
|
if (!thiz->param.vpp.In.FrameRateExtN)
|
|
|
|
thiz->param.vpp.In.FrameRateExtN = 30;
|
|
|
|
if (!thiz->param.vpp.Out.FrameRateExtN)
|
|
|
|
thiz->param.vpp.Out.FrameRateExtN = thiz->param.vpp.In.FrameRateExtN;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2018-03-06 13:52:04 +00:00
|
|
|
/* set vpp out picstruct as progressive if deinterlacing enabled */
|
|
|
|
if (thiz->flags & GST_MSDK_FLAG_DEINTERLACE)
|
|
|
|
thiz->param.vpp.Out.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
|
|
|
|
|
2018-06-07 23:28:44 +00:00
|
|
|
/* Enable the required filters */
|
|
|
|
ensure_filters (thiz);
|
|
|
|
|
2019-09-02 19:08:44 +00:00
|
|
|
/* Add extended buffers */
|
2018-06-07 23:28:44 +00:00
|
|
|
if (thiz->num_extra_params) {
|
|
|
|
thiz->param.NumExtParam = thiz->num_extra_params;
|
|
|
|
thiz->param.ExtParam = thiz->extra_params;
|
|
|
|
}
|
|
|
|
|
2021-08-24 09:59:59 +00:00
|
|
|
/* validate parameters and allow MFX to make adjustments */
|
2018-03-06 13:51:05 +00:00
|
|
|
status = MFXVideoVPP_Query (session, &thiz->param, &thiz->param);
|
|
|
|
if (status < MFX_ERR_NONE) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "Video VPP Query failed (%s)",
|
|
|
|
msdk_status_to_string (status));
|
|
|
|
goto no_vpp;
|
|
|
|
} else if (status > MFX_ERR_NONE) {
|
|
|
|
GST_WARNING_OBJECT (thiz, "Video VPP Query returned: %s",
|
|
|
|
msdk_status_to_string (status));
|
|
|
|
}
|
|
|
|
|
|
|
|
status = MFXVideoVPP_QueryIOSurf (session, &thiz->param, request);
|
|
|
|
if (status < MFX_ERR_NONE) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "VPP Query IO surfaces failed (%s)",
|
|
|
|
msdk_status_to_string (status));
|
|
|
|
goto no_vpp;
|
|
|
|
} else if (status > MFX_ERR_NONE) {
|
|
|
|
GST_WARNING_OBJECT (thiz, "VPP Query IO surfaces returned: %s",
|
|
|
|
msdk_status_to_string (status));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thiz->use_video_memory) {
|
|
|
|
/* Input surface pool pre-allocation */
|
2018-04-30 20:39:52 +00:00
|
|
|
request[0].Type |= MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET;
|
|
|
|
if (thiz->use_sinkpad_dmabuf)
|
|
|
|
request[0].Type |= MFX_MEMTYPE_EXPORT_FRAME;
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
/* Output surface pool pre-allocation */
|
2018-04-30 20:39:52 +00:00
|
|
|
request[1].Type |= MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET;
|
|
|
|
if (thiz->use_srcpad_dmabuf)
|
|
|
|
request[1].Type |= MFX_MEMTYPE_EXPORT_FRAME;
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
thiz->in_num_surfaces = request[0].NumFrameSuggested;
|
2018-03-06 13:51:32 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
status = MFXVideoVPP_Init (session, &thiz->param);
|
|
|
|
if (status < MFX_ERR_NONE) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "Init failed (%s)", msdk_status_to_string (status));
|
|
|
|
goto no_vpp;
|
|
|
|
} else if (status > MFX_ERR_NONE) {
|
|
|
|
GST_WARNING_OBJECT (thiz, "Init returned: %s",
|
|
|
|
msdk_status_to_string (status));
|
|
|
|
}
|
|
|
|
|
2018-06-07 23:29:29 +00:00
|
|
|
thiz->initialized = TRUE;
|
2018-03-06 13:51:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (thiz);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
no_vpp:
|
|
|
|
GST_OBJECT_UNLOCK (thiz);
|
2020-01-17 08:15:35 +00:00
|
|
|
gst_clear_object (&thiz->context);
|
2018-03-06 13:51:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_set_caps (GstBaseTransform * trans, GstCaps * caps,
|
|
|
|
GstCaps * out_caps)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
GstVideoInfo in_info, out_info;
|
|
|
|
gboolean sinkpad_info_changed = FALSE;
|
|
|
|
gboolean srcpad_info_changed = FALSE;
|
2018-03-06 13:52:04 +00:00
|
|
|
gboolean deinterlace;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2020-09-08 06:43:49 +00:00
|
|
|
if (!gst_caps_features_is_equal (gst_caps_get_features (caps, 0),
|
|
|
|
gst_caps_get_features (out_caps, 0)))
|
2018-04-30 20:40:32 +00:00
|
|
|
thiz->need_vpp = 1;
|
|
|
|
|
2023-05-30 10:01:49 +00:00
|
|
|
thiz->use_sinkpad_dmabuf = gst_msdkcaps_has_feature (caps,
|
|
|
|
GST_CAPS_FEATURE_MEMORY_DMABUF) ? TRUE : FALSE;
|
|
|
|
thiz->use_srcpad_dmabuf = gst_msdkcaps_has_feature (out_caps,
|
|
|
|
GST_CAPS_FEATURE_MEMORY_DMABUF) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (!gst_msdkcaps_video_info_from_caps (caps, &in_info, &thiz->sink_modifier))
|
2022-02-17 07:12:52 +00:00
|
|
|
goto error_no_video_info;
|
2023-05-30 10:01:49 +00:00
|
|
|
if (!gst_msdkcaps_video_info_from_caps (out_caps,
|
|
|
|
&out_info, &thiz->src_modifier))
|
2022-02-17 07:12:52 +00:00
|
|
|
goto error_no_video_info;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
if (!gst_video_info_is_equal (&in_info, &thiz->sinkpad_info))
|
|
|
|
sinkpad_info_changed = TRUE;
|
|
|
|
if (!gst_video_info_is_equal (&out_info, &thiz->srcpad_info))
|
|
|
|
srcpad_info_changed = TRUE;
|
|
|
|
|
2018-12-19 02:44:50 +00:00
|
|
|
if (!sinkpad_info_changed && !srcpad_info_changed && thiz->initialized)
|
|
|
|
return TRUE;
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
thiz->sinkpad_info = in_info;
|
|
|
|
thiz->srcpad_info = out_info;
|
2022-09-07 02:55:57 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
thiz->use_video_memory = TRUE;
|
|
|
|
|
2018-03-06 13:52:04 +00:00
|
|
|
/* check for deinterlace requirement */
|
|
|
|
deinterlace = gst_msdkvpp_is_deinterlace_enabled (thiz, &in_info);
|
|
|
|
if (deinterlace)
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_DEINTERLACE;
|
2018-03-22 16:04:02 +00:00
|
|
|
|
|
|
|
thiz->buffer_duration = GST_VIDEO_INFO_FPS_N (&out_info) > 0 ?
|
|
|
|
gst_util_uint64_scale (GST_SECOND, GST_VIDEO_INFO_FPS_D (&out_info),
|
|
|
|
GST_VIDEO_INFO_FPS_N (&out_info)) : 0;
|
2018-03-06 13:52:04 +00:00
|
|
|
|
2023-08-11 07:20:30 +00:00
|
|
|
thiz->have_mdcv = thiz->have_cll = FALSE;
|
|
|
|
if (gst_video_mastering_display_info_from_caps (&thiz->mdcv_info, caps))
|
|
|
|
thiz->have_mdcv = TRUE;
|
|
|
|
|
|
|
|
if (gst_video_content_light_level_from_caps (&thiz->cll_info, caps))
|
|
|
|
thiz->have_cll = TRUE;
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
if (!gst_msdkvpp_initialize (thiz))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-08-11 07:20:30 +00:00
|
|
|
if (!thiz->hdr_tone_mapping) {
|
|
|
|
if (thiz->have_mdcv) {
|
|
|
|
if (!gst_video_mastering_display_info_add_to_caps (&thiz->mdcv_info,
|
|
|
|
out_caps))
|
|
|
|
GST_WARNING ("Failed to add mastering display info to caps");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thiz->have_cll) {
|
|
|
|
if (!gst_video_content_light_level_add_to_caps (&thiz->cll_info,
|
|
|
|
out_caps))
|
|
|
|
GST_WARNING ("Failed to add content light level to caps");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-07 23:30:23 +00:00
|
|
|
/* set passthrough according to filter operation change */
|
|
|
|
gst_msdkvpp_set_passthrough (thiz);
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
/* Ensure sinkpad buffer pool */
|
2019-08-21 04:27:57 +00:00
|
|
|
if (thiz->sinkpad_buffer_pool)
|
|
|
|
gst_object_unref (thiz->sinkpad_buffer_pool);
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
thiz->sinkpad_buffer_pool =
|
|
|
|
gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps,
|
2022-09-07 02:55:57 +00:00
|
|
|
thiz->in_num_surfaces, FALSE);
|
2018-03-06 13:51:05 +00:00
|
|
|
if (!thiz->sinkpad_buffer_pool) {
|
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to ensure the sinkpad buffer pool");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2022-02-17 07:12:52 +00:00
|
|
|
|
|
|
|
error_no_video_info:
|
|
|
|
GST_ERROR_OBJECT (thiz, "Failed to get video info from caps");
|
|
|
|
return FALSE;
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
|
|
|
gst_msdkvpp_fixate_caps (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
GstCaps *result = NULL;
|
|
|
|
|
2018-04-30 20:39:52 +00:00
|
|
|
if (direction == GST_PAD_SRC) {
|
2023-02-20 02:17:53 +00:00
|
|
|
result = gst_caps_fixate (othercaps);
|
2018-04-30 20:39:52 +00:00
|
|
|
} else {
|
2019-08-23 01:51:20 +00:00
|
|
|
/*
|
|
|
|
* Override mirroring & rotation properties once video-direction
|
|
|
|
* is set explicitly
|
|
|
|
*/
|
|
|
|
if (thiz->flags & GST_MSDK_FLAG_VIDEO_DIRECTION)
|
|
|
|
gst_msdk_get_mfx_video_orientation_from_video_direction
|
|
|
|
(thiz->video_direction, &thiz->mirroring, &thiz->rotation);
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
result = gst_msdkvpp_fixate_srccaps (thiz, caps, othercaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (trans, "fixated to %" GST_PTR_FORMAT, result);
|
|
|
|
gst_caps_unref (othercaps);
|
2018-04-30 20:39:52 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generic code for now, requires changes in future when we
|
|
|
|
* add hardware query for supported formats, Framerate control etc */
|
|
|
|
static GstCaps *
|
|
|
|
gst_msdkvpp_transform_caps (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
|
|
|
{
|
2023-05-30 10:01:49 +00:00
|
|
|
GstCaps *out_caps = NULL;
|
|
|
|
GstCaps *tmp_caps;
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (trans,
|
|
|
|
"Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
|
|
|
|
(direction == GST_PAD_SINK) ? "sink" : "src");
|
|
|
|
|
2023-03-20 12:42:41 +00:00
|
|
|
if (direction == GST_PAD_SINK) {
|
2023-05-30 10:01:49 +00:00
|
|
|
tmp_caps =
|
2023-03-20 12:42:41 +00:00
|
|
|
gst_pad_get_pad_template_caps (GST_BASE_TRANSFORM_SRC_PAD (trans));
|
|
|
|
} else {
|
2023-05-30 10:01:49 +00:00
|
|
|
tmp_caps =
|
2023-03-20 12:42:41 +00:00
|
|
|
gst_pad_get_pad_template_caps (GST_BASE_TRANSFORM_SINK_PAD (trans));
|
|
|
|
}
|
2018-03-06 13:51:05 +00:00
|
|
|
|
2023-05-30 10:01:49 +00:00
|
|
|
if (!out_caps)
|
|
|
|
out_caps = tmp_caps;
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
if (out_caps && filter) {
|
|
|
|
GstCaps *intersection;
|
|
|
|
|
|
|
|
intersection = gst_caps_intersect_full (out_caps, filter,
|
|
|
|
GST_CAPS_INTERSECT_FIRST);
|
|
|
|
gst_caps_unref (out_caps);
|
|
|
|
out_caps = intersection;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, out_caps);
|
|
|
|
return out_caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_start (GstBaseTransform * trans)
|
|
|
|
{
|
|
|
|
if (!ensure_context (trans))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_stop (GstBaseTransform * trans)
|
|
|
|
{
|
|
|
|
gst_msdkvpp_close (GST_MSDKVPP (trans));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-08-17 14:36:59 +00:00
|
|
|
static gboolean
|
|
|
|
gst_msdkvpp_query (GstBaseTransform * trans, GstPadDirection direction,
|
|
|
|
GstQuery * query)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (trans);
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_CONTEXT:{
|
|
|
|
GstMsdkContext *msdk_context = NULL;
|
|
|
|
|
|
|
|
gst_object_replace ((GstObject **) & msdk_context,
|
|
|
|
(GstObject *) thiz->context);
|
|
|
|
ret = gst_msdk_handle_context_query (GST_ELEMENT_CAST (trans),
|
|
|
|
query, msdk_context);
|
|
|
|
gst_clear_object (&msdk_context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans,
|
|
|
|
direction, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
static void
|
|
|
|
gst_msdkvpp_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_HARDWARE:
|
|
|
|
thiz->hardware = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case PROP_ASYNC_DEPTH:
|
|
|
|
thiz->async_depth = g_value_get_uint (value);
|
|
|
|
break;
|
2018-03-06 13:51:32 +00:00
|
|
|
case PROP_DENOISE:
|
|
|
|
thiz->denoise_factor = g_value_get_uint (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_DENOISE;
|
|
|
|
break;
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-06 13:51:32 +00:00
|
|
|
case PROP_ROTATION:
|
|
|
|
thiz->rotation = g_value_get_enum (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_ROTATION;
|
|
|
|
break;
|
2019-08-23 01:51:20 +00:00
|
|
|
case PROP_MIRRORING:
|
|
|
|
thiz->mirroring = g_value_get_enum (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_MIRRORING;
|
|
|
|
break;
|
|
|
|
#endif
|
2018-03-06 13:52:04 +00:00
|
|
|
case PROP_DEINTERLACE_MODE:
|
|
|
|
thiz->deinterlace_mode = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case PROP_DEINTERLACE_METHOD:
|
|
|
|
thiz->deinterlace_method = g_value_get_enum (value);
|
|
|
|
break;
|
2018-03-21 14:45:35 +00:00
|
|
|
case PROP_HUE:
|
|
|
|
thiz->hue = g_value_get_float (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_HUE;
|
|
|
|
break;
|
|
|
|
case PROP_SATURATION:
|
|
|
|
thiz->saturation = g_value_get_float (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_SATURATION;
|
|
|
|
break;
|
|
|
|
case PROP_BRIGHTNESS:
|
|
|
|
thiz->brightness = g_value_get_float (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_BRIGHTNESS;
|
|
|
|
break;
|
|
|
|
case PROP_CONTRAST:
|
|
|
|
thiz->contrast = g_value_get_float (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_CONTRAST;
|
|
|
|
break;
|
2018-03-21 17:14:04 +00:00
|
|
|
case PROP_DETAIL:
|
|
|
|
thiz->detail = g_value_get_uint (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_DETAIL;
|
|
|
|
break;
|
2018-03-21 17:57:27 +00:00
|
|
|
case PROP_SCALING_MODE:
|
|
|
|
thiz->scaling_mode = g_value_get_enum (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_SCALING_MODE;
|
|
|
|
break;
|
2024-07-30 09:27:49 +00:00
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
case PROP_INTERPOLATION_METHOD:
|
|
|
|
thiz->interpolation_method = g_value_get_enum (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_INTERPOLATION_METHOD;
|
|
|
|
break;
|
|
|
|
#endif
|
2018-03-21 18:17:11 +00:00
|
|
|
case PROP_FORCE_ASPECT_RATIO:
|
|
|
|
thiz->keep_aspect = g_value_get_boolean (value);
|
|
|
|
break;
|
2018-03-22 16:04:02 +00:00
|
|
|
case PROP_FRC_ALGORITHM:
|
|
|
|
thiz->frc_algm = g_value_get_enum (value);
|
|
|
|
break;
|
2019-08-23 01:51:20 +00:00
|
|
|
case PROP_VIDEO_DIRECTION:
|
|
|
|
thiz->video_direction = g_value_get_enum (value);
|
|
|
|
thiz->flags |= GST_MSDK_FLAG_VIDEO_DIRECTION;
|
|
|
|
break;
|
2019-10-16 18:59:32 +00:00
|
|
|
case PROP_CROP_LEFT:
|
|
|
|
thiz->crop_left = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
case PROP_CROP_RIGHT:
|
|
|
|
thiz->crop_right = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
case PROP_CROP_TOP:
|
|
|
|
thiz->crop_top = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
case PROP_CROP_BOTTOM:
|
|
|
|
thiz->crop_bottom = g_value_get_uint (value);
|
|
|
|
break;
|
2023-08-11 07:20:30 +00:00
|
|
|
case PROP_HDR_TONE_MAPPING:
|
|
|
|
thiz->hdr_tone_mapping = g_value_get_boolean (value);
|
2023-10-10 01:52:48 +00:00
|
|
|
thiz->flags |= (thiz->hdr_tone_mapping ? GST_MSDK_FLAG_TONE_MAPPING : 0);
|
2023-08-11 07:20:30 +00:00
|
|
|
break;
|
2018-03-06 13:51:05 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_msdkvpp_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_HARDWARE:
|
|
|
|
g_value_set_boolean (value, thiz->hardware);
|
|
|
|
break;
|
|
|
|
case PROP_ASYNC_DEPTH:
|
|
|
|
g_value_set_uint (value, thiz->async_depth);
|
|
|
|
break;
|
2018-03-06 13:51:32 +00:00
|
|
|
case PROP_DENOISE:
|
|
|
|
g_value_set_uint (value, thiz->denoise_factor);
|
|
|
|
break;
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-06 13:51:32 +00:00
|
|
|
case PROP_ROTATION:
|
|
|
|
g_value_set_enum (value, thiz->rotation);
|
|
|
|
break;
|
2019-08-23 01:51:20 +00:00
|
|
|
case PROP_MIRRORING:
|
|
|
|
g_value_set_enum (value, thiz->mirroring);
|
|
|
|
break;
|
|
|
|
#endif
|
2018-03-06 13:52:04 +00:00
|
|
|
case PROP_DEINTERLACE_MODE:
|
|
|
|
g_value_set_enum (value, thiz->deinterlace_mode);
|
|
|
|
break;
|
|
|
|
case PROP_DEINTERLACE_METHOD:
|
|
|
|
g_value_set_enum (value, thiz->deinterlace_method);
|
|
|
|
break;
|
2018-03-21 14:45:35 +00:00
|
|
|
case PROP_HUE:
|
|
|
|
g_value_set_float (value, thiz->hue);
|
|
|
|
break;
|
|
|
|
case PROP_SATURATION:
|
|
|
|
g_value_set_float (value, thiz->saturation);
|
|
|
|
break;
|
|
|
|
case PROP_BRIGHTNESS:
|
|
|
|
g_value_set_float (value, thiz->brightness);
|
|
|
|
break;
|
|
|
|
case PROP_CONTRAST:
|
|
|
|
g_value_set_float (value, thiz->contrast);
|
|
|
|
break;
|
2018-03-21 17:14:04 +00:00
|
|
|
case PROP_DETAIL:
|
|
|
|
g_value_set_uint (value, thiz->detail);
|
|
|
|
break;
|
2018-03-21 17:57:27 +00:00
|
|
|
case PROP_SCALING_MODE:
|
|
|
|
g_value_set_enum (value, thiz->scaling_mode);
|
|
|
|
break;
|
2024-07-30 09:27:49 +00:00
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
case PROP_INTERPOLATION_METHOD:
|
|
|
|
g_value_set_enum (value, thiz->interpolation_method);
|
|
|
|
break;
|
|
|
|
#endif
|
2018-03-21 18:17:11 +00:00
|
|
|
case PROP_FORCE_ASPECT_RATIO:
|
|
|
|
g_value_set_boolean (value, thiz->keep_aspect);
|
|
|
|
break;
|
2018-03-22 16:04:02 +00:00
|
|
|
case PROP_FRC_ALGORITHM:
|
|
|
|
g_value_set_enum (value, thiz->frc_algm);
|
|
|
|
break;
|
2019-08-23 01:51:20 +00:00
|
|
|
case PROP_VIDEO_DIRECTION:
|
|
|
|
g_value_set_enum (value, thiz->video_direction);
|
|
|
|
break;
|
2019-10-16 18:59:32 +00:00
|
|
|
case PROP_CROP_LEFT:
|
|
|
|
g_value_set_uint (value, thiz->crop_left);
|
|
|
|
break;
|
|
|
|
case PROP_CROP_RIGHT:
|
|
|
|
g_value_set_uint (value, thiz->crop_right);
|
|
|
|
break;
|
|
|
|
case PROP_CROP_TOP:
|
|
|
|
g_value_set_uint (value, thiz->crop_top);
|
|
|
|
break;
|
|
|
|
case PROP_CROP_BOTTOM:
|
|
|
|
g_value_set_uint (value, thiz->crop_bottom);
|
|
|
|
break;
|
2023-08-11 07:20:30 +00:00
|
|
|
case PROP_HDR_TONE_MAPPING:
|
|
|
|
g_value_set_boolean (value, thiz->hdr_tone_mapping);
|
|
|
|
break;
|
2018-03-06 13:51:05 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-01-29 05:02:09 +00:00
|
|
|
gst_msdkvpp_dispose (GObject * object)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
2020-01-17 05:37:47 +00:00
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (object);
|
|
|
|
|
|
|
|
gst_clear_object (&thiz->old_context);
|
|
|
|
|
2020-01-29 05:02:09 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_msdkvpp_set_context (GstElement * element, GstContext * context)
|
|
|
|
{
|
|
|
|
GstMsdkContext *msdk_context = NULL;
|
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (element);
|
|
|
|
|
|
|
|
if (gst_msdk_context_get_context (context, &msdk_context)) {
|
|
|
|
gst_object_replace ((GstObject **) & thiz->context,
|
|
|
|
(GstObject *) msdk_context);
|
|
|
|
gst_object_unref (msdk_context);
|
2022-05-07 09:10:34 +00:00
|
|
|
} else
|
|
|
|
#ifndef _WIN32
|
2024-02-26 14:19:57 +00:00
|
|
|
if (gst_msdk_context_from_external_va_display (context,
|
|
|
|
thiz->hardware, GST_MSDK_JOB_VPP, &msdk_context)) {
|
2021-08-17 13:51:58 +00:00
|
|
|
gst_object_replace ((GstObject **) & thiz->context,
|
|
|
|
(GstObject *) msdk_context);
|
|
|
|
gst_object_unref (msdk_context);
|
2018-03-06 13:51:05 +00:00
|
|
|
}
|
2022-05-07 09:10:34 +00:00
|
|
|
#else
|
2024-02-26 14:19:57 +00:00
|
|
|
if (gst_msdk_context_from_external_d3d11_device (context,
|
|
|
|
thiz->hardware, GST_MSDK_JOB_VPP, &msdk_context)) {
|
2022-05-07 09:10:34 +00:00
|
|
|
gst_object_replace ((GstObject **) & thiz->context,
|
|
|
|
(GstObject *) msdk_context);
|
|
|
|
gst_object_unref (msdk_context);
|
|
|
|
}
|
|
|
|
#endif
|
2018-03-06 13:51:05 +00:00
|
|
|
|
|
|
|
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-03-20 12:42:41 +00:00
|
|
|
_msdkvpp_install_properties (GObjectClass * gobject_class)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
|
|
|
GParamSpec *obj_properties[PROP_N] = { NULL, };
|
|
|
|
|
|
|
|
obj_properties[PROP_HARDWARE] =
|
|
|
|
g_param_spec_boolean ("hardware", "Hardware", "Enable hardware VPP",
|
|
|
|
PROP_HARDWARE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_ASYNC_DEPTH] =
|
|
|
|
g_param_spec_uint ("async-depth", "Async Depth",
|
|
|
|
"Depth of asynchronous pipeline",
|
|
|
|
1, 1, PROP_ASYNC_DEPTH_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-03-06 13:51:32 +00:00
|
|
|
obj_properties[PROP_DENOISE] =
|
|
|
|
g_param_spec_uint ("denoise", "Denoising factor",
|
|
|
|
"Denoising Factor",
|
|
|
|
0, 100, PROP_DENOISE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-06 13:51:32 +00:00
|
|
|
obj_properties[PROP_ROTATION] =
|
|
|
|
g_param_spec_enum ("rotation", "Rotation",
|
2019-08-23 01:51:20 +00:00
|
|
|
"Rotation Angle (DEPRECATED, use video-direction instead)",
|
|
|
|
gst_msdkvpp_rotation_get_type (), PROP_ROTATION_DEFAULT,
|
|
|
|
G_PARAM_DEPRECATED | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_MIRRORING] =
|
|
|
|
g_param_spec_enum ("mirroring", "Mirroring",
|
|
|
|
"The Mirroring type (DEPRECATED, use video-direction instead)",
|
|
|
|
gst_msdkvpp_mirroring_get_type (), PROP_MIRRORING_DEFAULT,
|
|
|
|
G_PARAM_DEPRECATED | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
#endif
|
2018-03-06 13:51:32 +00:00
|
|
|
|
2018-03-06 13:52:04 +00:00
|
|
|
obj_properties[PROP_DEINTERLACE_MODE] =
|
|
|
|
g_param_spec_enum ("deinterlace-mode", "Deinterlace Mode",
|
|
|
|
"Deinterlace mode to use", gst_msdkvpp_deinterlace_mode_get_type (),
|
|
|
|
PROP_DEINTERLACE_MODE_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_DEINTERLACE_METHOD] =
|
|
|
|
g_param_spec_enum ("deinterlace-method", "Deinterlace Method",
|
|
|
|
"Deinterlace method to use", gst_msdkvpp_deinterlace_method_get_type (),
|
|
|
|
PROP_DEINTERLACE_METHOD_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-03-21 14:45:35 +00:00
|
|
|
obj_properties[PROP_HUE] =
|
|
|
|
g_param_spec_float ("hue", "Hue",
|
|
|
|
"The hue of the video",
|
|
|
|
-180, 180, PROP_HUE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_SATURATION] =
|
|
|
|
g_param_spec_float ("saturation", "Saturation",
|
|
|
|
"The Saturation of the video",
|
|
|
|
0, 10, PROP_SATURATION_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_BRIGHTNESS] =
|
|
|
|
g_param_spec_float ("brightness", "Brightness",
|
|
|
|
"The Brightness of the video",
|
|
|
|
-100, 100, PROP_BRIGHTNESS_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_CONTRAST] =
|
|
|
|
g_param_spec_float ("contrast", "Contrast",
|
|
|
|
"The Contrast of the video",
|
|
|
|
0, 10, PROP_CONTRAST_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-03-21 17:14:04 +00:00
|
|
|
obj_properties[PROP_DETAIL] =
|
|
|
|
g_param_spec_uint ("detail", "Detail",
|
|
|
|
"The factor of detail/edge enhancement filter algorithm",
|
|
|
|
0, 100, PROP_DETAIL_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-03-21 17:57:27 +00:00
|
|
|
obj_properties[PROP_SCALING_MODE] =
|
|
|
|
g_param_spec_enum ("scaling-mode", "Scaling Mode",
|
|
|
|
"The Scaling mode to use", gst_msdkvpp_scaling_mode_get_type (),
|
|
|
|
PROP_SCALING_MODE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2024-07-30 09:27:49 +00:00
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
obj_properties[PROP_INTERPOLATION_METHOD] =
|
|
|
|
g_param_spec_enum ("interpolation-method", "Interpolation Method",
|
|
|
|
"The Interpolation method used for scaling, note that not all interpolation-methods "
|
|
|
|
"may be compatible with all scaling-modes",
|
|
|
|
gst_msdkvpp_interpolation_method_get_type (),
|
|
|
|
PROP_INTERPOLATION_METHOD_DEFAULT, G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
#endif
|
|
|
|
|
2018-03-21 18:17:11 +00:00
|
|
|
obj_properties[PROP_FORCE_ASPECT_RATIO] =
|
|
|
|
g_param_spec_boolean ("force-aspect-ratio", "Force Aspect Ratio",
|
|
|
|
"When enabled, scaling will respect original aspect ratio",
|
|
|
|
PROP_FORCE_ASPECT_RATIO_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-03-22 16:04:02 +00:00
|
|
|
obj_properties[PROP_FRC_ALGORITHM] =
|
|
|
|
g_param_spec_enum ("frc-algorithm", "FrameRateControl Algorithm",
|
|
|
|
"The Framerate Control Alogorithm to use",
|
|
|
|
gst_msdkvpp_frc_algorithm_get_type (), PROP_FRC_ALGORITHM_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-08-23 01:51:20 +00:00
|
|
|
/*
|
|
|
|
* The video-direction to use, expressed as an enum value. See
|
|
|
|
* #GstVideoOrientationMethod.
|
|
|
|
*/
|
|
|
|
obj_properties[PROP_VIDEO_DIRECTION] = g_param_spec_enum ("video-direction",
|
|
|
|
"Video Direction", "Video direction: rotation and flipping"
|
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
|
|
|
", it will override both mirroring & rotation properties if set explicitly"
|
|
|
|
#endif
|
|
|
|
,
|
|
|
|
GST_TYPE_VIDEO_ORIENTATION_METHOD,
|
|
|
|
PROP_VIDEO_DIRECTION_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-10-16 18:59:32 +00:00
|
|
|
obj_properties[PROP_CROP_LEFT] = g_param_spec_uint ("crop-left",
|
|
|
|
"Crop Left", "Pixels to crop at left",
|
|
|
|
0, G_MAXUINT16, PROP_CROP_LEFT_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_CROP_RIGHT] = g_param_spec_uint ("crop-right",
|
|
|
|
"Crop Right", "Pixels to crop at right",
|
|
|
|
0, G_MAXUINT16, PROP_CROP_RIGHT_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_CROP_TOP] = g_param_spec_uint ("crop-top",
|
|
|
|
"Crop Top", "Pixels to crop at top",
|
|
|
|
0, G_MAXUINT16, PROP_CROP_TOP_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_properties[PROP_CROP_BOTTOM] = g_param_spec_uint ("crop-bottom",
|
|
|
|
"Crop Bottom", "Pixels to crop at bottom",
|
|
|
|
0, G_MAXUINT16, PROP_CROP_BOTTOM_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
2023-08-11 07:20:30 +00:00
|
|
|
/**
|
|
|
|
* GstMsdkVPP:hdr-tone-mapping:
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
obj_properties[PROP_HDR_TONE_MAPPING] =
|
|
|
|
g_param_spec_boolean ("hdr-tone-mapping", "HDR tone mapping",
|
|
|
|
"Enable HDR to SDR tone mapping (supported from TGL platforms)",
|
|
|
|
PROP_HDR_TONE_MAPPING_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
2019-10-16 18:59:32 +00:00
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
g_object_class_install_properties (gobject_class, PROP_N, obj_properties);
|
|
|
|
}
|
|
|
|
|
2023-03-20 12:42:41 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_msdkvpp_class_init (gpointer klass, gpointer data)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *element_class;
|
|
|
|
GstBaseTransformClass *trans_class;
|
|
|
|
MsdkVPPCData *cdata = data;
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
trans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_msdkvpp_set_property;
|
|
|
|
gobject_class->get_property = gst_msdkvpp_get_property;
|
|
|
|
gobject_class->dispose = gst_msdkvpp_dispose;
|
|
|
|
|
|
|
|
_msdkvpp_install_properties (gobject_class);
|
|
|
|
|
|
|
|
trans_class->start = GST_DEBUG_FUNCPTR (gst_msdkvpp_start);
|
|
|
|
trans_class->stop = GST_DEBUG_FUNCPTR (gst_msdkvpp_stop);
|
|
|
|
trans_class->transform_caps = GST_DEBUG_FUNCPTR (gst_msdkvpp_transform_caps);
|
|
|
|
trans_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_msdkvpp_fixate_caps);
|
|
|
|
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_msdkvpp_set_caps);
|
|
|
|
trans_class->transform = GST_DEBUG_FUNCPTR (gst_msdkvpp_transform);
|
|
|
|
trans_class->propose_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_msdkvpp_propose_allocation);
|
|
|
|
trans_class->decide_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_msdkvpp_decide_allocation);
|
|
|
|
trans_class->prepare_output_buffer =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_msdkvpp_prepare_output_buffer);
|
|
|
|
trans_class->query = GST_DEBUG_FUNCPTR (gst_msdkvpp_query);
|
|
|
|
|
|
|
|
element_class->set_context = gst_msdkvpp_set_context;
|
|
|
|
|
|
|
|
gst_element_class_set_static_metadata (element_class,
|
|
|
|
"Intel MSDK Video Postprocessor",
|
|
|
|
"Filter/Converter/Video;Filter/Converter/Video/Scaler;"
|
|
|
|
"Filter/Effect/Video;Filter/Effect/Video/Deinterlace",
|
|
|
|
"Video Postprocessing Filter based on " MFX_API_SDK,
|
|
|
|
"Sreerenj Balachandrn <sreerenj.balachandran@intel.com>");
|
|
|
|
|
|
|
|
gst_msdkcaps_pad_template_init (element_class,
|
|
|
|
cdata->sink_caps, cdata->src_caps, doc_sink_caps_str, doc_src_caps_str);
|
|
|
|
|
|
|
|
gst_caps_unref (cdata->sink_caps);
|
|
|
|
gst_caps_unref (cdata->src_caps);
|
|
|
|
g_free (cdata);
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:51:05 +00:00
|
|
|
static void
|
2023-03-20 12:42:41 +00:00
|
|
|
gst_msdkvpp_init (GTypeInstance * instance, gpointer g_class)
|
2018-03-06 13:51:05 +00:00
|
|
|
{
|
2023-03-20 12:42:41 +00:00
|
|
|
GstMsdkVPP *thiz = GST_MSDKVPP (instance);
|
2018-06-07 23:29:29 +00:00
|
|
|
thiz->initialized = FALSE;
|
2018-03-06 13:51:05 +00:00
|
|
|
thiz->hardware = PROP_HARDWARE_DEFAULT;
|
|
|
|
thiz->async_depth = PROP_ASYNC_DEPTH_DEFAULT;
|
2018-03-06 13:51:32 +00:00
|
|
|
thiz->denoise_factor = PROP_DENOISE_DEFAULT;
|
2019-08-23 01:51:20 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2018-03-06 13:51:32 +00:00
|
|
|
thiz->rotation = PROP_ROTATION_DEFAULT;
|
2019-08-23 01:51:20 +00:00
|
|
|
thiz->mirroring = PROP_MIRRORING_DEFAULT;
|
|
|
|
#else
|
|
|
|
thiz->rotation = MFX_ANGLE_0;
|
|
|
|
thiz->mirroring = MFX_MIRRORING_DISABLED;
|
|
|
|
#endif
|
2018-03-06 13:52:04 +00:00
|
|
|
thiz->deinterlace_mode = PROP_DEINTERLACE_MODE_DEFAULT;
|
|
|
|
thiz->deinterlace_method = PROP_DEINTERLACE_METHOD_DEFAULT;
|
2018-03-22 16:04:02 +00:00
|
|
|
thiz->buffer_duration = GST_CLOCK_TIME_NONE;
|
2018-03-21 14:45:35 +00:00
|
|
|
thiz->hue = PROP_HUE_DEFAULT;
|
|
|
|
thiz->saturation = PROP_SATURATION_DEFAULT;
|
|
|
|
thiz->brightness = PROP_BRIGHTNESS_DEFAULT;
|
|
|
|
thiz->contrast = PROP_CONTRAST_DEFAULT;
|
2018-03-21 17:14:04 +00:00
|
|
|
thiz->detail = PROP_DETAIL_DEFAULT;
|
2018-03-21 17:57:27 +00:00
|
|
|
thiz->scaling_mode = PROP_SCALING_MODE_DEFAULT;
|
2024-07-30 09:27:49 +00:00
|
|
|
#if (MFX_VERSION >= 1033)
|
|
|
|
thiz->interpolation_method = PROP_INTERPOLATION_METHOD_DEFAULT;
|
|
|
|
#endif
|
2018-03-21 18:17:11 +00:00
|
|
|
thiz->keep_aspect = PROP_FORCE_ASPECT_RATIO_DEFAULT;
|
2018-03-22 16:04:02 +00:00
|
|
|
thiz->frc_algm = PROP_FRC_ALGORITHM_DEFAULT;
|
2019-08-23 01:51:20 +00:00
|
|
|
thiz->video_direction = PROP_VIDEO_DIRECTION_DEFAULT;
|
2019-10-16 18:59:32 +00:00
|
|
|
thiz->crop_left = PROP_CROP_LEFT_DEFAULT;
|
|
|
|
thiz->crop_right = PROP_CROP_RIGHT_DEFAULT;
|
|
|
|
thiz->crop_top = PROP_CROP_TOP_DEFAULT;
|
|
|
|
thiz->crop_bottom = PROP_CROP_BOTTOM_DEFAULT;
|
2023-08-11 07:20:30 +00:00
|
|
|
thiz->hdr_tone_mapping = PROP_HDR_TONE_MAPPING_DEFAULT;
|
2023-05-30 10:01:49 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
thiz->sink_modifier = DRM_FORMAT_MOD_INVALID;
|
|
|
|
thiz->src_modifier = DRM_FORMAT_MOD_INVALID;
|
|
|
|
#endif
|
2018-03-06 13:51:05 +00:00
|
|
|
gst_video_info_init (&thiz->sinkpad_info);
|
|
|
|
gst_video_info_init (&thiz->srcpad_info);
|
|
|
|
}
|
2023-03-20 12:42:41 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_msdkvpp_register (GstPlugin * plugin,
|
|
|
|
GstMsdkContext * context, GstCaps * sink_caps,
|
|
|
|
GstCaps * src_caps, guint rank)
|
|
|
|
{
|
|
|
|
GType type;
|
|
|
|
MsdkVPPCData *cdata;
|
|
|
|
gchar *type_name, *feature_name;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
GTypeInfo type_info = {
|
|
|
|
.class_size = sizeof (GstMsdkVPPClass),
|
|
|
|
.class_init = gst_msdkvpp_class_init,
|
|
|
|
.instance_size = sizeof (GstMsdkVPP),
|
|
|
|
.instance_init = gst_msdkvpp_init
|
|
|
|
};
|
|
|
|
|
|
|
|
cdata = g_new (MsdkVPPCData, 1);
|
|
|
|
cdata->sink_caps = gst_caps_ref (sink_caps);
|
|
|
|
cdata->src_caps = gst_caps_ref (src_caps);
|
|
|
|
|
|
|
|
GST_MINI_OBJECT_FLAG_SET (cdata->sink_caps,
|
|
|
|
GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
GST_MINI_OBJECT_FLAG_SET (cdata->src_caps,
|
|
|
|
GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
|
|
|
|
|
|
|
|
type_info.class_data = cdata;
|
|
|
|
|
|
|
|
type_name = g_strdup ("GstMsdkVPP");
|
|
|
|
feature_name = g_strdup ("msdkvpp");
|
|
|
|
|
|
|
|
type = g_type_register_static (GST_TYPE_BASE_TRANSFORM,
|
|
|
|
type_name, &type_info, 0);
|
|
|
|
if (type)
|
|
|
|
ret = gst_element_register (plugin, feature_name, rank, type);
|
|
|
|
|
|
|
|
g_free (type_name);
|
|
|
|
g_free (feature_name);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|