Go to the documentation of this file.
23 #include <sys/types.h>
25 #include <mfx/mfxvideo.h>
63 uint8_t vps_buf[128], vps_rbsp_buf[128];
64 uint8_t *new_extradata;
108 vps.vps_max_layers = 1;
109 vps.vps_max_sub_layers =
sps.max_sub_layers;
110 vps.vps_temporal_id_nesting_flag =
sps.temporal_id_nesting_flag;
111 memcpy(&
vps.ptl, &
sps.ptl,
sizeof(
vps.ptl));
112 vps.vps_sub_layer_ordering_info_present_flag = 1;
114 vps.vps_max_dec_pic_buffering[
i] =
sps.temporal_layer[
i].max_dec_pic_buffering;
115 vps.vps_num_reorder_pics[
i] =
sps.temporal_layer[
i].num_reorder_pics;
116 vps.vps_max_latency_increase[
i] =
sps.temporal_layer[
i].max_latency_increase;
119 vps.vps_num_layer_sets = 1;
120 vps.vps_timing_info_present_flag =
sps.vui.vui_timing_info_present_flag;
121 vps.vps_num_units_in_tick =
sps.vui.vui_num_units_in_tick;
122 vps.vps_time_scale =
sps.vui.vui_time_scale;
123 vps.vps_poc_proportional_to_timing_flag =
sps.vui.vui_poc_proportional_to_timing_flag;
124 vps.vps_num_ticks_poc_diff_one =
sps.vui.vui_num_ticks_poc_diff_one_minus1 + 1;
125 vps.vps_num_hrd_parameters = 0;
138 bytestream2_put_be32(&pbc, 1);
140 bytestream2_put_byte(&pbc, 1);
144 bytestream2_put_be24(&pbc, 3);
147 bytestream2_put_byte(&pbc, bytestream2_get_byte(&gbc));
154 memcpy(new_extradata, vps_buf, vps_size);
170 static const char *
const uid_hevcenc_sw =
"2fca99749fdb49aeb121a5b63ef568f7";
171 static const char *
const uid_hevcenc_hw =
"6fadc791a0c2eb479ab6dcd5ea9da347";
175 "load_plugins is not empty, but load_plugin is not set to 'none'."
176 "The load_plugin value will be ignored.\n");
223 #define OFFSET(x) offsetof(QSVHEVCEncContext, x)
224 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
238 {
"idr_interval",
"Distance (in I-frames) between IDR frames",
OFFSET(qsv.idr_interval),
AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX,
VE,
"idr_interval" },
239 {
"begin_only",
"Output an IDR-frame only at the beginning of the stream", 0,
AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0,
VE,
"idr_interval" },
245 {
"load_plugins",
"A :-separate list of hexadecimal plugin UIDs to load in an internal session",
248 {
"look_ahead_depth",
"Depth of look ahead in number frames, available when extbrc option is enabled",
OFFSET(qsv.look_ahead_depth),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100,
VE },
255 #if QSV_VERSION_ATLEAST(1, 32)
259 {
"gpb",
"1: GPB (generalized P/B frame); 0: regular P frame",
OFFSET(qsv.gpb),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
VE},
261 {
"tile_cols",
"Number of columns for tiled encoding",
OFFSET(qsv.tile_cols),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX,
VE },
262 {
"tile_rows",
"Number of rows for tiled encoding",
OFFSET(qsv.tile_rows),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX,
VE },
263 {
"recovery_point_sei",
"Insert recovery point SEI messages",
OFFSET(qsv.recovery_point_sei),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1,
VE },
265 {
"pic_timing_sei",
"Insert picture timing SEI with pic_struct_syntax element",
OFFSET(qsv.pic_timing_sei),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
VE },
266 {
"transform_skip",
"Turn this option ON to enable transformskip",
OFFSET(qsv.transform_skip),
AV_OPT_TYPE_INT, { .i64 = -1}, -1, 1,
VE},
267 {
"int_ref_type",
"Intra refresh type. B frames should be set to 0",
OFFSET(qsv.int_ref_type),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX,
VE,
"int_ref_type" },
271 {
"int_ref_cycle_size",
"Number of frames in the intra refresh cycle",
OFFSET(qsv.int_ref_cycle_size),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX,
VE },
272 {
"int_ref_qp_delta",
"QP difference for the refresh MBs",
OFFSET(qsv.int_ref_qp_delta),
AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN, INT16_MAX,
VE },
273 {
"int_ref_cycle_dist",
"Distance between the beginnings of the intra-refresh cycles in frames",
OFFSET(qsv.int_ref_cycle_dist),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX,
VE },
294 {
"flags",
"+cgop" },
299 .
p.
name =
"hevc_qsv",
316 .p.priv_class = &
class,
319 .p.wrapper_name =
"qsv",
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
This structure describes decoded (raw) audio or video data.
#define QSV_OPTION_DBLK_IDC
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define QSV_OPTION_MAX_MIN_QP
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define FF_CODEC_ENCODE_CB(func)
const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[]
const FFCodec ff_hevc_qsv_encoder
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx)
#define QSV_OPTION_MAX_SLICE_SIZE
int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx)
Parse the SPS from the bitstream into the provided HEVCSPS struct.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
#define QSV_OPTION_LOW_DELAY_BRC
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
const char * av_default_item_name(void *ptr)
Return the context name.
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id, uint8_t *buf, int buf_size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int qsv_enc_init(AVCodecContext *avctx)
#define QSV_OPTION_EXTBRC
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645RBSP *rbsp, H2645NAL *nal, int small_padding)
Extract the raw (unescaped) bitstream.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
#define AV_PIX_FMT_X2RGB10
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static const AVOption options[]
int rbsp_buffer_alloc_size
#define QSV_OPTION_P_STRATEGY
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define AV_INPUT_BUFFER_PADDING_SIZE
#define QSV_OPTION_MAX_FRAME_SIZE
main external API structure.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
char * av_strdup(const char *s)
Duplicate a string.
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
#define AV_CODEC_CAP_HYBRID
Codec is potentially backed by a hardware implementation, but not necessarily.
This structure stores compressed data.
static const FFCodecDefault qsv_enc_defaults[]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static av_cold int qsv_enc_close(AVCodecContext *avctx)
#define QSV_OPTION_B_STRATEGY