MP3Encoder(UINT bitRate) { curBitRate = bitRate; lgf = lame_init(); if(!lgf) CrashError(TEXT("Unable to open mp3 encoder")); lame_set_in_samplerate(lgf, App->GetSampleRateHz()); lame_set_out_samplerate(lgf, App->GetSampleRateHz()); lame_set_num_channels(lgf, 2); lame_set_mode(lgf, STEREO); lame_set_disable_reservoir(lgf, TRUE); //bit reservoir has to be disabled for seamless streaming lame_set_VBR(lgf, vbr_off); lame_set_brate(lgf, bitRate); lame_init_params(lgf); outputFrameSize = lame_get_framesize(lgf); //1152 usually dwMP3MaxSize = DWORD(1.25*double(outputFrameSize*audioBlockSize) + 7200.0); MP3OutputBuffer.SetSize(dwMP3MaxSize+1); MP3OutputBuffer[0] = 0x2f; bFirstPacket = true; Log(TEXT("------------------------------------------")); Log(TEXT("%s"), GetInfoString().Array()); }
/* ---------------------------------------------- */ void ghid_dialog_about (void) { GtkWidget *dialog; GHidPort *out = &ghid_port; dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window), (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", GetInfoString ()); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); }
bool InitEncoder() { x264 = x264_encoder_open(¶mData); if (!x264) { return false; } Log::writeMessage(LOG_RTSPSERV, 1, "LiveSDK_Log:------------------------------------------"); Log::writeMessage(LOG_RTSPSERV, 1, "LiveSDK_Log:%s", WcharToAnsi(GetInfoString().Array()).c_str()); Log::writeMessage(LOG_RTSPSERV, 1, "LiveSDK_Log:------------------------------------------"); DataPacket packet; GetHeaders(packet); return true; }
QSVEncoder(int fps_, int width, int height, int quality, CTSTR preset, bool bUse444, int maxBitrate, int bufferSize, bool bUseCFR_, bool bDupeFrames_) : enc(nullptr) { Log(TEXT("------------------------------------------")); for(int i = 0; i < sizeof(validImpl)/sizeof(validImpl[0]); i++) { mfxIMPL impl = validImpl[i]; mfxVersion ver = version; auto result = session.Init(impl, &ver); if(result == MFX_ERR_NONE) { Log(TEXT("QSV version %u.%u using %s"), ver.Major, ver.Minor, implStr[impl]); break; } } fps = fps_; bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR")) != 0; bUseCFR = bUseCFR_; bDupeFrames = bDupeFrames_; memset(¶ms, 0, sizeof(params)); params.AsyncDepth = 1; params.mfx.CodecId = MFX_CODEC_AVC; params.mfx.TargetUsage = MFX_TARGETUSAGE_BEST_QUALITY; params.mfx.TargetKbps = maxBitrate; params.mfx.MaxKbps = maxBitrate; params.mfx.InitialDelayInKB = 1; //params.mfx.GopRefDist = 1; //params.mfx.NumRefFrame = 0; params.mfx.RateControlMethod = bUseCBR ? MFX_RATECONTROL_CBR : MFX_RATECONTROL_VBR; params.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY; auto& fi = params.mfx.FrameInfo; ConvertFrameRate(fps, fi.FrameRateExtN, fi.FrameRateExtD); fi.FourCC = MFX_FOURCC_NV12; fi.ChromaFormat = bUse444 ? MFX_CHROMAFORMAT_YUV444 : MFX_CHROMAFORMAT_YUV420; fi.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; fi.Width = ALIGN16(width); fi.Height = ALIGN16(height); fi.CropX = 0; fi.CropY = 0; fi.CropW = width; fi.CropH = height; this->width = width; this->height = height; enc.reset(new MFXVideoENCODE(session)); enc->Close(); auto result = enc->Init(¶ms); memset(&enc_surf, 0, sizeof(enc_surf)); memcpy(&enc_surf.Info, ¶ms.mfx.FrameInfo, sizeof(enc_surf.Info)); decltype(params) query; memcpy(&query, ¶ms, sizeof(params)); enc->GetVideoParam(&query); unsigned size = max(query.mfx.BufferSizeInKB*1000, bufferSize*1024/8); bs_buff.SetSize(size+31);//.resize(size+31); bs.Data = (mfxU8*)(((size_t)bs_buff.Array() + 31) / 32 * 32); bs.MaxLength = size; params.mfx.BufferSizeInKB = size/1000; Log(TEXT("Buffer size: %u configured, %u suggested by QSV; using %u"), bufferSize, query.mfx.BufferSizeInKB*1000*8/1024, size*8/1024); Log(TEXT("------------------------------------------")); Log(TEXT("%s"), GetInfoString().Array()); Log(TEXT("------------------------------------------")); memset(&ctrl, 0, sizeof(ctrl)); ctrl.FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF | MFX_FRAMETYPE_IDR; DataPacket packet; GetHeaders(packet); }
void QCSXCAD::aboutQCSXCAD(QWidget* parent) { QDialog infoWidget(parent); infoWidget.setWindowTitle("Info"); QLabel *infoLbl = new QLabel(); infoLbl->setText(GetInfoString()); infoLbl->setAlignment(Qt::AlignLeft); QGroupBox* DependGroup = new QGroupBox(tr("Used Libraries"),&infoWidget); QLabel *qtinfo = new QLabel(); QPushButton* qtButton = new QPushButton(QIcon(":/images/qt-logo.png"),QString()); qtButton->setToolTip(tr("About Qt")); qtButton->setIconSize(QSize(50,50)); QObject::connect(qtButton,SIGNAL(clicked()),qApp,SLOT(aboutQt())); qtinfo->setText(QString("GUI-Toolkit: Qt by Trolltech (OSS) <br>Version: %1<br>http://www.trolltech.com/<br>License: GNU General Public License (GPL)").arg(QT_VERSION,0,16)); qtinfo->setAlignment(Qt::AlignLeft); QLabel *vtkinfo = new QLabel(); QPushButton* vtkButton = new QPushButton(QIcon(":/images/vtk-logo.png"),QString()); vtkButton->setIconSize(QSize(50,50)); //vtkButton->setToolTip(tr("About Vtk")); //QObject::connect(vtkButton,SIGNAL(clicked()),qApp,SLOT(aboutQt())); vtkinfo->setText(QString("3D-Toolkit: Visualization Toolkit (VTK)<br>Version: %1<br>http://www.vtk.org/<br>License: BSD-License").arg(VTK_VERSION)); vtkinfo->setAlignment(Qt::AlignLeft); QLabel *CSXCADinfo = new QLabel(); CSXCADinfo->setText(ContinuousStructure::GetInfoLine().c_str()); CSXCADinfo->setAlignment(Qt::AlignLeft); QGridLayout *Glay = new QGridLayout(); Glay->addWidget(qtButton,1,1); Glay->addWidget(qtinfo,1,2); Glay->addWidget(vtkButton,2,1); Glay->addWidget(vtkinfo,2,2); Glay->addWidget(CSXCADinfo,3,2); Glay->setColumnStretch(1,0); Glay->setColumnStretch(2,1); DependGroup->setLayout(Glay); QGridLayout *infoLayout = new QGridLayout(); QPushButton* iconButt = new QPushButton(QCSXCAD::GetLibIcon(),""); iconButt->setFlat(true); iconButt->setIconSize(QSize(128,128)); infoLayout->addWidget(iconButt,1,1); infoLayout->addWidget(infoLbl,1,2,1,3); infoLayout->addWidget(DependGroup,2,1,1,3); QPushButton* OKBut = new QPushButton(tr("Ok")); QObject::connect(OKBut,SIGNAL(clicked()),&infoWidget,SLOT(accept())); infoLayout->addWidget(OKBut,3,2); infoLayout->setColumnStretch(1,1); infoLayout->setColumnStretch(3,1); infoWidget.setLayout(infoLayout); // infoWidget->show(); // infoWidget->adjustSize(); infoWidget.exec(); }
void NVENCEncoder::init() { NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS stEncodeSessionParams = { 0 }; NV_ENC_PRESET_CONFIG presetConfig = { 0 }; GUID clientKey = NV_CLIENT_KEY; CUcontext cuContextCurr; NVENCSTATUS nvStatus = NV_ENC_SUCCESS; int surfaceCount = 0; GUID encoderPreset = NV_ENC_PRESET_HQ_GUID; int useCustomPreset = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCustomSettings")); if (useCustomPreset) { String presetString = AppConfig->GetString(TEXT("Video Encoding"), TEXT("CustomSettings"), TEXT("default")).MakeLower(); if (presetString == TEXT("hp")) encoderPreset = NV_ENC_PRESET_HP_GUID; else if (presetString == TEXT("hq")) encoderPreset = NV_ENC_PRESET_HQ_GUID; else if (presetString == TEXT("bd")) encoderPreset = NV_ENC_PRESET_BD_GUID; else if (presetString == TEXT("ll")) encoderPreset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; else if (presetString == TEXT("llhp")) encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; else if (presetString == TEXT("llhq")) encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; else encoderPreset = NV_ENC_PRESET_DEFAULT_GUID; } TCHAR envClientKey[128] = { 0 }; DWORD envRes = GetEnvironmentVariable(TEXT("NVENC_KEY"), envClientKey, 128); if (envRes > 0 && envRes <= 128) { if (CLSIDFromString(envClientKey, &clientKey) == NOERROR) NvLog(TEXT("Got NVENC key from environment")); else NvLog(TEXT("NVENC_KEY environment variable has invalid format")); } mset(&initEncodeParams, 0, sizeof(NV_ENC_INITIALIZE_PARAMS)); mset(&encodeConfig, 0, sizeof(NV_ENC_CONFIG)); encodeConfig.version = NV_ENC_CONFIG_VER; presetConfig.version = NV_ENC_PRESET_CONFIG_VER; initEncodeParams.version = NV_ENC_INITIALIZE_PARAMS_VER; stEncodeSessionParams.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; stEncodeSessionParams.apiVersion = NVENCAPI_VERSION; stEncodeSessionParams.clientKeyPtr = &clientKey; cuContext = 0; checkCudaErrors(cuCtxCreate(&cuContext, 0, pNvencDevices[iNvencUseDeviceID])); checkCudaErrors(cuCtxPopCurrent(&cuContextCurr)); stEncodeSessionParams.device = (void*)cuContext; stEncodeSessionParams.deviceType = NV_ENC_DEVICE_TYPE_CUDA; nvStatus = pNvEnc->nvEncOpenEncodeSessionEx(&stEncodeSessionParams, &encoder); if (nvStatus != NV_ENC_SUCCESS) { encoder = 0; NvLog(TEXT("nvEncOpenEncodeSessionEx failed - invalid license key?")); goto error; } if (!populateEncodePresetGUIDs()) goto error; if (!checkPresetSupport(encoderPreset)) { NvLog(TEXT("Preset is not supported!")); goto error; } nvStatus = pNvEnc->nvEncGetEncodePresetConfig(encoder, NV_ENC_CODEC_H264_GUID, encoderPreset, &presetConfig); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("nvEncGetEncodePresetConfig failed")); goto error; } initEncodeParams.encodeGUID = NV_ENC_CODEC_H264_GUID; initEncodeParams.encodeHeight = height; initEncodeParams.encodeWidth = width; initEncodeParams.darHeight = height; initEncodeParams.darWidth = width; initEncodeParams.frameRateNum = fps; initEncodeParams.frameRateDen = 1; initEncodeParams.enableEncodeAsync = 0; initEncodeParams.enablePTD = 1; initEncodeParams.presetGUID = encoderPreset; initEncodeParams.encodeConfig = &encodeConfig; memcpy(&encodeConfig, &presetConfig.presetCfg, sizeof(NV_ENC_CONFIG)); if (keyint != 0) encodeConfig.gopLength = keyint * fps; if (maxBitRate != -1) { encodeConfig.rcParams.averageBitRate = maxBitRate * 1000; encodeConfig.rcParams.maxBitRate = maxBitRate * 1000; } if (bufferSize != -1) encodeConfig.rcParams.vbvBufferSize = bufferSize * 1000; if (bUseCBR) encodeConfig.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; encodeConfig.encodeCodecConfig.h264Config.enableVFR = bUseCFR ? 0 : 1; encodeConfig.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; encodeConfig.encodeCodecConfig.h264Config.bdirectMode = encodeConfig.frameIntervalP > 1 ? NV_ENC_H264_BDIRECT_MODE_TEMPORAL : NV_ENC_H264_BDIRECT_MODE_DISABLE; encodeConfig.encodeCodecConfig.h264Config.idrPeriod = encodeConfig.gopLength; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = colorDesc.matrix; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = colorDesc.fullRange; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = colorDesc.primaries; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = colorDesc.transfer; nvStatus = pNvEnc->nvEncInitializeEncoder(encoder, &initEncodeParams); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("nvEncInitializeEncoder failed")); goto error; } for (surfaceCount = 0; surfaceCount < maxSurfaceCount; ++surfaceCount) { NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 }; allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; allocSurf.width = (width + 31) & ~31; allocSurf.height = (height + 31) & ~31; allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL; nvStatus = pNvEnc->nvEncCreateInputBuffer(encoder, &allocSurf); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("nvEncCreateInputBuffer #%d failed"), surfaceCount); goto error; } inputSurfaces[surfaceCount].width = allocSurf.width; inputSurfaces[surfaceCount].height = allocSurf.height; inputSurfaces[surfaceCount].locked = false; inputSurfaces[surfaceCount].useCount = 0; inputSurfaces[surfaceCount].inputSurface = allocSurf.inputBuffer; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; allocOut.size = 1024 * 1024; allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; nvStatus = pNvEnc->nvEncCreateBitstreamBuffer(encoder, &allocOut); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("Failed allocating bitstream #%d buffer"), surfaceCount); outputSurfaces[surfaceCount].outputSurface = 0; surfaceCount += 1; goto error; } outputSurfaces[surfaceCount].outputSurface = allocOut.bitstreamBuffer; outputSurfaces[surfaceCount].size = allocOut.size; outputSurfaces[surfaceCount].busy = false; } NvLog(TEXT("------------------------------------------")); NvLog(TEXT("%s"), GetInfoString().Array()); NvLog(TEXT("------------------------------------------")); alive = true; return; error: alive = false; for (int i = 0; i < surfaceCount; ++i) { pNvEnc->nvEncDestroyInputBuffer(encoder, inputSurfaces[i].inputSurface); if (outputSurfaces[i].outputSurface != 0) pNvEnc->nvEncDestroyBitstreamBuffer(encoder, outputSurfaces[i].outputSurface); } surfaceCount = 0; if (encoder) pNvEnc->nvEncDestroyEncoder(encoder); encoder = 0; if (cuContext) cuCtxDestroy(cuContext); }
// /// Retrieves the file version information in the requested language id. // bool TModuleVersionInfo::GetFileVersion(LPCTSTR& fileVersion, uint lang) { return GetInfoString(viFileVersionStr, fileVersion, lang); }
QSVEncoder(int fps_, int width, int height, int quality, CTSTR preset, bool bUse444, ColorDescription &colorDesc, int maxBitrate, int bufferSize, bool bUseCFR_) : bFirstFrameProcessed(false), width(width), height(height), max_bitrate(maxBitrate) { fps = fps_; bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR")) != 0; bUseCFR = bUseCFR_; UINT keyframeInterval = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), 6); int keyint = fps*keyframeInterval; int bframes = 7; bool bHaveCustomImpl = false; impl_parameters custom = { 0 }; BOOL bUseCustomParams = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCustomSettings")) && AppConfig->GetInt(TEXT("Video Encoding"), TEXT("QSVUseVideoEncoderSettings")); if(bUseCustomParams) { StringList paramList; String strCustomParams = AppConfig->GetString(TEXT("Video Encoding"), TEXT("CustomSettings")); strCustomParams.KillSpaces(); if(strCustomParams.IsValid()) { Log(TEXT("Using custom encoder settings: \"%s\""), strCustomParams.Array()); strCustomParams.GetTokenList(paramList, ' ', FALSE); for(UINT i=0; i<paramList.Num(); i++) { String &strParam = paramList[i]; if(!schr(strParam, '=')) continue; String strParamName = strParam.GetToken(0, '='); String strParamVal = strParam.GetTokenOffset(1, '='); if(strParamName == "keyint") { int keyint_ = strParamVal.ToInt(); if(keyint_ < 0) continue; keyint = keyint_; } else if(strParamName == "bframes") { int bframes_ = strParamVal.ToInt(); if(bframes_ < 0) continue; bframes = bframes_; } else if(strParamName == "qsvimpl") { StringList bits; strParamVal.GetTokenList(bits, ',', true); if(bits.Num() < 3) continue; StringList version; bits[2].GetTokenList(version, '.', false); if(version.Num() != 2) continue; custom.type = bits[0].ToInt(); if(custom.type == 0) custom.type = MFX_IMPL_HARDWARE_ANY; auto &intf = bits[1].MakeLower(); custom.intf = intf == "d3d11" ? MFX_IMPL_VIA_D3D11 : (intf == "d3d9" ? MFX_IMPL_VIA_D3D9 : MFX_IMPL_VIA_ANY); custom.version.Major = version[0].ToInt(); custom.version.Minor = version[1].ToInt(); bHaveCustomImpl = true; } } } } if(!spawn_helper(event_prefix, qsvhelper_process, qsvhelper_thread, process_waiter)) CrashError(TEXT("Couldn't launch QSVHelper: %u"), GetLastError()); ipc_init_request request((event_prefix + INIT_REQUEST).Array()); request->mode = request->MODE_ENCODE; request->obs_process_id = GetCurrentProcessId(); request->fps = fps_; request->keyint = keyint; request->bframes = bframes; request->width = width; request->height = height; request->max_bitrate = maxBitrate; request->buffer_size = bufferSize; request->use_cbr = bUseCBR; request->full_range = colorDesc.fullRange; request->matrix = colorDesc.matrix; request->primaries = colorDesc.primaries; request->transfer = colorDesc.transfer; request->use_custom_impl = bHaveCustomImpl; request->custom_impl = custom.type; request->custom_intf = custom.intf; request->custom_version = custom.version; request.signal(); ipc_init_response response((event_prefix + INIT_RESPONSE).Array()); IPCWaiter response_waiter = process_waiter; response_waiter.push_back(response.signal_); if(response_waiter.wait_for_two(0, 1, INFINITE)) { DWORD code = 0; if(!GetExitCodeProcess(qsvhelper_process.h, &code)) CrashError(TEXT("Failed to initialize QSV session.")); switch(code) { case EXIT_INCOMPATIBLE_CONFIGURATION: CrashError(TEXT("QSVHelper.exe has exited because of an incompatible qsvimpl custom parameter (before response)")); case EXIT_NO_VALID_CONFIGURATION: if(OSGetVersion() < 8) CrashError(TEXT("QSVHelper.exe could not find a valid configuration. Make sure you have a (virtual) display connected to your iGPU")); CrashError(TEXT("QSVHelper.exe could not find a valid configuration")); default: CrashError(TEXT("QSVHelper.exe has exited with code %i (before response)"), code); } } Log(TEXT("------------------------------------------")); if(bHaveCustomImpl && !response->using_custom_impl) AppWarning(TEXT("Could not initialize QSV session using custom settings")); ver = response->version; auto intf_str = qsv_intf_str(response->requested_impl), actual_intf_str = qsv_intf_str(response->actual_impl); auto length = std::distance(std::begin(implStr), std::end(implStr)); auto impl = response->requested_impl & (MFX_IMPL_VIA_ANY - 1); if(impl > length) impl = static_cast<mfxIMPL>(length-1); Log(TEXT("QSV version %u.%u using %s%s (actual: %s%s)"), ver.Major, ver.Minor, implStr[impl], intf_str, implStr[response->actual_impl & (MFX_IMPL_VIA_ANY - 1)], actual_intf_str); target_usage = response->target_usage; encode_tasks.SetSize(response->bitstream_num); bs_buff = ipc_bitstream_buff((event_prefix + BITSTREAM_BUFF).Array(), response->bitstream_size*response->bitstream_num); if(!bs_buff) CrashError(TEXT("Failed to initialize QSV bitstream buffer (%u)"), GetLastError()); mfxU8 *bs_start = (mfxU8*)(((size_t)&bs_buff + 31)/32*32); for(unsigned i = 0; i < encode_tasks.Num(); i++) { zero(encode_tasks[i].surf); mfxBitstream &bs = encode_tasks[i].bs; zero(bs); bs.Data = bs_start + i*response->bitstream_size; bs.MaxLength = response->bitstream_size; idle_tasks << i; } frames.SetSize(response->frame_num); frame_buff = ipc_frame_buff((event_prefix + FRAME_BUFF).Array(), response->frame_size*response->frame_num); if(!frame_buff) CrashError(TEXT("Failed to initialize QSV frame buffer (%u)"), GetLastError()); mfxU8 *frame_start = (mfxU8*)(((size_t)&frame_buff + 15)/16*16); for(unsigned i = 0; i < frames.Num(); i++) { mfxFrameData& frame = frames[i]; zero(frame); frame.Y = frame_start + i * response->frame_size; frame.UV = frame_start + i * response->frame_size + response->UV_offset; frame.V = frame_start + i * response->frame_size + response->V_offset; frame.Pitch = response->frame_pitch; } Log(TEXT("Using %u bitstreams and %u frame buffers"), encode_tasks.Num(), frames.Num()); Log(TEXT("------------------------------------------")); Log(GetInfoString()); Log(TEXT("------------------------------------------")); DataPacket packet; GetHeaders(packet); frame_queue = ipc_frame_queue((event_prefix + FRAME_QUEUE).Array(), frames.Num()); if(!frame_queue) CrashError(TEXT("Failed to initialize frame queue (%u)"), GetLastError()); frame_buff_status = ipc_frame_buff_status((event_prefix + FRAME_BUFF_STATUS).Array(), frames.Num()); if(!frame_buff_status) CrashError(TEXT("Failed to initialize QSV frame buffer status (%u)"), GetLastError()); bs_info = ipc_bitstream_info((event_prefix + BITSTREAM_INFO).Array(), response->bitstream_num); if(!bs_info) CrashError(TEXT("Failed to initialize QSV bitstream info (%u)"), GetLastError()); filled_bitstream = ipc_filled_bitstream((event_prefix + FILLED_BITSTREAM).Array()); if(!filled_bitstream) CrashError(TEXT("Failed to initialize bitstream signal (%u)"), GetLastError()); stop = ipc_stop((event_prefix + STOP_REQUEST).Array()); if(!stop) CrashError(TEXT("Failed to initialize QSV stop signal (%u)"), GetLastError()); filled_bitstream_waiter = process_waiter; filled_bitstream_waiter.push_back(filled_bitstream.signal_); }
// /// Retrieves the special build number. // bool TModuleVersionInfo::GetSpecialBuild(LPCTSTR& specialBuild, uint lang) { // !CQ could check VS_FF_SPECIALBUILD flag first... return GetInfoString(viSpecialBuildStr, specialBuild, lang); }
// /// Retrieves the version of the product. // bool TModuleVersionInfo::GetProductVersion(LPCTSTR& prodVersion, uint lang) { return GetInfoString(viProductVersionStr, prodVersion, lang); }
// /// Retrieves the product name this module is associated with. // bool TModuleVersionInfo::GetProductName(LPCTSTR& prodName, uint lang) { return GetInfoString(viProductNameStr, prodName, lang); }
// /// Retrieves the original filename. // bool TModuleVersionInfo::GetOriginalFilename(LPCTSTR& originalFilename, uint lang) { return GetInfoString(viOriginalFilenameStr, originalFilename, lang); }
// /// Retrieves the copyright message. // bool TModuleVersionInfo::GetLegalCopyright(LPCTSTR& copyright, uint lang) { return GetInfoString(viLegalCopyrightStr, copyright, lang); }
// /// Retrieves the internal name of the module. // bool TModuleVersionInfo::GetInternalName(LPCTSTR& internalName, uint lang) { return GetInfoString(viInternalNameStr, internalName, lang); }
X264Encoder(int fps, int width, int height, int quality, CTSTR preset, bool bUse444, ColorDescription &colorDesc, int maxBitrate, int bufferSize, bool bUseCFR) { curPreset = preset; fps_ms = 1000/fps; StringList paramList; curProfile = AppConfig->GetString(TEXT("Video Encoding"), TEXT("X264Profile"), TEXT("high")); BOOL bUseCustomParams = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCustomSettings")); if(bUseCustomParams) { String strCustomParams = AppConfig->GetString(TEXT("Video Encoding"), TEXT("CustomSettings")); strCustomParams.KillSpaces(); if(strCustomParams.IsValid()) { Log(TEXT("Using custom x264 settings: \"%s\""), strCustomParams.Array()); strCustomParams.GetTokenList(paramList, ' ', FALSE); for(UINT i=0; i<paramList.Num(); i++) { String &strParam = paramList[i]; if(!schr(strParam, '=')) continue; String strParamName = strParam.GetToken(0, '='); String strParamVal = strParam.GetTokenOffset(1, '='); if(strParamName.CompareI(TEXT("preset"))) { if(valid_x264_string(strParamVal, (const char**)x264_preset_names)) curPreset = strParamVal; else Log(TEXT("invalid preset: %s"), strParamVal.Array()); paramList.Remove(i--); } else if(strParamName.CompareI(TEXT("tune"))) { if(valid_x264_string(strParamVal, (const char**)x264_tune_names)) curTune = strParamVal; else Log(TEXT("invalid tune: %s"), strParamVal.Array()); paramList.Remove(i--); } else if(strParamName.CompareI(TEXT("profile"))) { if(valid_x264_string(strParamVal, (const char **)x264_profile_names)) curProfile = strParamVal; else Log(TEXT("invalid profile: %s"), strParamVal.Array()); paramList.Remove(i--); } } } } zero(¶mData, sizeof(paramData)); LPSTR lpPreset = curPreset.CreateUTF8String(); LPSTR lpTune = curTune.CreateUTF8String(); if (x264_param_default_preset(¶mData, lpPreset, lpTune)) Log(TEXT("Failed to set x264 defaults: %s/%s"), curPreset.Array(), curTune.Array()); Free(lpTune); Free(lpPreset); this->width = width; this->height = height; paramData.b_deterministic = false; bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR"), 1) != 0; bPadCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("PadCBR"), 1) != 0; this->bUseCFR = bUseCFR; SetBitRateParams(maxBitrate, bufferSize); if(bUseCBR) { if(bPadCBR) paramData.i_nal_hrd = X264_NAL_HRD_CBR; paramData.rc.i_rc_method = X264_RC_ABR; paramData.rc.f_rf_constant = 0.0f; } else { paramData.rc.i_rc_method = X264_RC_CRF; paramData.rc.f_rf_constant = baseCRF+float(10-quality); } UINT keyframeInterval = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), 0); paramData.b_vfr_input = !bUseCFR; paramData.i_width = width; paramData.i_height = height; paramData.vui.b_fullrange = colorDesc.fullRange; paramData.vui.i_colorprim = colorDesc.primaries; paramData.vui.i_transfer = colorDesc.transfer; paramData.vui.i_colmatrix = colorDesc.matrix; if (keyframeInterval) paramData.i_keyint_max = fps*keyframeInterval; paramData.i_fps_num = fps; paramData.i_fps_den = 1; paramData.i_timebase_num = 1; paramData.i_timebase_den = 1000; paramData.pf_log = get_x264_log; paramData.i_log_level = X264_LOG_WARNING; for(UINT i=0; i<paramList.Num(); i++) { String &strParam = paramList[i]; if(!schr(strParam, '=')) continue; String strParamName = strParam.GetToken(0, '='); String strParamVal = strParam.GetTokenOffset(1, '='); if( strParamName.CompareI(TEXT("fps")) || strParamName.CompareI(TEXT("force-cfr"))) { Log(TEXT("The custom x264 command '%s' is unsupported, use the application settings instead"), strParam.Array()); continue; } else { LPSTR lpParam = strParamName.CreateUTF8String(); LPSTR lpVal = strParamVal.CreateUTF8String(); if(x264_param_parse(¶mData, lpParam, lpVal) != 0) Log(TEXT("The custom x264 command '%s' failed"), strParam.Array()); Free(lpParam); Free(lpVal); } } if(bUse444) paramData.i_csp = X264_CSP_I444; else paramData.i_csp = X264_CSP_I420; colorDesc.fullRange = paramData.vui.b_fullrange; colorDesc.primaries = paramData.vui.i_colorprim; colorDesc.transfer = paramData.vui.i_transfer; colorDesc.matrix = paramData.vui.i_colmatrix; if (curProfile) { LPSTR lpProfile = curProfile.CreateUTF8String(); if (x264_param_apply_profile (¶mData, lpProfile)) Log(TEXT("Failed to set x264 profile: %s"), curProfile.Array()); Free(lpProfile); } x264 = x264_encoder_open(¶mData); if(!x264) CrashError(TEXT("Could not initialize x264")); Log(TEXT("------------------------------------------")); Log(TEXT("%s"), GetInfoString().Array()); Log(TEXT("------------------------------------------")); DataPacket packet; GetHeaders(packet); }
void NVENCEncoder::init() { NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS stEncodeSessionParams = {0}; NV_ENC_PRESET_CONFIG presetConfig = {0}; GUID clientKey = NV_CLIENT_KEY; CUcontext cuContextCurr; NVENCSTATUS nvStatus = NV_ENC_SUCCESS; int surfaceCount = 0; GUID encoderPreset = NV_ENC_PRESET_HQ_GUID; dontTouchConfig = false; bool is2PassRC = false; String profileString = AppConfig->GetString(TEXT("Video Encoding"), TEXT("X264Profile"), TEXT("high")); String presetString = AppConfig->GetString(TEXT("Video Encoding"), TEXT("NVENCPreset"), TEXT("High Quality")); if (presetString == TEXT("High Performance")) { encoderPreset = NV_ENC_PRESET_HP_GUID; } else if (presetString == TEXT("High Quality")) { encoderPreset = NV_ENC_PRESET_HQ_GUID; } else if (presetString == TEXT("Bluray Disk")) { encoderPreset = NV_ENC_PRESET_BD_GUID; } else if (presetString == TEXT("Low Latency (2pass)")) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; is2PassRC = true; } else if (presetString == TEXT("High Performance Low Latency (2pass)")) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; is2PassRC = true; } else if (presetString == TEXT("High Quality Low Latency (2pass)")) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; is2PassRC = true; } else if (presetString == TEXT("Low Latency")) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; } else if (presetString == TEXT("High Performance Low Latency")) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; } else if (presetString == TEXT("High Quality Low Latency")) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; } else if (presetString == TEXT("Lossless")) { encoderPreset = NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID; dontTouchConfig = true; } else if (presetString == TEXT("High Performance Lossless")) { encoderPreset = NV_ENC_PRESET_LOSSLESS_HP_GUID; dontTouchConfig = true; } else if (presetString == TEXT("NVDefault")) { encoderPreset = NV_ENC_PRESET_DEFAULT_GUID; } else if (presetString == TEXT("Streaming")) { encoderPreset = NV_ENC_PRESET_STREAMING; clientKey = NV_ENC_KEY_STREAMING; } else if (presetString == TEXT("Streaming (2pass)")) { encoderPreset = NV_ENC_PRESET_STREAMING; is2PassRC = true; clientKey = NV_ENC_KEY_STREAMING; } else { if (height > 1080 || (height == 1080 && fps > 30)) { encoderPreset = NV_ENC_PRESET_HQ_GUID; } if (height > 720 || (height == 720 && fps > 30)) { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; } else { encoderPreset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; is2PassRC = true; } } TCHAR envClientKey[128] = {0}; DWORD envRes = GetEnvironmentVariable(TEXT("NVENC_KEY"), envClientKey, 128); if (envRes > 0 && envRes <= 128) { if (stringToGuid(envClientKey, &clientKey)) { NvLog(TEXT("Got NVENC key from environment")); } else { NvLog(TEXT("NVENC_KEY environment variable has invalid format")); } } mset(&initEncodeParams, 0, sizeof(NV_ENC_INITIALIZE_PARAMS)); mset(&encodeConfig, 0, sizeof(NV_ENC_CONFIG)); encodeConfig.version = NV_ENC_CONFIG_VER; presetConfig.version = NV_ENC_PRESET_CONFIG_VER; presetConfig.presetCfg.version = NV_ENC_CONFIG_VER; initEncodeParams.version = NV_ENC_INITIALIZE_PARAMS_VER; stEncodeSessionParams.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; stEncodeSessionParams.apiVersion = NVENCAPI_VERSION; stEncodeSessionParams.clientKeyPtr = &clientKey; cuContext = 0; checkCudaErrors(cuCtxCreate(&cuContext, 0, pNvencDevices[iNvencUseDeviceID])); checkCudaErrors(cuCtxPopCurrent(&cuContextCurr)); stEncodeSessionParams.device = (void*)cuContext; stEncodeSessionParams.deviceType = NV_ENC_DEVICE_TYPE_CUDA; nvStatus = pNvEnc->nvEncOpenEncodeSessionEx(&stEncodeSessionParams, &encoder); if (nvStatus != NV_ENC_SUCCESS) { encoder = 0; OBSMessageBox(NULL, Str("Encoder.NVENC.OldDriver"), NULL, MB_OK | MB_ICONERROR); NvLog(TEXT("nvEncOpenEncodeSessionEx failed with 0x%x - outdated driver?"), nvStatus); goto error; } if (!populateEncodePresetGUIDs()) goto error; if (!checkPresetSupport(encoderPreset)) { NvLog(TEXT("Preset is not supported!")); goto error; } nvStatus = pNvEnc->nvEncGetEncodePresetConfig(encoder, NV_ENC_CODEC_H264_GUID, encoderPreset, &presetConfig); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("nvEncGetEncodePresetConfig failed with 0x%x"), nvStatus); goto error; } initEncodeParams.encodeGUID = NV_ENC_CODEC_H264_GUID; initEncodeParams.encodeHeight = height; initEncodeParams.encodeWidth = width; initEncodeParams.darHeight = height; initEncodeParams.darWidth = width; initEncodeParams.frameRateNum = fps; initEncodeParams.frameRateDen = 1; initEncodeParams.enableEncodeAsync = 0; initEncodeParams.enablePTD = 1; initEncodeParams.presetGUID = encoderPreset; initEncodeParams.encodeConfig = &encodeConfig; memcpy(&encodeConfig, &presetConfig.presetCfg, sizeof(NV_ENC_CONFIG)); encodeConfig.version = NV_ENC_CONFIG_VER; if (!dontTouchConfig) { if (keyint != 0) encodeConfig.gopLength = keyint * fps; if (maxBitRate != -1) { encodeConfig.rcParams.averageBitRate = maxBitRate * 1000; encodeConfig.rcParams.maxBitRate = maxBitRate * 1000; } if (bufferSize != -1) { encodeConfig.rcParams.vbvBufferSize = bufferSize * 1000; encodeConfig.rcParams.vbvInitialDelay = bufferSize * 1000; } if (bUseCBR) { auto filler = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("PadCBR"), 1) != 0; if (is2PassRC) { encodeConfig.rcParams.rateControlMode = filler ? NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP : NV_ENC_PARAMS_RC_2_PASS_VBR; } else { encodeConfig.rcParams.rateControlMode = filler ? NV_ENC_PARAMS_RC_CBR : NV_ENC_PARAMS_RC_VBR; } encodeConfig.frameIntervalP = 1; encodeConfig.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; encodeConfig.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE; } else { encodeConfig.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR_MINQP; encodeConfig.rcParams.enableMinQP = 1; encodeConfig.rcParams.minQP.qpInterB = 32 - quality; encodeConfig.rcParams.minQP.qpInterP = 32 - quality; encodeConfig.rcParams.minQP.qpIntra = 32 - quality; encodeConfig.frameIntervalP = 3; } encodeConfig.encodeCodecConfig.h264Config.outputBufferingPeriodSEI = 1; encodeConfig.encodeCodecConfig.h264Config.outputPictureTimingSEI = 1; encodeConfig.encodeCodecConfig.h264Config.disableSPSPPS = 1; encodeConfig.encodeCodecConfig.h264Config.enableVFR = bUseCFR ? 0 : 1; encodeConfig.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; if(profileString.CompareI(TEXT("main"))) encodeConfig.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; else if(profileString.CompareI(TEXT("high"))) encodeConfig.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; encodeConfig.encodeCodecConfig.h264Config.disableSPSPPS = 1; encodeConfig.encodeCodecConfig.h264Config.bdirectMode = encodeConfig.frameIntervalP > 1 ? NV_ENC_H264_BDIRECT_MODE_TEMPORAL : NV_ENC_H264_BDIRECT_MODE_DISABLE; encodeConfig.encodeCodecConfig.h264Config.idrPeriod = encodeConfig.gopLength; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 1; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = colorDesc.matrix; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = colorDesc.fullRange; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.videoFormat = 5; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = colorDesc.primaries; encodeConfig.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = colorDesc.transfer; } nvStatus = pNvEnc->nvEncInitializeEncoder(encoder, &initEncodeParams); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("nvEncInitializeEncoder failed with 0x%x"), nvStatus); goto error; } for (surfaceCount = 0; surfaceCount < maxSurfaceCount; ++surfaceCount) { NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 }; allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; allocSurf.width = (width + 31) & ~31; allocSurf.height = (height + 31) & ~31; allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL; nvStatus = pNvEnc->nvEncCreateInputBuffer(encoder, &allocSurf); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("nvEncCreateInputBuffer #%d failed with 0x%x"), surfaceCount, nvStatus); goto error; } inputSurfaces[surfaceCount].width = allocSurf.width; inputSurfaces[surfaceCount].height = allocSurf.height; inputSurfaces[surfaceCount].locked = false; inputSurfaces[surfaceCount].useCount = 0; inputSurfaces[surfaceCount].inputSurface = allocSurf.inputBuffer; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; allocOut.size = outBufferSize; allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; nvStatus = pNvEnc->nvEncCreateBitstreamBuffer(encoder, &allocOut); if (nvStatus != NV_ENC_SUCCESS) { NvLog(TEXT("Failed allocating bitstream #%d buffer with 0x%x"), surfaceCount, nvStatus); outputSurfaces[surfaceCount].outputSurface = 0; surfaceCount += 1; goto error; } outputSurfaces[surfaceCount].outputSurface = allocOut.bitstreamBuffer; outputSurfaces[surfaceCount].size = allocOut.size; outputSurfaces[surfaceCount].busy = false; } NvLog(TEXT("------------------------------------------")); NvLog(TEXT("%s"), GetInfoString().Array()); NvLog(TEXT("------------------------------------------")); alive = true; return; error: alive = false; for (int i = 0; i < surfaceCount; ++i) { pNvEnc->nvEncDestroyInputBuffer(encoder, inputSurfaces[i].inputSurface); if (outputSurfaces[i].outputSurface != 0) pNvEnc->nvEncDestroyBitstreamBuffer(encoder, outputSurfaces[i].outputSurface); } surfaceCount = 0; if (encoder) pNvEnc->nvEncDestroyEncoder(encoder); encoder = 0; if (cuContext) cuCtxDestroy(cuContext); }
// // Query any given "\StringFileInfo\lang-charset\<str>" version info string. // lang indicates the language translation, may be 0 to signify file default. // String version. Throws exception on failure. [VH 2005-04-03] // tstring TModuleVersionInfo::GetInfoString(const tstring& str, uint lang) {LPCTSTR v = _T(""); E = GetInfoString(str.c_str (), v, lang); return v;}
QSVEncoder(int fps_, int width, int height, int quality, CTSTR preset, bool bUse444, int maxBitrate, int bufferSize, bool bUseCFR_, bool bDupeFrames_) : enc(nullptr) { Log(TEXT("------------------------------------------")); for(int i = 0; i < sizeof(validImpl)/sizeof(validImpl[0]); i++) { mfxIMPL impl = validImpl[i]; ver = version; mfxStatus result = MFX_ERR_UNKNOWN; for(ver.Minor = 6; ver.Minor >= 4; ver.Minor -= 2) { result = session.Init(impl, &ver); if(result == MFX_ERR_NONE) { Log(TEXT("QSV version %u.%u using %s"), ver.Major, ver.Minor, implStr[impl]); break; } } if(result == MFX_ERR_NONE) break; } session.SetPriority(MFX_PRIORITY_HIGH); fps = fps_; bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR")) != 0; bUseCFR = bUseCFR_; bDupeFrames = bDupeFrames_; memset(¶ms, 0, sizeof(params)); //params.AsyncDepth = 0; params.mfx.CodecId = MFX_CODEC_AVC; params.mfx.TargetUsage = MFX_TARGETUSAGE_BEST_QUALITY;//SPEED; params.mfx.TargetKbps = (mfxU16)(maxBitrate*0.9); params.mfx.MaxKbps = maxBitrate; //params.mfx.InitialDelayInKB = 1; //params.mfx.GopRefDist = 1; //params.mfx.NumRefFrame = 0; params.mfx.GopPicSize = 61; params.mfx.GopRefDist = 3; params.mfx.GopOptFlag = MFX_GOP_STRICT; params.mfx.IdrInterval = 2; params.mfx.NumSlice = 1; params.mfx.RateControlMethod = bUseCBR ? MFX_RATECONTROL_CBR : MFX_RATECONTROL_VBR; params.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY; auto& fi = params.mfx.FrameInfo; ConvertFrameRate(fps, fi.FrameRateExtN, fi.FrameRateExtD); fi.FourCC = MFX_FOURCC_NV12; fi.ChromaFormat = bUse444 ? MFX_CHROMAFORMAT_YUV444 : MFX_CHROMAFORMAT_YUV420; fi.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; fi.Width = ALIGN16(width); fi.Height = ALIGN16(height); fi.CropX = 0; fi.CropY = 0; fi.CropW = width; fi.CropH = height; this->width = width; this->height = height; enc.reset(new MFXVideoENCODE(session)); enc->Close(); mfxFrameAllocRequest req; memset(&req, 0, sizeof(req)); enc->QueryIOSurf(¶ms, &req); enc->Init(¶ms); decltype(params) query; memcpy(&query, ¶ms, sizeof(params)); enc->GetVideoParam(&query); unsigned num_surf = max(6, req.NumFrameSuggested + params.AsyncDepth); encode_tasks.SetSize(num_surf); const unsigned bs_size = max(query.mfx.BufferSizeInKB*1000, bufferSize*1024/8); bs_buff.SetSize(bs_size * encode_tasks.Num() + 31); params.mfx.BufferSizeInKB = bs_size/1000; mfxU8* bs_start = (mfxU8*)(((size_t)bs_buff.Array() + 31)/32*32); for(unsigned i = 0; i < encode_tasks.Num(); i++) { encode_tasks[i].sp = nullptr; mfxFrameSurface1& surf = encode_tasks[i].surf; memset(&surf, 0, sizeof(mfxFrameSurface1)); memcpy(&surf.Info, ¶ms.mfx.FrameInfo, sizeof(params.mfx.FrameInfo)); mfxBitstream& bs = encode_tasks[i].bs; memset(&bs, 0, sizeof(mfxBitstream)); bs.Data = bs_start + i*bs_size; bs.MaxLength = bs_size; idle_tasks << i; } frames.SetSize(num_surf+3); //+NUM_OUT_BUFFERS const unsigned lum_channel_size = fi.Width*fi.Height, uv_channel_size = fi.Width*fi.Height, frame_size = lum_channel_size + uv_channel_size; frame_buff.SetSize(frame_size * frames.Num() + 15); mfxU8* frame_start = (mfxU8*)(((size_t)frame_buff.Array() + 15)/16*16); memset(frame_start, 0, frame_size * frames.Num()); for(unsigned i = 0; i < frames.Num(); i++) { mfxFrameData& frame = frames[i]; memset(&frame, 0, sizeof(mfxFrameData)); frame.Y = frame_start + i * frame_size; frame.UV = frame_start + i * frame_size + lum_channel_size; frame.V = frame.UV + 1; frame.Pitch = fi.Width; } Log(TEXT("Using %u encode tasks"), encode_tasks.Num()); Log(TEXT("Buffer size: %u configured, %u suggested by QSV; using %u"), bufferSize, query.mfx.BufferSizeInKB*1000*8/1024, params.mfx.BufferSizeInKB*1000*8/1024); Log(TEXT("------------------------------------------")); Log(TEXT("%s"), GetInfoString().Array()); Log(TEXT("------------------------------------------")); memset(&ctrl, 0, sizeof(ctrl)); ctrl.FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF | MFX_FRAMETYPE_IDR; deferredFrames = 0; bUsingDecodeTimestamp = false && ver.Minor >= 6; DataPacket packet; GetHeaders(packet); }
// /// Retrieves the file description information in the requested language id. // bool TModuleVersionInfo::GetFileDescription(LPCTSTR& fileDesc, uint lang) { return GetInfoString(viFileDescStr, fileDesc, lang); }