Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Problem in ippiEncodeHuffman8x8_JPEG_16s1u_C1

nyryder
Beginner
375 Views
I am doing the JPEG encoding in the WIN32 Kernel space (The product is a windows driver). After the DCT function, i do quantization using ippiQuantFwd8x8_JPEG16s_C1I, and i call the ippiEncodeHuffman8x8_JPEG-16s1u_C1, to encode the Quantized DCT coefficients. This ippiEncodeHuffman function does not work 50% of the time. It returns either ippStsJPEGOutofBuffer"Attempt to access out of the buffer" error, or return the pDstCurrPos as zero, or pDstCurrPos as a unrealistic big number. I verified all the input parameters all appears to be valid. My question is there any limitation to run this function in kernel space?. My kernel thread runs at passive level and i tried with output buffers as page pool and nonpage pool of buffers. The input is non paged pool of buffer.
Is there any way i can get more trace information fromation from the ipp function??. Any help is highly appreciated. The version of IPP is 6.1.1.035.
0 Kudos
1 Solution
Vladimir_Dudnik
Employee
375 Views

Hello,

Did you take a look at IPP UIC JPEG codec sample? You may want to review this code to see how to call IPP functions in JPEG encoder. Basically we use the following sequence:

// raw table is quantization tables as specified in JPEG standard
// quality is quantization parameter 1..100, 1 - more compression worse quality, 100 - less compression but better quality
ippiQuantFwdRawTableInit_JPEG_8u(m_raw8u,quality);

// transform quantization table into internal IPP format (to avoid divide operation)
ippiQuantFwdTableInit_JPEG_8u16u(m_raw8u,m_qnt16u);

// initialialize internal huffman tables from raw huffman tables (defined in JPEG standard)
ippiEncodeHuffmanSpecInit_JPEG_8u(m_bits,m_vals,m_table);

// initialize huffman state (you need to allocate memory for state before this
ippiEncodeHuffmanStateInit_JPEG_8u(m_state);

// perform DCT and quantization
ippiDCTQuantFwd8x8LS_JPEG_8u16s_C1R(src,srcStep,pMCUBuf,qtbl);

// encode quantized DCT coefficients
ippiEncodeHuffman8x8_JPEG_16s1u_C1(
pMCUBuf,dst,dstLen,&currPos,
&curr_comp->m_lastDC,pDCTbl,pACTbl,m_state,0);

Regards,
Vladimir

View solution in original post

0 Kudos
2 Replies
Vladimir_Dudnik
Employee
376 Views

Hello,

Did you take a look at IPP UIC JPEG codec sample? You may want to review this code to see how to call IPP functions in JPEG encoder. Basically we use the following sequence:

// raw table is quantization tables as specified in JPEG standard
// quality is quantization parameter 1..100, 1 - more compression worse quality, 100 - less compression but better quality
ippiQuantFwdRawTableInit_JPEG_8u(m_raw8u,quality);

// transform quantization table into internal IPP format (to avoid divide operation)
ippiQuantFwdTableInit_JPEG_8u16u(m_raw8u,m_qnt16u);

// initialialize internal huffman tables from raw huffman tables (defined in JPEG standard)
ippiEncodeHuffmanSpecInit_JPEG_8u(m_bits,m_vals,m_table);

// initialize huffman state (you need to allocate memory for state before this
ippiEncodeHuffmanStateInit_JPEG_8u(m_state);

// perform DCT and quantization
ippiDCTQuantFwd8x8LS_JPEG_8u16s_C1R(src,srcStep,pMCUBuf,qtbl);

// encode quantized DCT coefficients
ippiEncodeHuffman8x8_JPEG_16s1u_C1(
pMCUBuf,dst,dstLen,&currPos,
&curr_comp->m_lastDC,pDCTbl,pACTbl,m_state,0);

Regards,
Vladimir
0 Kudos
nyryder
Beginner
375 Views

Hello,

Did you take a look at IPP UIC JPEG codec sample? You may want to review this code to see how to call IPP functions in JPEG encoder. Basically we use the following sequence:

// raw table is quantization tables as specified in JPEG standard
// quality is quantization parameter 1..100, 1 - more compression worse quality, 100 - less compression but better quality
ippiQuantFwdRawTableInit_JPEG_8u(m_raw8u,quality);

// transform quantization table into internal IPP format (to avoid divide operation)
ippiQuantFwdTableInit_JPEG_8u16u(m_raw8u,m_qnt16u);

// initialialize internal huffman tables from raw huffman tables (defined in JPEG standard)
ippiEncodeHuffmanSpecInit_JPEG_8u(m_bits,m_vals,m_table);

// initialize huffman state (you need to allocate memory for state before this
ippiEncodeHuffmanStateInit_JPEG_8u(m_state);

// perform DCT and quantization
ippiDCTQuantFwd8x8LS_JPEG_8u16s_C1R(src,srcStep,pMCUBuf,qtbl);

// encode quantized DCT coefficients
ippiEncodeHuffman8x8_JPEG_16s1u_C1(
pMCUBuf,dst,dstLen,&currPos,
&curr_comp->m_lastDC,pDCTbl,pACTbl,m_state,0);

Regards,
Vladimir
Vladmir,
Thanks for the reply. I did not inititalize the "ippiEncodeHuffmanStateInit_JPEG_8u(m_state)" huffman state before the DCTquantization. Once we initialize it, it is working consistently. One surprise note is that this encoder in user space with out huffman state initialization on every encode call, worked on 100,000 image input tests. But when we move it to the kernel space its failure rate is much higher.
With proper initalization it is working in kernel space also.
Once again thanks for the wonderful support.
0 Kudos
Reply