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

📄 decode.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.//////*/#include "j2kit.h"#include "cmdoptions.h"#include "fixedstring.h"// codec specific level#include "djp2file.h"#include "edib.h"#include "epnm.h"// codec meta level#include "mdjp2.h"#include "medib.h"#include "mepnm.h"#include "mapfileinput.h"#include "mapfileoutput.h"#include "byteinput.h"#include "byteoutput.h"#include "mrstrimage.h"#include "display.h"#include "transcodingexception.h"#include "sysexception.h"#include "stricmp.h"typedef ByteInputSigned<ByteInputBE<MapFileInput> > MapFileInputBE;typedef ByteOutputSigned<ByteOutputLE<MapFileOutput> > MapFileOutputLE;typedef ByteOutputSigned<ByteOutputBE<MapFileOutput> > MapFileOutputBE;class MapFileBoundedInputBE : public ByteInputBoundService<MapFileInputBE>{public:    MapFileBoundedInputBE() {}    virtual ~MapFileBoundedInputBE() {}    void Open(const char *fileName)    {        MapFileInput::Open(fileName);        PushSize(MapFileInput::Size());    }    void Close()    {        MapFileInput::Close();        PopSize();    }};void decode(const CmdOptions &options, BDiagnOutput &diagnOutput){    MRstrImage      metaImage;    MapFileBoundedInputBE jp2Stream;    BDiagnOutputPtr diagnOutputPtr(diagnOutput);    jp2Stream.Open(options.SrcFileName());    if(options.SrcFileType() == (CmdOptions::jp2))    {        DJP2File<MapFileBoundedInputBE> jp2File;        jp2File.AttachDiagnOutput(diagnOutput);        jp2File.Attach(jp2Stream);        jp2File.ReadIntroBoxes();        if(!jp2File.ReadNextCSMainHeader())            throw DiagnDescrCT<TranscodingException,missingJP2Codestream>();        ReAllocMetaImageComponents(jp2File.CSMainHeader(), metaImage);        SetMRstrImageResolution(jp2File.HeaderBox().Resolution(), metaImage.CaptureResolution(), metaImage.DisplayResolution());        SetMRstrImagePalette(jp2File.HeaderBox(), metaImage.Palette());        while(jp2File.ReadCSNextTilePartHeader())        {            while(jp2File.ReadCSPacket());        }        FixedBuffer<ImageCoreC<Ipp32s, 1> > interfaceImgRef(metaImage.NOfComponents());        SelectOnlyImageCore(metaImage.ComponentImage(), interfaceImgRef, metaImage.NOfComponents());        jp2File.UpdateCSImageComponents(interfaceImgRef);    }    else // JPEG 2000 codestream    {        DJP2Codestream<MapFileBoundedInputBE> j2kCodestream;        j2kCodestream.AttachDiagnOutput(diagnOutput);        j2kCodestream.Attach(jp2Stream);        j2kCodestream.ReadMainHeader();        ReAllocMetaImageComponents(j2kCodestream.MainHeader(), metaImage);        while(j2kCodestream.ReadNextTilePartHeader())        {            while(j2kCodestream.ReadPacket());        }        FixedBuffer<ImageCoreC<Ipp32s, 1> > interfaceImgRef(metaImage.NOfComponents());        SelectOnlyImageCore(metaImage.ComponentImage(), interfaceImgRef, metaImage.NOfComponents());        j2kCodestream.UpdateImageComponents(interfaceImgRef);    }    if(options.IsDisplay())    {        DIBEncoder<ByteOutputSigned<ByteOutputLE<MemoryOutput> > > dib;        dib.AttachDiagnOutput(diagnOutput);        SetBestDIBSizeAndResolution(metaImage, dib.Info(), true, diagnOutputPtr);        SetBestDIBDepthAndPalette  (metaImage, dib.Info(), diagnOutputPtr);//force to create 24-bit DIB without palette        dib.Info().SetDepth(Depth_24);//            dib.Info().SetOrigin(TopLeft);        ImagePn<Ipp32s> dibData(dib.Info().Size(), NOfChannels(dib.Info().Depth()));        ConvertImageChannelsToDIB  (metaImage, dib.Info(), dibData.Channels(), true, diagnOutputPtr);        ByteOutputSigned<ByteOutputLE<MemoryOutput> > dibStream;        FixedBuffer<Ipp8u> pixMap(dib.EstimateFileNOfBytes());        dibStream.Attach((Ipp8u *)pixMap);        dib.Attach(dibStream);        dib.WriteImageData(dibData.Channels());#ifndef XSCALE        if(DisplayPixMap(pixMap,                         dib.Info().Size().Width(),                         dib.Info().Size().Height(),                         options.SrcFileName()))        {                throw DiagnDescrCT<DisplayException,cannotDisplayPixMap>();        }#endif    }    else if(options.DstFileType() == (CmdOptions::bmp))    {        DIBEncoder<MapFileOutputLE> dib;        dib.AttachDiagnOutput(diagnOutput);        SetBestDIBSizeAndResolution(metaImage, dib.Info(), true, diagnOutputPtr);        SetBestDIBDepthAndPalette  (metaImage, dib.Info(), diagnOutputPtr);        ImagePn<Ipp32s> dibData(dib.Info().Size(), NOfChannels(dib.Info().Depth()));        ConvertImageChannelsToDIB  (metaImage, dib.Info(), dibData.Channels(), false, diagnOutputPtr);        MapFileOutputLE dibStream;        dibStream.Open(options.DstFileName(), dib.EstimateFileNOfBytes());        dib.Attach(dibStream);        dib.WriteFileHeader();        dib.WriteInfo();        dib.WriteImageData(dibData.Channels());    }    else /* PNM */    {        PNMEncoder<MapFileOutputBE> pnm;        PNMNumericFormat pnmNumFmt = options.IsPlainPNMOutput() ? PNM_TXT : PNM_BIN;        if(!Stricmp(options.DstFileNameExt(), "pnm"))            SetBestPNMInfo(metaImage, pnmNumFmt, pnm.Info());        else            SetBestPNMInfo(metaImage, pnmNumFmt, SpecColorFormat(options.DstFileNameExt()), pnm.Info());        ImagePn<Ipp32s> pnmData(pnm.Info().Size(), NOfChannels(pnm.Info().MagicNumber()));        ConvertImageChannelsToPNM(metaImage, pnm.Info(), pnmData.Channels(), false, diagnOutputPtr);        MapFileOutputBE pnmStream;        pnmStream.Open(options.DstFileName(), pnm.EstimateFileNOfBytes(pnmData.Channels()));        pnm.Attach(pnmStream);        pnm.WriteFileHeader();        pnm.WriteImageData(pnmData.Channels());    }}

⌨️ 快捷键说明

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