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
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 NppiJpegDecodeJobMemory. More... | |
#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
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
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
pSrc | Source-Image Pointer. |
nSrcStep | Source-Image Line Step. |
pDst | Destination-Image Pointer. |
nDstStep | Destination-Image Line Step. |
oSizeROI | Region-of-Interest (ROI). |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
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
pSrc | Byte-stuffed huffman encoded JPEG scan. |
nLength | Byte length of the input. |
restartInterval | Restart Interval, see JPEG standard. |
Ss | Start Coefficient, see JPEG standard. |
Se | End Coefficient, see JPEG standard. |
Ah | Bit Approximation High, see JPEG standard. |
Al | Bit Approximation Low, see JPEG standard. |
pDst | Destination-Image Pointer. |
nDstStep | Destination-Image Line Step. |
pHuffmanTableDC | DC Huffman table. |
pHuffmanTableAC | AC Huffman table. |
oSizeROI | Region-of-Interest (ROI). |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
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
pSrc | Byte-stuffed huffman encoded JPEG scan. |
nLength | Byte length of the input. |
nRestartInterval | Restart Interval, see JPEG standard. |
nSs | Start Coefficient, see JPEG standard. |
nSe | End Coefficient, see JPEG standard. |
nAh | Bit Approximation High, see JPEG standard. |
nAl | Bit Approximation Low, see JPEG standard. |
apDst | Destination-Image Pointer. |
aDstStep | Destination-Image Line Step. |
apHuffmanDCTable | DC Huffman tables. |
apHuffmanACTable | AC Huffman tables. |
aSizeROI | Region-of-Interest (ROI). |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
NppStatus nppiDecodeHuffmanSpecFreeHost_JPEG | ( | NppiDecodeHuffmanSpec * | pHuffmanSpec | ) |
Frees the host memory allocated by nppiDecodeHuffmanSpecInitAllocHost_JPEG.
Parameters
pHuffmanSpec | Pointer to the Huffman table for the decoder |
NppStatus nppiDecodeHuffmanSpecGetBufSize_JPEG | ( | int * | pSize | ) |
Returns the length of the NppiDecodeHuffmanSpec structure.
Parameters
pSize | Pointer to a variable that will receive the length of the NppiDecodeHuffmanSpec structure. |
Returns
Error codes:
- NPP_NULL_POINTER_ERROR If one of the pointers is 0.
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
pRawHuffmanTable | Huffman table formated as specified in the JPEG standard. |
eTableType | Enum specifying type of table (nppiDCTable or nppiACTable). |
ppHuffmanSpec | Pointer to returned pointer to the Huffman table for the decoder |
Returns
Error codes:
- NPP_NULL_POINTER_ERROR If one of the pointers is 0.
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
pRawHuffmanTable | Huffman table formated as specified in the JPEG standard. |
eTableType | Enum specifying type of table (nppiDCTable or nppiACTable). |
pHuffmanSpec | Pointer to the Huffman table for the decoder |
Returns
Error codes:
- NPP_NULL_POINTER_ERROR If one of the pointers is 0.
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
oSize | Image Dimension. |
nChannels | Number of channels in the image. |
pBufSize | Pointer 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
pSrc | Destination-Image Pointer. |
nSrcStep | Destination-Image Line Step. |
nRestartInterval | Restart Interval, see JPEG standard. Currently only values <=0 are supported. |
nSs | Start Coefficient, see JPEG standard. |
nSe | End Coefficient, see JPEG standard. |
nAh | Bit Approximation High, see JPEG standard. |
nAl | Bit Approximation Low, see JPEG standard. |
pDst | Byte-stuffed huffman encoded JPEG scan. |
nLength | Byte length of the huffman encoded JPEG scan. |
pHuffmanTableDC | DC Huffman table. |
pHuffmanTableAC | AC Huffman table. |
oSizeROI | Region-of-Interest (ROI). |
pTempStorage | Temporary storage. |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
- NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY If the device has compute capability < 2.0.
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
apSrc | Destination-Image Pointer. |
aSrcStep | Destination-Image Line Step. |
nRestartInterval | Restart Interval, see JPEG standard. Currently only values <=0 are supported. |
nSs | Start Coefficient, see JPEG standard. |
nSe | End Coefficient, see JPEG standard. |
nAh | Bit Approximation High, see JPEG standard. |
nAl | Bit Approximation Low, see JPEG standard. |
pDst | Byte-stuffed huffman encoded JPEG scan. |
nLength | Byte length of the huffman encoded JPEG scan. |
apHuffmanDCTable | DC Huffman tables. |
apHuffmanACTable | AC Huffman tables. |
aSizeROI | Region-of-Interest (ROI). |
pTempStorage | Temporary storage. |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
- NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY If the device has compute capability < 2.0.
NppStatus nppiEncodeHuffmanSpecFree_JPEG | ( | NppiEncodeHuffmanSpec * | pHuffmanSpec | ) |
Frees the memory allocated by nppiEncodeHuffmanSpecInitAlloc_JPEG.
Parameters
pHuffmanSpec | Pointer to the Huffman table for the encoder |
NppStatus nppiEncodeHuffmanSpecGetBufSize_JPEG | ( | int * | pSize | ) |
Returns the length of the NppiEncodeHuffmanSpec structure.
Parameters
pSize | Pointer to a variable that will receive the length of the NppiEncodeHuffmanSpec structure. |
Returns
Error codes:
- NPP_NULL_POINTER_ERROR If one of the pointers is 0.
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
pRawHuffmanTable | Huffman table formated as specified in the JPEG standard. |
eTableType | Enum specifying type of table (nppiDCTable or nppiACTable). |
pHuffmanSpec | Pointer to the Huffman table for the decoder |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_NULL_POINTER_ERROR If one of the pointers is 0.
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
pRawHuffmanTable | Huffman table formated as specified in the JPEG standard. |
eTableType | Enum specifying type of table (nppiDCTable or nppiACTable). |
ppHuffmanSpec | Pointer to returned pointer to the Huffman table for the encoder |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_NULL_POINTER_ERROR If one of the pointers is 0.
NppStatus nppiEncodeOptimizeHuffmanGetSize | ( | NppiSize | oSize, |
int | nChannels, | ||
int * | pBufSize | ||
) |
Calculates the size of the temporary buffer for optimize Huffman coding.
Parameters
oSize | Image Dimension. |
nChannels | Number of channels in the image. |
pBufSize | Pointer 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
pSrc | Destination-Image Pointer. |
nSrcStep | Destination-Image Line Step. |
nRestartInterval | Restart Interval, see JPEG standard. Currently only values <=0 are supported. |
nSs | Start Coefficient, see JPEG standard. |
nSe | End Coefficient, see JPEG standard. |
nAh | Bit Approximation High, see JPEG standard. |
nAl | Bit Approximation Low, see JPEG standard. |
pDst | Byte-stuffed huffman encoded JPEG scan. |
pLength | Pointer to the byte length of the huffman encoded JPEG scan. |
hpCodesDC | Host pointer to the code of the huffman tree for DC component. |
hpTableDC | Host pointer to the table of the huffman tree for DC component. |
hpCodesAC | Host pointer to the code of the huffman tree for AC component. |
hpTableAC | Host pointer to the table of the huffman tree for AC component. |
pHuffmanDCTable | DC Huffman table. |
pHuffmanACTable | AC Huffman table. |
oSizeROI | Region-of-Interest (ROI). |
pTempStorage | Temporary storage. |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
- NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY If the device has compute capability < 2.0.
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
apSrc | Destination-Image Pointer. |
aSrcStep | Destination-Image Line Step. |
nRestartInterval | Restart Interval, see JPEG standard. Currently only values <=0 are supported. |
nSs | Start Coefficient, see JPEG standard. |
nSe | End Coefficient, see JPEG standard. |
nAh | Bit Approximation High, see JPEG standard. |
nAl | Bit Approximation Low, see JPEG standard. |
pDst | Byte-stuffed huffman encoded JPEG scan. |
pLength | Pointer to the byte length of the huffman encoded JPEG scan. |
hpCodesDC | Host pointer to the code of the huffman tree for DC component. |
hpTableDC | Host pointer to the table of the huffman tree for DC component. |
hpCodesAC | Host pointer to the code of the huffman tree for AC component. |
hpTableAC | Host pointer to the table of the huffman tree for AC component. |
apHuffmanDCTable | DC Huffman tables. |
apHuffmanACTable | AC Huffman tables. |
oSizeROI | Region-of-Interest (ROI). |
pTempStorage | Temporary storage. |
nppStreamCtx | Application Managed Stream Context. |
Returns
Error codes:
- NPP_SIZE_ERROR For negative input height/width or not a multiple of 8 width/height.
- NPP_STEP_ERROR If input image width is not multiple of 8 or does not match ROI.
- NPP_NULL_POINTER_ERROR If the destination pointer is 0.
- NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY If the device has compute capability < 2.0.
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
oBlocks | Size 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
pJob | has to be initialized by nppiJpegDecodeJobCreateMemzero or nppiJpegDecodeJobCreateFinalize or manually. |
pMemory | has to point to valid structure, except for MEMZERO and FINALIZE scans, for which it can be NULL. |
See Also
nppiJpegDecodeJobCreateMemzero
nppiJpegDecodeJobCreateFinalize
This function can be used in two ways, depending on how much control do you need:
- 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.
- 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
nppStreamCtx | Application Managed Stream Context. |
Returns
- NPP_SUCCESS
- NPP_BAD_ARGUMENT_ERROR when the scan doesn't represent valid JPEG scan
- NPP_NULL_POINTER_ERROR when one of necessary arguments of buffers is NULL
- NPP_ERROR when encountered CUDA error
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
pJob | has to point to properly initialized job | |
[out] | aSize | will 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
Returns
- NPP_SUCCESS
- NPP_BAD_ARGUMENT_ERROR when the scan doesn't represent valid JPEG scan
- NPP_NULL_POINTER_ERROR when one of necessary arguments is NULL
Copyright © 2009-2019 NVIDIA Corporation