mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
encoder: add h264 encoder.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
parent
8174a35737
commit
652245fb87
4 changed files with 1955 additions and 0 deletions
|
@ -136,11 +136,13 @@ endif
|
|||
|
||||
libgstvaapi_enc_source_c = \
|
||||
gstvaapiencoder.c \
|
||||
gstvaapiencoder_h264.c \
|
||||
gstvaapiencoder_objects.c \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_enc_source_h = \
|
||||
gstvaapiencoder.h \
|
||||
gstvaapiencoder_h264.h \
|
||||
$(NULL)
|
||||
|
||||
libgstvaapi_enc_source_priv_h = \
|
||||
|
|
1786
gst-libs/gst/vaapi/gstvaapiencoder_h264.c
Normal file
1786
gst-libs/gst/vaapi/gstvaapiencoder_h264.c
Normal file
File diff suppressed because it is too large
Load diff
41
gst-libs/gst/vaapi/gstvaapiencoder_h264.h
Normal file
41
gst-libs/gst/vaapi/gstvaapiencoder_h264.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* gstvaapiencoder_h264.h - H.264 encoder
|
||||
*
|
||||
* Copyright (C) 2011-2013 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
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_ENCODER_H264_H
|
||||
#define GST_VAAPI_ENCODER_H264_H
|
||||
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVaapiEncoderH264 GstVaapiEncoderH264;
|
||||
|
||||
GstVaapiEncoder *
|
||||
gst_vaapi_encoder_h264_new (GstVaapiDisplay * display);
|
||||
|
||||
void
|
||||
gst_vaapi_encoder_h264_set_avc (GstVaapiEncoderH264 * encoder, gboolean is_avc);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_encoder_h264_is_avc (GstVaapiEncoderH264 * encoder);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /*GST_VAAPI_ENCODER_H264_H */
|
126
gst-libs/gst/vaapi/gstvaapiencoder_h264_priv.h
Normal file
126
gst-libs/gst/vaapi/gstvaapiencoder_h264_priv.h
Normal file
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* gstvaapiencoder_h264_priv.h - H.264 encoder (private definitions)
|
||||
*
|
||||
* Copyright (C) 2013 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
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_ENCODER_H264_PRIV_H
|
||||
#define GST_VAAPI_ENCODER_H264_PRIV_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <gst/base/gstbitwriter.h>
|
||||
#include <gst/vaapi/gstvaapiencoder.h>
|
||||
#include <gst/vaapi/gstvaapiencoder_priv.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_ENCODER_H264(encoder) \
|
||||
((GstVaapiEncoderH264 *)(encoder))
|
||||
#define GST_VAAPI_ENCODER_H264_CAST(encoder) \
|
||||
((GstVaapiEncoderH264 *)(encoder))
|
||||
#define GST_VAAPI_ENCODER_H264_CLASS(klass) \
|
||||
((GstVaapiEncoderH264Class *)(klass))
|
||||
#define GST_IS_VAAPI_ENCODER_H264_CLASS(klass) \
|
||||
((klass) != NULL)
|
||||
#define GST_VAAPI_ENCODER_H264_GET_CLASS(obj) \
|
||||
GST_VAAPI_ENCODER_H264_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(obj))
|
||||
|
||||
typedef struct _GstVaapiEncoderH264Class GstVaapiEncoderH264Class;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_10 = 10, /* QCIF format, < 380160 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_11 = 11, /* CIF format, < 768000 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_12 = 12, /* CIF format, < 1536000 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_13 = 13, /* CIF format, < 3041280 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_20 = 20, /* CIF format, < 3041280 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_21 = 21, /* HHR format, < 5068800 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_22 = 22, /* SD/4CIF format, < 5184000 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_30 = 30, /* SD/4CIF format, < 10368000 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_31 = 31, /* 720pHD format, < 27648000 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_32 = 32, /* SXGA format, < 55296000 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_40 = 40, /* 2Kx1K format, < 62914560 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_41 = 41, /* 2Kx1K format, < 62914560 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_42 = 42, /* 2Kx1K format, < 125829120 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_50 = 50, /* 3672x1536 format, < 150994944 samples/sec */
|
||||
GST_VAAPI_ENCODER_H264_LEVEL_51 = 51, /* 4096x2304 format, < 251658240 samples/sec */
|
||||
} GstVaapiEncoderH264Level;
|
||||
|
||||
#define GST_VAAPI_ENCODER_H264_DEFAULT_PROFILE GST_VAAPI_PROFILE_H264_BASELINE
|
||||
#define GST_VAAPI_ENCODER_H264_DEFAULT_LEVEL GST_VAAPI_ENCODER_H264_LEVEL_31
|
||||
#define GST_VAAPI_ENCODER_H264_DEFAULT_INIT_QP 26
|
||||
#define GST_VAAPI_ENCODER_H264_DEFAULT_MIN_QP 1
|
||||
#define GST_VAAPI_ENCODER_H264_DEFAULT_INTRA_PERIOD 30
|
||||
#define GST_VAAPI_ENCODER_H264_MAX_INTRA_PERIOD 512
|
||||
#define GST_VAAPI_ENCODER_H264_MAX_IDR_PERIOD 512
|
||||
|
||||
#define GST_VAAPI_ENCODER_H264_DEFAULT_SLICE_NUM 1
|
||||
|
||||
struct _GstVaapiEncoderH264
|
||||
{
|
||||
GstVaapiEncoder parent;
|
||||
|
||||
/* public */
|
||||
guint32 profile;
|
||||
guint32 level;
|
||||
guint32 bitrate; /*kbps */
|
||||
guint32 intra_period;
|
||||
guint32 idr_period;
|
||||
guint32 init_qp; /*default 24 */
|
||||
guint32 min_qp; /*default 1 */
|
||||
guint32 slice_num;
|
||||
guint32 b_frame_num;
|
||||
|
||||
/* private */
|
||||
gboolean is_avc; /* avc or bytestream */
|
||||
/* re-ordering */
|
||||
GQueue reorder_frame_list;
|
||||
guint reorder_state;
|
||||
guint frame_index;
|
||||
guint cur_frame_num;
|
||||
guint cur_present_index;
|
||||
GstClockTime cts_offset;
|
||||
|
||||
/* reference list */
|
||||
GQueue ref_list;
|
||||
guint max_ref_num;
|
||||
/* max reflist count */
|
||||
guint max_reflist0_count;
|
||||
guint max_reflist1_count;
|
||||
|
||||
/* frame, poc */
|
||||
guint32 max_frame_num;
|
||||
guint32 log2_max_frame_num;
|
||||
guint32 max_pic_order_cnt;
|
||||
guint32 log2_max_pic_order_cnt;
|
||||
guint32 idr_num;
|
||||
|
||||
GstBuffer *sps_data;
|
||||
GstBuffer *pps_data;
|
||||
|
||||
};
|
||||
|
||||
struct _GstVaapiEncoderH264Class
|
||||
{
|
||||
/*< private > */
|
||||
GstVaapiEncoderClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*GST_VAAPI_ENCODER_H264_PRIV_H */
|
Loading…
Reference in a new issue