Re: C : how to export raw YUV to a file ?
From: DEMAINE Benoit-Pierre (nntp_pipex_at_demaine.info)
Date: 10/06/04
- Next message: Dave Agans: "Debugging book and poster"
- Previous message: Michael J. Fromberger: "Re: location of the smallest element in a max-heap"
- In reply to: Arthur J. O'Dwyer: "Re: C : how to export raw YUV to a file ?"
- Next in thread: Willem: "Re: C : how to export raw YUV to a file ?"
- Reply: Willem: "Re: C : how to export raw YUV to a file ?"
- Reply: Arthur J. O'Dwyer: "Re: C : how to export raw YUV to a file ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 06 Oct 2004 03:34:17 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
| Here's a question for you: Why do PGP signatures always wind up in the
| body text of Usenet posts? Hasn't someone written a PGP client that can
| put the ugly stuff in headers where I don't have to look at it unless I
| want to?
I use mozilla thunderbird, and it never show PGP headers, exept when
they are commented as you just did :(
It simply notify valid or non valid PGP header somewhere above the
message by a specific icon.
| Okay, so you have two basic questions here: (1) How do I write an image
| to disk as a PNG-format file? (2) How do I deal with YUV images, as
| opposed to the more "canonical" (in most circles) RGB encoding?
I thought that some lib could directly export from YUV to png. Looks
like no.
~From that, I have a book which explains how to convert YUV<=>RGB. But
since I am learning clean coding, instead of doing by hand, I thought it
d be a good idear to use dedicated tools. => which lib can convert YUV
in anything else ?
| (1) Use libpng, a free PNG library available on the Web. There's a
| bare-bones example C source on my website:
| http://www.contrib.andrew.cmu.edu/~ajo/free-software/simple_png.c
| but depending on your level of expertise, it may be easier for you to
| read the libpng documentation yourself than try to figure out what my C
| routines are doing. ;)
160 lines example is what you call simple ... I dont want you to send me
a 'difficult' example ^^
I have read the man 3 libpng, and found a revealant section, but it
looks so big and complex, i guess I d make so many mistakes i d never be
able to make my code work properly.
let study the content :
what
unsigned char (*data)[3];
exactly mean ? array of pointers ?
I do not really understand how you read the file, or more precisely, how
you read the content of the picture.
oh : (*data) = malloc(*w * *h * sizeof **data);
that is interesting ... but I still do not understand what type is data :/
the part I am focussing on is:
~ for (j=0; j < h; ++j)
~ row_pointers[j] = (png_byte*)data[j*w+0];
so: data look to be an array of something, but I still do not understand
how many dimensions it has : 1 or 2 ?
in the read func, why the hell do you read data ? I thought you would
write it !
and in write, you also always read it ... what is the use of a var you
always read ???
all that remains much fuzzy to me.
***
I d just need to understand which format WritePNG() expect RGB data to
be. If i understand that, it is all done. - for now I dont.
***
| (a) Convert the YUV data to RGB data and write it to the file as RGB.
| You can find conversion formulas on the Web. This is a slightly lossy
| procedure, which means you won't be able to get back exactly the YUV
| values you started with. But that may not be a big deal.
I dont want to store RGB in file. I need a compessed format.
| (b) Just pretend YUV is RGB. For example, if you have a YUV triple
[...]
| as you remember that R=Y, G=U, and B=V.
my YUV is compleetely different than RGB. I cant assume what you say.
y= light, U = green/red V=blue/red ( IIRC)
| (c) Find an image format that supports YUV colorspace directly. AFAIK,
| the PNG format does not do YUV. I bet TIFF does, but TIFF is kind of
| cumbersome, in my opinion. Of course, you could also just dump the raw
| YUV data, if you didn't need to be able to see the pretty pictures
| outside of the application you're writing.
I could _optionally_ write data to a .yuv file, but I do not find any
documentation about their headers. I already learnt how to read headers
of .wav . But if I have to export YUV to anything, I ll do it to RGB.
- --
DEMAINE Benoît-Pierre http:/www.demaine.info/
\_o< apt-get remove ispell >o_/
There're 10 types of people: those who can count in binary and those who
can't
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBY1moGWSTLbOSw8IRAnQnAKC9G7M4GE4+2WORkU6997oFoYEUUQCfdMuR
ShCpSOSYwkn+BWhlsmoor0k=
=bQOz
-----END PGP SIGNATURE-----
- Next message: Dave Agans: "Debugging book and poster"
- Previous message: Michael J. Fromberger: "Re: location of the smallest element in a max-heap"
- In reply to: Arthur J. O'Dwyer: "Re: C : how to export raw YUV to a file ?"
- Next in thread: Willem: "Re: C : how to export raw YUV to a file ?"
- Reply: Willem: "Re: C : how to export raw YUV to a file ?"
- Reply: Arthur J. O'Dwyer: "Re: C : how to export raw YUV to a file ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|