Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Saving video as JPEG

marco_lopes
Beginner
353 Views
Hello all,

I'm new to IPP and I'm trying to write a program that saves a snapshot of a video as Jpeg.
I'm using the code from the example jpegview.

The video is in YUV422 format, coming from a usb camera. The capture software is based on MS DirectShow.

I'm copying two images one above the other, converting them to RGB:

CIppImage * pImage = new CIppImage();
Ipp8u* pAux = ippiMalloc_8u_C3(s.width, s.height * 2, &auxStep);
Ipp8u* pMiddle = pAux + (auxStep * s.height);
ippError = ippiYCbCr422ToBGR_8u_C2C3R((Ipp8u*)imaging.gpLeftBuffer, gDstStep, pAux, auxStep, s);
ippError = ippiYCbCr422ToBGR_8u_C2C3R((Ipp8u*)imaging.gpRightBuffer, gDstStep, pMiddle, auxStep, s);
Note: I've tried ippiYUV422ToRGB_8u_C2C3R as well.

Then I initialize my Image with doubled height:
CIppImage * pImage = new CIppImage();
s.height *= 2;
success = pImage->Alloc(s, 3, 8);
And copy the RGB data into it:

pImage->CopyFrom(pAux, auxStep, s);

The thing is when a save it, the colors are completelly wrong. I've tried to use BGR and RGB both failed.
I'm not sure what I'm doing wrong. Here are the jpeg settings:

 pJpegSettings->quality = 8;
 pJpegSettings->restart_interval = 0;
 pJpegSettings->huffman_opt = 0;
 pJpegSettings->point_transform = 0;
 pJpegSettings->predictor = 1; 
 pJpegSettings->use_qdct = 1;
 pJpegSettings->mode = JPEG_BASELINE;
 pJpegSettings->color = JC_UNKNOWN;
 pJpegSettings->sampling = JS_422;
 pJpegSettings->dct_scale = JD_1_1;
 pJpegSettings->comment_size = 0;
Do you guys have any idea what is the problem here ?

tia,

Marco




0 Kudos
1 Reply
Vladimir_Dudnik
Employee
353 Views

Hi Marco,

If your input format is YUY2 (YCbCr422) then you can use IPP JPEG codec directly. You need to set input color as JC_YCBCR and input sampling as JS_422. Note, codec do not support resampling, that means you also need to specify JPEG color as JC_YCBCR and JPEG sampling as JS_422.

Be aware that quality level you are using (8) is very low. You will get lot of compression artifacts as a result. Of course compression ration will be higher. Usually, level 75 provides good tradeoff for generic applications.

Regards,
Vladimir

0 Kudos
Reply