Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

JPEG Compressor - GetVideoParam

Darrell_S_
Beginner
817 Views

The following function returns 0 for the BufferSizeInKB for the JPEG Compressor - is this a bug?

I set up the encodeParams for my encoder - and I set it to use the JPEG compressor, set width, height, chroma format, the works....

MFXVideoENCODE encoder = new MFXVideoEncode(session);
encoder->Query(&encodeParam, &encodeParam);
encoder->Init(encoderParam);
mfxVideoParam param;
memset(&param, 0, sizeof(param));
encoder->GetVideoParam(&param);

printf("Encoder Param buffer size is %d\n",param.mfx.BufferSizeInKB);           <-- I find that this returns 0 - I don't think it should...

 

0 Kudos
15 Replies
Sravanthi_K_Intel
817 Views

Hello there - We do not have any outstanding bug as you observe for JPEG, so I suspect it is some parameter setting that may have caused this. Can you send a few more details on what you are trying to do? For example - the video params, and the status returned after each of the above-mentioned API calls. That can give a good idea about what step is not returning without an error.

sts = encoder->Query(&encodeParam, &encodeParam);
sts = encoder->Init(encoderParam);
mfxVideoParam param;
memset(&param, 0, sizeof(param));
sts = encoder->GetVideoParam(&param);

0 Kudos
Sravanthi_K_Intel
817 Views

One more thing, are you using the sample applications or tutorial applications provided with the Media SDK to test the above behavior? Or do you have your own application that you developed?

Anyway, once we know what the return status is for each of the above function call, and also the video params you set - we will know more.

0 Kudos
Darrell_S_
Beginner
817 Views

Hello Sravanthi,

I am attaching a modified version of the sample_encode.cpp so that it uses JPEG instead of H264.  

I am passing the following command line options:
-sw -g 854x480 -b 2899 -f 2400/100 bbb_850x480_422YUYV.yuv

and I am seeing the value of 0 being returned in the par.mfx.BufferSizeInKB.  

Please let me know which parameter that I might be setting wrong.

Thanks.

 

 

0 Kudos
Darrell_S_
Beginner
817 Views

The status returned for all the calls in simple_encode.cpp is MFX_ERR_NONE(0).

 

0 Kudos
Sravanthi_K_Intel
817 Views

Looks like Harsh answered part of your question on this thread - https://software.intel.com/en-us/forums/topic/532422 Does fixing that issue solve your problem? Like mentioned, we handle the resolutions you gave and also the encoding of JPEG without any issue. And yes, MSDK expects NV12 as the input format for VPP processing and encoding. Let me know if fixing your color conversion helps fix your issue.

 

0 Kudos
Darrell_S_
Beginner
817 Views

I am not doing VPP processing, but will explore what happens when I use NV12 as input.  The documentation is not very clear on this fact.  

0 Kudos
Sravanthi_K_Intel
817 Views

Hello there - Yes, my bad. I will run your sample program and get back to you with the cause for the issue.

0 Kudos
Sravanthi_K_Intel
817 Views

Hello there - I was able to reproduce the issue you are seeing my merely changing the codecID from AVC to JPEG in simple_encode tutorial. And the issue is independent of the width and height (I could reproduce the issue with QCIF sized video and the size you mention above) Thanks for pointing it out. I am working on it, and will get back to you with a fix soon.

0 Kudos
Darrell_S_
Beginner
817 Views

Thanks for confirming and exploring a solution.

0 Kudos
Sravanthi_K_Intel
817 Views

Hello there - 

- What is the version of MSDK you are using? Did you recently update to MSS 2015? Can you paste the command-line and the output info printed on screen when you run your encoder (such as version number, input params etc)? There may be a possible bug with the MSS version of the library (libmfxsw<arch>.dll) - so trying to narrow down the problem.

0 Kudos
Darrell_S_
Beginner
817 Views

The value of the version returned from the sample says {Minor=0, Major=1, Version=65536}
The value of the version returned from QueryVersion is (Minor=9, Major=1, Version=65545}

The command line for the simple_encode program is as follows:
-sw -g 854x480 -b 2899 -f 2400/100 c:\big_buck_bunny_854x480_422YUYV.yuv c:\big_buck_bunny.jpeg

I am using the file from http://www.bigbuckbunny.org and then used FFMPEG to remove the container and extract the YUV data in 422YUYV format.  But the input doesn't matter - every file gives me 0 for the BufferSizeInKB value.

I have a Macintosh laptop, but am running Parallels Desktop 9 for Mac so am actually running this test on Windows 8 Enterprise edition.

I don't follow you on MSS - what product is that?

I'm running 2013 version of Microsoft's Visual Studio.
I'm using the Media SDK 2014 R2 for Clients.


 

 

 

0 Kudos
Darrell_S_
Beginner
817 Views

Maybe you can clear up the confusion with a concrete example.

If my input is raw UYVY 422 and I want my output to be UYVY 422 encoded as JPEG, what parameters do I need to set?  How does the surface need to be defined?  (note, this works for aligned width/height)

Currently, I'm creating the following:
encoderSurface->Data.Y = ippiMalloc_8u_C2(MSDK_ALIGN32(width), MSDK_ALIGN32(height) * 2, &stride);
encoderSurface->Data.U = encoderSurface->Data.Y + 1;
encoderSurface->Data.V = encoderSurface->Data.Y + 3;
encoderSurface->Data.Pitch = stride;

I'm also setting the encoder parameter as follows:
encoderParam.mfx.FrameInfo.FourCC = MFX_FOURCC_YUY2;
encoderParam.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
encoderParam.mfx.CodecId = MFX_CODEC_JPEG;

mfxOutputBitStream.MaxLength = 4 + (MSDK_ALIGN16(width) * MSDK_ALIGN16(height) * 2 + 1023) / 1024; //Use PICSTRUCT_PROGRESSIVE
mfxOutputBitStream.Data = new  mfxU8[mfxOutputBitStream.MaxLength];

If I need to have the data in NV12 format - what needs to change here?  Do I need to convert down from 422 to 420 before I fill in the Data.Y, Data.U, and Data.V buffers?


 

 

0 Kudos
Sravanthi_K_Intel
817 Views

Thanks for the information. (Note: In this thread, the issue we are trying to debug is seeing the BufferSizeInKB=0 problem. You have another thread going on with Harsh which is seeing a different issue - I highly recommend you collate the issues under one thread so that we can isolate the cause and the effect).

So, with your MSDK 2014 R2 install, running SW implementation of JPEG encoder is failing. After multiple tests, I was not able to reproduce this on the platform closest to yours. I could successfully run JPEG encoder using your input resolution of 854x480 (NV12 albeit) without any problem - so my assumption that this could be a bug with MSS does not apply here. I ran the sample_encode application with the following commands "sample_encode.exe jpeg -i input.yuv -o output.mjpeg -w 854 -h 480 -sw"

You also mention that the JPEG encoder code you have works for 32-aligned width and height - right?

Okay, based on the above  observations - the issue seems to occur in your code ( there is no driver issue since you seem to be running the software impl anyway). Here is how we should proceed:

- Possible that the issue you are seeing is in your code. To ensure that - use sample_encode as base and modify you code accordingly. Also, for completeness sake, can you modify your code to use NV12 as input (instead of 422 format) and report if the issue recurs? Also, I would recommend you use sample_encode as your reference implementation and modify it for your needs. Sample_encode works for JPEG encode, for 853x480 as you have and has been tested multiple times by me on platform closet to yours.

0 Kudos
Sravanthi_K_Intel
817 Views

Hello Darrell,

I happened to read some of the responses you and Harsh have been exchanging, and I think these two threads operating in parallel is causing a lot of confusion. I am not sure if the issues reported in these two threads originate from the same code you attached, and if you are observing both the issues at the same time. To avoid confusion for all of us involved, I am going to suspend my responses to this thread temporarily - until the previous thread you have going on with Harsh is resolved. Harsh agrees too. But as Harsh mentioned, we are here to help you!

0 Kudos
Sravanthi_K_Intel
817 Views

Hello Darrell - I was able to find the issue causing JPEG Encoder to not work. In the previous versions of the JPEG encoder, the quality parameter (-q in sample_encode) assumed a default value when not explicitly set. In the latter versions, this became a mandatory parameter to set (value between 10-100). The documentation and the samples do not reflect this and we will fix them. 

So, the fix is as simple as specifying -q parameter! Here is an example command line that works for sample_encode:

sample_encode.exe jpeg -hw -i input.yuv -o output.mjpeg -w 854 -h 480 -q 10 -d3d11 (HW impl with video surfaces)

sample_encode.exe jpeg -sw -i input.yuv -o output.mjpeg -w 854 -h 480 -q 10  (SW impl with system surfaces)

Hope this helps. Let me know if you have more questions.

0 Kudos
Reply