📄 readparam.c
字号:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ippVideoEncoderMPEG4.h"
#include "readparam.h"
#include "enum.h"
#include "global_declare.h"
#include "def_gary.h"
int ippVideoEncoder_Init(int nPlanes, int yuvWidth, int yuvHeight, int yuvFormat, int expandSize)
{
int i;
VideoEncoder_mIsInit=0;
mSourceFormat = yuvFormat;
mSourceWidth = yuvWidth;
mSourceHeight = yuvHeight;
mExpandSize = expandSize;
if (mExpandSize < 0)
mExpandSize = 0;
mExpandSizeA = (mExpandSize + 15) & (~15);
mNumMacroBlockPerRow = (mSourceWidth + 15) / 16;
mNumMacroBlockPerCol = (mSourceHeight + 15) / 16;
mStepLuma = mExpandSizeA * 2 + mNumMacroBlockPerRow * 16;
mLumaPlaneSize = mStepLuma * (mExpandSizeA * 2 + mNumMacroBlockPerCol * 16);
if (mSourceFormat == IPPVC_CHROMA_420) {
mStepChroma = (mExpandSizeA / 2) * 2 + mNumMacroBlockPerRow * 8;
} else {
mStepChroma = 0;
}
mChromaPlaneSize = mStepChroma * ((mExpandSizeA / 2) * 2 + mNumMacroBlockPerCol * 8);
mPlanes = nPlanes;
if (mPlanes <= 0)
mPlanes = 2;
//mPtreY = (Ipp8u **)malloc(mPlanes*4);
// mPtreU = (Ipp8u **)malloc(mPlanes*4);
// mPtreV = (Ipp8u **)malloc(mPlanes*4);
// mPtrY = (Ipp8u **)malloc(mPlanes*4);
// mPtrU = (Ipp8u **)malloc(mPlanes*4);
// mPtrV = (Ipp8u **)malloc(mPlanes*4);
// mPtrY = (Ipp8u **)malloc(4*sizeof(Ipp8u *));
// mPtrU = (Ipp8u **)malloc(4*sizeof(Ipp8u *));
// mPtrV = (Ipp8u **)malloc(4*sizeof(Ipp8u *));
VideoEncoder_mIsInit = 1;
/*
mPtrY[0] = mPtreY_0_2[0] + mExpandSizeA + mExpandSizeA * mStepLuma;
mPtrU[0] = mPtreU_0_2[0] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrV[0] = mPtreV_0_2[0] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrY[1] = mPtreY_1_3[0] + mExpandSizeA + mExpandSizeA * mStepLuma;
mPtrU[1] = mPtreU_1_3[0] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrV[1] = mPtreV_1_3[0] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrY[2] = mPtreY_0_2[1] + mExpandSizeA + mExpandSizeA * mStepLuma;
mPtrU[2] = mPtreU_0_2[1] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrV[2] = mPtreV_0_2[1] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrY[3] = mPtreY_1_3[1] + mExpandSizeA + mExpandSizeA * mStepLuma;
mPtrU[3] = mPtreU_1_3[1] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtrV[3] = mPtreV_1_3[1] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
*/
/*
mPrefY[0] = mPrefeY[0] + mExpandSizeA + mExpandSizeA * mStepLuma;
mPrefU[0] = mPrefeU[0] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPrefV[0] = mPrefeV[0] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPrefY[1] = mPrefeY[1] + mExpandSizeA + mExpandSizeA * mStepLuma;
mPrefU[1] = mPrefeU[1] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPrefV[1] = mPrefeV[1] + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtr656[0] = mBuf656[0] + YUV656_BUF_WIDTH*2 + 8;
mPtr656[1] = mBuf656[1] + YUV656_BUF_WIDTH*2 + 8;
mPtr656[2] = mBuf656[2] + YUV656_BUF_WIDTH*2 + 8;
mPtr656[3] = mBuf656[3] + YUV656_BUF_WIDTH*2 + 8;
*/
mPrefY[0] = mPrefeY + mExpandSizeA + mExpandSizeA * mStepLuma;
mPrefU[0] = mPrefeU + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPrefV[0] = mPrefeV + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPrefY[1] = mPrefeY+MPREFEY_STEP + mExpandSizeA + mExpandSizeA * mStepLuma;
mPrefU[1] = mPrefeU+MPREFEUV_STEP + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPrefV[1] = mPrefeV+MPREFEUV_STEP + mExpandSizeA / 2 + (mExpandSizeA / 2) * mStepChroma;
mPtr656[0] = mBuf656+MBUF656_STEP*0 + YUV656_BUF_WIDTH*2 + 8;
mPtr656[1] = mBuf656+MBUF656_STEP*1 + YUV656_BUF_WIDTH*2 + 8;
mPtr656[2] = mBuf656+MBUF656_STEP*2 + YUV656_BUF_WIDTH*2 + 8;
mPtr656[3] = mBuf656+MBUF656_STEP*3 + YUV656_BUF_WIDTH*2 + 8;
// MB_buffer[0] = MB_refwin_buf0;
// MB_buffer[1] = MB_refwin_buf1;
// win_buffer[0] = MB_refwin_buf0+24*18+128;
// win_buffer[1] = MB_refwin_buf1+24*18+128;
MB_buffer[0] = MB_buf_0;
MB_buffer[1] = MB_buf_1;
refwin_Y = refwin_buffer;
refwin_U = refwin_buffer + 16*48*(REFWIN_NUM+2);
refwin_V = refwin_buffer + 16*48*(REFWIN_NUM+2) + 8*24*(REFWIN_NUM+2);
refmv = _refmv + 1;
refYDC = _refYDC + 1;
refUDC = _refUDC + 1;
refVDC = _refVDC + 1;
cur_dma_buf_i = 0;
next_dma_buf_i = 1;
cur_enc_buf_i = 0;
VideoEncoder_mError = IPPVC_ERROR_NOERR;
return IPPVC_ERROR_NOERR;
}
//int mp4encInit(void)
int mp4encInit(int img_format)
{
int i, j, k;
mQuantIVOP = 9; //par->quantIVOP;
mQuantPVOP = 9; //par->quantPVOP;
// mQuantBVOP = 9; //par->quantBVOP; ----no bvop;
mIVOPdist = IVOP_DIST; //par->IVOPdist;
mPVOPdist = 1; //par->PVOPdist;
// mBVOPdist = mPVOPdist - 1; ----no bvop;
// mMEalgorithm = 1; //par->MEalgorithm; ----no use;
// mMEaccuracy = 2; //par->MEaccuracy; ----no use;
// mME4mv = 0; //par->ME4mv; ----no 4mv;
mCalcPSNR = 0; //par->calcPSNR;
mPSNR_Y = mPSNR_U = mPSNR_V = 0;
VideoEncoderMPEG4_mFrameCount = 0;
//get_CurMB function selecting;
// get_MB = get_MB_dma_prepro;
// get_MB_refwin = get_MB_refwin_dma_prepro;
restore_MB_get_MB_refwin = restore_MB_get_MB_refwin_prepro;
MB_preprocess = MB_Gaus_filter;
// get_MB = get_MB_dma_no_pre;
// get_MB_refwin = get_MB_refwin_dma_no_pre;
// restore_MB_get_MB_refwin = restore_MB_get_MB_refwin_no_pre;
// MB_preprocess = MB_no_pre;
YUV656_BUF_WIDTH = 1440+8+8;
//YUV656_BUF_HEITH = 288 +2+2;
// setup MPEG-4 headers variables
// memset(&VOS, 0, sizeof(VOS)); //----no vos header
memset(&VO, 0, sizeof(VO));
memset(&VOL, 0, sizeof(VOL));
memset(&VOP, 0, sizeof(VOP));
// VOS.profile_and_level_indication = 1; //----no vos header
VO.is_visual_object_identifier = 1;
VO.visual_object_verid = MP4_ISO_IEC_14496_2;
VO.visual_object_priority = 1;
VO.visual_object_type =MP4_VIDEO_OBJECT_TYPE_VIDEO ;//1
VO.video_signal_type = 0;
//f VO.video_format;
//f VO.video_range;
//f VO.colour_description;
//f VO.colour_primaries;
//f VO.transfer_characteristics;
//f VO.matrix_coefficients;
VOL.short_video_header = 0;
VOL.random_accessible_vol = 0;
VOL.video_object_type_indication = MP4_VIDEO_OBJECT_TYPE_SIMPLE;
VOL.is_object_layer_identifier = 1;
VOL.video_object_layer_verid = MP4_ISO_IEC_14496_2;
VOL.video_object_layer_priority = 1;
VOL.aspect_ratio_info = MP4_ASPECT_RATIO_1_1;
//f VOL.par_width
//f VOL.par_height
VOL.vol_control_parameters = 0;
//f VOL.chroma_format;
//f VOL.low_delay;
//f VOL.vbv_parameters;
//f VOL.first_half_bit_rate;
//f VOL.latter_half_bit_rate;
//f VOL.first_half_vbv_buffer_size;
//f VOL.latter_half_vbv_buffer_size;
//f VOL.first_half_vbv_occupancy;
//f VOL.latter_half_vbv_occupancy;
VOL.video_object_layer_shape = MP4_SHAPE_TYPE_RECTANGULAR;
//f VOL.video_object_layer_shape_extension
VOL.vop_time_increment_resolution = 25;
VOL.fixed_vop_rate = 0;
VOL.fixed_vop_time_increment = 0;
VOL.vop_time_increment_resolution_bits = 1;
while (VOL.vop_time_increment_resolution >> VOL.vop_time_increment_resolution_bits)
VOL.vop_time_increment_resolution_bits ++;
refwin_Y_step = 16*(REFWIN_NUM+2);
refwin_UV_step = 8*(REFWIN_NUM+2);
if(img_format == IMG_FORMAT_CIF) {
VOL.video_object_layer_width = 352;
VOL.video_object_layer_height = 288;
MBDMA_YS0_x_mod = 4;
MBDMA_YS0_y_mod = YUV656_BUF_WIDTH-16*4+4;
MBDMA_YS0_y_mod_prepro = YUV656_BUF_WIDTH-18*4+4;
MBDMA_UVS0_y_mod = YUV656_BUF_WIDTH*2-8*8+8;
prepro_back_offset = YUV656_BUF_WIDTH + 4;
MB_byte_step = 64;
MB_row_step = 16;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -