- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
Currently I am trying to convert YUY2 image to JPEG XR format and vice versa. Here is code snippet that I use for compression:
JPEG XR encoder seems to work fine (i.e. without errors). However, I cannot open result JPEG XR image in any application that supports HD Proto format (usually it shows error message that says that it can not decode image since it is not valid HDP file). What is wrong with my code?
I also have one question related to JPEG XR decoder: can I use it for decoding usual JPEG files? For now it seems that JPEG XR decoder is aimed to decompress just JPEG XR files.
Could anyone help me out?
Currently I am trying to convert YUY2 image to JPEG XR format and vice versa. Here is code snippet that I use for compression:
[bash]bool Encode(const CVideoFrameIf& aSource, CVideoFrameIf& aDestination)
{
const int nOfComponents = 3;
// Prepares source image
Image srcImage;
ImageDataPtr srcDataPtr;
ImageDataOrder srcDataOrder;
ImageSamplingGeometry srcGeometry;
unsigned long srcWidth = aSource.GetWidth();
unsigned long srcHeight = aSource.GetHeight();
Rect srcRect(Point(0, 0), RectSize(srcWidth, srcHeight));
srcDataPtr.p8u = aSource.GetData();
srcDataOrder.ReAlloc(Interleaved, nOfComponents);
srcDataOrder.SetDataType(T8u);
srcDataOrder.PixelStep()[0] = nOfComponents;
srcDataOrder.LineStep() [0] = 2 * aSource.GetWidth(); // Y + U/2 + V/2
srcGeometry.ReAlloc(nOfComponents);
srcGeometry.SetEnumSampling(S422);
srcGeometry.SetRefGridRect(srcRect);
srcImage.ColorSpec().ReAlloc(nOfComponents);
srcImage.ColorSpec().SetComponentToColorMap(Direct);
srcImage.ColorSpec().SetColorSpecMethod(Enumerated);
srcImage.ColorSpec().SetEnumColorSpace(YCbCr);
for(int i = 0; i < nOfComponents; i++)
{
srcImage.ColorSpec().DataRange().SetAsRange8u(IPP_MAX_8U);
}
if( UIC::ExcStatusOk != srcImage.Buffer().Attach(&srcDataPtr, srcDataOrder, srcGeometry))
{
mLastError = "Could not attach data to image buffer";
return false;
}
if( UIC::ExcStatusOk != mEncoder.AttachImage(srcImage) )
{
mLastError = "Could not attach image to the encoder";
return false;
}
// Prepares destination image
CMemBuffOutput memBuf;
if( !BaseStream::IsOk( memBuf.Open(aDestination.GetData(), aDestination.GetFrameSize() ) ) )
{
mLastError = "Could not initialize memory buffer";
return false;
}
if( UIC::ExcStatusOk != mEncoder.AttachStream(memBuf) )
{
mLastError = "Could not attach stream";
return false;
}
// Adjusts encoder parameters
InputParams params;
Ipp16u tilesUniform[4] = {1, 1, 0, 0};
params.iQuality = GetQuality();
params.iOverlap = 0; // No Filter
params.iBands = 0; // All Bands
params.iSampling = 1; // 422
params.bAlphaPlane = 0; // No alpha plane
params.pTilesUniform = tilesUniform;
params.iTrim = 0;
params.iShift = 0;
params.bFrequency = 0;
params.bCMYKD = 0;
if( UIC::ExcStatusOk != mEncoder.SetParams(params) )
{
mLastError = "Could not set encoder parameters";
return false;
}
if( UIC::ExcStatusOk != mEncoder.WriteFileHeader(params.bAlphaPlane) )
{
mLastError = "Could not write file header";
return false;
}
if( UIC::ExcStatusOk != mEncoder.WriteHeader() )
{
mLastError = "Could not write image header";
return false;
}
if( UIC::ExcStatusOk != mEncoder.WriteData() )
{
mLastError = "Could not write data";
return false;
}
if( UIC::ExcStatusOk != mEncoder.FreeData() )
{
mLastError = "Could not free data";
return false;
}
}[/bash]
JPEG XR encoder seems to work fine (i.e. without errors). However, I cannot open result JPEG XR image in any application that supports HD Proto format (usually it shows error message that says that it can not decode image since it is not valid HDP file). What is wrong with my code?
I also have one question related to JPEG XR decoder: can I use it for decoding usual JPEG files? For now it seems that JPEG XR decoder is aimed to decompress just JPEG XR files.
Could anyone help me out?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In IPP UIC framework JPEG-XR decoder designed to decode only JPEG-XR files (same as JPEG-XR encoder will produce only JPEG-XR files). If you need to process JPEG files please check UIC JPEG codec (similar, UIC JPEG2000 codec for JPEG2000 files)
Note, JPEG-XR encoder does not support input as YUY2 format, you should resample it to 4:4:4 before encoding.
Regards,
Vladimir
In IPP UIC framework JPEG-XR decoder designed to decode only JPEG-XR files (same as JPEG-XR encoder will produce only JPEG-XR files). If you need to process JPEG files please check UIC JPEG codec (similar, UIC JPEG2000 codec for JPEG2000 files)
Note, JPEG-XR encoder does not support input as YUY2 format, you should resample it to 4:4:4 before encoding.
Regards,
Vladimir
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In IPP UIC framework JPEG-XR decoder designed to decode only JPEG-XR files (same as JPEG-XR encoder will produce only JPEG-XR files). If you need to process JPEG files please check UIC JPEG codec (similar, UIC JPEG2000 codec for JPEG2000 files)
Note, JPEG-XR encoder does not support input as YUY2 format, you should resample it to 4:4:4 before encoding.
Regards,
Vladimir
In IPP UIC framework JPEG-XR decoder designed to decode only JPEG-XR files (same as JPEG-XR encoder will produce only JPEG-XR files). If you need to process JPEG files please check UIC JPEG codec (similar, UIC JPEG2000 codec for JPEG2000 files)
Note, JPEG-XR encoder does not support input as YUY2 format, you should resample it to 4:4:4 before encoding.
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you. I've already found out that it is impossible to use YUY2 as encoder input or decoder output format for JPEG XR codec implementation. Is it restriction of JPEG XR format specification? If not, could you share your plans about further development of JPEG XR codec? Are you going to add YUY2 support in the future?
Thank you. I've already found out that it is impossible to use YUY2 as encoder input or decoder output format for JPEG XR codec implementation. Is it restriction of JPEG XR format specification? If not, could you share your plans about further development of JPEG XR codec? Are you going to add YUY2 support in the future?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is definetely not restriction of JPEG-XR specification. We do not have an immediate plans to develop any new functionality in our UIC JPEG-XR implementation, so I would recommend you to review UIC JPEG codec implementation to extact an idea of how YUY2 support was implemented in UIC JPEG codec and modify UIC JPEG-XR accordingly. Remember - it is a sample code, you are free to modify and customize it for your application needs.
Regards,
Vladimir
Regards,
Vladimir

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page