NPP Image Processing

11 篇文章 0 订阅

https://docs.nvidia.com/cuda/npp/group__image__compression.html#gab4e62e3527413293fa3d9e298ec1fe93

NVIDIA 2D Image And Signal Performance Primitives (NPP)  Version 10.1.1

Modules | Data Structures | Typedefs | Functions

Compression

NPP Image Processing

Image compression primitives. More...

Modules

 Quantization Functions
 

Data Structures

struct  NppiJpegFrameDescr
 JPEG frame descriptor. More...
 
struct  NppiJpegScanDescr
 JPEG scan descriptor. More...
 
struct  NppiJpegDecodeJob
 JPEG decode job used by nppiJpegDecodeJob (see that for more documentation) More...
 
struct  NppiJpegDecodeJobMemory
 Memory buffers used by one decode job. More...
 

Typedefs

typedef struct 
NppiDecodeHuffmanSpec 
NppiDecodeHuffmanSpec
 
typedef struct 
NppiEncodeHuffmanSpec 
NppiEncodeHuffmanSpec
 

Functions

NppStatus nppiDecodeHuffmanSpecGetBufSize_JPEG (int *pSize)
 Returns the length of the NppiDecodeHuffmanSpec structure. More...
 
NppStatus nppiDecodeHuffmanSpecInitHost_JPEG (const Npp8u *pRawHuffmanTable, NppiHuffmanTableType eTableType, NppiDecodeHuffmanSpec *pHuffmanSpec)
 Creates a Huffman table in a format that is suitable for the decoder on the host. More...
 
NppStatus nppiDecodeHuffmanSpecInitAllocHost_JPEG (const Npp8u *pRawHuffmanTable, NppiHuffmanTableType eTableType, NppiDecodeHuffmanSpec **ppHuffmanSpec)
 Allocates memory and creates a Huffman table in a format that is suitable for the decoder on the host. More...
 
NppStatus nppiDecodeHuffmanSpecFreeHost_JPEG (NppiDecodeHuffmanSpec *pHuffmanSpec)
 Frees the host memory allocated by nppiDecodeHuffmanSpecInitAllocHost_JPEG. More...
 
NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P1R_Ctx (const Npp8u *pSrc, Npp32s nLength, Npp32s restartInterval, Npp32s Ss, Npp32s Se, Npp32s Ah, Npp32s Al, Npp16s *pDst, Npp32s nDstStep, NppiDecodeHuffmanSpec *pHuffmanTableDC, NppiDecodeHuffmanSpec *pHuffmanTableAC, NppiSize oSizeROI, NppStreamContext nppStreamCtx)
 Huffman Decoding of the JPEG decoding on the host. More...
 
NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P1R (const Npp8u *pSrc, Npp32s nLength, Npp32s restartInterval, Npp32s Ss, Npp32s Se, Npp32s Ah, Npp32s Al, Npp16s *pDst, Npp32s nDstStep, NppiDecodeHuffmanSpec *pHuffmanTableDC, NppiDecodeHuffmanSpec *pHuffmanTableAC, NppiSize oSizeROI)
 
NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P3R_Ctx (const Npp8u *pSrc, Npp32s nLength, Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp16s *apDst[3], Npp32s aDstStep[3], NppiDecodeHuffmanSpec*apHuffmanDCTable[3], NppiDecodeHuffmanSpec *apHuffmanACTable[3], NppiSize aSizeROI[3], NppStreamContext nppStreamCtx)
 Huffman Decoding of the JPEG decoding on the host. More...
 
NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P3R (const Npp8u *pSrc, Npp32s nLength, Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp16s *apDst[3], Npp32s aDstStep[3], NppiDecodeHuffmanSpec *apHuffmanDCTable[3], NppiDecodeHuffmanSpec *apHuffmanACTable[3], NppiSize aSizeROI[3])
 
NppStatus nppiEncodeHuffmanSpecGetBufSize_JPEG (int *pSize)
 Returns the length of the NppiEncodeHuffmanSpec structure. More...
 
NppStatus nppiEncodeHuffmanSpecInit_JPEG_Ctx (const Npp8u *pRawHuffmanTable, NppiHuffmanTableType eTableType, NppiEncodeHuffmanSpec *pHuffmanSpec, NppStreamContext nppStreamCtx)
 Creates a Huffman table in a format that is suitable for the encoder. More...
 
NppStatus nppiEncodeHuffmanSpecInit_JPEG (const Npp8u *pRawHuffmanTable, NppiHuffmanTableType eTableType, NppiEncodeHuffmanSpec *pHuffmanSpec)
 
NppStatus nppiEncodeHuffmanSpecInitAlloc_JPEG_Ctx (const Npp8u *pRawHuffmanTable, NppiHuffmanTableType eTableType, NppiEncodeHuffmanSpec **ppHuffmanSpec, NppStreamContext nppStreamCtx)
 Allocates memory and creates a Huffman table in a format that is suitable for the encoder. More...
 
NppStatus nppiEncodeHuffmanSpecInitAlloc_JPEG (const Npp8u *pRawHuffmanTable, NppiHuffmanTableType eTableType, NppiEncodeHuffmanSpec **ppHuffmanSpec)
 
NppStatus nppiEncodeHuffmanSpecFree_JPEG (NppiEncodeHuffmanSpec *pHuffmanSpec)
 Frees the memory allocated by nppiEncodeHuffmanSpecInitAlloc_JPEG. More...
 
NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P1R_Ctx (const Npp16s *pSrc, Npp32s nSrcStep, Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *nLength, NppiEncodeHuffmanSpec *pHuffmanTableDC, NppiEncodeHuffmanSpec *pHuffmanTableAC, NppiSize oSizeROI, Npp8u *pTempStorage, NppStreamContext nppStreamCtx)
 Huffman Encoding of the JPEG Encoding. More...
 
NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P1R (const Npp16s *pSrc, Npp32s nSrcStep, Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *nLength, NppiEncodeHuffmanSpec *pHuffmanTableDC, NppiEncodeHuffmanSpec *pHuffmanTableAC, NppiSize oSizeROI, Npp8u *pTempStorage)
 
NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P3R_Ctx (Npp16s *apSrc[3], Npp32s aSrcStep[3], Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *nLength, NppiEncodeHuffmanSpec *apHuffmanDCTable[3], NppiEncodeHuffmanSpec *apHuffmanACTable[3], NppiSize aSizeROI[3], Npp8u *pTempStorage, NppStreamContext nppStreamCtx)
 Huffman Encoding of the JPEG Encoding. More...
 
NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P3R (Npp16s *apSrc[3], Npp32s aSrcStep[3], Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *nLength, NppiEncodeHuffmanSpec *apHuffmanDCTable[3], NppiEncodeHuffmanSpec *apHuffmanACTable[3], NppiSize aSizeROI[3], Npp8u *pTempStorage)
 
NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P1R_Ctx (const Npp16s *pSrc, Npp32s nSrcStep, Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *pLength, Npp8u *hpCodesDC, Npp8u *hpTableDC, Npp8u*hpCodesAC, Npp8u *hpTableAC, NppiEncodeHuffmanSpec *pHuffmanDCTable, NppiEncodeHuffmanSpec *pHuffmanACTable, NppiSize oSizeROI, Npp8u *pTempStorage, NppStreamContext nppStreamCtx)
 Optimize Huffman Encoding of the JPEG Encoding. More...
 
NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P1R (const Npp16s *pSrc, Npp32s nSrcStep, Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *pLength, Npp8u *hpCodesDC, Npp8u *hpTableDC, Npp8u*hpCodesAC, Npp8u *hpTableAC, NppiEncodeHuffmanSpec *pHuffmanDCTable, NppiEncodeHuffmanSpec *pHuffmanACTable, NppiSize oSizeROI, Npp8u *pTempStorage)
 
NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P3R_Ctx (Npp16s *apSrc[3], Npp32s aSrcStep[3], Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *pLength, Npp8u *hpCodesDC[3], Npp8u *hpTableDC[3], Npp8u *hpCodesAC[3], Npp8u *hpTableAC[3], NppiEncodeHuffmanSpec *apHuffmanDCTable[3], NppiEncodeHuffmanSpec *apHuffmanACTable[3], NppiSize oSizeROI[3], Npp8u *pTempStorage, NppStreamContext nppStreamCtx)
 Optimize Huffman Encoding of the JPEG Encoding. More...
 
NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P3R (Npp16s *apSrc[3], Npp32s aSrcStep[3], Npp32s nRestartInterval, Npp32s nSs, Npp32s nSe, Npp32s nAh, Npp32s nAl, Npp8u *pDst, Npp32s *pLength, Npp8u *hpCodesDC[3], Npp8u *hpTableDC[3], Npp8u*hpCodesAC[3], Npp8u *hpTableAC[3], NppiEncodeHuffmanSpec *apHuffmanDCTable[3], NppiEncodeHuffmanSpec *apHuffmanACTable[3], NppiSize oSizeROI[3], Npp8u *pTempStorage)
 
NppStatus nppiEncodeHuffmanGetSize (NppiSize oSize, int nChannels, size_t *pBufSize)
 Calculates the size of the temporary buffer for baseline Huffman encoding. More...
 
NppStatus nppiEncodeOptimizeHuffmanGetSize (NppiSize oSize, int nChannels, int *pBufSize)
 Calculates the size of the temporary buffer for optimize Huffman coding. More...
 
NppStatus nppiDCTInv4x4_WebP_16s_C1R_Ctx (const Npp16s *pSrc, int nSrcStep, Npp16s *pDst, int nDstStep, NppiSize oSizeROI, NppStreamContext nppStreamCtx)
 Inverse DCT in WebP decoding. More...
 
NppStatus nppiDCTInv4x4_WebP_16s_C1R (const Npp16s *pSrc, int nSrcStep, Npp16s *pDst, int nDstStep, NppiSize oSizeROI)
 

Hybrid CPU+GPU JPEG Huffman decoding

These functions and structs are used for Huffman decoding part of JPEG decode pipeline.

It uses hybrid CPU + GPU approach.

See nppiJpegDecodeJob for more documentation and example

enum  NppiJpegDecodeJobKind { 
  NPPI_JPEG_DECODE_SIMPLE
  NPPI_JPEG_DECODE_PRE
  NPPI_JPEG_DECODE_CPU
  NPPI_JPEG_DECODE_GPU
  NPPI_JPEG_DECODE_MEMZERO
  NPPI_JPEG_DECODE_FINALIZE 
}
 Type of job to execute. More...
 
NppStatus nppiJpegDecodeJobMemorySize (const NppiJpegDecodeJob *pJob, size_t *aSize)
 Calculates sizes of additional buffers used by the job. More...
 
NppStatus nppiJpegDecodeJob_Ctx (const NppiJpegDecodeJob *pJob, const NppiJpegDecodeJobMemory *pMemory, NppStreamContext nppStreamCtx)
 Executes a job – part of decoding. More...
 
NppStatus nppiJpegDecodeJob (const NppiJpegDecodeJob *pJob, const NppiJpegDecodeJobMemory *pMemory)
 
NppStatus nppiJpegDecodeJobCreateMemzero (NppiJpegDecodeJob *pJob)
 Initializes a job that has to be called at the beginning of decoding. More...
 
NppStatus nppiJpegDecodeJobCreateFinalize (NppiJpegDecodeJob *pJob)
 Initializes a job that has to be called at the end of decoding, in order to convert temporary representation of DCT coefficients to the final one. More...
 
size_t nppiJpegDecodeGetScanDeadzoneSize (void)
 This function returns how much additional memory has to be available after the end of compressed scan data. More...
 
size_t nppiJpegDecodeGetDCTBufferSize (NppiSize oBlocks)
 Returns how much memory has to be allocated for DCT coefficient buffers declared in NppiJpegDecodeJobMemoryMore...
 
#define NPPI_JPEG_DECODE_N_BUFFERS   3
 Number of additional buffers that may be used by JPEG decode jobs. More...
 

Detailed Description

Image compression primitives.

The JPEG standard defines a flow of level shift, DCT and quantization for forward JPEG transform and inverse level shift, IDCT and de-quantization for inverse JPEG transform. This group has the functions for both forward and inverse functions.

These functions can be found in the nppicom library. Linking to only the sub-libraries that you use can significantly save link time, application load time, and CUDA runtime startup time when using dynamic libraries.

Macro Definition Documentation

#define NPPI_JPEG_DECODE_N_BUFFERS   3

Number of additional buffers that may be used by JPEG decode jobs.

This number may change in the future, but it remain small.

See Also

NppiJpegDecodeJobMemory

Typedef Documentation

typedef struct NppiDecodeHuffmanSpec NppiDecodeHuffmanSpec

typedef struct NppiEncodeHuffmanSpec NppiEncodeHuffmanSpec

Enumeration Type Documentation

enum NppiJpegDecodeJobKind

Type of job to execute.

Usually you will need just SIMPLE for each scan, one MEMZERO at the beginning and FINALIZE at the end. See the example in nppiJpegDecodeJob

SIMPLE can be split into multiple jobs: PRE, CPU & GPU. Please note that if you don't use SIMPLE, you man need to add some memcopies and synchronizes as described in nppiJpegDecodeJob.

See Also

nppiJpegDecodeJob

Enumerator
NPPI_JPEG_DECODE_SIMPLE 

Decode whole scan using a single job.

NPPI_JPEG_DECODE_PRE 

Preprocessing scan on GPU.

NPPI_JPEG_DECODE_CPU 

Part of decoding run on CPU.

NPPI_JPEG_DECODE_GPU 

Part of decoding run on GPU.

NPPI_JPEG_DECODE_MEMZERO 

Zeroing memory before decoding.

NPPI_JPEG_DECODE_FINALIZE 

Change memory representation of DCT coefficients to final.

Function Documentation

NppStatus nppiDCTInv4x4_WebP_16s_C1R(const Npp16s * pSrc,
  int nSrcStep,
  Npp16s * pDst,
  int nDstStep,
  NppiSize oSizeROI 
 )  

NppStatus nppiDCTInv4x4_WebP_16s_C1R_Ctx(const Npp16s * pSrc,
  int nSrcStep,
  Npp16s * pDst,
  int nDstStep,
  NppiSize oSizeROI,
  NppStreamContext nppStreamCtx 
 )  

Inverse DCT in WebP decoding.

Input is the bitstream that contains the coefficients of 16x16 blocks. These coefficients are based on a 4x4 sub-block unit, e.g., Coeffs in 0th 4x4 block, 1st 4x4 block 2nd 4x4 block, etc. Output is the coefficients after inverse DCT transform. The output is put in an image format (i.e. raster scan order), different from the input order.

Parameters

pSrcSource-Image Pointer.
nSrcStepSource-Image Line Step.
pDstDestination-Image Pointer.
nDstStepDestination-Image Line Step.
oSizeROIRegion-of-Interest (ROI).
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P1R(const Npp8u * pSrc,
  Npp32s nLength,
  Npp32s restartInterval,
  Npp32s Ss,
  Npp32s Se,
  Npp32s Ah,
  Npp32s Al,
  Npp16s * pDst,
  Npp32s nDstStep,
  NppiDecodeHuffmanSpec * pHuffmanTableDC,
  NppiDecodeHuffmanSpec * pHuffmanTableAC,
  NppiSize oSizeROI 
 )  

NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P1R_Ctx(const Npp8u * pSrc,
  Npp32s nLength,
  Npp32s restartInterval,
  Npp32s Ss,
  Npp32s Se,
  Npp32s Ah,
  Npp32s Al,
  Npp16s * pDst,
  Npp32s nDstStep,
  NppiDecodeHuffmanSpec * pHuffmanTableDC,
  NppiDecodeHuffmanSpec * pHuffmanTableAC,
  NppiSize oSizeROI,
  NppStreamContext nppStreamCtx 
 )  

Huffman Decoding of the JPEG decoding on the host.

Input is expected in byte stuffed huffman encoded JPEG scan and output is expected to be 64x1 macro blocks.

Parameters

pSrcByte-stuffed huffman encoded JPEG scan.
nLengthByte length of the input.
restartIntervalRestart Interval, see JPEG standard.
SsStart Coefficient, see JPEG standard.
SeEnd Coefficient, see JPEG standard.
AhBit Approximation High, see JPEG standard.
AlBit Approximation Low, see JPEG standard.
pDstDestination-Image Pointer.
nDstStepDestination-Image Line Step.
pHuffmanTableDCDC Huffman table.
pHuffmanTableACAC Huffman table.
oSizeROIRegion-of-Interest (ROI).
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P3R(const Npp8u * pSrc,
  Npp32s nLength,
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp16s * apDst[3],
  Npp32s aDstStep[3],
  NppiDecodeHuffmanSpec * apHuffmanDCTable[3],
  NppiDecodeHuffmanSpec * apHuffmanACTable[3],
  NppiSize aSizeROI[3] 
 )  

NppStatus nppiDecodeHuffmanScanHost_JPEG_8u16s_P3R_Ctx(const Npp8u * pSrc,
  Npp32s nLength,
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp16s * apDst[3],
  Npp32s aDstStep[3],
  NppiDecodeHuffmanSpec * apHuffmanDCTable[3],
  NppiDecodeHuffmanSpec * apHuffmanACTable[3],
  NppiSize aSizeROI[3],
  NppStreamContext nppStreamCtx 
 )  

Huffman Decoding of the JPEG decoding on the host.

Input is expected in byte stuffed huffman encoded JPEG scan and output is expected to be 64x1 macro blocks.

Parameters

pSrcByte-stuffed huffman encoded JPEG scan.
nLengthByte length of the input.
nRestartIntervalRestart Interval, see JPEG standard.
nSsStart Coefficient, see JPEG standard.
nSeEnd Coefficient, see JPEG standard.
nAhBit Approximation High, see JPEG standard.
nAlBit Approximation Low, see JPEG standard.
apDstDestination-Image Pointer.
aDstStepDestination-Image Line Step.
apHuffmanDCTableDC Huffman tables.
apHuffmanACTableAC Huffman tables.
aSizeROIRegion-of-Interest (ROI).
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiDecodeHuffmanSpecFreeHost_JPEG(NppiDecodeHuffmanSpec * pHuffmanSpec) 

Frees the host memory allocated by nppiDecodeHuffmanSpecInitAllocHost_JPEG.

Parameters

pHuffmanSpecPointer to the Huffman table for the decoder

NppStatus nppiDecodeHuffmanSpecGetBufSize_JPEG(int * pSize) 

Returns the length of the NppiDecodeHuffmanSpec structure.

Parameters

pSizePointer to a variable that will receive the length of the NppiDecodeHuffmanSpec structure.

Returns

Error codes:

NppStatus nppiDecodeHuffmanSpecInitAllocHost_JPEG(const Npp8u * pRawHuffmanTable,
  NppiHuffmanTableType eTableType,
  NppiDecodeHuffmanSpec ** ppHuffmanSpec 
 )  

Allocates memory and creates a Huffman table in a format that is suitable for the decoder on the host.

Parameters

pRawHuffmanTableHuffman table formated as specified in the JPEG standard.
eTableTypeEnum specifying type of table (nppiDCTable or nppiACTable).
ppHuffmanSpecPointer to returned pointer to the Huffman table for the decoder

Returns

Error codes:

NppStatus nppiDecodeHuffmanSpecInitHost_JPEG(const Npp8u * pRawHuffmanTable,
  NppiHuffmanTableType eTableType,
  NppiDecodeHuffmanSpec * pHuffmanSpec 
 )  

Creates a Huffman table in a format that is suitable for the decoder on the host.

Parameters

pRawHuffmanTableHuffman table formated as specified in the JPEG standard.
eTableTypeEnum specifying type of table (nppiDCTable or nppiACTable).
pHuffmanSpecPointer to the Huffman table for the decoder

Returns

Error codes:

NppStatus nppiEncodeHuffmanGetSize(NppiSize oSize,
  int nChannels,
  size_t * pBufSize 
 )  

Calculates the size of the temporary buffer for baseline Huffman encoding.

See Also

nppiEncodeHuffmanScan_JPEG_8u16s_P1R()nppiEncodeHuffmanScan_JPEG_8u16s_P3R().

Parameters

oSizeImage Dimension.
nChannelsNumber of channels in the image.
pBufSizePointer to variable that returns the size of the temporary buffer.

Returns

NPP_SUCCESS Indicates no error. Any other value indicates an error or a warning

NPP_SIZE_ERROR Indicates an error condition if any image dimension has zero or negative value

NPP_NULL_POINTER_ERROR Indicates an error condition if pBufSize pointer is NULL

NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P1R(const Npp16s * pSrc,
  Npp32s nSrcStep,
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * nLength,
  NppiEncodeHuffmanSpec * pHuffmanTableDC,
  NppiEncodeHuffmanSpec * pHuffmanTableAC,
  NppiSize oSizeROI,
  Npp8u * pTempStorage 
 )  

NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P1R_Ctx(const Npp16s * pSrc,
  Npp32s nSrcStep,
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * nLength,
  NppiEncodeHuffmanSpec * pHuffmanTableDC,
  NppiEncodeHuffmanSpec * pHuffmanTableAC,
  NppiSize oSizeROI,
  Npp8u * pTempStorage,
  NppStreamContext nppStreamCtx 
 )  

Huffman Encoding of the JPEG Encoding.

Input is expected to be 64x1 macro blocks and output is expected as byte stuffed huffman encoded JPEG scan.

Parameters

pSrcDestination-Image Pointer.
nSrcStepDestination-Image Line Step.
nRestartIntervalRestart Interval, see JPEG standard. Currently only values <=0 are supported.
nSsStart Coefficient, see JPEG standard.
nSeEnd Coefficient, see JPEG standard.
nAhBit Approximation High, see JPEG standard.
nAlBit Approximation Low, see JPEG standard.
pDstByte-stuffed huffman encoded JPEG scan.
nLengthByte length of the huffman encoded JPEG scan.
pHuffmanTableDCDC Huffman table.
pHuffmanTableACAC Huffman table.
oSizeROIRegion-of-Interest (ROI).
pTempStorageTemporary storage.
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P3R(Npp16s * apSrc[3],
  Npp32s aSrcStep[3],
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * nLength,
  NppiEncodeHuffmanSpec * apHuffmanDCTable[3],
  NppiEncodeHuffmanSpec * apHuffmanACTable[3],
  NppiSize aSizeROI[3],
  Npp8u * pTempStorage 
 )  

NppStatus nppiEncodeHuffmanScan_JPEG_8u16s_P3R_Ctx(Npp16s * apSrc[3],
  Npp32s aSrcStep[3],
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * nLength,
  NppiEncodeHuffmanSpec * apHuffmanDCTable[3],
  NppiEncodeHuffmanSpec * apHuffmanACTable[3],
  NppiSize aSizeROI[3],
  Npp8u * pTempStorage,
  NppStreamContext nppStreamCtx 
 )  

Huffman Encoding of the JPEG Encoding.

Input is expected to be 64x1 macro blocks and output is expected as byte stuffed huffman encoded JPEG scan.

Parameters

apSrcDestination-Image Pointer.
aSrcStepDestination-Image Line Step.
nRestartIntervalRestart Interval, see JPEG standard. Currently only values <=0 are supported.
nSsStart Coefficient, see JPEG standard.
nSeEnd Coefficient, see JPEG standard.
nAhBit Approximation High, see JPEG standard.
nAlBit Approximation Low, see JPEG standard.
pDstByte-stuffed huffman encoded JPEG scan.
nLengthByte length of the huffman encoded JPEG scan.
apHuffmanDCTableDC Huffman tables.
apHuffmanACTableAC Huffman tables.
aSizeROIRegion-of-Interest (ROI).
pTempStorageTemporary storage.
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiEncodeHuffmanSpecFree_JPEG(NppiEncodeHuffmanSpec * pHuffmanSpec) 

Frees the memory allocated by nppiEncodeHuffmanSpecInitAlloc_JPEG.

Parameters

pHuffmanSpecPointer to the Huffman table for the encoder

NppStatus nppiEncodeHuffmanSpecGetBufSize_JPEG(int * pSize) 

Returns the length of the NppiEncodeHuffmanSpec structure.

Parameters

pSizePointer to a variable that will receive the length of the NppiEncodeHuffmanSpec structure.

Returns

Error codes:

NppStatus nppiEncodeHuffmanSpecInit_JPEG(const Npp8u * pRawHuffmanTable,
  NppiHuffmanTableType eTableType,
  NppiEncodeHuffmanSpec * pHuffmanSpec 
 )  

NppStatus nppiEncodeHuffmanSpecInit_JPEG_Ctx(const Npp8u * pRawHuffmanTable,
  NppiHuffmanTableType eTableType,
  NppiEncodeHuffmanSpec * pHuffmanSpec,
  NppStreamContext nppStreamCtx 
 )  

Creates a Huffman table in a format that is suitable for the encoder.

Parameters

pRawHuffmanTableHuffman table formated as specified in the JPEG standard.
eTableTypeEnum specifying type of table (nppiDCTable or nppiACTable).
pHuffmanSpecPointer to the Huffman table for the decoder
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiEncodeHuffmanSpecInitAlloc_JPEG(const Npp8u * pRawHuffmanTable,
  NppiHuffmanTableType eTableType,
  NppiEncodeHuffmanSpec ** ppHuffmanSpec 
 )  

NppStatus nppiEncodeHuffmanSpecInitAlloc_JPEG_Ctx(const Npp8u * pRawHuffmanTable,
  NppiHuffmanTableType eTableType,
  NppiEncodeHuffmanSpec ** ppHuffmanSpec,
  NppStreamContext nppStreamCtx 
 )  

Allocates memory and creates a Huffman table in a format that is suitable for the encoder.

Parameters

pRawHuffmanTableHuffman table formated as specified in the JPEG standard.
eTableTypeEnum specifying type of table (nppiDCTable or nppiACTable).
ppHuffmanSpecPointer to returned pointer to the Huffman table for the encoder
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiEncodeOptimizeHuffmanGetSize(NppiSize oSize,
  int nChannels,
  int * pBufSize 
 )  

Calculates the size of the temporary buffer for optimize Huffman coding.

Parameters

oSizeImage Dimension.
nChannelsNumber of channels in the image.
pBufSizePointer to variable that returns the size of the temporary buffer.

Returns

NPP_SUCCESS Indicates no error. Any other value indicates an error or a warning

NPP_SIZE_ERROR Indicates an error condition if any image dimension has zero or negative value

NPP_NULL_POINTER_ERROR Indicates an error condition if pBufSize pointer is NULL

NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P1R(const Npp16s * pSrc,
  Npp32s nSrcStep,
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * pLength,
  Npp8u * hpCodesDC,
  Npp8u * hpTableDC,
  Npp8u * hpCodesAC,
  Npp8u * hpTableAC,
  NppiEncodeHuffmanSpec * pHuffmanDCTable,
  NppiEncodeHuffmanSpec * pHuffmanACTable,
  NppiSize oSizeROI,
  Npp8u * pTempStorage 
 )  

NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P1R_Ctx(const Npp16s * pSrc,
  Npp32s nSrcStep,
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * pLength,
  Npp8u * hpCodesDC,
  Npp8u * hpTableDC,
  Npp8u * hpCodesAC,
  Npp8u * hpTableAC,
  NppiEncodeHuffmanSpec * pHuffmanDCTable,
  NppiEncodeHuffmanSpec * pHuffmanACTable,
  NppiSize oSizeROI,
  Npp8u * pTempStorage,
  NppStreamContext nppStreamCtx 
 )  

Optimize Huffman Encoding of the JPEG Encoding.

Input is expected to be 64x1 macro blocks and output is expected as byte stuffed huffman encoded JPEG scan.

Parameters

pSrcDestination-Image Pointer.
nSrcStepDestination-Image Line Step.
nRestartIntervalRestart Interval, see JPEG standard. Currently only values <=0 are supported.
nSsStart Coefficient, see JPEG standard.
nSeEnd Coefficient, see JPEG standard.
nAhBit Approximation High, see JPEG standard.
nAlBit Approximation Low, see JPEG standard.
pDstByte-stuffed huffman encoded JPEG scan.
pLengthPointer to the byte length of the huffman encoded JPEG scan.
hpCodesDCHost pointer to the code of the huffman tree for DC component.
hpTableDCHost pointer to the table of the huffman tree for DC component.
hpCodesACHost pointer to the code of the huffman tree for AC component.
hpTableACHost pointer to the table of the huffman tree for AC component.
pHuffmanDCTableDC Huffman table.
pHuffmanACTableAC Huffman table.
oSizeROIRegion-of-Interest (ROI).
pTempStorageTemporary storage.
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P3R(Npp16s * apSrc[3],
  Npp32s aSrcStep[3],
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * pLength,
  Npp8u * hpCodesDC[3],
  Npp8u * hpTableDC[3],
  Npp8u * hpCodesAC[3],
  Npp8u * hpTableAC[3],
  NppiEncodeHuffmanSpec * apHuffmanDCTable[3],
  NppiEncodeHuffmanSpec * apHuffmanACTable[3],
  NppiSize oSizeROI[3],
  Npp8u * pTempStorage 
 )  

NppStatus nppiEncodeOptimizeHuffmanScan_JPEG_8u16s_P3R_Ctx(Npp16s * apSrc[3],
  Npp32s aSrcStep[3],
  Npp32s nRestartInterval,
  Npp32s nSs,
  Npp32s nSe,
  Npp32s nAh,
  Npp32s nAl,
  Npp8u * pDst,
  Npp32s * pLength,
  Npp8u * hpCodesDC[3],
  Npp8u * hpTableDC[3],
  Npp8u * hpCodesAC[3],
  Npp8u * hpTableAC[3],
  NppiEncodeHuffmanSpec * apHuffmanDCTable[3],
  NppiEncodeHuffmanSpec * apHuffmanACTable[3],
  NppiSize oSizeROI[3],
  Npp8u * pTempStorage,
  NppStreamContext nppStreamCtx 
 )  

Optimize Huffman Encoding of the JPEG Encoding.

Input is expected to be 64x1 macro blocks and output is expected as byte stuffed huffman encoded JPEG scan.

Parameters

apSrcDestination-Image Pointer.
aSrcStepDestination-Image Line Step.
nRestartIntervalRestart Interval, see JPEG standard. Currently only values <=0 are supported.
nSsStart Coefficient, see JPEG standard.
nSeEnd Coefficient, see JPEG standard.
nAhBit Approximation High, see JPEG standard.
nAlBit Approximation Low, see JPEG standard.
pDstByte-stuffed huffman encoded JPEG scan.
pLengthPointer to the byte length of the huffman encoded JPEG scan.
hpCodesDCHost pointer to the code of the huffman tree for DC component.
hpTableDCHost pointer to the table of the huffman tree for DC component.
hpCodesACHost pointer to the code of the huffman tree for AC component.
hpTableACHost pointer to the table of the huffman tree for AC component.
apHuffmanDCTableDC Huffman tables.
apHuffmanACTableAC Huffman tables.
oSizeROIRegion-of-Interest (ROI).
pTempStorageTemporary storage.
nppStreamCtxApplication Managed Stream Context.

Returns

Error codes:

size_t nppiJpegDecodeGetDCTBufferSize(NppiSize oBlocks) 

Returns how much memory has to be allocated for DCT coefficient buffers declared in NppiJpegDecodeJobMemory.

The returned value may be bigger than simply number of blocks * 64 * sizeof (short), because decoder may use slightly bigger temporary representation of data.

Parameters

oBlocksSize of the interleaved component in blocks. (That means that the size of component in blocks has to be aligned according to subsampling of this component and frame).

This function assumes no ununsed space between rows, so at the end stride = oBlocks.width * 64 * sizeof (short).

size_t nppiJpegDecodeGetScanDeadzoneSize(void  ) 

This function returns how much additional memory has to be available after the end of compressed scan data.

The following buffers: pCpuScan and pGpuScan in NppiJpegDecodeJobMemory should have size at least pScan->length + nppiJpegDecodeGetScanDeadzoneSize().

The additional memory is needed because the decoder may perform some speculative reads after the end of compressed scan data.

NppStatus nppiJpegDecodeJob(const NppiJpegDecodeJob * pJob,
  const NppiJpegDecodeJobMemory * pMemory 
 )  

NppStatus nppiJpegDecodeJob_Ctx(const NppiJpegDecodeJob * pJob,
  const NppiJpegDecodeJobMemory * pMemory,
  NppStreamContext nppStreamCtx 
 )  

Executes a job – part of decoding.

Parameters

pJobhas to be initialized by nppiJpegDecodeJobCreateMemzero or nppiJpegDecodeJobCreateFinalize or manually.
pMemoryhas to point to valid structure, except for MEMZERO and FINALIZE scans, for which it can be NULL.

See Also

nppiJpegDecodeJobMemorySize

nppiJpegDecodeJobCreateMemzero

nppiJpegDecodeJobCreateFinalize

This function can be used in two ways, depending on how much control do you need:

  1. Decode whole scan in one job. That is accomplished when the job.eKind is set to NPPI_JPEG_DECODE_SIMPLE. Nppi function handless all in-scan synchronization (if needed). This is described in example.
  2. Split decoding of scan into multiple jobs. In this case, caller is responsible necessary synchronizations. If multiple jobs from the same scan claim to use the same additional buffer, it means that the jobs are exchaning information throught this buffer and the buffer should not be reused or reallocated meanwhile, additionaly if the buffer is used first by PRE job, and then by CPU job, caller has to call cudaStreamSynchronize before CPU job. NppiJpegDecodeJobKind for more information.

Example (pseudo)code for decoding JPEG: (Error handling code omitted for brevity. Each function which may return an error should be checked)

// Allocate DCT buffers (using nppiJpegDecodeGetDCTBufferSize)

NppiJpegFrameDescr frame;

// Fill frame info...

NppiJpegScanDescr scan;

NppiJpegDecodeJob job;

job.pFrame = frame;

job.pScan = scan;

nppiJpegDecodeJobCreateMemzero(&job);

nppiJpegDecodeJob(&job, NULL);

for (int i = 0; i < nScans; ++i)

{

// Fill scan info...

job.eKind = NPPI_JPEG_DECODE_SIMPLE;

size_t sizes[NPPI_JPEG_DECODE_N_BUFFERS];

nppiJpegDecodeJobMemorySize(&job, sizes);

NppiJpegJobMemory memory;

// Allocate and fill scan buffers (using nppiJpegDecodeGetScanBufferSize)...

// Fill the memory struct according to sizes...

nppiJpegDecodeJob(&job, &memory);

// Synchronization is needed only if you reuse buffers between scans.

cudaStreamSynchronize(nppGetStream()); or CudaStreamSynchronize(nppStreamCtx.hStream);

}

nppiJpegDecodeJobCreateFinalize(&job);

nppiJpegDecodeJob(&job, NULL);

// Perform further steps of decoding (iDCT etc.)

*

Parameters

nppStreamCtxApplication Managed Stream Context.

Returns

NppStatus nppiJpegDecodeJobCreateFinalize(NppiJpegDecodeJob * pJob) 

Initializes a job that has to be called at the end of decoding, in order to convert temporary representation of DCT coefficients to the final one.

Parameters

pJob,:pJob.pFrame should point to valid frame description *pJob.pScan will be overwritten.

NppStatus nppiJpegDecodeJobCreateMemzero(NppiJpegDecodeJob * pJob) 

Initializes a job that has to be called at the beginning of decoding.

Parameters

pJob,:pJob.pFrame should point to valid frame description. *pJob.pScan will be overwritten.

If the caller had manually zeroed the memory for DCT buffers, (note: whole nppiJpegDecodeGetDCTBufferSize has to be zeroed). this job doesn't have to be executed.

NppStatus nppiJpegDecodeJobMemorySize(const NppiJpegDecodeJob * pJob,
  size_t * aSize 
 )  

Calculates sizes of additional buffers used by the job.

Parameters

 pJobhas to point to properly initialized job
[out]aSizewill be filled with NPPI_JPEG_DECODE_N_BUFFERS sizes, aSize[i] telling how much memory has to be allocated for apCpuBuffer[i] and apGpuBuffer[i].

See Also

NppiJpegDecodeJobMemory

Returns


Copyright © 2009-2019 NVIDIA Corporation

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值