25 #include <sys/types.h> 
   26 #include <mfx/mfxvideo.h> 
   47     { MFX_PROFILE_AVC_BASELINE,                 
"baseline"              },
 
   48     { MFX_PROFILE_AVC_MAIN,                     
"main"                  },
 
   49     { MFX_PROFILE_AVC_EXTENDED,                 
"extended"              },
 
   50     { MFX_PROFILE_AVC_HIGH,                     
"high"                  },
 
   51 #if QSV_VERSION_ATLEAST(1, 15) 
   52     { MFX_PROFILE_AVC_HIGH_422,                 
"high 422"              },
 
   54 #if QSV_VERSION_ATLEAST(1, 4) 
   55     { MFX_PROFILE_AVC_CONSTRAINED_BASELINE,     
"constrained baseline"  },
 
   56     { MFX_PROFILE_AVC_CONSTRAINED_HIGH,         
"constrained high"      },
 
   57     { MFX_PROFILE_AVC_PROGRESSIVE_HIGH,         
"progressive high"      },
 
   59     { MFX_PROFILE_MPEG2_SIMPLE,                 
"simple"                },
 
   60     { MFX_PROFILE_MPEG2_MAIN,                   
"main"                  },
 
   61     { MFX_PROFILE_MPEG2_HIGH,                   
"high"                  },
 
   62     { MFX_PROFILE_VC1_SIMPLE,                   
"simple"                },
 
   63     { MFX_PROFILE_VC1_MAIN,                     
"main"                  },
 
   64     { MFX_PROFILE_VC1_ADVANCED,                 
"advanced"              },
 
   65 #if QSV_VERSION_ATLEAST(1, 8) 
   66     { MFX_PROFILE_HEVC_MAIN,                    
"main"                  },
 
   67     { MFX_PROFILE_HEVC_MAIN10,                  
"main10"                },
 
   68     { MFX_PROFILE_HEVC_MAINSP,                  
"mainsp"                },
 
   85     { MFX_RATECONTROL_CBR,     
"CBR" },
 
   86     { MFX_RATECONTROL_VBR,     
"VBR" },
 
   87     { MFX_RATECONTROL_CQP,     
"CQP" },
 
   89     { MFX_RATECONTROL_AVBR,    
"AVBR" },
 
   92     { MFX_RATECONTROL_LA,      
"LA" },
 
   95     { MFX_RATECONTROL_ICQ,     
"ICQ" },
 
   96     { MFX_RATECONTROL_LA_ICQ,  
"LA_ICQ" },
 
   99     { MFX_RATECONTROL_VCM,     
"VCM" },
 
  101 #if QSV_VERSION_ATLEAST(1, 10) 
  102     { MFX_RATECONTROL_LA_EXT,  
"LA_EXT" },
 
  105     { MFX_RATECONTROL_LA_HRD,  
"LA_HRD" },
 
  108     { MFX_RATECONTROL_QVBR,    
"QVBR" },
 
  123     if (val == MFX_CODINGOPTION_ON)
 
  125     else if (val == MFX_CODINGOPTION_OFF)
 
  131                              mfxExtBuffer **coding_opts)
 
  133     mfxInfoMFX *info = &q->
param.mfx;
 
  135     mfxExtCodingOption   *co = (mfxExtCodingOption*)coding_opts[0];
 
  137     mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
 
  144            info->GopPicSize, info->GopRefDist);
 
  145     if (info->GopOptFlag & MFX_GOP_CLOSED)
 
  147     if (info->GopOptFlag & MFX_GOP_STRICT)
 
  154     if (info->RateControlMethod == MFX_RATECONTROL_CBR ||
 
  155         info->RateControlMethod == MFX_RATECONTROL_VBR
 
  157         || info->RateControlMethod == MFX_RATECONTROL_VCM
 
  161                "BufferSizeInKB: %"PRIu16
"; InitialDelayInKB: %"PRIu16
"; TargetKbps: %"PRIu16
"; MaxKbps: %"PRIu16
"\n",
 
  162                info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, info->MaxKbps);
 
  163     } 
else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
 
  165                info->QPI, info->QPP, info->QPB);
 
  168     else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
 
  170                "TargetKbps: %"PRIu16
"; Accuracy: %"PRIu16
"; Convergence: %"PRIu16
"\n",
 
  171                info->TargetKbps, info->Accuracy, info->Convergence);
 
  175     else if (info->RateControlMethod == MFX_RATECONTROL_LA
 
  177              || info->RateControlMethod == MFX_RATECONTROL_LA_HRD
 
  181                "TargetKbps: %"PRIu16
"; LookAheadDepth: %"PRIu16
"\n",
 
  182                info->TargetKbps, co2->LookAheadDepth);
 
  186     else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) {
 
  188     } 
else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) {
 
  190                info->ICQQuality, co2->LookAheadDepth);
 
  195            info->NumSlice, info->NumRefFrame);
 
  201            "RecoveryPointSEI: %s IntRefType: %"PRIu16
"; IntRefCycleSize: %"PRIu16
"; IntRefQPDelta: %"PRId16
"\n",
 
  202            print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
 
  205 #if QSV_HAVE_MAX_SLICE_SIZE 
  211            "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
 
  217     if (co2->Trellis & MFX_TRELLIS_OFF) {
 
  219     } 
else if (!co2->Trellis) {
 
  229 #if QSV_VERSION_ATLEAST(1, 8) 
  231            "RepeatPPS: %s; NumMbPerSlice: %"PRIu16
"; LookAheadDS: ",
 
  233     switch (co2->LookAheadDS) {
 
  243     switch (co2->BRefType) {
 
  251 #if QSV_VERSION_ATLEAST(1, 9) 
  253            "MinQPI: %"PRIu8
"; MaxQPI: %"PRIu8
"; MinQPP: %"PRIu8
"; MaxQPP: %"PRIu8
"; MinQPB: %"PRIu8
"; MaxQPB: %"PRIu8
"\n",
 
  254            co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB);
 
  260                co->CAVLC == MFX_CODINGOPTION_ON ? 
"CAVLC" : 
"CABAC", co->MaxDecFrameBuffering);
 
  262                "NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n",
 
  275     int want_vcm    = q->
vcm;
 
  279                "Lookahead ratecontrol mode requested, but is not supported by this SDK version\n");
 
  284                "VCM ratecontrol mode requested, but is not supported by this SDK version\n");
 
  288     if (want_la + want_qscale + want_vcm > 1) {
 
  290                "More than one of: { constant qscale, lookahead, VCM } requested, " 
  291                "only one of them can be used at a time.\n");
 
  297                "ICQ ratecontrol mode requested, but is not supported by this SDK version\n");
 
  302         rc_mode = MFX_RATECONTROL_CQP;
 
  303         rc_desc = 
"constant quantization parameter (CQP)";
 
  307         rc_mode = MFX_RATECONTROL_VCM;
 
  308         rc_desc = 
"video conferencing mode (VCM)";
 
  313         rc_mode = MFX_RATECONTROL_LA;
 
  314         rc_desc = 
"VBR with lookahead (LA)";
 
  318             rc_mode = MFX_RATECONTROL_LA_ICQ;
 
  319             rc_desc = 
"intelligent constant quality with lookahead (LA_ICQ)";
 
  326         rc_mode = MFX_RATECONTROL_ICQ;
 
  327         rc_desc = 
"intelligent constant quality (ICQ)";
 
  331         rc_mode = MFX_RATECONTROL_CBR;
 
  332         rc_desc = 
"constant bitrate (CBR)";
 
  336         rc_mode = MFX_RATECONTROL_AVBR;
 
  337         rc_desc = 
"average variable bitrate (AVBR)";
 
  341         rc_mode = MFX_RATECONTROL_VBR;
 
  342         rc_desc = 
"variable bitrate (VBR)";
 
  353     mfxVideoParam param_out = { .mfx.CodecId = q->
param.mfx.CodecId };
 
  356 #define UNMATCH(x) (param_out.mfx.x != q->param.mfx.x) 
  358     ret = MFXVideoENCODE_Query(q->
session, &q->
param, ¶m_out);
 
  365         if (
UNMATCH(RateControlMethod))
 
  392     q->
param.mfx.CodecId = ret;
 
  394     if (avctx->
level > 0)
 
  404     q->
param.mfx.FrameInfo.CropX          = 0;
 
  405     q->
param.mfx.FrameInfo.CropY          = 0;
 
  410     q->
param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
 
  421         q->
param.mfx.FrameInfo.Width  = frames_hwctx->surfaces[0].Info.Width;
 
  422         q->
param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
 
  433     q->
param.mfx.Interleaved          = 1;
 
  435     q->
param.mfx.RestartInterval      = 0;
 
  451     q->
param.mfx.CodecId = ret;
 
  453     if (avctx->
level > 0)
 
  461                     "valid range is 0-%d, using %d instead\n",
 
  462                     MFX_TARGETUSAGE_BEST_SPEED, MFX_TARGETUSAGE_BEST_SPEED);
 
  476     q->
param.mfx.EncodedOrder       = 0;
 
  477     q->
param.mfx.BufferSizeInKB     = 0;
 
  485     q->
param.mfx.FrameInfo.CropX          = 0;
 
  486     q->
param.mfx.FrameInfo.CropY          = 0;
 
  491     q->
param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
 
  506         q->
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
 
  510         q->
param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
 
  521         q->
param.mfx.FrameInfo.Width  = frames_hwctx->surfaces[0].Info.Width;
 
  522         q->
param.mfx.FrameInfo.Height = frames_hwctx->surfaces[0].Info.Height;
 
  537     switch (q->
param.mfx.RateControlMethod) {
 
  538     case MFX_RATECONTROL_CBR:
 
  539     case MFX_RATECONTROL_VBR:
 
  541     case MFX_RATECONTROL_VCM:
 
  548     case MFX_RATECONTROL_CQP:
 
  552         q->
param.mfx.QPP = av_clip(quant, 0, 51);
 
  557     case MFX_RATECONTROL_AVBR:
 
  564     case MFX_RATECONTROL_LA:
 
  569     case MFX_RATECONTROL_LA_ICQ:
 
  571     case MFX_RATECONTROL_ICQ:
 
  581         q->
extco.Header.BufferId      = MFX_EXTBUFF_CODING_OPTION;
 
  585                                         MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
 
  588             q->
extco.RateDistortionOpt = q->
rdo > 0 ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  591 #if FF_API_CODER_TYPE 
  597             q->
extco.CAVLC = q->
cavlc ? MFX_CODINGOPTION_ON
 
  598                                       : MFX_CODINGOPTION_UNKNOWN;
 
  602                                              MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  609             q->
extco.AUDelimiter          = q->
aud ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  616             q->extco2.Header.BufferId     = MFX_EXTBUFF_CODING_OPTION2;
 
  617             q->extco2.Header.BufferSz     = 
sizeof(q->extco2);
 
  627                 q->extco2.BitrateLimit = q->
bitrate_limit ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  629                 q->extco2.MBBRC = q->
mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  631                 q->extco2.ExtBRC = q->
extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  635 #if QSV_HAVE_MAX_SLICE_SIZE 
  641             q->extco2.Trellis = q->
trellis;
 
  648 #if QSV_HAVE_BREF_TYPE 
  649 #if FF_API_PRIVATE_OPT 
  656                 q->extco2.BRefType = q->
b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
 
  658                 q->extco2.AdaptiveI = q->
adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  660                 q->extco2.AdaptiveB = q->
adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
  663 #if QSV_VERSION_ATLEAST(1, 9) 
  665                 av_log(avctx, 
AV_LOG_ERROR, 
"qmin and or qmax are set but invalid, please make sure min <= max\n");
 
  668             if (avctx->
qmin >= 0) {
 
  669                 q->extco2.MinQPI = avctx->
qmin > 51 ? 51 : avctx->
qmin;
 
  670                 q->extco2.MinQPP = q->extco2.MinQPB = q->extco2.MinQPI;
 
  672             if (avctx->
qmax >= 0) {
 
  673                 q->extco2.MaxQPI = avctx->
qmax > 51 ? 51 : avctx->
qmax;
 
  674                 q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
 
  683             ret = MFXQueryVersion(q->
session,&ver);
 
  685                 q->extmfp.Header.BufferId     = MFX_EXTBUFF_MULTI_FRAME_PARAM;
 
  686                 q->extmfp.Header.BufferSz     = 
sizeof(q->extmfp);
 
  688                 q->extmfp.MFMode = q->mfmode;
 
  698                "some encoding parameters are not supported by the QSV " 
  699                "runtime. Please double check the input parameters.\n");
 
  710     ret = MFXVideoENCODE_GetVideoParam(q->
session, &q->
param);
 
  713                                   "Error calling GetVideoParam");
 
  731     mfxExtCodingOptionSPSPPS extradata = {
 
  732         .Header.BufferId = MFX_EXTBUFF_CODING_OPTION_SPSPPS,
 
  733         .Header.BufferSz = 
sizeof(extradata),
 
  734         .SPSBuffer = sps_buf, .SPSBufSize = 
sizeof(sps_buf),
 
  735         .PPSBuffer = pps_buf, .PPSBufSize = 
sizeof(pps_buf)
 
  738     mfxExtCodingOption co = {
 
  739         .Header.BufferId = MFX_EXTBUFF_CODING_OPTION,
 
  740         .Header.BufferSz = 
sizeof(co),
 
  743     mfxExtCodingOption2 co2 = {
 
  744         .Header.BufferId = MFX_EXTBUFF_CODING_OPTION2,
 
  745         .Header.BufferSz = 
sizeof(co2),
 
  749     mfxExtBuffer *ext_buffers[] = {
 
  750         (mfxExtBuffer*)&extradata,
 
  760     q->
param.ExtParam    = ext_buffers;
 
  763     ret = MFXVideoENCODE_GetVideoParam(q->
session, &q->
param);
 
  766                                   "Error calling GetVideoParam");
 
  770     if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)) {
 
  780     memcpy(avctx->
extradata,                        sps_buf, extradata.SPSBufSize);
 
  782         memcpy(avctx->
extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize);
 
  783     avctx->
extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize;
 
  802     mfxFrameSurface1 *surfaces;
 
  816     for (i = 0; i < nb_surfaces; i++) {
 
  817         surfaces[i].Info      = q->
req.Info;
 
  821     q->
opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
 
  850                                          q->
param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY);
 
  878     return sizeof(
AVPacket) + 
sizeof(mfxSyncPoint*) + 
sizeof(mfxBitstream*);
 
  889     int opaque_alloc = 0;
 
  910             if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
 
  911                 iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
 
  912             else if (frames_hwctx->frame_type &
 
  913                      (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
 
  914                 iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
 
  919         iopattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
 
  920     q->
param.IOPattern = iopattern;
 
  939     if (ret == MFX_WRN_PARTIAL_ACCELERATION) {
 
  941     } 
else if (ret < 0) {
 
  943                                   "Error querying encoder params");
 
  949                                   "Error querying (IOSurf) the encoding parameters");
 
  976             if (j < qsv->nb_ext_buffers)
 
  989                                   "Error initializing the encoder");
 
  992                              "Warning in encoder initialization");
 
 1017             av_free(enc_ctrl->Payload[i]);
 
 1019         enc_ctrl->NumPayload = 0;
 
 1053         last  = &frame->
next;
 
 1054         frame = frame->
next;
 
 1061     if (!frame->
frame) {
 
 1137                                        MFX_PICSTRUCT_FIELD_BFF;
 
 1139             qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
 
 1141             qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
 
 1143             qf->
surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
 
 1159     if (q->
param.mfx.CodecId == MFX_CODEC_AVC) {
 
 1160         if (q->
param.mfx.CodecProfile == MFX_PROFILE_AVC_BASELINE ||
 
 1161             q->
param.mfx.CodecLevel < MFX_LEVEL_AVC_21 ||
 
 1162             q->
param.mfx.CodecLevel > MFX_LEVEL_AVC_41)
 
 1164                    "Interlaced coding is supported" 
 1165                    " at Main/High Profile Level 2.2-4.0\n");
 
 1174 #if QSV_VERSION_ATLEAST(1, 26) 
 1175     mfxExtAVCEncodedFrameInfo *enc_info;
 
 1176     mfxExtBuffer **enc_buf;
 
 1179     mfxFrameSurface1 *surf = 
NULL;
 
 1180     mfxSyncPoint *sync     = 
NULL;
 
 1182     mfxEncodeCtrl* enc_ctrl = 
NULL;
 
 1208     bs->Data      = new_pkt.
data;
 
 1209     bs->MaxLength = new_pkt.
size;
 
 1211 #if QSV_VERSION_ATLEAST(1, 26) 
 1217         enc_info->Header.BufferId = MFX_EXTBUFF_ENCODED_FRAME_INFO;
 
 1218         enc_info->Header.BufferSz = 
sizeof (*enc_info);
 
 1219         bs->NumExtParam = 1;
 
 1220         enc_buf = 
av_mallocz(
sizeof(mfxExtBuffer *));
 
 1223         enc_buf[0] = (mfxExtBuffer *)enc_info;
 
 1225         bs->ExtParam = enc_buf;
 
 1236  #if QSV_VERSION_ATLEAST(1, 26) 
 1247         ret = MFXVideoENCODE_EncodeFrameAsync(q->
session, enc_ctrl, surf, bs, sync);
 
 1248         if (ret == MFX_WRN_DEVICE_BUSY)
 
 1250     } 
while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_WRN_IN_EXECUTION);
 
 1258 #if QSV_VERSION_ATLEAST(1, 26) 
 1265         return (ret == MFX_ERR_MORE_DATA) ?
 
 1280 #if QSV_VERSION_ATLEAST(1, 26) 
 1305 #if QSV_VERSION_ATLEAST(1, 26) 
 1306         mfxExtAVCEncodedFrameInfo *enc_info;
 
 1307         mfxExtBuffer **enc_buf;
 
 1316             ret = MFXVideoCORE_SyncOperation(q->
session, *sync, 1000);
 
 1317         } 
while (ret == MFX_WRN_IN_EXECUTION);
 
 1321         new_pkt.size = bs->DataLength;
 
 1323         if (bs->FrameType & MFX_FRAMETYPE_IDR ||
 
 1324             bs->FrameType & MFX_FRAMETYPE_xIDR)
 
 1327         if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & MFX_FRAMETYPE_xI)
 
 1329         else if (bs->FrameType & MFX_FRAMETYPE_P || bs->FrameType & MFX_FRAMETYPE_xP)
 
 1331         else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB)
 
 1334 #if FF_API_CODED_FRAME 
 1340 #if QSV_VERSION_ATLEAST(1, 26) 
 1342             enc_buf = bs->ExtParam;
 
 1343             enc_info = (mfxExtAVCEncodedFrameInfo *)(*bs->ExtParam);
 
 1354             if (
pkt->
size < new_pkt.size) {
 
 1361             memcpy(
pkt->
data, new_pkt.data, new_pkt.size);
 
 1382         MFXVideoENCODE_Close(q->
session);
 
const char const char void * val
#define FF_COMPRESSION_DEFAULT
#define QSV_MAX_ENC_PAYLOAD
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data. 
AVBufferRef * opaque_alloc_buf
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q)
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT. 
#define AV_LOG_WARNING
Something somehow does not look correct. 
mfxExtOpaqueSurfaceAlloc opaque_alloc
int64_t bit_rate
the average bitrate 
Memory handling functions. 
This struct is allocated as AVHWFramesContext.hwctx. 
int max_bitrate
Maximum bitrate of the stream, in bits per second. 
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts. 
int repeat_pict
When decoding, this signals how much the picture must be delayed. 
static int get_free_frame(QSVEncContext *q, QSVFrame **f)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx. 
QSVFramesContext frames_ctx
#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_usleep(unsigned usec)
Sleep for a period of time. 
int nb_opaque_surfaces
Encoding only, and only if opaque_alloc is set to non-zero. 
mfxSession internal_session
static void print_interlace_msg(AVCodecContext *avctx, QSVEncContext *q)
float i_quant_offset
qscale offset between P and I-frames 
int min_bitrate
Minimum bitrate of the stream, in bits per second. 
AVBufferRef * hw_frames_ctx
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer. 
int ff_qsv_print_error(void *log_ctx, mfxStatus err, const char *error_string)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed. 
AVFifoBuffer * async_fifo
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values. 
void * hwaccel_context
Hardware accelerator context. 
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame. 
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user). 
uint8_t * extradata
some codecs need / can use extradata like Huffman tables. 
int opaque_alloc
Encoding only. 
mfxFrameSurface1 ** opaque_surfaces
static int qsv_retrieve_enc_jpeg_params(AVCodecContext *avctx, QSVEncContext *q)
#define AV_LOG_VERBOSE
Detailed information. 
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer. 
int interlaced_frame
The content of the picture is interlaced. 
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits. 
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
static const char * print_threestate(mfxU16 val)
int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession, QSVFramesContext *qsv_frames_ctx, const char *load_plugins, int opaque)
int opaque_alloc_type
Encoding only, and only if opaque_alloc is set to non-zero. 
#define AV_PKT_FLAG_KEY
The packet contains a keyframe. 
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers. 
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values. 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
int qmax
maximum quantizer 
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback. 
int flags
AV_CODEC_FLAG_*. 
static unsigned int qsv_fifo_item_size(void)
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
int max_dec_frame_buffering
int iopattern
The IO pattern to use. 
static unsigned int qsv_fifo_size(const AVFifoBuffer *fifo)
static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q)
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst. 
int rc_buffer_size
decoder bitstream buffer size 
int ff_qsv_print_warning(void *log_ctx, mfxStatus err, const char *warning_string)
int64_t rc_min_rate
minimum bitrate 
int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
int refs
number of reference frames 
static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, mfxExtBuffer **coding_opts)
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst. 
enum AVPictureType pict_type
Picture type of the frame. 
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale. 
int width
picture width / height. 
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
#define MFX_LOOKAHEAD_DS_OFF
static const char * print_profile(mfxU16 profile)
#define MFX_LOOKAHEAD_DS_2x
preferred ID for MPEG-1/2 video decoding 
attribute_deprecated int coder_type
#define FF_ARRAY_ELEMS(a)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
This structure describes the bitrate properties of an encoded bitstream. 
static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q)
Libavcodec external API header. 
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
mfxExtBuffer ** ext_buffers
Extra buffers to pass to encoder or decoder initialization. 
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line. 
attribute_deprecated int b_frame_strategy
static const struct @131 rc_names[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure. 
void av_packet_unref(AVPacket *pkt)
Wipe the packet. 
uint8_t * data
The data buffer. 
int qmin
minimum quantizer 
void * hwctx
The format-specific data, allocated and freed automatically along with this context. 
static void free_encoder_ctrl_payloads(mfxEncodeCtrl *enc_ctrl)
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero. 
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2. 
AVBufferRef * opaque_surfaces
Encoding only, and only if opaque_alloc is set to non-zero. 
#define FF_CODER_TYPE_VLC
#define FF_COMPLIANCE_NORMAL
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
Rational number (pair of numerator and denominator). 
This struct describes a set or pool of "hardware" frames (i.e. 
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure. 
float b_quant_offset
qscale offset between IP and B-frames 
This struct is used for communicating QSV parameters between libavcodec and the caller. 
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data. 
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields. 
int global_quality
Global quality for codecs which cannot change it per frame. 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only 
static int check_enc_param(AVCodecContext *avctx, QSVEncContext *q)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header. 
common internal and external API header 
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer. 
int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, const char *load_plugins)
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream 
#define AVERROR_UNKNOWN
Unknown error, typically from an external library. 
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context. 
static const struct @130 profile_names[]
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int slices
Number of slices. 
#define MFX_LOOKAHEAD_DS_4x
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer. 
#define FF_ENABLE_DEPRECATION_WARNINGS
int top_field_first
If the content is interlaced, is top field displayed first. 
int avg_bitrate
Average bitrate of the stream, in bits per second. 
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda 
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int look_ahead_downsampling
static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
static const char * print_ratecontrol(mfxU16 rc_mode)
mfxExtBuffer * extparam_internal[2+QSV_HAVE_CO2+(QSV_HAVE_MF *2)]
An API-specific header for AV_HWDEVICE_TYPE_QSV. 
#define av_malloc_array(a, b)
#define AV_CODEC_FLAG_CLOSED_GOP
int depth
Number of bits in the component. 
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
AVPixelFormat
Pixel format. 
This structure stores compressed data. 
static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q)
mfxSession session
If non-NULL, the session to use for encoding or decoding. 
int strict_std_compliance
strictly follow the standard (MPEG-4, ...). 
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx. 
static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame)
int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVBufferRef *device_ref, const char *load_plugins)
static int submit_frame(QSVEncContext *q, const AVFrame *frame, QSVFrame **new_frame)
int64_t rc_max_rate
maximum bitrate 
void * av_mallocz_array(size_t nmemb, size_t size)
SetEncodeCtrlCB * set_encode_ctrl_cb
static void clear_unused_frames(QSVEncContext *q)