⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_h264_crc.h

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 H
字号:
////               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) 2004 - 2005 Intel Corporation. All Rights Reserved.//#ifndef CRC264_H__#define CRC264_H__#include "umc_h264_video_encoder.h"#include "stdlib.h"#include "string.h"#include "umc_h264_arc.h"#include <ipps.h>#define PREV_FRM_IMPACT         0.05#define CPB_SAFE_PART           0.1#define INITIAL_FRAME_QUANT     26#define HISTORY_SIZE            20#define MB_MODEL_BITRATE_THRESHOLD 0.085 /* in bits per pixel */#ifndef min#define min(x,y) ((x) < (y) ? (x) : (y))#endif#ifndef max#define max(x,y) ((x) > (y) ? (x) : (y))#endif#define SQR(x) ((x)*(x))#define DATA_TYPE Ipp32snamespace UMC{struct Queue{    DATA_TYPE   *data;    Ipp32s         max_data_cout;    Ipp32s         cur_data_count;    Ipp32s         head;    Ipp32s         tail;    Queue(Ipp32s _max_data_cout=HISTORY_SIZE)    {        max_data_cout = 0;        cur_data_count = 0;        head = 0;        tail = 0;        data = (Ipp32s *)ippsMalloc_8u(sizeof(DATA_TYPE)*(_max_data_cout));        if(data==NULL)            return;        max_data_cout = _max_data_cout;        tail = max_data_cout-1;        memset(data,0,_max_data_cout*sizeof(DATA_TYPE));    }    ~Queue()    {        if(data)            ippsFree(data);        max_data_cout = 0;        cur_data_count = 0;        head = 0;        tail = 0;        data = NULL;    }    Ipp32s q_push(DATA_TYPE value)    {        if(cur_data_count<max_data_cout)        {            tail = (tail+1)%max_data_cout;            data[tail] = value;            cur_data_count++;            return 1;        }        return 0;    }    Ipp32s q_pop(DATA_TYPE* value)    {        if(cur_data_count>0)        {            *value = data[head];            head = (head+1)%max_data_cout;            cur_data_count--;        }        return 0;    }    Ipp32s q_push_force(DATA_TYPE value)    {        if(cur_data_count<max_data_cout)        {            return q_push(value);        }        else        {            DATA_TYPE tmp;            q_pop(&tmp);            return q_push(value);        }    }    DATA_TYPE q_get(Ipp32s index)    {        if(cur_data_count>index)        {            return data[(head+index)%max_data_cout];        }        return 0;    }    DATA_TYPE q_get_last()    {        if(cur_data_count>0)        {            return data[tail];        }        return 0;    }};struct RateMacroblock{    Ipp32u mb_qp;    Ipp32u mb_bites_used;    Ipp32u mb_complexity;    Ipp32u mb_sum;    Ipp32u mb_sad;    Ipp32u max_skip_error;    Ipp32f mb_weight;    Ipp32u type;    Ipp32u pattern;    Ipp32u quant;    RateMacroblock()    {        mb_qp=mb_bites_used=mb_complexity=mb_sum=mb_sad=max_skip_error=type=pattern=quant=0;        mb_weight=1.0;    }};struct RDModel{    Ipp64f X11;    Ipp64f X1;    Ipp64f X2;    Queue Q;    Queue E;    Queue R;};#define INITIAL_A1 100.#define INITIAL_A2 400.#define INITIAL_A3 0.#define INTRA_QP_WEIGHT ((2.0/3.0))struct CH264ConstRateControl:public CRateControl{private:    Ipp8u cur_frame_type;    RDModel *model;    RDModel *model_mbI;    RDModel *model_mbP;    RateMacroblock *mbs;    Ipp32u mb_count;    Ipp32u width,height,pitch,width_mb,height_mb;    Ipp32u cur_frame_number,last_intra_frame;    Ipp32u frames_coded[5];    Ipp32u total_frames_coded;    Ipp32u frm_mbs_skipped;    Ipp32s last_mb_number;    Ipp32s frm_bits_rest;    Ipp32u target_bits_per_second;    Ipp32u target_bits_per_frame;    Ipp32s cpb_bits,cpb_size;    Ipp32u frame_quant_cur;    Ipp32u qp_min,qp_max,intra_qp_max,queue_size,dqp_max;    Ipp32u total_frm_skipped;    Ipp8u *cur_y_plane,*cur_u_plane,*cur_v_plane;    Ipp32s last_frm_stuffed_bits;    Ipp32u last_mb_frame_quant;    Ipp32u queue_bits_per_frame,intra_coded_frames_in_queue;    Ipp32u prev_mb_bits;    Ipp64s start_bits_encoded;    Ipp64f target_frames_per_second;    Ipp64f init_frame_time;    Ipp64f   A1I,A2I,A3I;    Ipp64f   A1P,A2P,A3P;    Ipp64f min_frs,max_frs,i_frames_mult;    //Ipp64f S; /* weighted sum of all mb. coplexities */    Ipp64f SI; /* weighted sum of all mb. coplexities */    Ipp64f SP; /* weighted sum of all mb. coplexities */    Ipp64s last_mb_bit_pos;    Ipp64s last_frm_bit_pos;    Ipp64s queue_start_bits,queue_bits;    Ipp64f bpp;public:    CH264ConstRateControl(Ipp32u c_width,Ipp32u c_height,Ipp32u c_pitch,Ipp32u target_bps,Ipp32u _qp_min,Ipp32u _qp_max);    void SetRateControlOptions(H264AdvRate_Options *options);    virtual ~CH264ConstRateControl()    {        delete []model;        delete model_mbI;        delete model_mbP;        delete []mbs;    }    Ipp32u CalculateComplexity();    void CalculateComplexity2(H264Extra_MB_Info *ExMBInfo);    Ipp32u UpdateMBComplexity(Ipp32u number);    virtual Ipp32u PictureRateControl(Ipp8u *y_plane,Ipp8u *u_plane,Ipp8u *v_plane,Ipp32u frame_number,Ipp32u frame_type,Ipp64s bits_encoded,H264Extra_MB_Info *ExMBInfo,double start_frame_time,double stop_frame_time);    virtual Ipp32u PostPictureRateControl(Ipp64s bits_encoded);    virtual Ipp32u MacroblockRateControl(Ipp32s mb_number,Ipp32s mb_type,Ipp64s bits_encoded,Ipp32u mb_sad);    virtual Ipp32u PostMacroblockRateControl(Ipp32s mb_number,Ipp64s bits_encoded,Ipp32u actual_quant,Ipp32u cbp);};#define MB_COMPLEXITY(i) (max(2560, mbs[i].mb_complexity/* *(mbs[i].type<=MBTYPE_PCM)*/))#define MB_COMPLEXITY2(i) (max(64, mbs[i].mb_sad/* *(mbs[i].type<=MBTYPE_PCM)*/))//#define MB_COMPLEXITY(i) mbs[i].mb_complexity} //namespace UMC#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -