25 #include <sys/types.h> 
   27 #include <mfx/mfxvideo.h> 
   54             int sei_payload_size = 0;
 
   55             mfxU8* sei_data = 
NULL;
 
   56             mfxPayload* payload = 
NULL;
 
   58             sei_payload_size = side_data->
size + 13;
 
   68             sei_data[1] = sei_payload_size - 2; 
 
   77                 MKTAG(
'G', 
'A', 
'9', 
'4'));
 
   80                 ((side_data->
size/3) & 0x1f) | 0xC0;
 
   84             memcpy(sei_data + 12, side_data->
data, side_data->
size);
 
   86             sei_data[side_data->
size+12] = 255;
 
   94             payload->BufSize = side_data->
size + 13;
 
   95             payload->NumBit = payload->BufSize * 8;
 
   97             payload->Data = sei_data;
 
   99             enc_ctrl->NumExtParam = 0;
 
  100             enc_ctrl->NumPayload = 1;
 
  101             enc_ctrl->Payload[0] = payload;
 
  130 #define OFFSET(x) offsetof(QSVH264EncContext, x) 
  131 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 
  135     { 
"idr_interval", 
"Distance (in I-frames) between IDR frames", 
OFFSET(qsv.idr_interval), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, 
VE },
 
  136     { 
"pic_timing_sei",    
"Insert picture timing SEI with pic_struct_syntax element", 
OFFSET(qsv.pic_timing_sei), 
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, 
VE },
 
  137     { 
"single_sei_nal_unit",    
"Put all the SEI messages into one NALU",        
OFFSET(qsv.single_sei_nal_unit),     
AV_OPT_TYPE_INT, { .i64 = -1 }, -1,          1, 
VE },
 
  138     { 
"max_dec_frame_buffering", 
"Maximum number of frames buffered in the DPB", 
OFFSET(qsv.max_dec_frame_buffering), 
AV_OPT_TYPE_INT, { .i64 = 0 },   0, UINT16_MAX, 
VE },
 
  141     { 
"look_ahead",       
"Use VBR algorithm with look ahead",    
OFFSET(qsv.look_ahead),       
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, 
VE },
 
  142     { 
"look_ahead_depth", 
"Depth of look ahead in number frames", 
OFFSET(qsv.look_ahead_depth), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, 
VE },
 
  145 #if QSV_VERSION_ATLEAST(1,8) 
  146     { 
"look_ahead_downsampling", 
NULL, 
OFFSET(qsv.look_ahead_downsampling), 
AV_OPT_TYPE_INT, { .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, MFX_LOOKAHEAD_DS_UNKNOWN, MFX_LOOKAHEAD_DS_2x, 
VE, 
"look_ahead_downsampling" },
 
  147     { 
"unknown"                , 
NULL, 0, 
AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, INT_MIN, INT_MAX,     
VE, 
"look_ahead_downsampling" },
 
  148     { 
"off"                    , 
NULL, 0, 
AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_OFF     }, INT_MIN, INT_MAX,     
VE, 
"look_ahead_downsampling" },
 
  149     { 
"2x"                     , 
NULL, 0, 
AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_2x      }, INT_MIN, INT_MAX,     
VE, 
"look_ahead_downsampling" },
 
  152     { 
"int_ref_type", 
"Intra refresh type",                                      
OFFSET(qsv.int_ref_type),            
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, 
VE, 
"int_ref_type" },
 
  155     { 
"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 },
 
  156     { 
"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 },
 
  157     { 
"recovery_point_sei", 
"Insert recovery point SEI messages",                
OFFSET(qsv.recovery_point_sei),      
AV_OPT_TYPE_INT, { .i64 = -1 },               -1,          1, 
VE },
 
  167     { 
"baseline", 
NULL, 0, 
AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX,     
VE, 
"profile" },
 
  171     { 
"a53cc" , 
"Use A53 Closed Captions (if available)", 
OFFSET(qsv.a53_cc), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 
VE},
 
  190     { 
"flags",     
"+cgop" },
 
  191 #if FF_API_PRIVATE_OPT 
  192     { 
"b_strategy", 
"-1"   },
 
  199     .long_name      = 
NULL_IF_CONFIG_SMALL(
"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"),
 
  210     .priv_class     = &
class,
 
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
 
This structure describes decoded (raw) audio or video data. 
 
#define LIBAVUTIL_VERSION_INT
 
static av_cold int init(AVCodecContext *avctx)
 
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
 
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
 
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
 
int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static const AVCodecDefault qsv_enc_defaults[]
 
Structure to hold side data for an AVFrame. 
 
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
 
static const AVOption options[]
 
H.264 / AVC / MPEG4 part10 codec. 
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
 
ATSC A53 Part 4 Closed Captions. 
 
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
 
const char * name
Name of the codec implementation. 
 
AVCodec ff_h264_qsv_encoder
 
Libavcodec external API header. 
 
static int qsv_h264_set_encode_ctrl(AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl *enc_ctrl)
 
main external API structure. 
 
Describe the class of an AVClass context structure. 
 
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
 
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure. 
 
static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static enum AVPixelFormat pix_fmts[]
 
static av_cold int qsv_enc_init(AVCodecContext *avctx)
 
common internal api header. 
 
static av_cold int qsv_enc_close(AVCodecContext *avctx)
 
#define MKTAG(a, b, c, d)
 
AVPixelFormat
Pixel format. 
 
This structure stores compressed data. 
 
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
 
SetEncodeCtrlCB * set_encode_ctrl_cb