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

📄 cbencoder.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) 2002-2005 Intel Corporation. All Rights Reserved.//////*//*//  Code block encoder class encapsulates interface for//      IPP JPEG 2000 entropy coding functions.//////*/#include "cbencoder.h"#include "diagndescr.h"#include "memexception.h"const int CBEncoder::m_buffSize = 1024;CBEncoder::CBEncoder(int guardBits, int codingOptions, IppiMQTermination mqTermType): m_codingOptions(codingOptions), m_termType(mqTermType), m_buffer(m_buffSize), m_guardBits(guardBits){    IppiSize size = {64, 64};    ippiEncodeInitAlloc_JPEG2K(&m_state, size);    if(!m_state) throw DiagnDescrCT<MemoryException,faultMalloc>();}CBEncoder::~CBEncoder() { ippiEncodeFree_JPEG2K(m_state); }void CBEncoder::Encode(        const ImageCore32sC1 &precImg,        const Rect           &cbRect,              IppiWTSubband   subband,              int             sbDynRange,              int             sbLowestNonSfBits,              ECodeBlock     &cb    ){    int sfBits;    int nOfTermPasses; // stub, there is no need in this implementation    int nOfPasses;    ImageCore32sC1 cbImg = precImg.SubImage(cbRect.Origin());    int magnBits = 31 - sbLowestNonSfBits;    if(magnBits > 31) magnBits = 31;    if(magnBits <  0) magnBits =  0;    Shift(cbImg, cbRect.Size(), sbLowestNonSfBits);    Complement(cbImg, cbRect.Size());    ippiEncodeLoadCodeBlock_JPEG2K_32s_C1R(        cbImg.Data(),        cbImg.LineStep(),        cbRect.Size(),        m_state,        subband,        magnBits,        m_termType,        ippMQRateApprGood,        m_codingOptions,       &sfBits,       &nOfPasses,       &nOfTermPasses);    cb.SetNOfZeroBits(sbDynRange + m_guardBits - sfBits - 1);    int isNotFinish = 1;    while(isNotFinish)    {        int len = m_buffSize;        ippiEncodeStoreBits_JPEG2K_1u(m_buffer, &len, m_state, &isNotFinish);        m_accum.Write(m_buffer, len);    }    cb.ReceiveComprData(m_accum);    for(int i = 0; i < nOfPasses; i++)    {        int    rate;        double dist;        ippiEncodeGetRate_JPEG2K(m_state, i, &rate);        ippiEncodeGetDist_JPEG2K(m_state, i, &dist);        cb.PushPass(rate, dist);    }}

⌨️ 快捷键说明

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