mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
Remove all FEI related
FEI encoders are not actively mantained neither tested, and it is using infrastructure that is changing and FEI is stopping this effort. Also it is required to rethink how FEI can be used in GStreamer.
This commit is contained in:
parent
1364070eca
commit
9da5196b5a
39 changed files with 1 additions and 12794 deletions
|
@ -54,19 +54,6 @@ coded_buffer_proxy_finalize (GstVaapiCodedBufferProxy * proxy)
|
|||
/* Notify the user function that the object is now destroyed */
|
||||
if (proxy->destroy_func)
|
||||
proxy->destroy_func (proxy->destroy_data);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
if (proxy->mbcode)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mbcode, NULL);
|
||||
if (proxy->mv)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mv, NULL);
|
||||
if (proxy->dist)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->dist, NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
|
@ -108,11 +95,6 @@ gst_vaapi_coded_buffer_proxy_new_from_pool (GstVaapiCodedBufferPool * pool)
|
|||
proxy->user_data_destroy = NULL;
|
||||
proxy->pool = gst_vaapi_video_pool_ref (GST_VAAPI_VIDEO_POOL (pool));
|
||||
proxy->buffer = gst_vaapi_video_pool_get_object (proxy->pool);
|
||||
#if USE_H264_FEI_ENCODER
|
||||
proxy->mv = NULL;
|
||||
proxy->mbcode = NULL;
|
||||
proxy->dist = NULL;
|
||||
#endif
|
||||
if (!proxy->buffer)
|
||||
goto error;
|
||||
gst_mini_object_ref (GST_MINI_OBJECT_CAST (proxy->buffer));
|
||||
|
@ -272,104 +254,3 @@ gst_vaapi_coded_buffer_proxy_set_user_data (GstVaapiCodedBufferProxy * proxy,
|
|||
|
||||
coded_buffer_proxy_set_user_data (proxy, user_data, destroy_func);
|
||||
}
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
|
||||
/**
|
||||
* gst_vaapi_coded_buffer_proxy_get_fei_mb_code:
|
||||
* @proxy: a #GstVaapiCodedBufferProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiMbCode stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiMbcode, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiMbCode *
|
||||
gst_vaapi_coded_buffer_proxy_get_fei_mbcode (GstVaapiCodedBufferProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, 0);
|
||||
return proxy->mbcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_coded_buffer_proxy_get_fei_mv:
|
||||
* @proxy: a #GstVaapiCodedBufferProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiMv stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiMv, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiMv *
|
||||
gst_vaapi_coded_buffer_proxy_get_fei_mv (GstVaapiCodedBufferProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, 0);
|
||||
return proxy->mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_coded_buffer_proxy_get_fei_distortion:
|
||||
* @proxy: a #GstVaapiCodedBufferProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiDistortion stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiDistortion, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiDistortion *
|
||||
gst_vaapi_coded_buffer_proxy_get_fei_distortion (GstVaapiCodedBufferProxy *
|
||||
proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, 0);
|
||||
return proxy->dist;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_coded_buffer_proxy_set_fei_mb_code:
|
||||
* @proxy: #GstVaapiCodedBufferProxy
|
||||
* @mbcode: the #GstVaapiEncFeiMbCode to be stored in @proxy
|
||||
*
|
||||
* Associates the @mbcode with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_coded_buffer_proxy_set_fei_mb_code (GstVaapiCodedBufferProxy * proxy,
|
||||
GstVaapiEncFeiMbCode * mbcode)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mbcode, (GstVaapiFeiCodecObject *) mbcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_coded_buffer_proxy_set_fei_mv:
|
||||
* @proxy: #GstVaapiCodedBufferProxy
|
||||
* @mv: the #GstVaapiEncFeiMv to be stored in @proxy
|
||||
*
|
||||
* Associates the @mv with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_coded_buffer_proxy_set_fei_mv (GstVaapiCodedBufferProxy * proxy,
|
||||
GstVaapiEncFeiMv * mv)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mv, (GstVaapiFeiCodecObject *) mv);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_coded_buffer_proxy_set_fei_distortion:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @dist: the #GstVaapiEncFeiDistortion to be stored in @proxy
|
||||
*
|
||||
* Associates the @dist with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_coded_buffer_proxy_set_fei_distortion (GstVaapiCodedBufferProxy *
|
||||
proxy, GstVaapiEncFeiDistortion * dist)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->dist, (GstVaapiFeiCodecObject *) dist);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
#include <gst/vaapi/gstvaapicodedbuffer.h>
|
||||
#include <gst/vaapi/gstvaapicodedbufferpool.h>
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
|
@ -81,29 +77,6 @@ void
|
|||
gst_vaapi_coded_buffer_proxy_set_user_data (GstVaapiCodedBufferProxy * proxy,
|
||||
gpointer user_data, GDestroyNotify destroy_func);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
|
||||
GstVaapiEncFeiMbCode *
|
||||
gst_vaapi_coded_buffer_proxy_get_fei_mbcode (GstVaapiCodedBufferProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiMv *
|
||||
gst_vaapi_coded_buffer_proxy_get_fei_mv (GstVaapiCodedBufferProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiDistortion *
|
||||
gst_vaapi_coded_buffer_proxy_get_fei_distortion (GstVaapiCodedBufferProxy * proxy);
|
||||
|
||||
void
|
||||
gst_vaapi_coded_buffer_proxy_set_fei_mb_code (GstVaapiCodedBufferProxy * proxy,
|
||||
GstVaapiEncFeiMbCode *mbcode);
|
||||
void
|
||||
gst_vaapi_coded_buffer_proxy_set_fei_mv (GstVaapiCodedBufferProxy * proxy,
|
||||
GstVaapiEncFeiMv *mv);
|
||||
void
|
||||
gst_vaapi_coded_buffer_proxy_set_fei_distortion (GstVaapiCodedBufferProxy * proxy,
|
||||
GstVaapiEncFeiDistortion *dist);
|
||||
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_CODED_BUFFER_PROXY_H */
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
#include "gstvaapicodedbuffer_priv.h"
|
||||
#include "gstvaapiminiobject.h"
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_CODED_BUFFER_PROXY(proxy) \
|
||||
|
@ -46,12 +42,6 @@ struct _GstVaapiCodedBufferProxy
|
|||
gpointer destroy_data;
|
||||
GDestroyNotify user_data_destroy;
|
||||
gpointer user_data;
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
GstVaapiEncFeiMbCode *mbcode;
|
||||
GstVaapiEncFeiMv *mv;
|
||||
GstVaapiEncFeiDistortion *dist;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -317,14 +317,6 @@ config_create (GstVaapiContext * context)
|
|||
attrib = &attribs[++attrib_index];
|
||||
g_assert (attrib_index < G_N_ELEMENTS (attribs));
|
||||
}
|
||||
#endif
|
||||
#if USE_H264_FEI_ENCODER
|
||||
if (cip->entrypoint == GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI) {
|
||||
attrib->type = (VAConfigAttribType) VAConfigAttribFEIFunctionType;
|
||||
attrib = &attribs[++attrib_index];
|
||||
g_assert (attrib_index < G_N_ELEMENTS (attribs));
|
||||
/* FIXME: Query the read-only supported MV predictors */
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ typedef enum {
|
|||
* @packed_headers: notify encoder that packed headers are submitted (mask).
|
||||
* @roi_capability: if encoder supports regions-of-interest.
|
||||
* @roi_num_supported: The number of regions-of-interest supported.
|
||||
* @fei_function: The functional mode for FEI Entrypoint (VA_FEI_FUNCTION_*).
|
||||
*
|
||||
* Extra configuration for encoding.
|
||||
*/
|
||||
|
@ -72,7 +71,6 @@ struct _GstVaapiConfigInfoEncoder
|
|||
guint packed_headers;
|
||||
gboolean roi_capability;
|
||||
guint roi_num_supported;
|
||||
guint fei_function;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -538,8 +538,7 @@ ensure_profiles (GstVaapiDisplay * display)
|
|||
g_ptr_array_add (priv->decoders, cfg);
|
||||
if ((cfg->entrypoints & ENTRY_POINT_FLAG (SLICE_ENCODE))
|
||||
|| (cfg->entrypoints & ENTRY_POINT_FLAG (PICTURE_ENCODE))
|
||||
|| (cfg->entrypoints & ENTRY_POINT_FLAG (SLICE_ENCODE_LP))
|
||||
|| (cfg->entrypoints & ENTRY_POINT_FLAG (SLICE_ENCODE_FEI)))
|
||||
|| (cfg->entrypoints & ENTRY_POINT_FLAG (SLICE_ENCODE_LP)))
|
||||
g_ptr_array_add (priv->encoders, cfg);
|
||||
}
|
||||
|
||||
|
|
|
@ -730,7 +730,6 @@ set_context_info (GstVaapiEncoder * encoder)
|
|||
GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
|
||||
const GstVideoFormat format =
|
||||
GST_VIDEO_INFO_FORMAT (GST_VAAPI_ENCODER_VIDEO_INFO (encoder));
|
||||
guint fei_function = config->fei_function;
|
||||
|
||||
g_assert (cip->profile != GST_VAAPI_PROFILE_UNKNOWN);
|
||||
g_assert (cip->entrypoint != GST_VAAPI_ENTRYPOINT_INVALID);
|
||||
|
@ -748,7 +747,6 @@ set_context_info (GstVaapiEncoder * encoder)
|
|||
config->packed_headers = get_packed_headers (encoder);
|
||||
config->roi_capability =
|
||||
get_roi_capability (encoder, &config->roi_num_supported);
|
||||
config->fei_function = fei_function;
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -827,13 +825,6 @@ gst_vaapi_encoder_reconfigure_internal (GstVaapiEncoder * encoder)
|
|||
if (!gst_vaapi_encoder_ensure_context (encoder))
|
||||
goto error_reset_context;
|
||||
|
||||
/* Currently only FEI entrypoint needed this.
|
||||
* FEI ENC+PAK requires two contexts where the first one is for ENC
|
||||
* and the second one is for PAK */
|
||||
if (klass->ensure_secondary_context
|
||||
&& !klass->ensure_secondary_context (encoder))
|
||||
goto error_reset_secondary_context;
|
||||
|
||||
#if VA_CHECK_VERSION(0,36,0)
|
||||
if (get_config_attribute (encoder, VAConfigAttribEncQualityRange,
|
||||
&quality_level_max) && quality_level_max > 0) {
|
||||
|
@ -888,11 +879,6 @@ error_reset_context:
|
|||
GST_ERROR ("failed to update VA context");
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
error_reset_secondary_context:
|
||||
{
|
||||
GST_ERROR ("failed to create/update secondary VA context");
|
||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* gstvaapiencoder_h264_fei.h - H.264 FEI encoder
|
||||
*
|
||||
* Copyright (C) 2016-2017 Intel Corporation
|
||||
* Author: Yi A Wang <yi.a.wang@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_ENCODER_H264_FEI_H
|
||||
#define GST_VAAPI_ENCODER_H264_FEI_H
|
||||
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
#include <gst/vaapi/gstvaapiutils_h264.h>
|
||||
#include <gst/vaapi/gstvaapifeiutils_h264.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VAAPI_ENCODER_H264_FEI \
|
||||
(gst_vaapi_encoder_h264_fei_get_type ())
|
||||
#define GST_VAAPI_ENCODER_H264_FEI(encoder) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((encoder), GST_TYPE_VAAPI_ENCODER_H264_FEI, GstVaapiEncoderH264Fei))
|
||||
#define GST_IS_VAAPI_ENCODER_H264_FEI(encoder) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((encoder), GST_TYPE_VAAPI_ENCODER_H264_FEI))
|
||||
|
||||
typedef struct _GstVaapiEncoderH264Fei GstVaapiEncoderH264Fei;
|
||||
typedef struct _GstVaapiEncoderH264FeiClass GstVaapiEncoderH264FeiClass;
|
||||
|
||||
GType
|
||||
gst_vaapi_encoder_h264_fei_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GstVaapiEncoder *
|
||||
gst_vaapi_encoder_h264_fei_new (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_encoder_h264_fei_set_max_profile (GstVaapiEncoderH264Fei * encoder,
|
||||
GstVaapiProfile profile);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_encoder_h264_fei_get_profile_and_level (GstVaapiEncoderH264Fei * encoder,
|
||||
GstVaapiProfile * out_profile_ptr, GstVaapiLevelH264 * out_level_ptr);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_encoder_h264_is_fei_stats_out_enabled (GstVaapiEncoderH264Fei * encoder);
|
||||
|
||||
GstVaapiFeiMode
|
||||
gst_vaapi_encoder_h264_fei_get_function_mode (GstVaapiEncoderH264Fei *encoder);
|
||||
|
||||
void
|
||||
gst_vaapi_encoder_h264_fei_set_function_mode (GstVaapiEncoderH264Fei * encoder,
|
||||
guint fei_mode);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*GST_VAAPI_ENCODER_H264_FEI_H */
|
|
@ -349,15 +349,6 @@ gst_vaapi_enc_picture_destroy (GstVaapiEncPicture * picture)
|
|||
|
||||
gst_vaapi_codec_object_replace (&picture->sequence, NULL);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
gst_vaapi_codec_object_replace (&picture->mvpred, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->mbcntrl, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->qp, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->mbcode, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->mv, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->dist, NULL);
|
||||
#endif
|
||||
|
||||
gst_vaapi_surface_proxy_replace (&picture->proxy, NULL);
|
||||
picture->surface_id = VA_INVALID_ID;
|
||||
picture->surface = NULL;
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
#include <gst/vaapi/gstvaapidecoder_objects.h>
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVaapiEncPicture GstVaapiEncPicture;
|
||||
|
@ -270,14 +266,6 @@ struct _GstVaapiEncPicture
|
|||
guint frame_num;
|
||||
guint poc;
|
||||
guint temporal_id;
|
||||
#if USE_H264_FEI_ENCODER
|
||||
GstVaapiEncFeiMbControl *mbcntrl;
|
||||
GstVaapiEncFeiMvPredictor *mvpred;
|
||||
GstVaapiEncFeiQp *qp;
|
||||
GstVaapiEncFeiMbCode *mbcode;
|
||||
GstVaapiEncFeiMv *mv;
|
||||
GstVaapiEncFeiDistortion *dist;
|
||||
#endif
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
|
|
|
@ -334,9 +334,6 @@ struct _GstVaapiEncoderClass
|
|||
GstVaapiEncoderStatus (*get_codec_data) (GstVaapiEncoder * encoder,
|
||||
GstBuffer ** codec_data);
|
||||
|
||||
/* To create a secondary context for a single base encoder */
|
||||
gboolean (*ensure_secondary_context) (GstVaapiEncoder * encoder);
|
||||
|
||||
/* Iterator that retrieves the pending pictures in the reordered
|
||||
* list */
|
||||
gboolean (*get_pending_reordered) (GstVaapiEncoder * encoder,
|
||||
|
|
|
@ -1,386 +0,0 @@
|
|||
/*
|
||||
* gstvaapifei_objects.c - VA FEI objects abstraction
|
||||
*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "gstvaapiencoder_priv.h"
|
||||
#include "gstvaapicompat.h"
|
||||
#include "gstvaapiutils.h"
|
||||
#include "gstvaapifei_objects.h"
|
||||
#include "gstvaapifei_objects_priv.h"
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Base Codec Object --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_FEI_CODEC_OBJECT_GET_CLASS(object) \
|
||||
gst_vaapi_fei_codec_object_get_class(object)
|
||||
|
||||
const GstVaapiFeiCodecObjectClass *
|
||||
gst_vaapi_fei_codec_object_get_class (GstVaapiFeiCodecObject * object)
|
||||
{
|
||||
return (const GstVaapiFeiCodecObjectClass *)
|
||||
GST_VAAPI_MINI_OBJECT_GET_CLASS (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_fei_codec_object_create (GstVaapiFeiCodecObject * object,
|
||||
const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
const GstVaapiFeiCodecObjectClass *klass;
|
||||
|
||||
g_return_val_if_fail (args->param_size > 0, FALSE);
|
||||
|
||||
if (GST_VAAPI_MINI_OBJECT_FLAG_IS_SET (object,
|
||||
GST_VAAPI_FEI_CODEC_OBJECT_FLAG_CONSTRUCTED))
|
||||
return TRUE;
|
||||
|
||||
klass = GST_VAAPI_FEI_CODEC_OBJECT_GET_CLASS (object);
|
||||
if (!klass->create || !klass->create (object, args))
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_MINI_OBJECT_FLAG_SET (object,
|
||||
GST_VAAPI_FEI_CODEC_OBJECT_FLAG_CONSTRUCTED);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstVaapiFeiCodecObject *
|
||||
gst_vaapi_fei_codec_object_new (const GstVaapiFeiCodecObjectClass *
|
||||
object_class, GstVaapiFeiCodecBase * codec, gconstpointer param,
|
||||
guint param_size, gconstpointer data, guint data_size, guint flags)
|
||||
{
|
||||
GstVaapiFeiCodecObject *obj;
|
||||
GstVaapiFeiCodecObjectConstructorArgs args;
|
||||
|
||||
obj = (GstVaapiFeiCodecObject *)
|
||||
gst_vaapi_mini_object_new0 (GST_VAAPI_MINI_OBJECT_CLASS (object_class));
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
obj = GST_VAAPI_FEI_CODEC_OBJECT (obj);
|
||||
obj->codec = codec;
|
||||
|
||||
args.param = param;
|
||||
args.param_size = param_size;
|
||||
args.data = data;
|
||||
args.data_size = data_size;
|
||||
args.flags = flags;
|
||||
|
||||
if (gst_vaapi_fei_codec_object_create (obj, &args))
|
||||
return obj;
|
||||
|
||||
gst_vaapi_fei_codec_object_unref (obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GstVaapiFeiCodecObject *
|
||||
gst_vaapi_fei_codec_object_ref (GstVaapiFeiCodecObject * object)
|
||||
{
|
||||
return ((GstVaapiFeiCodecObject *)
|
||||
gst_vaapi_mini_object_ref (GST_VAAPI_MINI_OBJECT (object)));
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_fei_codec_object_unref (GstVaapiFeiCodecObject * object)
|
||||
{
|
||||
gst_vaapi_mini_object_unref (GST_VAAPI_MINI_OBJECT (object));
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_fei_codec_object_replace (GstVaapiFeiCodecObject ** old_object_ptr,
|
||||
GstVaapiFeiCodecObject * new_object)
|
||||
{
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) (old_object_ptr),
|
||||
GST_VAAPI_MINI_OBJECT (new_object));
|
||||
}
|
||||
|
||||
/* FeiFixme: map_unlocked and map_lock could be needed */
|
||||
gboolean
|
||||
gst_vaapi_fei_codec_object_map (GstVaapiFeiCodecObject * object,
|
||||
gpointer * data, guint * size)
|
||||
{
|
||||
g_return_val_if_fail (object != NULL, FALSE);
|
||||
|
||||
/*FeiFixme: explicit map if not yet mapped */
|
||||
*data = object->param;
|
||||
*size = object->param_size;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_fei_codec_object_unmap (GstVaapiFeiCodecObject * object)
|
||||
{
|
||||
g_return_if_fail (object != NULL);
|
||||
vaapi_unmap_buffer (GST_VAAPI_ENCODER_CAST (object->codec)->va_display,
|
||||
object->param_id, &object->param);
|
||||
}
|
||||
|
||||
#define GET_ENCODER(obj) GST_VAAPI_ENCODER_CAST((obj)->parent_instance.codec)
|
||||
#define GET_VA_DISPLAY(obj) GET_ENCODER(obj)->va_display
|
||||
#define GET_VA_CONTEXT(obj) GET_ENCODER(obj)->va_context
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- FEI Mb Code buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GST_VAAPI_FEI_CODEC_DEFINE_TYPE (GstVaapiEncFeiMbCode,
|
||||
gst_vaapi_enc_fei_mb_code);
|
||||
|
||||
void
|
||||
gst_vaapi_enc_fei_mb_code_destroy (GstVaapiEncFeiMbCode * fei_mb_code)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mb_code->parent_instance;
|
||||
vaapi_destroy_buffer (GET_VA_DISPLAY (fei_mb_code), &object->param_id);
|
||||
object->param = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_enc_fei_mb_code_create (GstVaapiEncFeiMbCode *
|
||||
fei_mb_code, const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mb_code->parent_instance;
|
||||
object->param_id = VA_INVALID_ID;
|
||||
return vaapi_create_buffer (GET_VA_DISPLAY (fei_mb_code),
|
||||
GET_VA_CONTEXT (fei_mb_code),
|
||||
(VABufferType) VAEncFEIMBCodeBufferType, args->param_size,
|
||||
args->param, &object->param_id, &object->param);
|
||||
}
|
||||
|
||||
GstVaapiEncFeiMbCode *
|
||||
gst_vaapi_enc_fei_mb_code_new (GstVaapiEncoder * encoder,
|
||||
gconstpointer param, guint param_size)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object;
|
||||
|
||||
object = gst_vaapi_fei_codec_object_new (&GstVaapiEncFeiMbCodeClass,
|
||||
GST_VAAPI_FEI_CODEC_BASE (encoder), param, param_size, NULL, 0, 0);
|
||||
if (!object)
|
||||
return NULL;
|
||||
object->param_size = param_size;
|
||||
return GST_VAAPI_ENC_FEI_MB_CODE_CAST (object);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- FEI MV buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GST_VAAPI_FEI_CODEC_DEFINE_TYPE (GstVaapiEncFeiMv, gst_vaapi_enc_fei_mv);
|
||||
|
||||
void
|
||||
gst_vaapi_enc_fei_mv_destroy (GstVaapiEncFeiMv * fei_mv)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mv->parent_instance;
|
||||
vaapi_destroy_buffer (GET_VA_DISPLAY (fei_mv), &object->param_id);
|
||||
object->param = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_enc_fei_mv_create (GstVaapiEncFeiMv *
|
||||
fei_mv, const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mv->parent_instance;
|
||||
object->param_id = VA_INVALID_ID;
|
||||
return vaapi_create_buffer (GET_VA_DISPLAY (fei_mv),
|
||||
GET_VA_CONTEXT (fei_mv),
|
||||
(VABufferType) VAEncFEIMVBufferType, args->param_size,
|
||||
args->param, &object->param_id, &object->param);
|
||||
}
|
||||
|
||||
GstVaapiEncFeiMv *
|
||||
gst_vaapi_enc_fei_mv_new (GstVaapiEncoder * encoder,
|
||||
gconstpointer param, guint param_size)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object;
|
||||
|
||||
object = gst_vaapi_fei_codec_object_new (&GstVaapiEncFeiMvClass,
|
||||
GST_VAAPI_FEI_CODEC_BASE (encoder), param, param_size, NULL, 0, 0);
|
||||
if (!object)
|
||||
return NULL;
|
||||
object->param_size = param_size;
|
||||
return GST_VAAPI_ENC_FEI_NEW_MV_CAST (object);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- FEI Mv predictor buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GST_VAAPI_FEI_CODEC_DEFINE_TYPE (GstVaapiEncFeiMvPredictor,
|
||||
gst_vaapi_enc_fei_mv_predictor);
|
||||
|
||||
void
|
||||
gst_vaapi_enc_fei_mv_predictor_destroy (GstVaapiEncFeiMvPredictor *
|
||||
fei_mv_predictor)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mv_predictor->parent_instance;
|
||||
vaapi_destroy_buffer (GET_VA_DISPLAY (fei_mv_predictor), &object->param_id);
|
||||
object->param = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_enc_fei_mv_predictor_create (GstVaapiEncFeiMvPredictor *
|
||||
fei_mv_predictor, const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mv_predictor->parent_instance;
|
||||
object->param_id = VA_INVALID_ID;
|
||||
return vaapi_create_buffer (GET_VA_DISPLAY (fei_mv_predictor),
|
||||
GET_VA_CONTEXT (fei_mv_predictor),
|
||||
(VABufferType) VAEncFEIMVPredictorBufferType, args->param_size,
|
||||
args->param, &object->param_id, &object->param);
|
||||
}
|
||||
|
||||
GstVaapiEncFeiMvPredictor *
|
||||
gst_vaapi_enc_fei_mv_predictor_new (GstVaapiEncoder * encoder,
|
||||
gconstpointer param, guint param_size)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object;
|
||||
|
||||
object = gst_vaapi_fei_codec_object_new (&GstVaapiEncFeiMvPredictorClass,
|
||||
GST_VAAPI_FEI_CODEC_BASE (encoder), param, param_size, NULL, 0, 0);
|
||||
if (!object)
|
||||
return NULL;
|
||||
object->param_size = param_size;
|
||||
return GST_VAAPI_ENC_FEI_NEW_MV_PREDICTOR_CAST (object);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- FEI Mb Control buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GST_VAAPI_FEI_CODEC_DEFINE_TYPE (GstVaapiEncFeiMbControl,
|
||||
gst_vaapi_enc_fei_mb_control);
|
||||
|
||||
void
|
||||
gst_vaapi_enc_fei_mb_control_destroy (GstVaapiEncFeiMbControl * fei_mb_control)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mb_control->parent_instance;
|
||||
vaapi_destroy_buffer (GET_VA_DISPLAY (fei_mb_control), &object->param_id);
|
||||
object->param = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_enc_fei_mb_control_create (GstVaapiEncFeiMbControl *
|
||||
fei_mb_control, const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_mb_control->parent_instance;
|
||||
object->param_id = VA_INVALID_ID;
|
||||
return vaapi_create_buffer (GET_VA_DISPLAY (fei_mb_control),
|
||||
GET_VA_CONTEXT (fei_mb_control),
|
||||
(VABufferType) VAEncFEIMBControlBufferType, args->param_size,
|
||||
args->param, &object->param_id, &object->param);
|
||||
}
|
||||
|
||||
GstVaapiEncFeiMbControl *
|
||||
gst_vaapi_enc_fei_mb_control_new (GstVaapiEncoder * encoder,
|
||||
gconstpointer param, guint param_size)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object;
|
||||
|
||||
object = gst_vaapi_fei_codec_object_new (&GstVaapiEncFeiMbControlClass,
|
||||
GST_VAAPI_FEI_CODEC_BASE (encoder), param, param_size, NULL, 0, 0);
|
||||
if (!object)
|
||||
return NULL;
|
||||
object->param_size = param_size;
|
||||
return GST_VAAPI_ENC_FEI_NEW_MB_CONTROL_CAST (object);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- FEI qp buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GST_VAAPI_FEI_CODEC_DEFINE_TYPE (GstVaapiEncFeiQp, gst_vaapi_enc_fei_qp);
|
||||
|
||||
void
|
||||
gst_vaapi_enc_fei_qp_destroy (GstVaapiEncFeiQp * fei_qp)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_qp->parent_instance;
|
||||
vaapi_destroy_buffer (GET_VA_DISPLAY (fei_qp), &object->param_id);
|
||||
object->param = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_enc_fei_qp_create (GstVaapiEncFeiQp * fei_qp,
|
||||
const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_qp->parent_instance;
|
||||
object->param_id = VA_INVALID_ID;
|
||||
return vaapi_create_buffer (GET_VA_DISPLAY (fei_qp),
|
||||
GET_VA_CONTEXT (fei_qp),
|
||||
(VABufferType) VAEncQPBufferType, args->param_size,
|
||||
args->param, &object->param_id, &object->param);
|
||||
}
|
||||
|
||||
GstVaapiEncFeiQp *
|
||||
gst_vaapi_enc_fei_qp_new (GstVaapiEncoder * encoder,
|
||||
gconstpointer param, guint param_size)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object;
|
||||
|
||||
object = gst_vaapi_fei_codec_object_new (&GstVaapiEncFeiQpClass,
|
||||
GST_VAAPI_FEI_CODEC_BASE (encoder), param, param_size, NULL, 0, 0);
|
||||
if (!object)
|
||||
return NULL;
|
||||
object->param_size = param_size;
|
||||
return GST_VAAPI_ENC_FEI_NEW_QP_CAST (object);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- FEI Distortion buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GST_VAAPI_FEI_CODEC_DEFINE_TYPE (GstVaapiEncFeiDistortion,
|
||||
gst_vaapi_enc_fei_distortion);
|
||||
|
||||
void
|
||||
gst_vaapi_enc_fei_distortion_destroy (GstVaapiEncFeiDistortion * fei_dist)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_dist->parent_instance;
|
||||
vaapi_destroy_buffer (GET_VA_DISPLAY (fei_dist), &object->param_id);
|
||||
object->param = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_enc_fei_distortion_create (GstVaapiEncFeiDistortion * fei_dist,
|
||||
const GstVaapiFeiCodecObjectConstructorArgs * args)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object = &fei_dist->parent_instance;
|
||||
object->param_id = VA_INVALID_ID;
|
||||
return vaapi_create_buffer (GET_VA_DISPLAY (fei_dist),
|
||||
GET_VA_CONTEXT (fei_dist),
|
||||
(VABufferType) VAEncFEIDistortionBufferType, args->param_size,
|
||||
args->param, &object->param_id, &object->param);
|
||||
}
|
||||
|
||||
GstVaapiEncFeiDistortion *
|
||||
gst_vaapi_enc_fei_distortion_new (GstVaapiEncoder * encoder,
|
||||
gconstpointer param, guint param_size)
|
||||
{
|
||||
GstVaapiFeiCodecObject *object;
|
||||
|
||||
object = gst_vaapi_fei_codec_object_new (&GstVaapiEncFeiDistortionClass,
|
||||
GST_VAAPI_FEI_CODEC_BASE (encoder), param, param_size, NULL, 0, 0);
|
||||
if (!object)
|
||||
return NULL;
|
||||
object->param_size = param_size;
|
||||
return GST_VAAPI_ENC_FEI_NEW_DISTORTION_CAST (object);
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* gstvaapifei_objects.h - VA FEI objects abstraction
|
||||
*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_FEI_OBJECTS_H
|
||||
#define GST_VAAPI_FEI_OBJECTS_H
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_FEI_CODEC_OBJECT(obj) \
|
||||
((GstVaapiFeiCodecObject *) (obj))
|
||||
|
||||
typedef struct _GstVaapiFeiCodecObject GstVaapiFeiCodecObject;
|
||||
|
||||
typedef struct _GstVaapiEncFeiMbCode GstVaapiEncFeiMbCode;
|
||||
typedef struct _GstVaapiEncFeiMv GstVaapiEncFeiMv;
|
||||
typedef struct _GstVaapiEncFeiMvPredictor GstVaapiEncFeiMvPredictor;
|
||||
typedef struct _GstVaapiEncFeiMbControl GstVaapiEncFeiMbControl;
|
||||
typedef struct _GstVaapiEncFeiQp GstVaapiEncFeiQp;
|
||||
typedef struct _GstVaapiEncFeiDistortion GstVaapiEncFeiDistortion;
|
||||
|
||||
struct _GstVaapiEncoder;
|
||||
|
||||
/* ----------------- Base Codec Object ---------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiFeiCodecObject *
|
||||
gst_vaapi_fei_codec_object_ref (GstVaapiFeiCodecObject *object);
|
||||
|
||||
void
|
||||
gst_vaapi_fei_codec_object_unref (GstVaapiFeiCodecObject *object);
|
||||
|
||||
void
|
||||
gst_vaapi_fei_codec_object_replace (GstVaapiFeiCodecObject **old_object_ptr,
|
||||
GstVaapiFeiCodecObject *new_object);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_fei_codec_object_map (GstVaapiFeiCodecObject *object,
|
||||
gpointer *data, guint *size);
|
||||
|
||||
void
|
||||
gst_vaapi_fei_codec_object_unmap (GstVaapiFeiCodecObject *object);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MB Code buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiEncFeiMbCode *
|
||||
gst_vaapi_enc_fei_mb_code_new (struct _GstVaapiEncoder * encoder, gconstpointer param,
|
||||
guint param_size);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MV Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiEncFeiMv *
|
||||
gst_vaapi_enc_fei_mv_new (struct _GstVaapiEncoder * encoder, gconstpointer param,
|
||||
guint param_size);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MV Predictor Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiEncFeiMvPredictor *
|
||||
gst_vaapi_enc_fei_mv_predictor_new (struct _GstVaapiEncoder * encoder, gconstpointer param,
|
||||
guint param_size);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MB Control Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiEncFeiMbControl *
|
||||
gst_vaapi_enc_fei_mb_control_new (struct _GstVaapiEncoder * encoder, gconstpointer param,
|
||||
guint param_size);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- QP Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiEncFeiQp *
|
||||
gst_vaapi_enc_fei_qp_new (struct _GstVaapiEncoder * encoder, gconstpointer param,
|
||||
guint param_size);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Distortion Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GstVaapiEncFeiDistortion *
|
||||
gst_vaapi_enc_fei_distortion_new (struct _GstVaapiEncoder * encoder, gconstpointer param,
|
||||
guint param_size);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_FEI_OBJECTS_H */
|
|
@ -1,236 +0,0 @@
|
|||
/*
|
||||
* gstvaapifei_objects_priv.h - VA FEI objects abstraction (priv definitions)
|
||||
*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_FEI_OBJECTS_PRIV_H
|
||||
#define GST_VAAPI_FEI_OBJECTS_PRIV_H
|
||||
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#include <gst/vaapi/gstvaapiencoder_objects.h>
|
||||
#include <va/va.h>
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef gpointer GstVaapiFeiCodecBase;
|
||||
typedef struct _GstVaapiFeiCodecObjectClass GstVaapiFeiCodecObjectClass;
|
||||
|
||||
#define GST_VAAPI_FEI_CODEC_BASE(obj) \
|
||||
((GstVaapiFeiCodecBase *) (obj))
|
||||
|
||||
enum
|
||||
{
|
||||
GST_VAAPI_FEI_CODEC_OBJECT_FLAG_CONSTRUCTED = (1 << 0),
|
||||
GST_VAAPI_FEI_CODEC_OBJECT_FLAG_LAST = (1 << 1)
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gconstpointer param;
|
||||
guint param_size;
|
||||
gconstpointer data;
|
||||
guint data_size;
|
||||
guint flags;
|
||||
} GstVaapiFeiCodecObjectConstructorArgs;
|
||||
|
||||
typedef gboolean
|
||||
(*GstVaapiFeiCodecObjectCreateFunc)(GstVaapiFeiCodecObject * object,
|
||||
const GstVaapiFeiCodecObjectConstructorArgs * args);
|
||||
|
||||
typedef GDestroyNotify GstVaapiFeiCodecObjectDestroyFunc;
|
||||
|
||||
/**
|
||||
* GstVaapiFeiCodecObject:
|
||||
*
|
||||
* A #GstVaapiMiniObject holding the base codec object data
|
||||
*/
|
||||
struct _GstVaapiFeiCodecObject
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiMiniObject parent_instance;
|
||||
GstVaapiFeiCodecBase *codec;
|
||||
VABufferID param_id;
|
||||
gpointer param;
|
||||
guint param_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVaapiFeiCodecObjectClass:
|
||||
*
|
||||
* The #GstVaapiFeiCodecObject base class.
|
||||
*/
|
||||
struct _GstVaapiFeiCodecObjectClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiMiniObjectClass parent_class;
|
||||
|
||||
GstVaapiFeiCodecObjectCreateFunc create;
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const GstVaapiFeiCodecObjectClass *
|
||||
gst_vaapi_fei_codec_object_get_class (GstVaapiFeiCodecObject * object) G_GNUC_CONST;
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GstVaapiFeiCodecObject *
|
||||
gst_vaapi_fei_codec_object_new (const GstVaapiFeiCodecObjectClass * object_class,
|
||||
GstVaapiFeiCodecBase * codec, gconstpointer param, guint param_size,
|
||||
gconstpointer data, guint data_size, guint flags);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MB Code Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_ENC_FEI_MB_CODE_CAST(obj) \
|
||||
((GstVaapiEncFeiMbCode *) (obj))
|
||||
/**
|
||||
* GstVaapiEncFeiMbCode:
|
||||
*
|
||||
* A #GstVaapiFeiCodecObject holding a mb code buffer.
|
||||
*/
|
||||
struct _GstVaapiEncFeiMbCode
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiFeiCodecObject parent_instance;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MV Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_ENC_FEI_NEW_MV_CAST(obj) \
|
||||
((GstVaapiEncFeiMv *) (obj))
|
||||
/**
|
||||
* GstVaapiEncFeiMv:
|
||||
*
|
||||
* A #GstVaapiFeiCodecObject holding a mv buffer.
|
||||
*/
|
||||
struct _GstVaapiEncFeiMv
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiFeiCodecObject parent_instance;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MV Predictor Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_ENC_FEI_NEW_MV_PREDICTOR_CAST(obj) \
|
||||
((GstVaapiEncFeiMvPredictor *) (obj))
|
||||
/**
|
||||
* GstVaapiEncFeiMvPredictor:
|
||||
*
|
||||
* A #GstVaapiFeiCodecObject holding a mv predictor buffer.
|
||||
*/
|
||||
struct _GstVaapiEncFeiMvPredictor
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiFeiCodecObject parent_instance;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- MB Control Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_ENC_FEI_NEW_MB_CONTROL_CAST(obj) \
|
||||
((GstVaapiEncFeiMbControl *) (obj))
|
||||
/**
|
||||
* GstVaapiEncFeiMbControl:
|
||||
*
|
||||
* A #GstVaapiFeiCodecObject holding a mb control buffer.
|
||||
*/
|
||||
struct _GstVaapiEncFeiMbControl
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiFeiCodecObject parent_instance;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- QP Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_ENC_FEI_NEW_QP_CAST(obj) \
|
||||
((GstVaapiEncFeiQp *) (obj))
|
||||
/**
|
||||
* GstVaapiEncFeiQp:
|
||||
*
|
||||
* A #GstVaapiFeiCodecObject holding a qp buffer.
|
||||
*/
|
||||
struct _GstVaapiEncFeiQp
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiFeiCodecObject parent_instance;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Distortion Buffer --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_ENC_FEI_NEW_DISTORTION_CAST(obj) \
|
||||
((GstVaapiEncFeiDistortion *) (obj))
|
||||
/**
|
||||
* GstVaapiEncFeiDistortion:
|
||||
*
|
||||
* A #GstVaapiFeiCodecObject holding a distortion buffer.
|
||||
*/
|
||||
struct _GstVaapiEncFeiDistortion
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiFeiCodecObject parent_instance;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Helpers to create fei objects --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define GST_VAAPI_FEI_CODEC_DEFINE_TYPE(type, prefix) \
|
||||
G_GNUC_INTERNAL \
|
||||
void \
|
||||
G_PASTE (prefix, _destroy) (type *); \
|
||||
\
|
||||
G_GNUC_INTERNAL \
|
||||
gboolean \
|
||||
G_PASTE (prefix, _create) (type *, \
|
||||
const GstVaapiFeiCodecObjectConstructorArgs * args); \
|
||||
\
|
||||
static const GstVaapiFeiCodecObjectClass G_PASTE (type, Class) = { \
|
||||
.parent_class = { \
|
||||
.size = sizeof (type), \
|
||||
.finalize = (GstVaapiFeiCodecObjectDestroyFunc) \
|
||||
G_PASTE (prefix, _destroy) \
|
||||
}, \
|
||||
.create = (GstVaapiFeiCodecObjectCreateFunc) \
|
||||
G_PASTE (prefix, _create), \
|
||||
}
|
||||
|
||||
/* GstVaapiEncFeiMiscParam */
|
||||
#define GST_VAAPI_ENC_FEI_MISC_PARAM_NEW(codec, encoder) \
|
||||
gst_vaapi_enc_misc_param_new (GST_VAAPI_ENCODER_CAST (encoder), \
|
||||
VAEncMiscParameterTypeFEIFrameControl, \
|
||||
sizeof (G_PASTE (VAEncMiscParameterFEIFrameControl, codec)))
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_FEI_OBJECTS_H */
|
File diff suppressed because it is too large
Load diff
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* gstvaapifeienc_h264.h - FEI Enc abstract
|
||||
*
|
||||
* Copyright (C) 2016-2018 Intel Corporation
|
||||
* Author: Leilei Shang <leilei.shang@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_FEI_H264_ENC_H
|
||||
#define GST_VAAPI_FEI_H264_ENC_H
|
||||
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
#include <gst/vaapi/gstvaapiutils_h264.h>
|
||||
#include <gst/vaapi/gstvaapifeiutils_h264.h>
|
||||
#include <gst/vaapi/gstvaapifei_objects_priv.h>
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VAAPI_FEI_ENC_H264 \
|
||||
(gst_vaapi_feienc_h264_get_type ())
|
||||
#define GST_VAAPI_FEI_ENC_H264(encoder) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((encoder), GST_TYPE_VAAPI_FEI_ENC_H264, GstVaapiFeiEncH264))
|
||||
#define GST_IS_VAAPI_FEI_ENC_H264(encoder) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((encoder), GST_TYPE_VAAPI_FEI_ENC_H264))
|
||||
|
||||
typedef struct _GstVaapiFeiEncH264 GstVaapiFeiEncH264;
|
||||
typedef struct _GstVaapiFeiEncH264Class GstVaapiFeiEncH264Class;
|
||||
|
||||
GType
|
||||
gst_vaapi_feienc_h264_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GstVaapiEncoder *
|
||||
gst_vaapi_feienc_h264_new (GstVaapiDisplay * display);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_feienc_h264_set_max_profile (GstVaapiFeiEncH264 * feienc,
|
||||
GstVaapiProfile profile);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_feienc_h264_set_ref_pool (GstVaapiFeiEncH264 * feienc, gpointer ref_pool_ptr);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feienc_h264_encode (GstVaapiEncoder * base_encoder,
|
||||
GstVaapiEncPicture * picture, GstVaapiSurfaceProxy * reconstruct,
|
||||
GstVaapiCodedBufferProxy * codedbuf_proxy, GstVaapiFeiInfoToPakH264 *info_to_pak);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feienc_h264_flush (GstVaapiEncoder * base_encoder);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feienc_h264_reordering (GstVaapiEncoder * base_encoder,
|
||||
GstVideoCodecFrame * frame, GstVaapiEncPicture ** output);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feienc_h264_reconfigure (GstVaapiEncoder * base_encoder);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_feienc_h264_get_profile_and_idc (GstVaapiFeiEncH264 * feienc,
|
||||
GstVaapiProfile * out_profile_ptr, guint8 * out_profile_idc_ptr);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /*GST_VAAPI_FEI_H264_ENC_H */
|
File diff suppressed because it is too large
Load diff
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* gstvaapifeipak_h264.h - H.264 FEI PAK
|
||||
*
|
||||
* Copyright (C) 2016-2018 Intel Corporation
|
||||
* Author: Chen Xiaomin <xiaomin.chen@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_FEIPAK_H264_H
|
||||
#define GST_VAAPI_FEIPAK_H264_H
|
||||
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
#include <gst/vaapi/gstvaapiutils_h264.h>
|
||||
#include <gst/vaapi/gstvaapifeiutils_h264.h>
|
||||
#include <gst/vaapi/gstvaapifei_objects_priv.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVaapiFEIPakH264 GstVaapiFEIPakH264;
|
||||
|
||||
/**
|
||||
* GstVaapiEncoderH264Prop:
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_MAX_BFRAMES: Number of B-frames between I
|
||||
* and P (uint).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_INIT_QP: Initial quantizer value (uint).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_MIN_QP: Minimal quantizer value (uint).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_NUM_SLICES: Number of slices per frame (uint).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_CABAC: Enable CABAC entropy coding mode (bool).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_DCT8X8: Enable adaptive use of 8x8
|
||||
* transforms in I-frames (bool).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_CPB_LENGTH: Length of the CPB buffer
|
||||
* in milliseconds (uint).
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_NUM_VIEWS: Number of views per frame.
|
||||
* @GST_VAAPI_FEIPAK_H264_PROP_VIEW_IDS: View IDs
|
||||
*
|
||||
* The set of H.264 feipak specific configurable properties.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEIPAK_H264_PROP_MAX_BFRAMES = -1,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_INIT_QP = -2,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_MIN_QP = -3,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_NUM_SLICES = -4,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_CABAC = -5,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_DCT8X8 = -6,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_CPB_LENGTH = -7,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_NUM_VIEWS = -8,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_VIEW_IDS = -9,
|
||||
GST_VAAPI_FEIPAK_H264_PROP_NUM_REF = -10,
|
||||
} GstVaapiFEIPakH264Prop;
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feipak_h264_reconfigure (GstVaapiFEIPakH264 * feipak,
|
||||
VAContextID va_context, GstVaapiProfile profile, guint8 profile_idc,
|
||||
guint mb_width, guint mb_height, guint32 num_views, guint slices_num,
|
||||
guint32 num_ref_frames);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feipak_h264_encode (GstVaapiFEIPakH264 * feipak,
|
||||
GstVaapiEncPicture * picture, GstVaapiCodedBufferProxy * codedbuf,
|
||||
GstVaapiSurfaceProxy * surface, GstVaapiFeiInfoToPakH264 *info_to_pak);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feipak_h264_flush (GstVaapiFEIPakH264 * feipak);
|
||||
|
||||
GstVaapiFEIPakH264 *gst_vaapi_feipak_h264_new (GstVaapiEncoder * encoder,
|
||||
GstVaapiDisplay * display, VAContextID va_context);
|
||||
|
||||
GstVaapiEncoderStatus
|
||||
gst_vaapi_feipak_h264_set_property (GstVaapiFEIPakH264 * feipak,
|
||||
gint prop_id, const GValue * value);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_feipak_h264_get_ref_pool (GstVaapiFEIPakH264 * feipak,
|
||||
gpointer * ref_pool_ptr);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*GST_VAAPI_FEIPAK_H264_H */
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* gstvaapifeiutils_h264_fei.c - Fei related utilities for H264
|
||||
*
|
||||
* Copyright (C) 2016-2018 Intel Corporation
|
||||
* Author: Wang, Yi <yi.a.wang@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "sysdeps.h"
|
||||
#include <gst/codecparsers/gsth264parser.h>
|
||||
|
||||
#include "gstvaapifeiutils_h264.h"
|
||||
|
||||
/* FeiFixme: This is common fei modes for all codecs,
|
||||
* move to a generic header file */
|
||||
/* --- GstVaapiFeiMode --- */
|
||||
GType
|
||||
gst_vaapi_fei_mode_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GFlagsValue encoding_mode_values[] = {
|
||||
{GST_VAAPI_FEI_MODE_ENC,
|
||||
"ENC Mode", "ENC"},
|
||||
{GST_VAAPI_FEI_MODE_PAK,
|
||||
"PAK Mode", "PAK"},
|
||||
{GST_VAAPI_FEI_MODE_ENC_PAK,
|
||||
"ENC_PAK Mode", "ENC_PAK"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type =
|
||||
g_flags_register_static ("GstVaapiFeiMode", encoding_mode_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* --- GstVaapiFeiH264SearchPath --- */
|
||||
GType
|
||||
gst_vaapi_fei_h264_search_path_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GEnumValue search_path_values[] = {
|
||||
{GST_VAAPI_FEI_H264_FULL_SEARCH_PATH,
|
||||
"full search path", "full"},
|
||||
{GST_VAAPI_FEI_H264_DIAMOND_SEARCH_PATH,
|
||||
"diamond search path", "diamond"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type = g_enum_register_static ("GstVaapiFeiH264SearchPath",
|
||||
search_path_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* --- GstVaapiFeiH264SearchWindow --- */
|
||||
GType
|
||||
gst_vaapi_fei_h264_search_window_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GEnumValue search_window_values[] = {
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_NONE,
|
||||
"not use predefined search window", "none"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_TINY,
|
||||
"4 SUs 24x24 window diamond search", "tiny"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_SMALL,
|
||||
"9 SUs 28x28 window diamond search", "small"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_DIAMOND,
|
||||
"16 SUs 48x40 window diamond search", "diamond"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_LARGE_DIAMOND,
|
||||
"32 SUs 48x40 window diamond search", "large diamond"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_EXHAUSTIVE,
|
||||
"48 SUs 48x40 window full search", "exhaustive"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_HORI_DIAMOND,
|
||||
"16 SUs 64x32 window diamond search", "horizon diamond"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_HORI_LARGE_DIAMOND,
|
||||
"32 SUs 64x32 window diamond search", "horizon large diamond"},
|
||||
{GST_VAAPI_FEI_H264_SEARCH_WINDOW_HORI_EXHAUSTIVE,
|
||||
"48 SUs 64x32 window full search", "horizon exhaustive"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type = g_enum_register_static ("GstVaapiFeiH264SearchWindow",
|
||||
search_window_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* --- GstVaapiFeiH264SubPelMode --- */
|
||||
GType
|
||||
gst_vaapi_fei_h264_sub_pel_mode_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GEnumValue sub_pel_mode_values[] = {
|
||||
{GST_VAAPI_FEI_H264_INTEGER_ME,
|
||||
"integer mode searching", "integer"},
|
||||
{GST_VAAPI_FEI_H264_HALF_ME,
|
||||
"half-pel mode searching", "half"},
|
||||
{GST_VAAPI_FEI_H264_QUARTER_ME,
|
||||
"quarter-pel mode searching", "quarter"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type = g_enum_register_static ("GstVaapiFeiH264SubPelMode",
|
||||
sub_pel_mode_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* --- GstVaapiFeiH264SadMode --- */
|
||||
GType
|
||||
gst_vaapi_fei_h264_sad_mode_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GEnumValue sad_mode_values[] = {
|
||||
{GST_VAAPI_FEI_H264_SAD_NONE_TRANS,
|
||||
"none transform adjusted", "none"},
|
||||
{GST_VAAPI_FEI_H264_SAD_HAAR_TRANS,
|
||||
"Haar transform adjusted", "haar"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type =
|
||||
g_enum_register_static ("GstVaapiFeiH264SadMode", sad_mode_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* --- GstVaapiFeiH264IntraPartMask --- */
|
||||
GType
|
||||
gst_vaapi_fei_h264_intra_part_mask_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GFlagsValue intra_part_mask_values[] = {
|
||||
{GST_VAAPI_FEI_H264_DISABLE_INTRA_NONE,
|
||||
"enable all intra mode", "enable all"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_INTRA_16x16,
|
||||
"luma_intra_16x16 disabled", "intra16x16 disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_INTRA_8x8,
|
||||
"luma_intra_8x8 disabled", "intra8x8 disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_INTRA_4x4,
|
||||
"luma_intra_4x4 disabled", "intra4x4 disabled"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type = g_flags_register_static ("GstVaapiFeiH264IntraPartMask",
|
||||
intra_part_mask_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
/* --- GstVaapiFeiH264SubMbPartMask --- */
|
||||
GType
|
||||
gst_vaapi_fei_h264_sub_mb_part_mask_get_type (void)
|
||||
{
|
||||
static volatile gsize g_type = 0;
|
||||
|
||||
static const GFlagsValue sub_mb_part_mask_values[] = {
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_NONE,
|
||||
"enable all subpartitions", "enable all"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_16x16,
|
||||
"16x16 sub-macroblock disabled", "16x16 submb part disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x16x8,
|
||||
"2x(16x8) sub-macroblock within 16x16 disabled",
|
||||
"16x8 submb part disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x8x16,
|
||||
"2x(8x16) sub-macroblock within 16x16 disabled",
|
||||
"8x16 submb part disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_1x8x8,
|
||||
"1x(8x8) sub-partition for 4x(8x8) within 16x16 disabled",
|
||||
"8x8 submb part disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x8x4,
|
||||
"2x(8x4) sub-partition for 4x(8x8) within 16x16 disabled",
|
||||
"8x4 submb part disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x4x8,
|
||||
"2x(4x8) sub-partition for 4x(8x8) within 16x16 disabled",
|
||||
"4x8 submb part disabled"},
|
||||
{GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_4x4x4,
|
||||
"4x(4x4) sub-partition for 4x(8x8) within 16x16 disabled",
|
||||
"4x4 submb part disabled"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type = g_flags_register_static ("GstVaapiFeiH264SubMbPartMask",
|
||||
sub_mb_part_mask_values);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
* gstvaapifeiutils_h264.h - FEI related utilities for H264
|
||||
*
|
||||
* Copyright (C) 2016-2018 Intel Corporation
|
||||
* Author: Wang, Yi <yi.a.wang@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_FEI_UTILS_H264_H
|
||||
#define GST_VAAPI_FEI_UTILS_H264_H
|
||||
|
||||
#include <va/va.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVaapiFeiInfoToPakH264 GstVaapiFeiInfoToPakH264;
|
||||
|
||||
/* Structure useful for FEI ENC+PAK mode */
|
||||
struct _GstVaapiFeiInfoToPakH264
|
||||
{
|
||||
VAEncSequenceParameterBufferH264 h264_enc_sps;
|
||||
VAEncPictureParameterBufferH264 h264_enc_pps;
|
||||
GArray *h264_slice_headers;
|
||||
guint h264_slice_num;
|
||||
};
|
||||
|
||||
/******************* Common FEI enum definition for all codecs ***********/
|
||||
/* FeiFixme: This should be a common fei mode for all codecs,
|
||||
* move to a common header file */
|
||||
#define GST_VAAPI_FEI_MODE_DEFAULT GST_VAAPI_FEI_MODE_ENC_PAK
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_MODE_ENC = (1 << 0),
|
||||
GST_VAAPI_FEI_MODE_PAK = (1 << 1),
|
||||
GST_VAAPI_FEI_MODE_ENC_PAK = (1 << 2)
|
||||
} GstVaapiFeiMode;
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_MODE:
|
||||
*
|
||||
* A type that represents the fei encoding mode.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiMode
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_MODE (gst_vaapi_fei_mode_get_type())
|
||||
|
||||
|
||||
/******************* H264 Specific FEI enum definitions ***********/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_H264_FULL_SEARCH_PATH = 0,
|
||||
GST_VAAPI_FEI_H264_DIAMOND_SEARCH_PATH,
|
||||
} GstVaapiFeiH264SearchPath;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_NONE = 0,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_TINY,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_SMALL,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_DIAMOND,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_LARGE_DIAMOND,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_EXHAUSTIVE,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_HORI_DIAMOND,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_HORI_LARGE_DIAMOND,
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_HORI_EXHAUSTIVE,
|
||||
} GstVaapiFeiH264SearchWindow;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_H264_INTEGER_ME = 0,
|
||||
GST_VAAPI_FEI_H264_HALF_ME = 1,
|
||||
GST_VAAPI_FEI_H264_QUARTER_ME = 3,
|
||||
} GstVaapiFeiH264SubPelMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_H264_SAD_NONE_TRANS = 0,
|
||||
GST_VAAPI_FEI_H264_SAD_HAAR_TRANS = 2,
|
||||
} GstVaapiFeiH264SadMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_H264_DISABLE_INTRA_NONE = 0,
|
||||
GST_VAAPI_FEI_H264_DISABLE_INTRA_16x16 = (1 << 0),
|
||||
GST_VAAPI_FEI_H264_DISABLE_INTRA_8x8 = (1 << 1),
|
||||
GST_VAAPI_FEI_H264_DISABLE_INTRA_4x4 = (1 << 2),
|
||||
} GstVaapiFeiH264IntraPartMask;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_NONE = 0,
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_16x16 = (1 << 1),
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x16x8 = (1 << 2),
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x8x16 = (1 << 3),
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_1x8x8 = (1 << 4),
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x8x4 = (1 << 5),
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_2x4x8 = (1 << 6),
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_4x4x4 = (1 << 7),
|
||||
} GstVaapiFeiH264SubMbPartMask;
|
||||
|
||||
#define GST_VAAPI_FEI_H264_SEARCH_PATH_DEFAULT \
|
||||
GST_VAAPI_FEI_H264_FULL_SEARCH_PATH
|
||||
#define GST_VAAPI_FEI_H264_SEARCH_WINDOW_DEFAULT \
|
||||
GST_VAAPI_FEI_H264_SEARCH_WINDOW_NONE
|
||||
#define GST_VAAPI_FEI_H264_SUB_PEL_MODE_DEFAULT \
|
||||
GST_VAAPI_FEI_H264_INTEGER_ME
|
||||
#define GST_VAAPI_FEI_H264_SAD_MODE_DEFAULT \
|
||||
GST_VAAPI_FEI_H264_SAD_NONE_TRANS
|
||||
#define GST_VAAPI_FEI_H264_INTRA_PART_MASK_DEFAULT \
|
||||
GST_VAAPI_FEI_H264_DISABLE_INTRA_NONE
|
||||
#define GST_VAAPI_FEI_H264_SUB_MB_PART_MASK_DEFAULT \
|
||||
GST_VAAPI_FEI_H264_DISABLE_SUB_MB_PART_MASK_NONE
|
||||
#define GST_VAAPI_FEI_H264_SEARCH_PATH_LENGTH_DEFAULT 32
|
||||
#define GST_VAAPI_FEI_H264_REF_WIDTH_DEFAULT 32
|
||||
#define GST_VAAPI_FEI_H264_REF_HEIGHT_DEFAULT 32
|
||||
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_H264_SEARCH_PATH:
|
||||
*
|
||||
* A type that represents the fei control param: search path.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiSearchPath
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_H264_SEARCH_PATH gst_vaapi_fei_h264_search_path_get_type()
|
||||
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_H264_SEARCH_WINDOW:
|
||||
*
|
||||
* A type that represents the fei control param: search window.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiSearchWindow
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_H264_SEARCH_WINDOW gst_vaapi_fei_h264_search_window_get_type()
|
||||
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_H264_SAD_MODE:
|
||||
*
|
||||
* A type that represents the fei control param: sad mode.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiSadMode
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_H264_SAD_MODE gst_vaapi_fei_h264_sad_mode_get_type()
|
||||
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_H264_INTRA_PART_MASK:
|
||||
*
|
||||
* A type that represents the fei control param: intra part mask.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiIntaPartMask
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_H264_INTRA_PART_MASK gst_vaapi_fei_h264_intra_part_mask_get_type()
|
||||
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_H264_SUB_PEL_MODE:
|
||||
*
|
||||
* A type that represents the fei control param: sub pel mode.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiSubPelMode
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_H264_SUB_PEL_MODE gst_vaapi_fei_h264_sub_pel_mode_get_type()
|
||||
|
||||
/**
|
||||
* GST_VAAPI_TYPE_FEI_H264_SUB_MB_PART_MASK:
|
||||
*
|
||||
* A type that represents the fei control param: sub maroclock partition mask.
|
||||
*
|
||||
* Return value: the #GType of GstVaapiFeiH264SubMbPartMask
|
||||
*/
|
||||
#define GST_VAAPI_TYPE_FEI_H264_SUB_MB_PART_MASK gst_vaapi_fei_h264_sub_mb_part_mask_get_type()
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_mode_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_h264_search_path_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_h264_search_window_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_h264_sad_mode_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_h264_sub_pel_mode_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_h264_intra_part_mask_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_h264_sub_mb_part_mask_get_type (void)
|
||||
G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* GST_VAAPI_UTILS_FEI_H264_H */
|
|
@ -149,9 +149,6 @@ static const GstVaapiEntrypointMap gst_vaapi_entrypoints[] = {
|
|||
{GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE, VAEntrypointEncPicture},
|
||||
#if VA_CHECK_VERSION(0,39,1)
|
||||
{GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP, VAEntrypointEncSliceLP},
|
||||
#endif
|
||||
#if USE_H264_FEI_ENCODER
|
||||
{GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI, VAEntrypointFEI},
|
||||
#endif
|
||||
{0,}
|
||||
};
|
||||
|
|
|
@ -196,7 +196,6 @@ typedef enum {
|
|||
* @GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE: Encode Picture
|
||||
* @GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP: Encode Slice low power/
|
||||
* high performace varient
|
||||
* @GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI: FEI Encode
|
||||
*
|
||||
* The set of all entrypoints for #GstVaapiEntrypoint
|
||||
*/
|
||||
|
@ -208,7 +207,6 @@ typedef enum {
|
|||
GST_VAAPI_ENTRYPOINT_SLICE_ENCODE,
|
||||
GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE,
|
||||
GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP,
|
||||
GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI
|
||||
} GstVaapiEntrypoint;
|
||||
|
||||
const gchar *
|
||||
|
|
|
@ -50,27 +50,6 @@ gst_vaapi_surface_proxy_finalize (GstVaapiSurfaceProxy * proxy)
|
|||
/* Notify the user function that the object is now destroyed */
|
||||
if (proxy->destroy_func)
|
||||
proxy->destroy_func (proxy->destroy_data);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
if (proxy->mvpred)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mvpred, NULL);
|
||||
if (proxy->mbcntrl)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mbcntrl, NULL);
|
||||
if (proxy->qp)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->qp, NULL);
|
||||
if (proxy->mbcode)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mbcode, NULL);
|
||||
if (proxy->mv)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mv, NULL);
|
||||
if (proxy->dist)
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->dist, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline const GstVaapiMiniObjectClass *
|
||||
|
@ -90,14 +69,6 @@ gst_vaapi_surface_proxy_init_properties (GstVaapiSurfaceProxy * proxy)
|
|||
proxy->timestamp = GST_CLOCK_TIME_NONE;
|
||||
proxy->duration = GST_CLOCK_TIME_NONE;
|
||||
proxy->has_crop_rect = FALSE;
|
||||
#if USE_H264_FEI_ENCODER
|
||||
proxy->mvpred = NULL;
|
||||
proxy->mbcntrl = NULL;
|
||||
proxy->qp = NULL;
|
||||
proxy->mbcode = NULL;
|
||||
proxy->mv = NULL;
|
||||
proxy->dist = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,51 +192,6 @@ gst_vaapi_surface_proxy_copy (GstVaapiSurfaceProxy * proxy)
|
|||
if (copy->has_crop_rect)
|
||||
copy->crop_rect = proxy->crop_rect;
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
|
||||
if (proxy->mv)
|
||||
copy->mv = (GstVaapiEncFeiMv *)
|
||||
gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT (proxy->mv));
|
||||
else
|
||||
copy->mv = NULL;
|
||||
|
||||
if (proxy->mbcode)
|
||||
copy->mbcode = (GstVaapiEncFeiMbCode *)
|
||||
gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(proxy->mbcode));
|
||||
else
|
||||
copy->mbcode = NULL;
|
||||
|
||||
if (proxy->mvpred)
|
||||
copy->mvpred = (GstVaapiEncFeiMvPredictor *)
|
||||
gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(proxy->mvpred));
|
||||
else
|
||||
copy->mvpred = NULL;
|
||||
|
||||
if (proxy->qp)
|
||||
copy->qp = (GstVaapiEncFeiQp *)
|
||||
gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT (proxy->qp));
|
||||
else
|
||||
copy->qp = NULL;
|
||||
|
||||
if (proxy->mbcntrl)
|
||||
copy->mbcntrl = (GstVaapiEncFeiMbControl *)
|
||||
gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(proxy->mbcntrl));
|
||||
else
|
||||
copy->mbcntrl = NULL;
|
||||
|
||||
if (proxy->dist)
|
||||
copy->dist = (GstVaapiEncFeiDistortion *)
|
||||
gst_vaapi_fei_codec_object_ref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(proxy->dist));
|
||||
else
|
||||
copy->dist = NULL;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -479,199 +405,3 @@ gst_vaapi_surface_proxy_set_crop_rect (GstVaapiSurfaceProxy * proxy,
|
|||
if (proxy->has_crop_rect)
|
||||
proxy->crop_rect = *crop_rect;
|
||||
}
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_get_fei_mb_code:
|
||||
* @proxy: a #GstVaapiSurfaceProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiMbCode stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiMbcode, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiMbCode *
|
||||
gst_vaapi_surface_proxy_get_fei_mb_code (GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, NULL);
|
||||
return proxy->mbcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_get_fei_mv:
|
||||
* @proxy: a #GstVaapiSurfaceProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiMv stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiMv, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiMv *
|
||||
gst_vaapi_surface_proxy_get_fei_mv (GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, NULL);
|
||||
return proxy->mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_get_fei_distortion:
|
||||
* @proxy: a #GstVaapiSurfaceProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiDistortion stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiDistortion, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiDistortion *
|
||||
gst_vaapi_surface_proxy_get_fei_distortion (GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, NULL);
|
||||
return proxy->dist;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_get_fei_qp:
|
||||
* @proxy: a #GstVaapiSurfaceProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiQp stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiQp, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiQp *
|
||||
gst_vaapi_surface_proxy_get_fei_qp (GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, NULL);
|
||||
return proxy->qp;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_get_fei_mv_predictor:
|
||||
* @proxy: a #GstVaapiSurfaceProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiMvPredictor stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiMvPredictor, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiMvPredictor *
|
||||
gst_vaapi_surface_proxy_get_fei_mv_predictor (GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, NULL);
|
||||
return proxy->mvpred;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_get_fei_mb_control:
|
||||
* @proxy: a #GstVaapiSurfaceProxy
|
||||
*
|
||||
* Returns the #GstVaapiEncFeiMbControl stored in the @proxy
|
||||
*
|
||||
* Return value: the #GstVaapiEncFeiMbControl, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
GstVaapiEncFeiMbControl *
|
||||
gst_vaapi_surface_proxy_get_fei_mb_control (GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
g_return_val_if_fail (proxy != NULL, NULL);
|
||||
return proxy->mbcntrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_set_fei_mb_code:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @mbcode: the #GstVaapiEncFeiMbCode to be stored in @proxy
|
||||
*
|
||||
* Associates the @mbcode with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mb_code (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMbCode * mbcode)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mbcode, (GstVaapiFeiCodecObject *) mbcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_set_fei_mv:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @mv: the #GstVaapiEncFeiMv to be stored in @proxy
|
||||
*
|
||||
* Associates the @mv with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mv (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMv * mv)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mv, (GstVaapiFeiCodecObject *) mv);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_set_fei_distortion:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @dist: the #GstVaapiEncFeiDistortion to be stored in @proxy
|
||||
*
|
||||
* Associates the @dist with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_distortion (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiDistortion * dist)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->dist, (GstVaapiFeiCodecObject *) dist);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_set_fei_qp:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @qp: the #GstVaapiEncFeiQp to be stored in @proxy
|
||||
*
|
||||
* Associates the @qp with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_qp (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiQp * qp)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->qp, (GstVaapiFeiCodecObject *) qp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_set_fei_mv_predictor:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @mvpred: the #GstVaapiEncFeiMvPredictor to be stored in @proxy
|
||||
*
|
||||
* Associates the @mvpred with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mv_predictor (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMvPredictor * mvpred)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mvpred, (GstVaapiFeiCodecObject *) mvpred);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_proxy_set_fei_mb_control:
|
||||
* @proxy: #GstVaapiSurfaceProxy
|
||||
* @mbcntrl: the #GstVaapiEncFeiMbControl to be stored in @proxy
|
||||
*
|
||||
* Associates the @mbcntrl with the @proxy
|
||||
*/
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mb_control (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMbControl * mbcntrl)
|
||||
{
|
||||
g_return_if_fail (proxy != NULL);
|
||||
gst_vaapi_fei_codec_object_replace ((GstVaapiFeiCodecObject **) &
|
||||
proxy->mbcntrl, (GstVaapiFeiCodecObject *) mbcntrl);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,10 +28,6 @@
|
|||
#include <gst/vaapi/gstvaapisurface.h>
|
||||
#include <gst/vaapi/gstvaapisurfacepool.h>
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
|
@ -156,46 +152,6 @@ void
|
|||
gst_vaapi_surface_proxy_set_crop_rect (GstVaapiSurfaceProxy * proxy,
|
||||
const GstVaapiRectangle * crop_rect);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
|
||||
GstVaapiEncFeiMbCode *
|
||||
gst_vaapi_surface_proxy_get_fei_mb_code (GstVaapiSurfaceProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiMv *
|
||||
gst_vaapi_surface_proxy_get_fei_mv (GstVaapiSurfaceProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiDistortion *
|
||||
gst_vaapi_surface_proxy_get_fei_distortion (GstVaapiSurfaceProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiQp *
|
||||
gst_vaapi_surface_proxy_get_fei_qp (GstVaapiSurfaceProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiMvPredictor *
|
||||
gst_vaapi_surface_proxy_get_fei_mv_predictor (GstVaapiSurfaceProxy * proxy);
|
||||
|
||||
GstVaapiEncFeiMbControl *
|
||||
gst_vaapi_surface_proxy_get_fei_mb_control (GstVaapiSurfaceProxy * proxy);
|
||||
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mb_code (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMbCode *mbcode);
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mv (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMv *mv);
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_distortion (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiDistortion *dist);
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_qp (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiQp *mbcode);
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mv_predictor (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMvPredictor *mvpred);
|
||||
void
|
||||
gst_vaapi_surface_proxy_set_fei_mb_control (GstVaapiSurfaceProxy * proxy,
|
||||
GstVaapiEncFeiMbControl *mbcntrl);
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_SURFACE_PROXY_H */
|
||||
|
|
|
@ -48,15 +48,6 @@ struct _GstVaapiSurfaceProxy
|
|||
gpointer destroy_data;
|
||||
GstVaapiRectangle crop_rect;
|
||||
guint has_crop_rect:1;
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
GstVaapiEncFeiMvPredictor *mvpred;
|
||||
GstVaapiEncFeiMbControl *mbcntrl;
|
||||
GstVaapiEncFeiQp *qp;
|
||||
GstVaapiEncFeiMbCode *mbcode;
|
||||
GstVaapiEncFeiMv *mv;
|
||||
GstVaapiEncFeiDistortion *dist;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define GST_VAAPI_SURFACE_PROXY_FLAGS GST_VAAPI_MINI_OBJECT_FLAGS
|
||||
|
|
|
@ -112,23 +112,6 @@ if USE_VP9_ENCODER
|
|||
gstlibvaapi_headers += 'gstvaapiencoder_vp9.h'
|
||||
endif
|
||||
|
||||
if USE_H264_FEI_ENCODER
|
||||
gstlibvaapi_sources += [
|
||||
'gstvaapifeiutils_h264.c',
|
||||
'gstvaapifei_objects.c',
|
||||
'gstvaapifeienc_h264.c',
|
||||
'gstvaapifeipak_h264.c',
|
||||
'gstvaapiencoder_h264_fei.c',
|
||||
]
|
||||
gstlibvaapi_headers += [
|
||||
'gstvaapifeiutils_h264.h',
|
||||
'gstvaapifei_objects.h',
|
||||
'gstvaapifeienc_h264.h',
|
||||
'gstvaapifeipak_h264.h',
|
||||
'gstvaapiencoder_h264_fei.h',
|
||||
]
|
||||
endif
|
||||
|
||||
if USE_DRM
|
||||
gstlibvaapi_sources += [
|
||||
'gstvaapidisplay_drm.c',
|
||||
|
|
|
@ -39,11 +39,6 @@
|
|||
#if USE_VP9_ENCODER
|
||||
#include "gstvaapiencode_vp9.h"
|
||||
#endif
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
#include "gstvaapiencode_h264_fei.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
gboolean _gst_vaapi_has_video_processing = FALSE;
|
||||
|
@ -179,14 +174,6 @@ gst_vaapiencode_register (GstPlugin * plugin, GstVaapiDisplay * display)
|
|||
}
|
||||
}
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
if (gst_vaapi_display_has_encoder (display,
|
||||
GST_VAAPI_PROFILE_H264_MAIN, GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI)) {
|
||||
gst_element_register (plugin, "vaapih264feienc",
|
||||
GST_RANK_SECONDARY, GST_TYPE_VAAPIENCODE_H264_FEI);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_array_unref (codecs);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -253,9 +253,6 @@ gst_vaapiencode_push_frame (GstVaapiEncode * encode, gint64 timeout)
|
|||
GstVaapiEncoderStatus status;
|
||||
GstBuffer *out_buffer;
|
||||
GstFlowReturn ret;
|
||||
#if USE_H264_FEI_ENCODER
|
||||
GstVaapiFeiVideoMeta *feimeta = NULL;
|
||||
#endif
|
||||
|
||||
status = gst_vaapi_encoder_get_buffer_with_timeout (encode->encoder,
|
||||
&codedbuf_proxy, timeout);
|
||||
|
@ -281,14 +278,6 @@ gst_vaapiencode_push_frame (GstVaapiEncode * encode, gint64 timeout)
|
|||
ret = klass->alloc_buffer (encode,
|
||||
GST_VAAPI_CODED_BUFFER_PROXY_BUFFER (codedbuf_proxy), &out_buffer);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
if (klass->save_stats_to_meta) {
|
||||
feimeta = klass->save_stats_to_meta (encode, codedbuf_proxy);
|
||||
if (feimeta != NULL)
|
||||
gst_buffer_set_vaapi_fei_video_meta (out_buffer, feimeta);
|
||||
}
|
||||
#endif
|
||||
|
||||
gst_vaapi_coded_buffer_proxy_replace (&codedbuf_proxy, NULL);
|
||||
if (ret != GST_FLOW_OK)
|
||||
goto error_allocate_buffer;
|
||||
|
@ -675,10 +664,6 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
|
|||
GstFlowReturn ret;
|
||||
GstBuffer *buf;
|
||||
GstTaskState task_state;
|
||||
#if USE_H264_FEI_ENCODER
|
||||
GstVaapiFeiVideoMeta *feimeta = NULL;
|
||||
GstVaapiEncodeClass *const klass = GST_VAAPIENCODE_GET_CLASS (venc);
|
||||
#endif
|
||||
|
||||
task_state = gst_pad_get_task_state (srcpad);
|
||||
if (task_state == GST_TASK_STOPPED || task_state == GST_TASK_PAUSED)
|
||||
|
@ -703,12 +688,6 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
|
|||
if (!proxy)
|
||||
goto error_buffer_no_surface_proxy;
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
feimeta = gst_buffer_get_vaapi_fei_video_meta (buf);
|
||||
if (feimeta && klass->load_control_data)
|
||||
klass->load_control_data (encode, feimeta, proxy);
|
||||
#endif
|
||||
|
||||
gst_video_codec_frame_set_user_data (frame,
|
||||
gst_vaapi_surface_proxy_ref (proxy),
|
||||
(GDestroyNotify) gst_vaapi_surface_proxy_unref);
|
||||
|
|
|
@ -27,12 +27,6 @@
|
|||
#include "gstvaapipluginbase.h"
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
#include <gst/vaapi/gstvaapisurface.h>
|
||||
#include <gst/vaapi/gstvaapicodedbufferproxy.h>
|
||||
#include "gstvaapifeivideometa.h"
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VAAPIENCODE \
|
||||
|
@ -84,17 +78,6 @@ struct _GstVaapiEncodeClass
|
|||
/* Get all possible profiles based on allowed caps */
|
||||
GArray * (*get_allowed_profiles) (GstVaapiEncode * encode,
|
||||
GstCaps * allowed);
|
||||
|
||||
#if USE_H264_FEI_ENCODER
|
||||
|
||||
gboolean (*load_control_data) (GstVaapiEncode *encoder,
|
||||
GstVaapiFeiVideoMeta *feimeta,
|
||||
GstVaapiSurfaceProxy *proxy);
|
||||
|
||||
GstVaapiFeiVideoMeta* (*save_stats_to_meta) (GstVaapiEncode *base_encode,
|
||||
GstVaapiCodedBufferProxy *proxy);
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
GType
|
||||
|
|
|
@ -1,513 +0,0 @@
|
|||
/*
|
||||
* gstvaapiencode_h264_fei.c - VA-API H.264 FEI ncoder
|
||||
*
|
||||
* Copyright (C) 2016-2019 Intel Corporation
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
* Author: Yi A Wang <yi.a.wang@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:element-vaapih264feienc
|
||||
* @short_description: A VA-API FEI based H.264 video encoder
|
||||
*
|
||||
* Encodes raw video streams into H.264 bitstreams.
|
||||
*
|
||||
* ## Example launch line
|
||||
*
|
||||
* |[
|
||||
* gst-launch-1.0 -ev videotestsrc num-buffers=60 ! vaapih264feienc fei-mode=ENC_PAK ! filesink location=test.264
|
||||
* ]|
|
||||
*/
|
||||
|
||||
#include "gstcompat.h"
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapiencoder_h264_fei.h>
|
||||
#include <gst/vaapi/gstvaapiutils_h264.h>
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#include <gst/vaapi/gstvaapifeiutils_h264.h>
|
||||
#include "gstvaapiencode_h264_fei.h"
|
||||
#include "gstvaapipluginutil.h"
|
||||
#include "gstvaapivideomemory.h"
|
||||
#include "gstvaapifeivideometa.h"
|
||||
#include <gst/vaapi/gstvaapicodedbufferproxy.h>
|
||||
|
||||
#define GST_VAAPI_ENCODE_FLOW_MEM_ERROR GST_FLOW_CUSTOM_ERROR
|
||||
#define GST_PLUGIN_NAME "vaapih264feienc"
|
||||
#define GST_PLUGIN_DESC "A VA-API FEI based advanced H264 video encoder"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_vaapi_h264_fei_encode_debug);
|
||||
#define GST_CAT_DEFAULT gst_vaapi_h264_fei_encode_debug
|
||||
|
||||
#define GST_CODEC_CAPS \
|
||||
"video/x-h264, " \
|
||||
"stream-format = (string) { avc, byte-stream }, " \
|
||||
"alignment = (string) au"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static const char gst_vaapiencode_h264_fei_sink_caps_str[] =
|
||||
GST_VAAPI_MAKE_SURFACE_CAPS ", "
|
||||
GST_CAPS_INTERLACED_FALSE "; "
|
||||
GST_VIDEO_CAPS_MAKE (GST_VAAPI_FORMATS_ALL) ", "
|
||||
GST_CAPS_INTERLACED_FALSE ";"
|
||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_MEMORY_DMABUF, GST_VAAPI_FORMATS_ALL) ","
|
||||
GST_CAPS_INTERLACED_FALSE;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static const char gst_vaapiencode_h264_fei_src_caps_str[] =
|
||||
GST_CODEC_CAPS ", "
|
||||
"profile = (string) { constrained-baseline, baseline, main, high, multiview-high, stereo-high }";
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static GstStaticPadTemplate gst_vaapiencode_h264_fei_sink_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (gst_vaapiencode_h264_fei_sink_caps_str));
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static GstStaticPadTemplate gst_vaapiencode_h264_fei_src_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (gst_vaapiencode_h264_fei_src_caps_str));
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* h264 encode */
|
||||
G_DEFINE_TYPE (GstVaapiEncodeH264Fei, gst_vaapiencode_h264_fei,
|
||||
GST_TYPE_VAAPIENCODE);
|
||||
|
||||
static void
|
||||
gst_vaapiencode_h264_fei_init (GstVaapiEncodeH264Fei * encode)
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapiencode_h264_fei_finalize (GObject * object)
|
||||
{
|
||||
G_OBJECT_CLASS (gst_vaapiencode_h264_fei_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GstVaapiProfile best_profile;
|
||||
guint best_score;
|
||||
} FindBestProfileData;
|
||||
|
||||
static void
|
||||
find_best_profile_value (FindBestProfileData * data, const GValue * value)
|
||||
{
|
||||
const gchar *str;
|
||||
GstVaapiProfile profile;
|
||||
guint score;
|
||||
|
||||
if (!value || !G_VALUE_HOLDS_STRING (value))
|
||||
return;
|
||||
|
||||
str = g_value_get_string (value);
|
||||
if (!str)
|
||||
return;
|
||||
profile = gst_vaapi_utils_h264_get_profile_from_string (str);
|
||||
if (!profile)
|
||||
return;
|
||||
score = gst_vaapi_utils_h264_get_profile_score (profile);
|
||||
if (score < data->best_score)
|
||||
return;
|
||||
data->best_profile = profile;
|
||||
data->best_score = score;
|
||||
}
|
||||
|
||||
static GstVaapiProfile
|
||||
find_best_profile (GstCaps * caps)
|
||||
{
|
||||
FindBestProfileData data;
|
||||
guint i, j, num_structures, num_values;
|
||||
|
||||
data.best_profile = GST_VAAPI_PROFILE_UNKNOWN;
|
||||
data.best_score = 0;
|
||||
|
||||
num_structures = gst_caps_get_size (caps);
|
||||
for (i = 0; i < num_structures; i++) {
|
||||
GstStructure *const structure = gst_caps_get_structure (caps, i);
|
||||
const GValue *const value = gst_structure_get_value (structure, "profile");
|
||||
|
||||
if (!value)
|
||||
continue;
|
||||
if (G_VALUE_HOLDS_STRING (value))
|
||||
find_best_profile_value (&data, value);
|
||||
else if (GST_VALUE_HOLDS_LIST (value)) {
|
||||
num_values = gst_value_list_get_size (value);
|
||||
for (j = 0; j < num_values; j++)
|
||||
find_best_profile_value (&data, gst_value_list_get_value (value, j));
|
||||
}
|
||||
}
|
||||
return data.best_profile;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapiencode_h264_fei_set_config (GstVaapiEncode * base_encode)
|
||||
{
|
||||
GstVaapiEncoderH264Fei *const encoder =
|
||||
GST_VAAPI_ENCODER_H264_FEI (base_encode->encoder);
|
||||
GstCaps *allowed_caps;
|
||||
GstVaapiProfile profile;
|
||||
|
||||
/* Check for the largest profile that is supported */
|
||||
allowed_caps =
|
||||
gst_pad_get_allowed_caps (GST_VAAPI_PLUGIN_BASE_SRC_PAD (base_encode));
|
||||
if (!allowed_caps)
|
||||
return TRUE;
|
||||
|
||||
profile = find_best_profile (allowed_caps);
|
||||
gst_caps_unref (allowed_caps);
|
||||
if (profile) {
|
||||
GST_INFO ("using %s profile as target decoder constraints",
|
||||
gst_vaapi_utils_h264_get_profile_string (profile));
|
||||
if (!gst_vaapi_encoder_h264_fei_set_max_profile (encoder, profile))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_vaapiencode_h264_fei_get_caps (GstVaapiEncode * base_encode)
|
||||
{
|
||||
GstVaapiEncodeH264Fei *const encode =
|
||||
GST_VAAPIENCODE_H264_FEI_CAST (base_encode);
|
||||
GstCaps *caps, *allowed_caps;
|
||||
|
||||
caps = gst_caps_from_string (GST_CODEC_CAPS);
|
||||
|
||||
/* Check whether "stream-format" is avcC mode */
|
||||
allowed_caps =
|
||||
gst_pad_get_allowed_caps (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode));
|
||||
if (allowed_caps) {
|
||||
const char *stream_format = NULL;
|
||||
GstStructure *structure;
|
||||
guint i, num_structures;
|
||||
|
||||
num_structures = gst_caps_get_size (allowed_caps);
|
||||
for (i = 0; !stream_format && i < num_structures; i++) {
|
||||
structure = gst_caps_get_structure (allowed_caps, i);
|
||||
if (!gst_structure_has_field_typed (structure, "stream-format",
|
||||
G_TYPE_STRING))
|
||||
continue;
|
||||
stream_format = gst_structure_get_string (structure, "stream-format");
|
||||
}
|
||||
encode->is_avc = stream_format && strcmp (stream_format, "avc") == 0;
|
||||
gst_caps_unref (allowed_caps);
|
||||
}
|
||||
gst_caps_set_simple (caps, "stream-format", G_TYPE_STRING,
|
||||
encode->is_avc ? "avc" : "byte-stream", NULL);
|
||||
|
||||
base_encode->need_codec_data = encode->is_avc;
|
||||
|
||||
/* XXX: update profile and level information */
|
||||
return caps;
|
||||
}
|
||||
|
||||
static GstVaapiEncoder *
|
||||
gst_vaapiencode_h264_fei_alloc_encoder (GstVaapiEncode * base,
|
||||
GstVaapiDisplay * display)
|
||||
{
|
||||
return gst_vaapi_encoder_h264_fei_new (display);
|
||||
}
|
||||
|
||||
/* h264 NAL byte stream operations */
|
||||
static guint8 *
|
||||
_h264_byte_stream_next_nal (guint8 * buffer, guint32 len, guint32 * nal_size)
|
||||
{
|
||||
const guint8 *cur = buffer;
|
||||
const guint8 *const end = buffer + len;
|
||||
guint8 *nal_start = NULL;
|
||||
guint32 flag = 0xFFFFFFFF;
|
||||
guint32 nal_start_len = 0;
|
||||
|
||||
g_assert (buffer && nal_size);
|
||||
if (len < 3) {
|
||||
*nal_size = len;
|
||||
nal_start = (len ? buffer : NULL);
|
||||
return nal_start;
|
||||
}
|
||||
|
||||
/*locate head postion */
|
||||
if (!buffer[0] && !buffer[1]) {
|
||||
if (buffer[2] == 1) { /* 0x000001 */
|
||||
nal_start_len = 3;
|
||||
} else if (!buffer[2] && len >= 4 && buffer[3] == 1) { /* 0x00000001 */
|
||||
nal_start_len = 4;
|
||||
}
|
||||
}
|
||||
nal_start = buffer + nal_start_len;
|
||||
cur = nal_start;
|
||||
|
||||
/*find next nal start position */
|
||||
while (cur < end) {
|
||||
flag = ((flag << 8) | ((*cur++) & 0xFF));
|
||||
if ((flag & 0x00FFFFFF) == 0x00000001) {
|
||||
if (flag == 0x00000001)
|
||||
*nal_size = cur - 4 - nal_start;
|
||||
else
|
||||
*nal_size = cur - 3 - nal_start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cur >= end) {
|
||||
*nal_size = end - nal_start;
|
||||
if (nal_start >= end) {
|
||||
nal_start = NULL;
|
||||
}
|
||||
}
|
||||
return nal_start;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_start_code_to_size (guint8 nal_start_code[4], guint32 nal_size)
|
||||
{
|
||||
nal_start_code[0] = ((nal_size >> 24) & 0xFF);
|
||||
nal_start_code[1] = ((nal_size >> 16) & 0xFF);
|
||||
nal_start_code[2] = ((nal_size >> 8) & 0xFF);
|
||||
nal_start_code[3] = (nal_size & 0xFF);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_h264_convert_byte_stream_to_avc (GstBuffer * buf)
|
||||
{
|
||||
GstMapInfo info;
|
||||
guint32 nal_size;
|
||||
guint8 *nal_start_code, *nal_body;
|
||||
guint8 *frame_end;
|
||||
|
||||
g_assert (buf);
|
||||
|
||||
if (!gst_buffer_map (buf, &info, GST_MAP_READ | GST_MAP_WRITE))
|
||||
return FALSE;
|
||||
|
||||
nal_start_code = info.data;
|
||||
frame_end = info.data + info.size;
|
||||
nal_size = 0;
|
||||
|
||||
while ((frame_end > nal_start_code) &&
|
||||
(nal_body = _h264_byte_stream_next_nal (nal_start_code,
|
||||
frame_end - nal_start_code, &nal_size)) != NULL) {
|
||||
if (!nal_size)
|
||||
goto error;
|
||||
|
||||
g_assert (nal_body - nal_start_code == 4);
|
||||
_start_code_to_size (nal_start_code, nal_size);
|
||||
nal_start_code = nal_body + nal_size;
|
||||
}
|
||||
gst_buffer_unmap (buf, &info);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
error:
|
||||
{
|
||||
gst_buffer_unmap (buf, &info);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
alloc_buffer (GstVaapiEncode * encode,
|
||||
GstVaapiCodedBuffer * coded_buf, GstBuffer ** outbuf_ptr)
|
||||
{
|
||||
GstVaapiEncoderH264Fei *const encoder =
|
||||
GST_VAAPI_ENCODER_H264_FEI (encode->encoder);
|
||||
GstBuffer *buf;
|
||||
gint32 buf_size;
|
||||
GstVaapiFeiMode fei_mode;
|
||||
|
||||
g_return_val_if_fail (coded_buf != NULL, GST_FLOW_ERROR);
|
||||
g_return_val_if_fail (outbuf_ptr != NULL, GST_FLOW_ERROR);
|
||||
|
||||
fei_mode = gst_vaapi_encoder_h264_fei_get_function_mode (encoder);
|
||||
|
||||
if (fei_mode == GST_VAAPI_FEI_MODE_ENC)
|
||||
buf_size = 4; /* just avoid zero size buffer allocation */
|
||||
else
|
||||
buf_size = gst_vaapi_coded_buffer_get_size (coded_buf);
|
||||
|
||||
if (buf_size <= 0)
|
||||
goto error_invalid_buffer;
|
||||
|
||||
buf =
|
||||
gst_video_encoder_allocate_output_buffer (GST_VIDEO_ENCODER_CAST (encode),
|
||||
buf_size);
|
||||
if (!buf)
|
||||
goto error_create_buffer;
|
||||
|
||||
/* There is no encoded output content in ENC only mode */
|
||||
if (fei_mode != GST_VAAPI_FEI_MODE_ENC) {
|
||||
if (!gst_vaapi_coded_buffer_copy_into (buf, coded_buf))
|
||||
goto error_copy_buffer;
|
||||
}
|
||||
|
||||
*outbuf_ptr = buf;
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* ERRORS */
|
||||
error_invalid_buffer:
|
||||
{
|
||||
GST_ERROR ("invalid GstVaapiCodedBuffer size (%d bytes)", buf_size);
|
||||
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
|
||||
}
|
||||
error_create_buffer:
|
||||
{
|
||||
GST_ERROR ("failed to create output buffer of size %d", buf_size);
|
||||
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
|
||||
}
|
||||
error_copy_buffer:
|
||||
{
|
||||
GST_ERROR ("failed to copy GstVaapiCodedBuffer data");
|
||||
gst_buffer_unref (buf);
|
||||
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_vaapiencode_h264_fei_alloc_buffer (GstVaapiEncode * base_encode,
|
||||
GstVaapiCodedBuffer * coded_buf, GstBuffer ** out_buffer_ptr)
|
||||
{
|
||||
GstVaapiEncodeH264Fei *const encode =
|
||||
GST_VAAPIENCODE_H264_FEI_CAST (base_encode);
|
||||
GstVaapiEncoderH264Fei *const encoder =
|
||||
GST_VAAPI_ENCODER_H264_FEI (base_encode->encoder);
|
||||
GstFlowReturn ret;
|
||||
|
||||
g_return_val_if_fail (encoder != NULL, GST_FLOW_ERROR);
|
||||
|
||||
ret = alloc_buffer (base_encode, coded_buf, out_buffer_ptr);
|
||||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
if (!encode->is_avc)
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* Convert to avcC format */
|
||||
if (!_h264_convert_byte_stream_to_avc (*out_buffer_ptr))
|
||||
goto error_convert_buffer;
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* ERRORS */
|
||||
error_convert_buffer:
|
||||
{
|
||||
GST_ERROR ("failed to convert from bytestream format to avcC format");
|
||||
gst_buffer_replace (out_buffer_ptr, NULL);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapiencode_h264_load_control_data (GstVaapiEncode * base_encode,
|
||||
GstVaapiFeiVideoMeta * feimeta, GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
if (feimeta != NULL) {
|
||||
gst_vaapi_surface_proxy_set_fei_mb_code (proxy, feimeta->mbcode);
|
||||
gst_vaapi_surface_proxy_set_fei_mv (proxy, feimeta->mv);
|
||||
gst_vaapi_surface_proxy_set_fei_mv_predictor (proxy, feimeta->mvpred);
|
||||
gst_vaapi_surface_proxy_set_fei_mb_control (proxy, feimeta->mbcntrl);
|
||||
gst_vaapi_surface_proxy_set_fei_qp (proxy, feimeta->qp);
|
||||
gst_vaapi_surface_proxy_set_fei_distortion (proxy, feimeta->dist);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static GstVaapiFeiVideoMeta *
|
||||
gst_vaapiencode_h264_save_stats_to_meta (GstVaapiEncode * base_encode,
|
||||
GstVaapiCodedBufferProxy * proxy)
|
||||
{
|
||||
GstVaapiEncoderH264Fei *const encoder =
|
||||
GST_VAAPI_ENCODER_H264_FEI (base_encode->encoder);
|
||||
GstVaapiFeiVideoMeta *feimeta = NULL;
|
||||
GstVaapiEncFeiMbCode *mbcode = NULL;
|
||||
GstVaapiEncFeiMv *mv = NULL;
|
||||
GstVaapiEncFeiDistortion *dist = NULL;
|
||||
|
||||
if (!gst_vaapi_encoder_h264_is_fei_stats_out_enabled (encoder))
|
||||
return NULL;
|
||||
|
||||
feimeta = gst_vaapi_fei_video_meta_new ();
|
||||
if (feimeta == NULL)
|
||||
return NULL;
|
||||
|
||||
mbcode = gst_vaapi_coded_buffer_proxy_get_fei_mbcode (proxy);
|
||||
if (mbcode)
|
||||
feimeta->mbcode = (GstVaapiEncFeiMbCode *)
|
||||
gst_vaapi_fei_codec_object_ref ((GstVaapiFeiCodecObject *) mbcode);
|
||||
|
||||
mv = gst_vaapi_coded_buffer_proxy_get_fei_mv (proxy);
|
||||
if (mv)
|
||||
feimeta->mv = (GstVaapiEncFeiMv *)
|
||||
gst_vaapi_fei_codec_object_ref ((GstVaapiFeiCodecObject *) mv);
|
||||
|
||||
dist = gst_vaapi_coded_buffer_proxy_get_fei_distortion (proxy);
|
||||
if (dist)
|
||||
feimeta->dist = (GstVaapiEncFeiDistortion *)
|
||||
gst_vaapi_fei_codec_object_ref ((GstVaapiFeiCodecObject *) dist);
|
||||
|
||||
return feimeta;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapiencode_h264_fei_class_init (GstVaapiEncodeH264FeiClass * klass)
|
||||
{
|
||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||
gpointer encoder_class;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_vaapi_h264_fei_encode_debug,
|
||||
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
|
||||
|
||||
object_class->finalize = gst_vaapiencode_h264_fei_finalize;
|
||||
object_class->set_property = gst_vaapiencode_set_property_subclass;
|
||||
object_class->get_property = gst_vaapiencode_get_property_subclass;
|
||||
|
||||
encode_class->set_config = gst_vaapiencode_h264_fei_set_config;
|
||||
encode_class->get_caps = gst_vaapiencode_h264_fei_get_caps;
|
||||
encode_class->alloc_encoder = gst_vaapiencode_h264_fei_alloc_encoder;
|
||||
encode_class->alloc_buffer = gst_vaapiencode_h264_fei_alloc_buffer;
|
||||
|
||||
encode_class->load_control_data = gst_vaapiencode_h264_load_control_data;
|
||||
encode_class->save_stats_to_meta = gst_vaapiencode_h264_save_stats_to_meta;
|
||||
|
||||
gst_element_class_set_static_metadata (element_class,
|
||||
"VA-API H264 FEI Advanced encoder (Experimental)",
|
||||
"Codec/Encoder/Video/Hardware",
|
||||
GST_PLUGIN_DESC,
|
||||
"Sreerenj Balachandran <sreerenj.balachandran@intel.com> ,"
|
||||
"Yi A Wang <yi.a.wang@intel.com>");
|
||||
|
||||
/* sink pad */
|
||||
gst_element_class_add_static_pad_template (element_class,
|
||||
&gst_vaapiencode_h264_fei_sink_factory);
|
||||
|
||||
/* src pad */
|
||||
gst_element_class_add_static_pad_template (element_class,
|
||||
&gst_vaapiencode_h264_fei_src_factory);
|
||||
|
||||
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_H264_FEI);
|
||||
g_assert (encoder_class);
|
||||
gst_vaapiencode_class_install_properties (encode_class, encoder_class);
|
||||
g_type_class_unref (encoder_class);
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* gstvaapiencode_h264i_fei.h - VA-API H.264 FEI encoder
|
||||
*
|
||||
* Copyright (C) 2016-2017 Intel Corporation
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
* Author: Yi A Wang <yi.a.wang@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPIENCODE_H264_FEI_FEI_H
|
||||
#define GST_VAAPIENCODE_H264_FEI_FEI_H
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstvaapiencode.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VAAPIENCODE_H264_FEI \
|
||||
(gst_vaapiencode_h264_fei_get_type ())
|
||||
#define GST_VAAPIENCODE_H264_FEI_CAST(obj) \
|
||||
((GstVaapiEncodeH264Fei *)(obj))
|
||||
#define GST_VAAPIENCODE_H264_FEI(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPIENCODE_H264_FEI, \
|
||||
GstVaapiEncodeH264Fei))
|
||||
#define GST_VAAPIENCODE_H264_FEI_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPIENCODE_H264_FEI, \
|
||||
GstVaapiEncodeH264FeiClass))
|
||||
#define GST_VAAPIENCODE_H264_FEI_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPIENCODE_H264_FEI, \
|
||||
GstVaapiEncodeH264FeiClass))
|
||||
#define GST_IS_VAAPIENCODE_H264_FEI(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE_H264_FEI))
|
||||
#define GST_IS_VAAPIENCODE_H264_FEI_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE_H264_FEI))
|
||||
|
||||
typedef struct _GstVaapiEncodeH264Fei GstVaapiEncodeH264Fei;
|
||||
typedef struct _GstVaapiEncodeH264FeiClass GstVaapiEncodeH264FeiClass;
|
||||
|
||||
struct _GstVaapiEncodeH264Fei
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiEncode parent_instance;
|
||||
|
||||
guint is_avc:1; /* [FALSE]=byte-stream (default); [TRUE]=avcC */
|
||||
};
|
||||
|
||||
struct _GstVaapiEncodeH264FeiClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiEncodeClass parent_class;
|
||||
};
|
||||
|
||||
GType
|
||||
gst_vaapiencode_h264_fei_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPIENCODE_H264_FEI_FEI_H */
|
|
@ -1,210 +0,0 @@
|
|||
/*
|
||||
* gstvaapifeivideometa.c - Gst VA FEI video meta
|
||||
*
|
||||
* Copyright (C) 2016-2017 Intel Corporation
|
||||
* Author: Yi A Wang <yi.a.wang@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:gstvaapifeivideometa
|
||||
* @short_description: VA FEI video meta for GStreamer
|
||||
*/
|
||||
#include "gstcompat.h"
|
||||
#include "gstvaapifeivideometa.h"
|
||||
|
||||
static void
|
||||
gst_vaapi_fei_video_meta_finalize (GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
if (meta->mbcode)
|
||||
gst_vaapi_fei_codec_object_unref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mbcode));
|
||||
if (meta->mv)
|
||||
gst_vaapi_fei_codec_object_unref (GST_VAAPI_FEI_CODEC_OBJECT (meta->mv));
|
||||
if (meta->mvpred)
|
||||
gst_vaapi_fei_codec_object_unref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mvpred));
|
||||
if (meta->mbcntrl)
|
||||
gst_vaapi_fei_codec_object_unref (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mbcntrl));
|
||||
if (meta->qp)
|
||||
gst_vaapi_fei_codec_object_unref (GST_VAAPI_FEI_CODEC_OBJECT (meta->qp));
|
||||
if (meta->dist)
|
||||
gst_vaapi_fei_codec_object_unref (GST_VAAPI_FEI_CODEC_OBJECT (meta->dist));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_fei_video_meta_init (GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
}
|
||||
|
||||
static inline GstVaapiFeiVideoMeta *
|
||||
_gst_vaapi_fei_video_meta_create (void)
|
||||
{
|
||||
return g_slice_new0 (GstVaapiFeiVideoMeta);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_gst_vaapi_fei_video_meta_destroy (GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
g_slice_free1 (sizeof (*meta), meta);
|
||||
}
|
||||
|
||||
GstVaapiFeiVideoMeta *
|
||||
gst_vaapi_fei_video_meta_new (void)
|
||||
{
|
||||
GstVaapiFeiVideoMeta *meta;
|
||||
|
||||
meta = _gst_vaapi_fei_video_meta_create ();
|
||||
if (!meta)
|
||||
return NULL;
|
||||
gst_vaapi_fei_video_meta_init (meta);
|
||||
return meta;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_gst_vaapi_fei_video_meta_free (GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
g_atomic_int_inc (&meta->ref_count);
|
||||
|
||||
gst_vaapi_fei_video_meta_finalize (meta);
|
||||
|
||||
if (G_LIKELY (g_atomic_int_dec_and_test (&meta->ref_count)))
|
||||
_gst_vaapi_fei_video_meta_destroy (meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_fei_video_meta_ref:
|
||||
* @meta: a #GstVaapiFeiVideoMeta
|
||||
*
|
||||
* Atomically increases the reference count of the given @meta by one.
|
||||
*
|
||||
* Returns: The same @meta argument
|
||||
*/
|
||||
GstVaapiFeiVideoMeta *
|
||||
gst_vaapi_fei_video_meta_ref (GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
g_return_val_if_fail (meta != NULL, NULL);
|
||||
|
||||
g_atomic_int_inc (&meta->ref_count);
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_fei_video_meta_unref:
|
||||
* @meta: a #GstVaapiFeiVideoMeta
|
||||
*
|
||||
* Atomically decreases the reference count of the @meta by one. If
|
||||
* the reference count reaches zero, the object will be free'd.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_fei_video_meta_unref (GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
g_return_if_fail (meta != NULL);
|
||||
g_return_if_fail (meta->ref_count > 0);
|
||||
if (g_atomic_int_dec_and_test (&meta->ref_count))
|
||||
_gst_vaapi_fei_video_meta_free (meta);
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_video_meta_api_get_type (void)
|
||||
{
|
||||
static gsize g_type;
|
||||
static const gchar *tags[] = { "memory", NULL };
|
||||
|
||||
if (g_once_init_enter (&g_type)) {
|
||||
GType type = gst_meta_api_type_register ("GstVaapiFeiVideoMetaAPI", tags);
|
||||
g_once_init_leave (&g_type, type);
|
||||
}
|
||||
return g_type;
|
||||
}
|
||||
|
||||
|
||||
#define GST_VAAPI_FEI_VIDEO_META_HOLDER(meta) \
|
||||
((GstVaapiFeiVideoMetaHolder *) (meta))
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_fei_video_meta_holder_init (GstVaapiFeiVideoMetaHolder * meta,
|
||||
gpointer params, GstBuffer * buffer)
|
||||
{
|
||||
meta->meta = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_fei_video_meta_holder_free (GstVaapiFeiVideoMetaHolder * meta,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
if (meta->meta)
|
||||
gst_vaapi_fei_video_meta_unref (meta->meta);
|
||||
}
|
||||
|
||||
|
||||
#define GST_VAAPI_FEI_VIDEO_META_INFO gst_vaapi_fei_video_meta_info_get ()
|
||||
static const GstMetaInfo *
|
||||
gst_vaapi_fei_video_meta_info_get (void)
|
||||
{
|
||||
static gsize g_meta_info;
|
||||
|
||||
if (g_once_init_enter (&g_meta_info)) {
|
||||
gsize meta_info =
|
||||
GPOINTER_TO_SIZE (gst_meta_register (GST_VAAPI_FEI_VIDEO_META_API_TYPE,
|
||||
"GstVaapiFeiVideoMeta", sizeof (GstVaapiFeiVideoMetaHolder),
|
||||
(GstMetaInitFunction) gst_vaapi_fei_video_meta_holder_init,
|
||||
(GstMetaFreeFunction) gst_vaapi_fei_video_meta_holder_free,
|
||||
NULL));
|
||||
g_once_init_leave (&g_meta_info, meta_info);
|
||||
}
|
||||
return GSIZE_TO_POINTER (g_meta_info);
|
||||
}
|
||||
|
||||
GstVaapiFeiVideoMeta *
|
||||
gst_buffer_get_vaapi_fei_video_meta (GstBuffer * buffer)
|
||||
{
|
||||
GstVaapiFeiVideoMeta *meta;
|
||||
GstMeta *m;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
||||
|
||||
m = gst_buffer_get_meta (buffer, GST_VAAPI_FEI_VIDEO_META_API_TYPE);
|
||||
if (!m)
|
||||
return NULL;
|
||||
|
||||
meta = GST_VAAPI_FEI_VIDEO_META_HOLDER (m)->meta;
|
||||
if (meta)
|
||||
meta->buffer = buffer;
|
||||
return meta;
|
||||
}
|
||||
|
||||
void
|
||||
gst_buffer_set_vaapi_fei_video_meta (GstBuffer * buffer,
|
||||
GstVaapiFeiVideoMeta * meta)
|
||||
{
|
||||
GstMeta *m = NULL;
|
||||
|
||||
g_return_if_fail (GST_IS_BUFFER (buffer));
|
||||
g_return_if_fail (GST_VAAPI_IS_FEI_VIDEO_META (meta));
|
||||
|
||||
m = gst_buffer_add_meta (buffer, GST_VAAPI_FEI_VIDEO_META_INFO, NULL);
|
||||
|
||||
if (m)
|
||||
GST_VAAPI_FEI_VIDEO_META_HOLDER (m)->meta =
|
||||
gst_vaapi_fei_video_meta_ref (meta);
|
||||
return;
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* gstvaapifeivideometa.h - Gstreamer/VA video meta
|
||||
*
|
||||
* Copyright (C) 2016-2017 Intel Corporation
|
||||
* Author: Yi A Wang <yi.a.wang@intel.com>
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_FEI_VIDEO_META_H
|
||||
#define GST_VAAPI_FEI_VIDEO_META_H
|
||||
|
||||
#include <va/va.h>
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVaapiFeiVideoMeta GstVaapiFeiVideoMeta;
|
||||
typedef struct _GstVaapiFeiVideoMetaHolder GstVaapiFeiVideoMetaHolder;
|
||||
|
||||
#define GST_VAAPI_FEI_VIDEO_META(obj) \
|
||||
((GstVaapiFeiVideoMeta *) (obj))
|
||||
#define GST_VAAPI_IS_FEI_VIDEO_META(obj) \
|
||||
(GST_VAAPI_FEI_VIDEO_META (obj) != NULL)
|
||||
|
||||
struct _GstVaapiFeiVideoMetaHolder
|
||||
{
|
||||
GstMeta base;
|
||||
GstVaapiFeiVideoMeta *meta;
|
||||
};
|
||||
|
||||
struct _GstVaapiFeiVideoMeta {
|
||||
GstVaapiEncFeiMbCode *mbcode;
|
||||
GstVaapiEncFeiMv *mv;
|
||||
GstVaapiEncFeiMvPredictor *mvpred;
|
||||
GstVaapiEncFeiMbControl *mbcntrl;
|
||||
GstVaapiEncFeiQp *qp;
|
||||
GstVaapiEncFeiDistortion *dist;
|
||||
|
||||
GstBuffer *buffer;
|
||||
gint ref_count;
|
||||
};
|
||||
|
||||
#define GST_VAAPI_FEI_VIDEO_META_API_TYPE \
|
||||
gst_vaapi_fei_video_meta_api_get_type ()
|
||||
|
||||
GType
|
||||
gst_vaapi_fei_video_meta_api_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GstVaapiFeiVideoMeta *
|
||||
gst_vaapi_fei_video_meta_new (void);
|
||||
|
||||
GstVaapiFeiVideoMeta *
|
||||
gst_vaapi_fei_video_meta_ref (GstVaapiFeiVideoMeta * meta);
|
||||
|
||||
void
|
||||
gst_vaapi_fei_video_meta_unref (GstVaapiFeiVideoMeta * meta);
|
||||
|
||||
GstVaapiFeiVideoMeta *
|
||||
gst_buffer_get_vaapi_fei_video_meta (GstBuffer * buffer);
|
||||
|
||||
void
|
||||
gst_buffer_set_vaapi_fei_video_meta (GstBuffer * buffer, GstVaapiFeiVideoMeta * meta);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_FEI_VIDEO_META_H */
|
|
@ -33,13 +33,6 @@ if USE_VP9_ENCODER
|
|||
vaapi_sources += 'gstvaapiencode_vp9.c'
|
||||
endif
|
||||
|
||||
if USE_H264_FEI_ENCODER
|
||||
vaapi_sources += [
|
||||
'gstvaapifeivideometa.c',
|
||||
'gstvaapiencode_h264_fei.c',
|
||||
]
|
||||
endif
|
||||
|
||||
gstvaapi = library('gstvaapi',
|
||||
vaapi_sources,
|
||||
c_args : gstreamer_vaapi_args + ['-DGST_USE_UNSTABLE_API'],
|
||||
|
|
|
@ -110,7 +110,6 @@ endif
|
|||
|
||||
USE_ENCODERS = get_option('with_encoders') != 'no'
|
||||
USE_VP9_ENCODER = USE_ENCODERS and cc.has_header('va/va_enc_vp9.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
|
||||
USE_H264_FEI_ENCODER = USE_ENCODERS and cc.has_header('va/va_fei_h264.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
|
||||
|
||||
USE_DRM = libva_drm_dep.found() and libdrm_dep.found() and libudev_dep.found() and get_option('with_drm') != 'no'
|
||||
USE_EGL = gmodule_dep.found() and egl_dep.found() and GLES_VERSION_MASK != 0 and get_option('with_egl') != 'no'
|
||||
|
@ -141,7 +140,6 @@ cdata.set10('USE_EGL', USE_EGL)
|
|||
cdata.set10('USE_ENCODERS', USE_ENCODERS)
|
||||
cdata.set10('USE_GLX', USE_GLX)
|
||||
cdata.set10('USE_VP9_ENCODER', USE_VP9_ENCODER)
|
||||
cdata.set10('USE_H264_FEI_ENCODER', USE_H264_FEI_ENCODER)
|
||||
cdata.set10('USE_WAYLAND', USE_WAYLAND)
|
||||
cdata.set10('USE_X11', USE_X11)
|
||||
cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
|
||||
|
|
|
@ -46,13 +46,6 @@ if USE_ENCODERS
|
|||
test_examples += [ 'simple-encoder' ]
|
||||
endif
|
||||
|
||||
if USE_H264_FEI_ENCODER
|
||||
test_examples += [
|
||||
'test-fei-enc-out',
|
||||
'test-fei-enc-in',
|
||||
]
|
||||
endif
|
||||
|
||||
if USE_GLX
|
||||
test_examples += [ 'test-textures' ]
|
||||
endif
|
||||
|
|
|
@ -1,680 +0,0 @@
|
|||
/*
|
||||
* test-fei-enc-in.c - Test FEI input buffer submission
|
||||
*
|
||||
* Copyright (C) 2016 Intel Corporation
|
||||
*
|
||||
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* sample pipeline: ./test-fei-enc-input -c h264 -o out.264 -e 4 -q 1 sample_i420.y4m */
|
||||
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "gst/vaapi/sysdeps.h"
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
#include <gst/vaapi/gstvaapiencoder_h264_fei.h>
|
||||
#include <gst/vaapi/gstvaapisurfacepool.h>
|
||||
#include <gst/vaapi/gstvaapisurfaceproxy.h>
|
||||
#include <gst/vaapi/gstvaapifei_objects.h>
|
||||
#include "output.h"
|
||||
#include "y4mreader.h"
|
||||
#include <va/va.h>
|
||||
|
||||
static guint g_bitrate = 0;
|
||||
static gchar *g_codec_str;
|
||||
static gchar *g_output_file_name;
|
||||
static char **g_input_files = NULL;
|
||||
static gchar *input_mv_name = NULL;
|
||||
static gchar *input_mbmode_name = NULL;
|
||||
static guint input_mv_size;
|
||||
static guint input_mbmode_size;
|
||||
static guint input_qp;
|
||||
static guint enable_mbcntrl;
|
||||
static guint enable_mvpred;
|
||||
static guint fei_mode;
|
||||
|
||||
#define SURFACE_NUM 16
|
||||
|
||||
#define ENC 1
|
||||
#define PAK 2
|
||||
#define ENC_PLUS_PAK 3
|
||||
#define ENC_PAK 4
|
||||
|
||||
static GOptionEntry g_options[] = {
|
||||
{"codec", 'c', 0, G_OPTION_ARG_STRING, &g_codec_str,
|
||||
"codec to use for video encoding (h264)", NULL},
|
||||
{"bitrate", 'b', 0, G_OPTION_ARG_INT, &g_bitrate,
|
||||
"desired bitrate expressed in kbps", NULL},
|
||||
{"output", 'o', 0, G_OPTION_ARG_FILENAME, &g_output_file_name,
|
||||
"output file name", NULL},
|
||||
{"imv", 'v', 0, G_OPTION_ARG_STRING, &input_mv_name,
|
||||
"pak mv input file", NULL},
|
||||
{"imbmode ", 'm', 0, G_OPTION_ARG_STRING, &input_mbmode_name,
|
||||
"pak mbmode input file", NULL},
|
||||
{"imvsize", 's', 0, G_OPTION_ARG_INT, &input_mv_size,
|
||||
"input stream width", NULL},
|
||||
{"imbmodesize", 'd', 0, G_OPTION_ARG_INT, &input_mbmode_size,
|
||||
"input stream height", NULL},
|
||||
{"iqp", 'q', 0, G_OPTION_ARG_INT, &input_qp,
|
||||
"input qp val (it will get replicated for each macrobock)", NULL},
|
||||
{"imbcntrl", 'l', 0, G_OPTION_ARG_INT, &enable_mbcntrl,
|
||||
"enable macroblock control for each macrobock", NULL},
|
||||
{"imbpred", 'p', 0, G_OPTION_ARG_INT, &enable_mvpred,
|
||||
"enable mv predictor for each macroblock", NULL},
|
||||
{"fei-mode", 'e', 0, G_OPTION_ARG_INT, &fei_mode,
|
||||
"1:ENC 2:PAK 3:ENC+PAK 4:ENC_PAK", NULL},
|
||||
|
||||
{G_OPTION_REMAINING, ' ', 0, G_OPTION_ARG_FILENAME_ARRAY, &g_input_files,
|
||||
"input file name", NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiEncoder *encoder;
|
||||
guint read_frames;
|
||||
guint encoded_frames;
|
||||
guint saved_frames;
|
||||
Y4MReader *parser;
|
||||
FILE *output_file;
|
||||
int mv_fd;
|
||||
int mbmode_fd;
|
||||
guint input_mv_size;
|
||||
guint input_mbmode_size;
|
||||
guint input_stopped:1;
|
||||
guint encode_failed:1;
|
||||
} App;
|
||||
|
||||
static inline gchar *
|
||||
generate_output_filename (const gchar * ext)
|
||||
{
|
||||
gchar *fn;
|
||||
int i = 0;
|
||||
|
||||
while (1) {
|
||||
fn = g_strdup_printf ("temp%02d.%s", i, ext);
|
||||
if (g_file_test (fn, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
|
||||
i++;
|
||||
g_free (fn);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_options (int *argc, char *argv[])
|
||||
{
|
||||
GOptionContext *ctx;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
||||
ctx = g_option_context_new (" - encoder test options");
|
||||
if (!ctx)
|
||||
return FALSE;
|
||||
|
||||
g_option_context_add_group (ctx, gst_init_get_option_group ());
|
||||
g_option_context_add_main_entries (ctx, g_options, NULL);
|
||||
g_option_context_set_help_enabled (ctx, TRUE);
|
||||
success = g_option_context_parse (ctx, argc, &argv, &error);
|
||||
if (!success) {
|
||||
g_printerr ("Option parsing failed: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (!g_codec_str)
|
||||
g_codec_str = g_strdup ("h264");
|
||||
if (!g_output_file_name)
|
||||
g_output_file_name = generate_output_filename (g_codec_str);
|
||||
|
||||
bail:
|
||||
g_option_context_free (ctx);
|
||||
return success;
|
||||
}
|
||||
|
||||
static void
|
||||
print_yuv_info (App * app)
|
||||
{
|
||||
g_print ("\n");
|
||||
g_print ("Encode : %s\n", g_codec_str);
|
||||
g_print ("Resolution : %dx%d\n", app->parser->width, app->parser->height);
|
||||
g_print ("Source YUV : %s\n", g_input_files ? g_input_files[0] : "stdin");
|
||||
g_print ("Frame Rate : %0.1f fps\n",
|
||||
1.0 * app->parser->fps_n / app->parser->fps_d);
|
||||
g_print ("Coded file : %s\n", g_output_file_name);
|
||||
g_print ("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_num_frame (App * app)
|
||||
{
|
||||
g_print ("\n");
|
||||
g_print ("read frames : %d\n", app->read_frames);
|
||||
g_print ("encoded frames : %d\n", app->encoded_frames);
|
||||
g_print ("saved frames : %d\n", app->saved_frames);
|
||||
g_print ("\n");
|
||||
}
|
||||
|
||||
static GstVaapiEncoder *
|
||||
encoder_new (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiEncoder *encoder = NULL;
|
||||
|
||||
if (!g_strcmp0 (g_codec_str, "h264")) {
|
||||
encoder = gst_vaapi_encoder_h264_fei_new (display);
|
||||
gst_vaapi_encoder_h264_fei_set_function_mode (GST_VAAPI_ENCODER_H264_FEI
|
||||
(encoder), fei_mode);
|
||||
gst_vaapi_encoder_h264_fei_set_max_profile (GST_VAAPI_ENCODER_H264_FEI
|
||||
(encoder), GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE);
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
return encoder;
|
||||
}
|
||||
|
||||
static inline GstVideoCodecState *
|
||||
new_codec_state (gint width, gint height, gint fps_n, gint fps_d)
|
||||
{
|
||||
GstVideoCodecState *state;
|
||||
|
||||
state = g_slice_new0 (GstVideoCodecState);
|
||||
state->ref_count = 1;
|
||||
gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, width,
|
||||
height);
|
||||
|
||||
state->info.fps_n = fps_n;
|
||||
state->info.fps_d = fps_d;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_format (GstVaapiEncoder * encoder, gint width, gint height, gint fps_n,
|
||||
gint fps_d)
|
||||
{
|
||||
GstVideoCodecState *in_state;
|
||||
GstVaapiEncoderStatus status;
|
||||
|
||||
in_state = new_codec_state (width, height, fps_n, fps_d);
|
||||
status = gst_vaapi_encoder_set_codec_state (encoder, in_state);
|
||||
g_slice_free (GstVideoCodecState, in_state);
|
||||
|
||||
return (status == GST_VAAPI_ENCODER_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
allocate_buffer (GstVaapiCodedBuffer * vbuf)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
gssize size;
|
||||
|
||||
size = gst_vaapi_coded_buffer_get_size (vbuf);
|
||||
|
||||
if (size <= 0) {
|
||||
g_warning ("Invalid VA buffer size (%zd)", size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf = gst_buffer_new_and_alloc (size);
|
||||
if (!buf) {
|
||||
g_warning ("Failed to create output buffer of size %zd", size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gst_vaapi_coded_buffer_copy_into (buf, vbuf)) {
|
||||
g_warning ("Failed to copy VA buffer data");
|
||||
gst_buffer_unref (buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static GstVaapiEncoderStatus
|
||||
get_encoder_buffer (GstVaapiEncoder * encoder, GstBuffer ** buffer)
|
||||
{
|
||||
GstVaapiCodedBufferProxy *proxy = NULL;
|
||||
GstVaapiEncoderStatus status;
|
||||
|
||||
status = gst_vaapi_encoder_get_buffer_with_timeout (encoder, &proxy, 50000);
|
||||
if (status < GST_VAAPI_ENCODER_STATUS_SUCCESS) {
|
||||
g_warning ("Failed to get a buffer from encoder: %d", status);
|
||||
return status;
|
||||
} else if (status > GST_VAAPI_ENCODER_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
*buffer = allocate_buffer (GST_VAAPI_CODED_BUFFER_PROXY_BUFFER (proxy));
|
||||
gst_vaapi_coded_buffer_proxy_unref (proxy);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
outputs_to_file (GstBuffer * buffer, FILE * file)
|
||||
{
|
||||
GstMapInfo info;
|
||||
size_t written;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (!gst_buffer_map (buffer, &info, GST_MAP_READ))
|
||||
return FALSE;
|
||||
|
||||
if (info.size <= 0 || !info.data)
|
||||
return FALSE;
|
||||
|
||||
written = fwrite (info.data, 1, info.size, file);
|
||||
if (written < info.size) {
|
||||
g_warning ("write file error.");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
bail:
|
||||
gst_buffer_unmap (buffer, &info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
get_buffer_thread (gpointer data)
|
||||
{
|
||||
App *app = data;
|
||||
|
||||
GstVaapiEncoderStatus ret;
|
||||
GstBuffer *obuf;
|
||||
|
||||
while (1) {
|
||||
obuf = NULL;
|
||||
ret = get_encoder_buffer (app->encoder, &obuf);
|
||||
if (app->input_stopped && ret > GST_VAAPI_ENCODER_STATUS_SUCCESS) {
|
||||
break; /* finished */
|
||||
} else if (ret > GST_VAAPI_ENCODER_STATUS_SUCCESS) { /* another chance */
|
||||
continue;
|
||||
}
|
||||
if (ret < GST_VAAPI_ENCODER_STATUS_SUCCESS) { /* fatal error */
|
||||
app->encode_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
app->encoded_frames++;
|
||||
g_debug ("encoded frame %d, buffer = %p", app->encoded_frames, obuf);
|
||||
|
||||
if (app->output_file && outputs_to_file (obuf, app->output_file))
|
||||
app->saved_frames++;
|
||||
|
||||
gst_buffer_unref (obuf);
|
||||
}
|
||||
if (obuf)
|
||||
gst_buffer_replace (&obuf, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
app_free (App * app)
|
||||
{
|
||||
g_return_if_fail (app);
|
||||
|
||||
if (app->parser)
|
||||
y4m_reader_close (app->parser);
|
||||
|
||||
if (app->encoder) {
|
||||
gst_vaapi_encoder_flush (app->encoder);
|
||||
gst_object_unref (app->encoder);
|
||||
}
|
||||
|
||||
if (app->display)
|
||||
gst_object_unref (app->display);
|
||||
|
||||
if (app->output_file)
|
||||
fclose (app->output_file);
|
||||
|
||||
g_slice_free (App, app);
|
||||
}
|
||||
|
||||
static App *
|
||||
app_new (const gchar * input_fn, const gchar * output_fn)
|
||||
{
|
||||
App *app = g_slice_new0 (App);
|
||||
if (!app)
|
||||
return NULL;
|
||||
app->parser = y4m_reader_open (input_fn);
|
||||
if (!app->parser) {
|
||||
g_warning ("Could not parse input stream.");
|
||||
goto error;
|
||||
}
|
||||
|
||||
app->output_file = fopen (output_fn, "w");
|
||||
if (app->output_file == NULL) {
|
||||
g_warning ("Could not open file \"%s\" for writing: %s.", output_fn,
|
||||
g_strerror (errno));
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* if PAK only */
|
||||
if (fei_mode == 2) {
|
||||
if (!input_mv_name || !input_mbmode_name) {
|
||||
g_warning ("pak only mode need an mv and mbmode files as input");
|
||||
assert (0);
|
||||
}
|
||||
|
||||
if (input_mv_name)
|
||||
app->mv_fd = open (input_mv_name, O_RDONLY, 0);
|
||||
if (input_mbmode_name)
|
||||
app->mbmode_fd = open (input_mbmode_name, O_RDONLY, 0);
|
||||
|
||||
assert (app->mv_fd >= 0);
|
||||
assert (app->mbmode_fd >= 0);
|
||||
}
|
||||
|
||||
app->display = video_output_create_display (NULL);
|
||||
if (!app->display) {
|
||||
g_warning ("Could not create VA display.");
|
||||
goto error;
|
||||
}
|
||||
|
||||
app->encoder = encoder_new (app->display);
|
||||
if (!app->encoder) {
|
||||
g_warning ("Could not create encoder.");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!set_format (app->encoder, app->parser->width, app->parser->height,
|
||||
app->parser->fps_n, app->parser->fps_d)) {
|
||||
g_warning ("Could not set format.");
|
||||
goto error;
|
||||
}
|
||||
|
||||
return app;
|
||||
|
||||
error:
|
||||
app_free (app);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
upload_frame (GstVaapiEncoder * encoder, GstVaapiSurfaceProxy * proxy)
|
||||
{
|
||||
GstVideoCodecFrame *frame;
|
||||
GstVaapiEncoderStatus ret;
|
||||
|
||||
frame = g_slice_new0 (GstVideoCodecFrame);
|
||||
gst_video_codec_frame_set_user_data (frame,
|
||||
gst_vaapi_surface_proxy_ref (proxy),
|
||||
(GDestroyNotify) gst_vaapi_surface_proxy_unref);
|
||||
|
||||
ret = gst_vaapi_encoder_put_frame (encoder, frame);
|
||||
return (ret == GST_VAAPI_ENCODER_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
load_frame (App * app, GstVaapiImage * image)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (!gst_vaapi_image_map (image))
|
||||
return FALSE;
|
||||
|
||||
ret = y4m_reader_load_image (app->parser, image);
|
||||
|
||||
if (!gst_vaapi_image_unmap (image))
|
||||
return FALSE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
app_run (App * app)
|
||||
{
|
||||
GstVaapiImage *image;
|
||||
GstVaapiVideoPool *pool;
|
||||
GThread *buffer_thread;
|
||||
gsize id;
|
||||
gint i;
|
||||
|
||||
int ret = EXIT_FAILURE;
|
||||
image = gst_vaapi_image_new (app->display, GST_VIDEO_FORMAT_I420,
|
||||
app->parser->width, app->parser->height);
|
||||
|
||||
{
|
||||
GstVideoInfo vi;
|
||||
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_ENCODED,
|
||||
app->parser->width, app->parser->height);
|
||||
pool = gst_vaapi_surface_pool_new_full (app->display, &vi, 0);
|
||||
}
|
||||
buffer_thread = g_thread_new ("get buffer thread", get_buffer_thread, app);
|
||||
|
||||
while (1) {
|
||||
GstVaapiSurfaceProxy *proxy;
|
||||
GstVaapiSurface *surface;
|
||||
gpointer data = NULL;
|
||||
guint size = 0;
|
||||
gint rt = 0;
|
||||
guint mb_width, mb_height, mb_size;
|
||||
|
||||
if (!load_frame (app, image))
|
||||
break;
|
||||
|
||||
if (!gst_vaapi_image_unmap (image))
|
||||
break;
|
||||
|
||||
proxy =
|
||||
gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL (pool));
|
||||
if (!proxy) {
|
||||
g_warning ("Could not get surface proxy from pool.");
|
||||
break;
|
||||
}
|
||||
surface = gst_vaapi_surface_proxy_get_surface (proxy);
|
||||
if (!surface) {
|
||||
g_warning ("Could not get surface from proxy.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!gst_vaapi_surface_put_image (surface, image)) {
|
||||
g_warning ("Could not update surface");
|
||||
break;
|
||||
}
|
||||
|
||||
mb_width = (app->parser->width + 15) >> 4;
|
||||
mb_height = (app->parser->height + 15) >> 4;
|
||||
mb_size = mb_width * mb_height;
|
||||
|
||||
/* PAK Only */
|
||||
if (fei_mode == PAK) {
|
||||
GstVaapiEncFeiMbCode *mbcode;
|
||||
GstVaapiEncFeiMv *mv;
|
||||
guint mv_size, mbmode_size;
|
||||
|
||||
mv_size = mb_width * mb_height * 128;
|
||||
mbmode_size = mb_width * mb_height * 64;
|
||||
|
||||
if (input_mv_size)
|
||||
assert (input_mv_size == mv_size);
|
||||
|
||||
if (input_mbmode_size)
|
||||
assert (input_mbmode_size == mbmode_size);
|
||||
|
||||
/* Upload mbmode data */
|
||||
mbcode = gst_vaapi_enc_fei_mb_code_new (app->encoder, NULL, mbmode_size);
|
||||
rt = gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT (mbcode),
|
||||
&data, &size);
|
||||
assert (rt == 1);
|
||||
rt = read (app->mbmode_fd, data, mbmode_size);
|
||||
assert (rt >= 0);
|
||||
|
||||
/* Upload mv data */
|
||||
mv = gst_vaapi_enc_fei_mv_new (app->encoder, NULL, mv_size);
|
||||
rt = gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT (mv),
|
||||
&data, &size);
|
||||
assert (rt == 1);
|
||||
rt = read (app->mv_fd, data, mv_size);
|
||||
assert (rt >= 0);
|
||||
|
||||
/* assign mv and mbmode buffers to input surface proxy */
|
||||
gst_vaapi_surface_proxy_set_fei_mb_code (proxy, mbcode);
|
||||
gst_vaapi_surface_proxy_set_fei_mv (proxy, mv);
|
||||
|
||||
} else {
|
||||
/* ENC, ENC+PAK and ENC_PAK */
|
||||
|
||||
if (input_qp) {
|
||||
GstVaapiEncFeiQp *qp = NULL;
|
||||
VAEncQPBufferH264 *pqp = NULL;
|
||||
guint qp_size = 0;
|
||||
|
||||
qp_size = mb_width * mb_height * sizeof (VAEncQPBufferH264);
|
||||
|
||||
qp = gst_vaapi_enc_fei_qp_new (app->encoder, NULL, qp_size);
|
||||
rt = gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT (qp),
|
||||
&data, &size);
|
||||
assert (rt == 1);
|
||||
|
||||
pqp = (VAEncQPBufferH264 *) data;
|
||||
for (i = 0; i < mb_size; i++) {
|
||||
pqp->qp = input_qp;
|
||||
pqp++;
|
||||
}
|
||||
gst_vaapi_surface_proxy_set_fei_qp (proxy, qp);
|
||||
}
|
||||
|
||||
if (enable_mbcntrl) {
|
||||
GstVaapiEncFeiMbControl *mbcntrl = NULL;
|
||||
VAEncFEIMBControlH264 *pmbcntrl = NULL;
|
||||
guint mbcntrl_size = 0;
|
||||
|
||||
mbcntrl_size = mb_width * mb_height * sizeof (VAEncFEIMBControlH264);
|
||||
mbcntrl =
|
||||
gst_vaapi_enc_fei_mb_control_new (app->encoder, NULL, mbcntrl_size);
|
||||
rt = gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(mbcntrl), &data, &size);
|
||||
assert (rt == 1);
|
||||
|
||||
pmbcntrl = (VAEncFEIMBControlH264 *) data;
|
||||
for (i = 0; i < mb_size; i++) {
|
||||
pmbcntrl->force_to_intra = 1;
|
||||
pmbcntrl->force_to_skip = 0;
|
||||
pmbcntrl->force_to_nonskip = 0;
|
||||
pmbcntrl->enable_direct_bias_adjustment = 0;
|
||||
pmbcntrl->enable_motion_bias_adjustment = 0;
|
||||
pmbcntrl->ext_mv_cost_scaling_factor = 0;
|
||||
pmbcntrl->target_size_in_word = 0xff;
|
||||
pmbcntrl->max_size_in_word = 0xff;
|
||||
pmbcntrl++;
|
||||
}
|
||||
gst_vaapi_surface_proxy_set_fei_mb_control (proxy, mbcntrl);
|
||||
}
|
||||
|
||||
if (enable_mvpred) {
|
||||
GstVaapiEncFeiMvPredictor *mvpred = NULL;
|
||||
VAEncFEIMVPredictorH264 *pmvpred = NULL;
|
||||
guint mvpred_size = 0, j;
|
||||
|
||||
mvpred_size = mb_width * mb_height * sizeof (VAEncFEIMVPredictorH264);
|
||||
mvpred =
|
||||
gst_vaapi_enc_fei_mv_predictor_new (app->encoder, NULL,
|
||||
mvpred_size);
|
||||
rt = gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(mvpred), &data, &size);
|
||||
assert (rt == 1);
|
||||
|
||||
pmvpred = (VAEncFEIMVPredictorH264 *) data;
|
||||
for (i = 0; i < mb_size; i++) {
|
||||
for (j = 0; i < 4; i++) {
|
||||
pmvpred->ref_idx[j].ref_idx_l0 = 0;
|
||||
pmvpred->ref_idx[j].ref_idx_l1 = 0;
|
||||
|
||||
pmvpred->mv[j].mv0[0] = 0x8000;
|
||||
pmvpred->mv[j].mv0[1] = 0x8000;
|
||||
pmvpred->mv[j].mv1[0] = 0x8000;
|
||||
pmvpred->mv[j].mv1[1] = 0x8000;
|
||||
}
|
||||
pmvpred++;
|
||||
}
|
||||
gst_vaapi_surface_proxy_set_fei_mv_predictor (proxy, mvpred);
|
||||
}
|
||||
}
|
||||
|
||||
if (!upload_frame (app->encoder, proxy)) {
|
||||
g_warning ("put frame failed");
|
||||
break;
|
||||
}
|
||||
|
||||
app->read_frames++;
|
||||
id = gst_vaapi_surface_get_id (surface);
|
||||
g_debug ("input frame %d, surface id = %" G_GSIZE_FORMAT, app->read_frames,
|
||||
id);
|
||||
|
||||
gst_vaapi_surface_proxy_unref (proxy);
|
||||
}
|
||||
|
||||
app->input_stopped = TRUE;
|
||||
|
||||
g_thread_join (buffer_thread);
|
||||
|
||||
if (!app->encode_failed && feof (app->parser->fp))
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
gst_vaapi_video_pool_replace (&pool, NULL);
|
||||
gst_vaapi_image_unref (image);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
App *app;
|
||||
int ret = EXIT_FAILURE;
|
||||
gchar *input_fn;
|
||||
|
||||
if (!parse_options (&argc, argv))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
/* @TODO: iterate all the input files */
|
||||
input_fn = g_input_files ? g_input_files[0] : NULL;
|
||||
if (input_fn && !g_file_test (input_fn,
|
||||
G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
|
||||
g_warning ("input file \"%s\" doesn't exist", input_fn);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
app = app_new (input_fn, g_output_file_name);
|
||||
if (!app)
|
||||
goto bail;
|
||||
print_yuv_info (app);
|
||||
ret = app_run (app);
|
||||
print_num_frame (app);
|
||||
|
||||
app_free (app);
|
||||
|
||||
bail:
|
||||
g_free (g_codec_str);
|
||||
g_free (g_output_file_name);
|
||||
g_strfreev (g_input_files);
|
||||
|
||||
gst_deinit ();
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -1,300 +0,0 @@
|
|||
/*
|
||||
* test-fei-enc-out.c - FEI Encoder Test application to dump output buffers
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* ./test-fei-enc -i sample_320x240.nv12 -f nv12 -w 320 -h 240 -o out.264 -v mv.out -d dist.out -m mbcode.out -e 1 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/app/gstappsink.h>
|
||||
#include <stdlib.h>
|
||||
#include "../gst/vaapi/gstvaapifeivideometa.h"
|
||||
#include <gst/video/video.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GstElement *pipeline, *filesrc, *videoparse, *enc, *capsfilter, *appsink;
|
||||
GError *err = NULL;
|
||||
GstStateChangeReturn ret;
|
||||
GstSample *sample;
|
||||
GstVideoFormat raw_format = GST_VIDEO_FORMAT_NV12;
|
||||
GOptionContext *ctx;
|
||||
FILE *file = NULL;
|
||||
FILE *mv_file = NULL;
|
||||
FILE *dist_file = NULL;
|
||||
FILE *mbcode_file = NULL;
|
||||
FILE *fei_stat_file = NULL;
|
||||
gchar *input_file_name = NULL;
|
||||
gchar *output_file_name = NULL;
|
||||
gchar *output_mv_name = NULL;
|
||||
gchar *output_distortion_name = NULL;
|
||||
gchar *output_mbcode_name = NULL;
|
||||
gchar *input_format;
|
||||
guint input_width;
|
||||
guint input_height;
|
||||
guint enc_frame_num = 0;
|
||||
guint block_size = 0;
|
||||
guint fei_mode = 1;
|
||||
guint fei_mode_flag = 0x00000004;
|
||||
gboolean link_ok = FALSE;
|
||||
guint mv_buffer_size = 0;
|
||||
guint mbcode_buffer_size = 0;
|
||||
guint dist_buffer_size = 0;
|
||||
gpointer mapped_data = NULL;
|
||||
guint mapped_data_size = 0;
|
||||
const gchar *caps_string = "video/x-h264, profile=constrained-baseline";
|
||||
GstCaps *filter_caps = NULL;
|
||||
|
||||
GOptionEntry options[] = {
|
||||
{"input file", 'i', 0, G_OPTION_ARG_STRING, &input_file_name,
|
||||
"file to encode", NULL},
|
||||
{"output file", 'o', 0, G_OPTION_ARG_STRING, &output_file_name,
|
||||
"encpak output file", NULL},
|
||||
{"output mv file", 'v', 0, G_OPTION_ARG_STRING, &output_mv_name,
|
||||
"encpak mv output file", NULL},
|
||||
{"output distortion file", 'd', 0, G_OPTION_ARG_STRING,
|
||||
&output_distortion_name,
|
||||
"encpak distortion output file", NULL},
|
||||
{"output mbcode file", 'm', 0, G_OPTION_ARG_STRING, &output_mbcode_name,
|
||||
"encpak mbcode output file", NULL},
|
||||
{"format", 'f', 0, G_OPTION_ARG_STRING, &input_format,
|
||||
"input raw format: nv12 or i420", NULL},
|
||||
{"width", 'w', 0, G_OPTION_ARG_INT, &input_width,
|
||||
"input stream width", NULL},
|
||||
{"height", 'h', 0, G_OPTION_ARG_INT, &input_height,
|
||||
"input stream height", NULL},
|
||||
{"frame-num", 'n', 0, G_OPTION_ARG_INT, &enc_frame_num,
|
||||
"numumber of buffers to be encoded", NULL},
|
||||
{"blocksize", 's', 0, G_OPTION_ARG_INT, &block_size,
|
||||
"single buffer size of input stream", NULL},
|
||||
{"fei-mode", 'e', 0, G_OPTION_ARG_INT, &fei_mode,
|
||||
"1: ENC_PAK 2: ENC+PAK", NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
ctx =
|
||||
g_option_context_new
|
||||
("encpak with element filesrc, videoparse, vaapih264feienc, appsink");
|
||||
g_option_context_add_main_entries (ctx, options, NULL);
|
||||
g_option_context_add_group (ctx, gst_init_get_option_group ());
|
||||
|
||||
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
|
||||
g_print ("Error intializing: %s\n", err->message);
|
||||
g_option_context_free (ctx);
|
||||
g_clear_error (&err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (input_file_name == NULL || output_file_name == NULL) {
|
||||
g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL));
|
||||
g_option_context_free (ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!g_strcmp0 (input_format, "nv12"))
|
||||
raw_format = GST_VIDEO_FORMAT_NV12;
|
||||
else if (!g_strcmp0 (input_format, "i420"))
|
||||
raw_format = GST_VIDEO_FORMAT_I420;
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (!input_width || !input_height) {
|
||||
g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL));
|
||||
g_option_context_free (ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (fei_mode) {
|
||||
case 1:
|
||||
fei_mode_flag = 0x00000004;
|
||||
break;
|
||||
case 2:
|
||||
fei_mode_flag = 0x00000001 | 0x00000002;
|
||||
break;
|
||||
default:
|
||||
printf ("Unknown fei mode \n");
|
||||
g_assert (0);
|
||||
break;
|
||||
}
|
||||
|
||||
g_option_context_free (ctx);
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
/* create pipeline */
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
filesrc = gst_element_factory_make ("filesrc", "source");
|
||||
videoparse = gst_element_factory_make ("videoparse", "videoparse");
|
||||
enc = gst_element_factory_make ("vaapih264feienc", "encpak");
|
||||
capsfilter = gst_element_factory_make ("capsfilter", "enccaps");
|
||||
appsink = gst_element_factory_make ("appsink", "sink");
|
||||
|
||||
/* element prop setup */
|
||||
g_object_set (G_OBJECT (filesrc), "location", input_file_name, NULL);
|
||||
g_object_set (G_OBJECT (videoparse), "format", raw_format,
|
||||
"width", input_width, "height", input_height, NULL);
|
||||
|
||||
if (enc_frame_num != 0)
|
||||
g_object_set (G_OBJECT (filesrc), "num-buffers", enc_frame_num, NULL);
|
||||
if (block_size != 0)
|
||||
g_object_set (G_OBJECT (filesrc), "blocksize", block_size, NULL);
|
||||
|
||||
g_object_set (G_OBJECT (enc), "fei-mode", fei_mode_flag, NULL);
|
||||
g_object_set (G_OBJECT (enc), "search-window", 5, NULL);
|
||||
g_object_set (G_OBJECT (enc), "max-bframes", 0, NULL);
|
||||
|
||||
filter_caps = gst_caps_from_string (caps_string);
|
||||
if (filter_caps)
|
||||
g_object_set (G_OBJECT (capsfilter), "caps", filter_caps, NULL);
|
||||
gst_caps_unref (filter_caps);
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), filesrc, videoparse, enc, capsfilter,
|
||||
appsink, NULL);
|
||||
|
||||
link_ok =
|
||||
gst_element_link_many (filesrc, videoparse, enc, capsfilter, appsink,
|
||||
NULL);
|
||||
if (!link_ok) {
|
||||
g_print ("filesrc, enc and appsink link fail");
|
||||
return -1;
|
||||
}
|
||||
|
||||
file = fopen (output_file_name, "wb");
|
||||
|
||||
if (output_mv_name != NULL)
|
||||
mv_file = fopen (output_mv_name, "wb");
|
||||
|
||||
if (output_mbcode_name != NULL)
|
||||
mbcode_file = fopen (output_mbcode_name, "wb");
|
||||
|
||||
if (output_distortion_name != NULL)
|
||||
dist_file = fopen (output_distortion_name, "wb");
|
||||
|
||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
g_printerr ("Unable to set the pipeline to the playing state.\n");
|
||||
gst_object_unref (pipeline);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* pull sample from pipeline */
|
||||
while (1) {
|
||||
g_signal_emit_by_name (appsink, "pull-sample", &sample, NULL);
|
||||
if (sample) {
|
||||
GstBuffer *buffer = NULL;
|
||||
GstMapInfo map, info;
|
||||
GstMemory *mem;
|
||||
GstVaapiFeiVideoMeta *meta = NULL;
|
||||
GstMeta *m = NULL;
|
||||
const GstMetaInfo *meta_info;
|
||||
GType api;
|
||||
|
||||
g_debug ("appsink received sample.\n");
|
||||
buffer = gst_sample_get_buffer (sample);
|
||||
if (gst_buffer_map (buffer, &map, GST_MAP_READ)) {
|
||||
mem = gst_buffer_peek_memory (buffer, 0);
|
||||
if (gst_memory_map (mem, &info, GST_MAP_READ))
|
||||
fwrite (info.data, 1, info.size, file);
|
||||
|
||||
gst_memory_unmap (mem, &info);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
}
|
||||
|
||||
meta_info = gst_meta_get_info ("GstVaapiFeiVideoMeta");
|
||||
api = meta_info->api;
|
||||
m = gst_buffer_get_meta (buffer, api);
|
||||
if (m != NULL)
|
||||
meta = ((GstVaapiFeiVideoMetaHolder *) (m))->meta;
|
||||
|
||||
if (meta != NULL) {
|
||||
|
||||
if (mv_file != NULL) {
|
||||
mapped_data = NULL;
|
||||
mapped_data_size = 0;
|
||||
if (gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mv), &mapped_data, &mapped_data_size)) {
|
||||
fwrite (mapped_data, 1, mapped_data_size, mv_file);
|
||||
gst_vaapi_fei_codec_object_unmap (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mv));
|
||||
mv_buffer_size = mapped_data_size;
|
||||
}
|
||||
}
|
||||
|
||||
if (mbcode_file != NULL) {
|
||||
mapped_data = NULL;
|
||||
mapped_data_size = 0;
|
||||
if (gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mbcode), &mapped_data, &mapped_data_size)) {
|
||||
fwrite (mapped_data, 1, mapped_data_size, mbcode_file);
|
||||
gst_vaapi_fei_codec_object_unmap (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->mbcode));
|
||||
mbcode_buffer_size = mapped_data_size;
|
||||
}
|
||||
}
|
||||
|
||||
if (dist_file != NULL) {
|
||||
mapped_data = NULL;
|
||||
mapped_data_size = 0;
|
||||
if (gst_vaapi_fei_codec_object_map (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->dist), &mapped_data, &mapped_data_size)) {
|
||||
fwrite (mapped_data, 1, mapped_data_size, dist_file);
|
||||
gst_vaapi_fei_codec_object_unmap (GST_VAAPI_FEI_CODEC_OBJECT
|
||||
(meta->dist));
|
||||
dist_buffer_size = mapped_data_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gst_sample_unref (sample);
|
||||
} else {
|
||||
g_print ("appsink finished receive sample.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fixme: Currently assuming the input video has only one resoultion
|
||||
* which may not be true */
|
||||
/* create a status file for dumping size of each fei output buffer */
|
||||
if (output_mv_name || output_mbcode_name || output_distortion_name) {
|
||||
fei_stat_file = fopen ("fei_stat.out", "wb");
|
||||
fprintf (fei_stat_file, "Frame_MotionVectorData_Buffer_Size => %d \n",
|
||||
mv_buffer_size);
|
||||
fprintf (fei_stat_file, "Frame_MacroblcokCode_Buffer_Size => %d \n",
|
||||
mbcode_buffer_size);
|
||||
fprintf (fei_stat_file, "Frame_Distortion_Buffer_Size => %d \n",
|
||||
dist_buffer_size);
|
||||
}
|
||||
|
||||
/* free */
|
||||
fclose (file);
|
||||
if (mv_file != NULL)
|
||||
fclose (mv_file);
|
||||
if (mbcode_file != NULL)
|
||||
fclose (mbcode_file);
|
||||
if (dist_file != NULL)
|
||||
fclose (dist_file);
|
||||
if (fei_stat_file)
|
||||
fclose (fei_stat_file);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue