Community
cancel
Showing results for 
Search instead for 
Did you mean: 
pas059
Beginner
92 Views

uic jpec encoder

Hi,

I'm trying to evaluate uic jpeg encoder performancesand encounter manydifficulties. I can present source image in BGRA or YUV422 (YUY2) and i just want to convert it in jpeg in a memory stream (CMemBuffOutput). I started from samples and generally all seam to be correct beforethecall to encoder.WriteHeader() wich returns -1 (which is not informative) or simply crashes.

Someone can indicate a sample that just works or a more complete documentation?

thanks in advance

Pascal
0 Kudos
5 Replies
Vladimir_Dudnik
Employee
92 Views

Hi Pascal,

it seems you arleade started from UIC samples (uic_transcoder_con and/or picnic). We do not have other samples for UIC framework.

I think that error which you get is related to uncorrect parameters you apply to UIC codec. Is it possible to provide a code snippet to see how you call UIC codec?

Regards,
Vladimir
pas059
Beginner
92 Views

Hi Vladimir,

i'm agree with you, this is probably a bad parameterization. I also found a sample (from you?) called 'jpeg_ycbcr422'.

below a code snippet
>>

JPEGEncoder encoder;

CMemBuffOutput mso;

ImageDataPtr imDataPtr[3];

ExcStatus status = encoder.Init();

status = mso.Open( *compImage , outputBufferLength );

status = encoder.AttachStream( mso );

JPEGEncoderParamsBAS jpegParam;

jpegParam.SetRestartInterval(0);

jpegParam.SetHuffmanOption(0);

jpegParam.SetQuality( 80 );

jpegParam.SetColor( JC_YCBCR ); // JC_YCBCR or(JCOLOR)YCbCr )?

jpegParam.SetSampling( JS_422 );

status = encoder.SetParams( jpegParam );

int nOfComponents = 3;

UIC::Image uicImage;

UIC::RectSize size( width , height );

UIC::Point origin( 0 , 0 );

UIC::Rect refgrid( origin , size );

UIC::ImageSamplingGeometry geometry;

geometry.SetRefGridRect( refgrid );

status = geometry.ReAlloc( nOfComponents );

status = geometry.SetEnumSampling( S422 ); // UIC::ImageEnumSampling::S422

ImageDataOrder dataOrder;

dataOrder.SetDataType( T8u );

status = dataOrder.ReAlloc( Plane , nOfComponents ); //or Interleaved?

for( int i = 0; i < nOfComponents; i++)

{

dataOrder.PixelStep() = i == 0 ? 2 : 4;

dataOrder.LineStep() = width * 2;

}

status = uicImage.ColorSpec().ReAlloc( nOfComponents );

uicImage.ColorSpec().SetColorSpecMethod( Enumerated );

uicImage.ColorSpec().SetComponentToColorMap( Direct );

for( int i = 0; i < nOfComponents; i++)

{

uicImage.ColorSpec().DataRange().SetAsRange8u( 255 );

}

uicImage.ColorSpec().SetEnumColorSpace( YCbCr ); //ImageEnumColorSpace::YCbCr

// yuv422Ptr is initialized elsewhere as a byte *
imDataPtr[0].p8u = yuv422Ptr; // 1st Y component

imDataPtr[1].p8u = yuv422Ptr + 1; // 1st U component

imDataPtr[2].p8u = yuv422Ptr + 3; // 1st V component

status = uicImage.Buffer().Attach( imDataPtr , dataOrder , geometry );

status = encoder.AttachImage( uicImage );

status = encoder.WriteHeader();

if(ExcStatusOk != status) return 0;


>>
thanks in advance for your help
Pascal
Vladimir_Dudnik
Employee
92 Views

The sampleproject you mentioned should be available on this forum. It was indended to showcase how to encode from YUY2 format to JPEG and how to decode to YUY2 fomat (instead of RGB).

This sample should work (at least it did once posted :) )

Vladimir
pas059
Beginner
92 Views

hi Vladimir,

i found it and i tried somthing equivalent of it, but without success. In fact, it's not possible to verify if this sample works as it is not a complete applicationexemple and so this imply to imagine the values of the input parameters! In addition, there is a "strange" parameter on the line:

dataOrder.ReAlloc(Plane, in_image->nChannels);
i would expect "interleaced" rather than "Plane" with YUV422 (YUY2).

Really, what can be really helpfull, is to have a complete application exemple with project file for Visual Studio (yes, i work under windows). I already lost too much time for just evaluating the performances.
Is there something like this?

thanks in advance,
Pascal
ILevi1
Valued Contributor I
92 Views

Deleted and submitted issue on premier.intel.com.
Reply