📄 umc_h263_video_encoder.cpp
字号:
/*////////////////////////////////////////////////////////////////////////////////// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright(c) 2005 Intel Corporation. All Rights Reserved.//*/#include "vm_debug.h"#include "vm_time.h"#include "umc_h263_video_encoder.h"#include "umc_video_data.h"namespace UMC{H263VideoEncoder::H263VideoEncoder(){ m_IsInit = false;}H263VideoEncoder::~H263VideoEncoder(){ Close();}Status H263VideoEncoder::Reset(){ return UMC_NOT_IMPLEMENTED;}Status H263VideoEncoder::SetParams(BaseCodecParams* params){ return UMC_NOT_IMPLEMENTED;}Status H263VideoEncoder::Init(BaseCodecParams* init){ H263EncoderParams *pParam = DynamicCast<H263EncoderParams> (init); if (NULL == pParam) return UMC_NULL_PTR; if (m_IsInit) Close(); m_Param = *pParam; int h263status = h263enc.Init(&pParam->m_Param); if (h263status == H263_STS_ERR_PARAM) return UMC_FAILED_TO_INITIALIZE; if (h263status == H263_STS_ERR_NOMEM) return UMC_ALLOC; m_FrameCount = 0; m_IsInit = true; return UMC_OK;}Status H263VideoEncoder::GetInfo(BaseCodecParams* info){ H263EncoderParams* pParam = DynamicCast<H263EncoderParams>(info); if (!m_IsInit) return UMC_NOT_INITIALIZED; if (!pParam) return UMC_NULL_PTR; *pParam = m_Param; return UMC_OK;}Status H263VideoEncoder::Close(){ if (!m_IsInit) return UMC_NOT_INITIALIZED; h263enc.Close(); m_IsInit = false; return UMC_OK;}Status H263VideoEncoder::GetFrame(MediaData* pIn, MediaData* pOut){ if (!m_IsInit) return UMC_NOT_INITIALIZED; VideoData* pVideoDataIn = DynamicCast<VideoData> (pIn); if (!pOut) return UMC_NULL_PTR; h263enc.InitBuffer((Ipp8u*)pOut->GetDataPointer(), pOut->GetBufferSize()); if (pIn) { // copy YUV to internal frame IppiSize roi; Ipp8u *pY, *pU, *pV; int stepL, stepC; h263enc.GetFrameWriteInfo(&pY, &pU, &pV, &stepL, &stepC); roi.width = m_Param.src_width; roi.height = m_Param.src_height; ippiCopy_8u_C1R(pVideoDataIn->m_lpDest[0], pVideoDataIn->m_lPitch[0], pY, stepL, roi); roi.width >>= 1; roi.height >>= 1; ippiCopy_8u_C1R(pVideoDataIn->m_lpDest[1], pVideoDataIn->m_lPitch[1], pU, stepC, roi); ippiCopy_8u_C1R(pVideoDataIn->m_lpDest[2], pVideoDataIn->m_lPitch[2], pV, stepC, roi); } int sts = h263enc.EncodeFrame(pIn == NULL); pOut->SetDataSize(h263enc.GetBufferFullness()); if (pIn) { pIn->SetDataSize(0); pOut->SetTime(pIn->GetTime()); } m_FrameCount ++; //return (sts == H263_STS_BUFFERED) ? UMC_NOT_ENOUGH_DATA : (sts == H263_STS_NODATA) ? UMC_END_OF_STREAM : UMC_OK; return UMC_OK;}VideoEncoder* createH263VideoEncoder(){ H263VideoEncoder* ptr = new H263VideoEncoder; return ptr;}Status H263EncoderParams::ReadParamFile(const vm_char *FileName){ FILE *InputFile; vm_char str[STR_LEN+1]; InputFile = vm_file_open(FileName, VM_STRING("rt")); if (!InputFile) { vm_debug_trace(4,__VM_STRING("Error: Couldn't open file '%s'\n"), FileName); return UMC_OPERATION_FAILED; } vm_file_gets(str, STR_LEN, InputFile); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%s"), m_SourceFileName); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.Width); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.Height); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &numFramesToEncode); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.TimeResolution); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.TimeIncrement); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.quantIVOP); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.quantPVOP); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.quantBVOP); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.IVOPdist); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.PVOPdist); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.PVOPsearchWidth); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.PVOPsearchHeight);/* vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.BVOPsearchWidthForw); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.BVOPsearchHeightForw); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.BVOPsearchWidthBack); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.BVOPsearchHeightBack);*/ vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.MEalgorithm); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.MEaccuracy); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.calcPSNR); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.RateControl); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.BitRate); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.SceneChangeThreshold); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.UMV); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.advPred); vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.advIntra);// vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.deblockFilt);// vm_file_gets(str, STR_LEN, InputFile); vm_string_sscanf(str, VM_STRING("%d"), &m_Param.data_partitioned); fclose(InputFile); m_Param.bsBuffer = (Ipp8u*)1; m_Param.bsBuffSize = 1; // encoder will not allocate buffer src_width = m_Param.Width; src_height = m_Param.Height; return UMC_OK;}}; //namespace UMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -