Success! Subscription added.
Success! Subscription removed.
Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile.
Hello,
based on the sample_encode from the MSDK repository, I tried to make it generate a monochrome jpeg image by setting the output chroma format to MFX_CHROMAFORMAT_MONOCHROME.
This does not work and terminates with the error MFX_ERR_INVALID_PARAM.
How can I use MSDK or oneAPI to encode gray scale images to JPEG?
Thank you.
Hi Nico,
Here is the advice from dev team, in order to use monochrome frame buffer for JPEG encode, you need to make changes to the following settings in sample_encode:
m_mfxVppParams.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_MONOCHROME;
m_mfxEncParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_MONOCHROME;
Mark Liu
Link Copied
Hello,
Please can you provide following information.
Hello VaradJ_intel,
Thank you for your reply.
1.) Media SDK version is 1.34, hardware is Intel Core i7-9700
2.) Operating system is Windows 10 Pro version 20H2
3.) The original image is an 8 Bit per pixel single channel gray JPEG named original.jpg in the attachments.
I decoded the original image to original.yuv contained in the attached original.yuv.zip (zipped because .yuv attachment is not allowed).
I called the sample_encode with these parameters: jpeg -q 75 -i original.yuv -o encoded_by_sample_encode.jpg -w 768 -h 240, the result is attached encoded_by_sample_encode.jpg.
The sample_encode does exactly what I need. It encodes an image to a gray single channel 8 Bit per pixel JPEG very fast. This encoding speed is very useful to the company I work for. The speed is why we would like to use Intel hardware to encode images to JPEG if we can make use of the hardware.
I just need to change the input of the sample_encode from a 3 channel 24 Bit per pixel YUV uncompressed image file to a single channel 8 Bit per pixel gray uncompressed buffer.
4.) I try to describe how I modified the sample_encode files, but I cannot share all of the code I use.
I use a propietary software JPEG decoder from the company I work for, so I cannot share this code.
It just decodes a single channel gray JPEG image to a std::vector<unsigned char> buffer and I know this part of the code works fine.
Now this buffer is used a function based on the main function of sample_encode.cpp as seen in attached main.cpp from code_snippets.zip. I used the same parameters that the original sample_encode uses. I set breakpoints in the original sample_encode and copied all parameters to the modified code as seen in main.cpp.
I changed the pipeline_encode and sample_encode files to use a buffer as input.
For some reason when I run this code it creates a 24 Bit per pixel JPEG image with a green color as seen in encoded_by_sample_encode_modified_to_read_from_buffer_encodeFourCC_NV12.jpg.
So I see the image is created as a color image, that is why I try to force the output chroma format to MFX_CHROMAFORMAT_MONOCHROME as seen in pipeline_encode_chroma.cpp.
When I run this code the line sts = m_pmfxENC->EncodeFrameAsync(In.pCtrl, In.pSurface, &pTask->mfxBS, &pTask->EncSyncP); in pipeline_encode.cpp sets sts to MFX_ERR_INVALID_VIDEO_PARAM (-15).
So I see MSDK can encode single channel gray JPEG images using the hardware.
I would like to reproduce this result with a single channel 8 Bit per pixel gray buffer instead of a YUV 3 channel 24 Bit per pixel file as input.
1.) How do I need to set the parameters to encode a single channel buffer to a single channel JPEG image?
1.1) Which values should I use for input FourCC and output FourCC?
1.2) Which values should I use for input chroma format and output chroma format?
1.3) Which other parameters do I need to set?
Thank you very much.
Hi Nico,
Thanks for the information, we have created an internal request to investigate this issue.
I will keep you updated with the progress.
Mark
Hi Nico,
Here is the advice from dev team, in order to use monochrome frame buffer for JPEG encode, you need to make changes to the following settings in sample_encode:
m_mfxVppParams.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_MONOCHROME;
m_mfxEncParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_MONOCHROME;
Mark Liu
Hi Mark,
Your suggestion works to fix my problem.
Thank you very much.
Community support is provided Monday to Friday. Other contact methods are available here.
Intel does not verify all solutions, including but not limited to any file transfers that may appear in this community. Accordingly, Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.
For more complete information about compiler optimizations, see our Optimization Notice.