Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

Encoding ROI with higher quality

Is it possible to dynamically set the encoder to encode a specific ROI with high quality in respect to the rest of the image?

Or alternatively set the encoder to encode an ROI as Intra_Block_4x4?

Thanks.

 

 

 

 

0 Kudos
9 Replies
Highlighted
9 Views

Hello Yossi - You can specify an ROI size during encoder function using the mfxExtEncoderROI. This structure can be specified for every frame to be encoded and then passed to the EncodeFrameAsync call-back function. This structure specifies the ROI that the encoder has to focus on, and has to align on macro-block boundaries. You can find more information in the doc/mediasdk-man.pdf document:p112.

If you are looking for a global setting instead (where you specify the ROI for the entire video stream), you can use the Crop values in the mfxFrameInfo structure.

Hope this answers your question.

 

0 Kudos
Highlighted
Beginner
9 Views

Thanks Sravanthi for you quick reply.
Actually, I did try to use mfxExtEncoderROI, but after I specified the ROI using this function, I used mfxvideoencoade_Query and got status = -3 which I think indicates that ROI feature is not supported. I tested the same code on different machines (different h/w) and always got the same 'status = -3' error so I assumed that this (i.e ROI) feature is indeed not supported yet.

After reading your reply, I'll get back to the code I wrote and double-check it to see that I haven't missed something.

Thanks!

 

 

 

0 Kudos
Highlighted
Beginner
9 Views

OK, after updating my HD Graphic Driver the code seems to be working fine (no more status = -3), 
but IMHO the ROI doesn't look like it was encoded with higher quality.
Any advice?


Here's my code:

mfxExtCodingOption extendedCodingOptions;
memset(&extendedCodingOptions, 0, sizeof(extendedCodingOptions));
extendedCodingOptions.Header.BufferId        = MFX_EXTBUFF_CODING_OPTION;
extendedCodingOptions.Header.BufferSz        = sizeof(extendedCodingOptions);
extendedCodingOptions.MaxDecFrameBuffering    = 1;
 
 
mfxExtEncoderROI extendedRoiOptions;
memset(&extendedRoiOptions, 0, sizeof(extendedCodingOptions));
extendedRoiOptions.Header.BufferId = MFX_EXTBUFF_ENCODER_ROI;
extendedRoiOptions.ROI[0].Left   = 16;
extendedRoiOptions.ROI[0].Right  = 160;
extendedRoiOptions.ROI[0].Top    = 0;
extendedRoiOptions.ROI[0].Bottom = 160;
extendedRoiOptions.ROI[0].Priority = 3; 
extendedRoiOptions.NumROI = 1;
 
mfxExtBuffer* extendedBuffers[2];
extendedBuffers[0] = (mfxExtBuffer*)&extendedCodingOptions;
extendedBuffers[1] = (mfxExtBuffer*)&extendedRoiOptions;
mfxEncParams.ExtParam       = extendedBuffers;
mfxEncParams.NumExtParam    = 2;

 

 

 

0 Kudos
Highlighted
Employee
9 Views

Hi Yossi,

Your configuration looks correct. What driver version are you using now?

To see if ROI was really treated by bitrate control differently you can check QPs of macroblocks within the ROI using some stream analyzer, e.g. Elecard's. If you'll see that there is a single QP for the whole frame then it will mean ROI wasn't applied. 

Also, are you using it with AVC? With CBR or VBR bitrate control mode? 

If you find it's not working please send us the tracer tool log so that we could replicate your full configuration.

Regards,

Nina

0 Kudos
Highlighted
Beginner
9 Views

I'm using CBR bitrate control mode, and it looks like the QP of all MB are the same.

Do you have any working example which uses MFX_EXTBUFF_ENCODER_ROI?

0 Kudos
Highlighted
9 Views

Hi Yossi,

mfxExtEncoderROI is only supported in Windows with CQP bitrate control mode, it is not supported in CBR. Thanks!

0 Kudos
Highlighted
Employee
9 Views

Hi Yossi, 

ROI works only with the CQP bit control method, and not with CBR(which is mentioned in our manual, sorry for the confusion). 
Attached is the changes you need to do to use ROI in sample_encode. cmd line : sample_encode.exe h264 -i ducks_1080p.yuv -o out_roi_async_1.h264 -cqp -qpi 17 -qpb 17 -qpp 17 -async 1 -hw  -f 30 -w 1920 -h 1080 
You can change the ROI size using top, bottom, left, right params.  

To check if it is working fine, use Intel(R) Video Pro Analyzer to check the QP heat map, through Info overlay mode. In case this doesn't work, please let us know your system details we will look at it. 

Thanks,
Surbhi

0 Kudos
Highlighted
Beginner
9 Views

Thanks Surbhi,

I ran sample_code with your changes and indeed it seems to be working (meaning, better quality for the ROI) BUT only for the first frame of the video.
Do you have any idea why?
Maybe I have to re-set the ROI option inside the Encoding Loop?!

Thanks,
Yossi

 

 

 

 

0 Kudos
Highlighted
Employee
9 Views

read once more original answer from Sravanthi --> ROI extended buffer for a frame

SRAVANTHI K. (Intel) wrote:

Hello Yossi - You can specify an ROI size during encoder function using the mfxExtEncoderROI. This structure can be specified for every frame to be encoded and then passed to the EncodeFrameAsync call-back function. This structure specifies the ROI that the encoder has to focus on, and has to align on macro-block boundaries. You can find more information in the doc/mediasdk-man.pdf document:p112.

 

0 Kudos