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

📄 umc_h264_base.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 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) 2004 - 2005 Intel Corporation. All Rights Reserved.//#include <string.h>#include "umc_h264_video_encoder.h"#define ENCODER_SUPPORTS_IYUV//#define USE_IMPLICIT_WEIGHTED_BIPREDnamespace UMC{Ipp32uH264VideoEncoder::MaxCompressedSize    (    const H264_Image_Format &,    const H264_Image_Format &dst    ){    // We assume that CheckTransform has validated the transformation    Ipp32u size = GetBsBufferMaxSize(dst.dimensions.width, dst.dimensions.height);    return size;}////////////////////////// Determine buffer sizeIpp32uH264VideoEncoder::GetBsBufferMaxSize(const Ipp32u w, const Ipp32u h){    Ipp32u wpadded, hpadded;    Ipp32u size;    wpadded = (w + 0xf) & ~0xf;    hpadded = (h + 0xf) & ~0xf;    size = wpadded * hpadded;    return ((size)+(size>>1)+4096);    // TBD: see if buffer size can be reduced}// Propose_Format suggests a compression format based on the given input format.//// Implement the H264_Encoder Rate Control interfaces//// These interfaces apply to rate control for a non-layered video sequence//StatusH264VideoEncoder::Set_Rate_Controls(const H264_Rate_Controls &rc){    m_info.rate_controls = rc;    return UMC_OK;}StatusH264VideoEncoder::Set_Key_Frame_Controls(const H264_Key_Frame_Controls &kfc){    // if the current interval is one, and the new interval is not one    // the next frame must be forced intra to generate a new reference    // frame, note the encoder's decoder will be called when the interval    // is not one in the main encode loop, see bSkipDecoder    if ( m_info.key_frame_controls.method == H264_KFCM_INTERVAL         && m_info.key_frame_controls.interval == 1 // cur interval         && !(kfc.method == H264_KFCM_INTERVAL && kfc.interval == 1)       )    {        m_bMakeNextFrameKey = true;    }    m_info.key_frame_controls = kfc;    if (kfc.method == H264_KFCM_INTERVAL)        m_uIntraFrameInterval = kfc.interval;    else        m_uIntraFrameInterval = 0;    // Set BRC local variables    if (kfc.rate_controls.method == H264_RCM_BITRATE)    {        return UMC_UNSUPPORTED;    }    return UMC_OK;}StatusH264VideoEncoder::Make_Next_Frame_Key(){    m_bMakeNextFrameKey = true;    return UMC_OK;}StatusH264VideoEncoder::Set_B_Frames(Ipp32u number_of_B_frames){    Status ps = UMC_OK;    Ipp32s      i = 0;    // TBD, if we have already begun compressing frames, do we need to    // do more work here to change our B frame generation pattern?    if (number_of_B_frames < H264_Max_B_Frames)    {        m_info.B_Frame_Rate = number_of_B_frames;        profile_frequency = number_of_B_frames + 1;#ifdef USE_IMPLICIT_WEIGHTED_BIPRED        m_info.use_implicit_weighted_bipred =            (number_of_B_frames > 1) ? 1 : 0;#else        m_info.use_implicit_weighted_bipred =  0;#endif        eFrameType[0] = PREDPIC;        for (i = 1; i < profile_frequency; i++)        {            eFrameType[i] = BPREDPIC;        }    }    else    {        ps = UMC_BAD_FORMAT;    }    return ps;}#ifdef _TEST_PARM_StatusH264VideoEncoder::Set_Test_Value (Ipp32s test_value){    Status ps = UMC_OK;    m_info.Test_Value = test_value;    return ps;}#endifStatus H264VideoEncoder::Set_Num_Slices(Ipp32u number_of_slices){    Status ps = UMC_OK;    if (number_of_slices >= 1)    {        m_info.Num_Slices = (Ipp16u) number_of_slices;    }    else    {        ps = UMC_BAD_FORMAT;    }    return ps;}Status H264VideoEncoder::Set_Deblocking_Loop_Filter(Ipp8u Filter_Mode, Ipp32s Alpha, Ipp32s Beta){    Status ps = UMC_OK;    if (Filter_Mode > 2) {        ps = UMC_BAD_FORMAT;    } else if ((Alpha > 6) || (Alpha < -6) || (Beta > 6) || (Beta < -6)) {        ps = UMC_BAD_FORMAT;    } else {        m_info.Deblocking_Filter_Mode = Filter_Mode;        m_info.Deblocking_Filter_Alpha = Alpha;        m_info.Deblocking_Filter_Beta = Beta;    }    return ps;}StatusH264VideoEncoder::Get_Sequence_Controls    (    H264_Sequence_Controls  &sc    ){    sc.key_frame_controls = m_info.key_frame_controls;    sc.number_of_B_frames = m_info.B_Frame_Rate;    sc.rate_controls = m_info.rate_controls;    return UMC_OK;}} //namespace UMC

⌨️ 快捷键说明

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