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.
3058 Discussions

Problem when creating multiple sessions for compressing jpegs of differing sizes

Stephen_V_2
Beginner
325 Views

I've successfully used the media SDK to produce a RTSP application that streams mjpeg, where the image size is fixed. However, I have a problem when trying to create jpegs for varying size images, which are patches extracted from the raw images and saved to disk.

The code below illustrates the problem, with the call to MFXInit returning MFX_ERR_UNSUPPORTED after a number of calls (usually 66 on my machine).

My application does retain the sessions so that they can be reused for images of the same size but I don't know how to handle the error below so eventually my application stops generating images.

What is the recommended approach for handling the varying image size?

S. 

 

    mfxStatus status;

    mfxIMPL impl = MFX_IMPL_HARDWARE_ANY;
    mfxVersion ver;
    ver.Major = 1;
    ver.Minor = 3;

    int count = 0;

    for( int height = 40; height <= 80; height += 1 )
    {
        for( int width = 10; width <= 40; width += 1 )
        {
            mfxSession* session = new mfxSession();

            status = MFXInit( impl, &ver, session );
            assert( status >= MFX_ERR_NONE );

            mfxVideoParam video_params;
            memset(&video_params, 0, sizeof(mfxVideoParam));
            video_params.mfx.CodecId = MFX_CODEC_JPEG;
            video_params.mfx.CodecProfile = MFX_PROFILE_JPEG_BASELINE;
            //video_params.mfx.CodecLevel = MFX_LEVEL_UNKNOWN;
            video_params.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
            video_params.mfx.Quality = 20;
            video_params.mfx.Interleaved = MFX_SCANTYPE_INTERLEAVED;
            video_params.mfx.FrameInfo.FourCC = MFX_FOURCC_YV12;
            video_params.mfx.FrameInfo.ChromaFormat =  MFX_CHROMAFORMAT_YUV420;
            video_params.mfx.FrameInfo.Width =  width;
            video_params.mfx.FrameInfo.Height = height;
            video_params.mfx.FrameInfo.CropW = width;
            video_params.mfx.FrameInfo.CropH = height;
            video_params.mfx.FrameInfo.FrameRateExtD = 1;
            video_params.mfx.FrameInfo.FrameRateExtN = 30;
            video_params.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
            video_params.mfx.RestartInterval = 0;
            video_params.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
            video_params.AsyncDepth = 4;    
            video_params.mfx.BufferSizeInKB = MSDK_ALIGN32(width)*MSDK_ALIGN32(height)* 2 / 1000;
            memset(video_params.mfx.reserved5, 0, sizeof(video_params.mfx.reserved5));

            status = MFXVideoENCODE_Query( *session, &video_params, &video_params );
            assert( status >= MFX_ERR_NONE );

            status = MFXVideoENCODE_Init( *session, &video_params );
            assert( status >= MFX_ERR_NONE );

            vcl_cout << ++count << " : " << height << " x " << width << vcl_endl;
        }
    }

0 Kudos
3 Replies
Jiandong_Z_Intel
Employee
325 Views

Hi There,

From your parameter setting -

video_params.mfx.FrameInfo.FourCC = MFX_FOURCC_YV12;

Currently MSDK encode only support MFX_FOURCC_NV12 as input,  more info refer to page 24-26 in Intel Media SDK Reference Manual .

Can you do VPP (YV12->NV12) first ?

Thanks

Zachary

 

0 Kudos
Stephen_V_2
Beginner
325 Views

Hello Zachary,

Thanks for your reply. I will change my code to use NV12 to comply with the reference manual.

However, I still expect to have problems with creating multiple sessions. Even if I call MFXVideoENCODE_Close( *session ); at the end of the inner loop, I still get an error after a number of iterations (usually 66?). I would like to understand what strategy I should use to manage the sessions so that I can encode multiple images of various sizes. I am very much a beginner with the media SDK so can you explain what the error actually means and whether this will occur similarly on other platforms.

Thanks,

S.

0 Kudos
Surbhi_M_Intel
Employee
325 Views

Hi Stephen, 

Since I don't have your complete code it not be simple to indicate why you are seeing MFXInit fail after certain no. of calls but I would recommend you to look at the multiple sessions topic(pg 10) in the Media SDK manual.It explains well how to create multiple sessions of encode/decode. Also you should check sample_multi_transcode from the samples package, which has implemented the multiple encode and decode sessions. Also, can you send us the system analyzer logs to make sure you have the correct set up ?

Thanks,
Surbhi

 

0 Kudos
Reply