[M4IF Technotes] ´ð¸´: [M4IF Technotes] YCrCb to RGB conversion
lmwang
lmwang brovic.com
Thu May 8 10:40:30 EDT 2003
Below is my test sample to yuv2avi,for yuv420 to avi(cif), it works. Use
avilib.
#include "avilib.h"
#include "stdio.h"
/* A simple test tool of yuv2avi */
int main(int argc,char* argv[])
{
FILE* fpYUV;
char input_yuv[352*288*3/2];
avi_t* pAviHandle;
char VideoFmtYV12[4] = \ // YCrCb
{
'Y','V','1','2'
};
char VideoFmtIYUV[4] = \ // YCbCr
{
'I','Y','U','V'
};
fpYUV = fopen("test.yuv","rb");
if(!fpYUV)
{
printf("fopen failed \n");
return -1;
}
pAviHandle = AVI_open_output_file("test.avi");
if(! pAviHandle)
{
printf("avi file open failed \n");
return -1;
}
AVI_set_video(pAviHandle,352,288,25,VideoFmtIYUV);
while(!feof(fpYUV))
{
fread(input_yuv,1,352*288*3/2, fpYUV);
AVI_write_frame(pAviHandle,input_yuv,352*288*3/2);
};
// close open file
AVI_close(pAviHandle);
fclose(fpYUV);
}
Best Regards,
Limin
-----????-----
???: technotes-admin lists.m4if.org
[mailto:technotes-admin lists.m4if.org] ?? Wesley De Neve
????: 2003?5?8? 3:35
???: Rosiles Gerardo-ra9355; technotes lists.m4if.org
??: Re: [M4IF Technotes] YCrCb to RGB conversion
Hi Gerardo, Tobias, all,
Rosiles Gerardo-ra9355 wrote:
> Hi Wesley,
>
> This method is correct in DSP terms. The difference in
> implementation could be the filters that are actually used. One more
> thing to be aware of is if you are working with interlaced or
> progessive frames. The spatial relations between Chroma and Luma are
> different between the two scans. For interlaced scan a different set
> of filter taps would be required. It seems this site explains only
> the case for progressive conversions.
good to know that.
> Do the yuvtoavi tools support interlaced standard conversion?
I don't think they support deinterlacing, but I'm not sure about that
due to
the lack of documentation. The input test sequences were normally
progressive.
I'm interested in the applied formulas because there has to be a large
difference between the ones applied in the avitoyuv/yuvtoavi tools and
those
implemented by the tool as found on
http://www.ee.surrey.ac.uk/Personal/S.Worrall/dloads/yuv2avi.zip.
I did a test with the foreman test sequence in which I placed the first
frame in an AVI file by making use of yuv2avi (also doing a conversion
to
the RGB888 colorspace). After that I immediately extracted the frame in
question from the AVI file by the avitoyuv tool (doing a conversion back
from RGB888 to YCrCb). Result: Y-PSNR +/- 20 dB (and this without
compression...). Today I've seen in the history of this mailinglist that
yuv2avi indeed has some strange behaviour
(http://lists.m4if.org/pipermail/technotes/2002-July/000982.html).
As Tobias already mentioned, it's indeed better to implement those tools
by
yourself and I've done that for PSNR calculation, for RGB/YCrCb
conversion
(based on the equations as described by MSDN), and for putting YCrCb
frames
in the MOV file format (not yet for the AVI file format). On the other
hand,
I do not want to invent the wheel twice ;-).
Thanks for the replies,
Wesley
_______________________________________________
Technotes mailing list
Technotes lists.m4if.org
http://lists.m4if.org/mailman/listinfo/technotes
More information about the Mp4-tech
mailing list