[RFC] Request for pixdesc API review
Hi, we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}. pixdescs API is the designated replacement for the hackish PixFmtInfo system defined in libavcodec/imgconvert.c, and it may be used, once completed, at least by lavfi and lsws code. Since now mainly just Micheal and me worked on it, before pixdescs API can be published, we need, as suggested by Michael, a review of the new API from some other developer, especially to get sure that it is clear enough and we are not missing pieces. See the thread: http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/99224 In particular I plan to move it back to lavc and start to replace the functions using PixFmtInfo with corresponding functions using pixdescs, then once this will be done I plan to move it again to lavu and enable it. Comments are very welcome. Regards. -- FFmpeg = Fierce and Faboulous Magical Pitiless Erratic God
Hi, On Sun, Nov 8, 2009 at 12:35 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}.
Seems pretty sane on a first glance. What exactly are you looking for in our comments? What is the BITSTREAM flag? Is it the same as "no padding to align each pixel to the byte"? Some explanation there would help me, I'd have to look at the code to see what it does. Any timeline on when swscale will use this? Thanks! Ronald
On date Monday 2009-11-09 12:05:15 -0500, Ronald S. Bultje encoded:
Hi,
On Sun, Nov 8, 2009 at 12:35 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}.
Seems pretty sane on a first glance. What exactly are you looking for in our comments?
If it is clear, if it is expressive enough to do what we currently do with PixFmtInfo (that's already true) and possibly more, for example I would like to avoid all that switch (pix_fmt) case PIX_FMT_FOO stuff, if it can be managed more generically. For example adding a pixel format shouldn't require to edit all the functions dealing with pixel format stuff, it should be sufficient to hook up the description to the pixel format descriptions array. That would also make a lot easier to implement more generic lavfi filters. I suspect it still lacks something in that regard, but I feel like we'll discover it only re-implementing imgconvert.c functions making use of it.
What is the BITSTREAM flag? Is it the same as "no padding to align each pixel to the byte"? Some explanation there would help me, I'd have to look at the code to see what it does.
Yes a bitstream format is basically a format for which the component associated to a pixel is not byte aligned, typical examples are monowhite and monoblack, this flag also affects how some fields are interpreted (for example step_minus1).
Any timeline on when swscale will use this?
Well, once pixdesc API will be public it should be possible to trivially remove duplicated code (e.g. USE_PAL() and sws_format_name()), and should be possible to use the pixdesc descriptions to perform operations in a more generic way, note that I'm not volunteering for this so it won't depend on me.
Thanks!
Regards. -- FFmpeg = Faithful and Frenzy Magnificient Powered Elaborated Gospel
On Mon, Nov 09, 2009 at 10:40:23PM +0100, Stefano Sabatini wrote:
On date Monday 2009-11-09 12:05:15 -0500, Ronald S. Bultje encoded:
Hi,
On Sun, Nov 8, 2009 at 12:35 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}.
Seems pretty sane on a first glance. What exactly are you looking for in our comments?
If it is clear, if it is expressive enough to do what we currently do with PixFmtInfo (that's already true) and possibly more, for example I would like to avoid all that switch (pix_fmt) case PIX_FMT_FOO stuff, if it can be managed more generically.
For example adding a pixel format shouldn't require to edit all the functions dealing with pixel format stuff, it should be sufficient to hook up the description to the pixel format descriptions array.
yes but there always will be obscure formats the generic code cant handle, its also not its goal. Goal is to handle the normal 98%. Some things that shuffle bits around in ways that need several pages to explain (hello apple) is not something that i care about, such things can better be considered very poorly designed codec bitsterams rather than pixel formats. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato
On date Monday 2009-11-09 23:07:35 +0100, Michael Niedermayer encoded:
On Mon, Nov 09, 2009 at 10:40:23PM +0100, Stefano Sabatini wrote: [...]
For example adding a pixel format shouldn't require to edit all the functions dealing with pixel format stuff, it should be sufficient to hook up the description to the pixel format descriptions array.
yes but there always will be obscure formats the generic code cant handle, its also not its goal. Goal is to handle the normal 98%. Some things that shuffle bits around in ways that need several pages to explain (hello apple) is not something that i care about, such things can better be considered very poorly designed codec bitsterams rather than pixel formats.
I'm perfectly fine with this consideration, note that there isn't any of the current supported formats which requires special handling, we could reserve a flag (PIX_FMT_SPECIAL) for such formats. Regards. -- FFmpeg = Freak and Faboulous Mere Puritan Elected Glue
On date Monday 2009-11-09 12:05:15 -0500, Ronald S. Bultje encoded: [...]
What is the BITSTREAM flag? Is it the same as "no padding to align each pixel to the byte"? Some explanation there would help me, I'd have to look at the code to see what it does.
Is the attached patch somehow clarifying? Regards. -- FFmpeg = Friendly and Fierce MultiPurpose Exploitable Game
On Mon, Nov 23, 2009 at 09:48:49PM +0100, Stefano Sabatini wrote:
On date Monday 2009-11-09 12:05:15 -0500, Ronald S. Bultje encoded: [...]
What is the BITSTREAM flag? Is it the same as "no padding to align each pixel to the byte"? Some explanation there would help me, I'd have to look at the code to see what it does.
Is the attached patch somehow clarifying?
Regards. -- FFmpeg = Friendly and Fierce MultiPurpose Exploitable Game
pixdesc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 52983fe25db2467e1fa075ebff291e9e258dc7bb clarify-pix-desc-bistream.patch Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-23 21:05:53.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-23 21:21:39.000000000 +0100 @@ -86,7 +86,11 @@
#define PIX_FMT_BE 1 ///< Pixel format is big-endian. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette. -#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +/** + * All values of a component are bit-wise packed end to end, that is, + * the bits of the component values are not byte-aligned.
i for one dont consider this better [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting.
On date Monday 2009-11-23 22:44:57 +0100, Michael Niedermayer encoded:
On Mon, Nov 23, 2009 at 09:48:49PM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-23 21:05:53.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-23 21:21:39.000000000 +0100 @@ -86,7 +86,11 @@
#define PIX_FMT_BE 1 ///< Pixel format is big-endian. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette. -#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +/** + * All values of a component are bit-wise packed end to end, that is, + * the bits of the component values are not byte-aligned.
i for one dont consider this better
Well then I'd say patch dropped, unless someone else wants to suggest something better. Regards. -- FFmpeg = Frenzy Faithful Muttering Powered Easy Glue
Hi, On Nov, 2009, at 6:28 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it
wrote: On date Monday 2009-11-23 22:44:57 +0100, Michael Niedermayer encoded:
On Mon, Nov 23, 2009 at 09:48:49PM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-23 21:05:53.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-23 21:21:39.000000000 +0100 @@ -86,7 +86,11 @@
#define PIX_FMT_BE 1 ///< Pixel format is big-endian. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data [1], values are indexes in this palette. -#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +/** + * All values of a component are bit-wise packed end to end, that is, + * the bits of the component values are not byte-aligned.
i for one dont consider this better
Well then I'd say patch dropped, unless someone else wants to suggest something better.
Data is not byte-aligned per pixel? Ronald
On date Tuesday 2009-11-24 19:02:17 -0500, Ronald S. Bultje encoded:
Hi,
On Nov, 2009, at 6:28 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
On date Monday 2009-11-23 22:44:57 +0100, Michael Niedermayer encoded:
On Mon, Nov 23, 2009 at 09:48:49PM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-23 21:05:53.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-23 21:21:39.000000000 +0100 @@ -86,7 +86,11 @@
#define PIX_FMT_BE 1 ///< Pixel format is big-endian. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data [1], values are indexes in this palette. -#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +/** + * All values of a component are bit-wise packed end to end, that is, + * the bits of the component values are not byte-aligned.
i for one dont consider this better
Well then I'd say patch dropped, unless someone else wants to suggest something better.
Data is not byte-aligned per pixel?
Yes per pixel they are, but not per pixel component. Regards. -- FFmpeg = Fantastic and Faithless Multimedia Patchable Encoding/decoding God
Hi, On Nov 24, 2009, at 8:11 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it
wrote: On date Tuesday 2009-11-24 19:02:17 -0500, Ronald S. Bultje encoded:
Hi,
On Nov, 2009, at 6:28 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
On date Monday 2009-11-23 22:44:57 +0100, Michael Niedermayer encoded:
On Mon, Nov 23, 2009 at 09:48:49PM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/libavutil/pixdesc.h === ================================================================ --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-23 21:05:53.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-23 21:21:39.000000000 +0100 @@ -86,7 +86,11 @@
#define PIX_FMT_BE 1 ///< Pixel format is big-endian. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data [1], values are indexes in this palette. -#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +/** + * All values of a component are bit-wise packed end to end, that is, + * the bits of the component values are not byte-aligned.
i for one dont consider this better
Well then I'd say patch dropped, unless someone else wants to suggest something better.
Data is not byte-aligned per pixel?
Yes per pixel they are, but not per pixel component.
There you go, add that and you're done. In fact, now I know what the flag means w/o looking at the code. Ronald
On date Tuesday 2009-11-24 21:30:22 -0500, Ronald S. Bultje encoded:
Hi,
On Nov 24, 2009, at 8:11 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
On date Tuesday 2009-11-24 19:02:17 -0500, Ronald S. Bultje encoded:
Hi,
On Nov, 2009, at 6:28 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
On date Monday 2009-11-23 22:44:57 +0100, Michael Niedermayer encoded:
On Mon, Nov 23, 2009 at 09:48:49PM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/libavutil/pixdesc.h === ================================================================ --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-23 21:05:53.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-23 21:21:39.000000000 +0100 @@ -86,7 +86,11 @@
#define PIX_FMT_BE 1 ///< Pixel format is big-endian. #define PIX_FMT_PAL 2 ///< Pixel format has a palette in data [1], values are indexes in this palette. -#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +/** + * All values of a component are bit-wise packed end to end, that is, + * the bits of the component values are not byte-aligned.
i for one dont consider this better
Well then I'd say patch dropped, unless someone else wants to suggest something better.
Data is not byte-aligned per pixel?
Yes per pixel they are, but not per pixel component.
There you go, add that and you're done. In fact, now I know what the flag means w/o looking at the code.
Mmmh thinking again at it, saying that "for bitstream formats the bits composing a pixel are byte-aligned, but the bits composing a component are not" is neither correct (think at monow/monob) neither particularly clear, since I can't find better words for describing it I'll leave the docs as they are. Regards. -- FFmpeg = Foolish and Furious Mega Puritan Ecumenical Gospel
Hi Stefano, On Thu, Dec 3, 2009 at 8:03 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
Mmmh thinking again at it, saying that "for bitstream formats the bits composing a pixel are byte-aligned, but the bits composing a component are not" is neither correct (think at monow/monob) neither particularly clear, since I can't find better words for describing it I'll leave the docs as they are.
Better to fix it, but think of a better desc. Do monob/w have this flag set? If not, maybe "format where data for individual pixels is byte-aligned, but their individual color components are not". If it is, then "format where data for individual pixels or their individual color components are not byte-aligned". Ronald
On date Sunday 2009-11-08 18:35:43 +0100, Stefano Sabatini encoded:
Hi,
we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}.
pixdescs API is the designated replacement for the hackish PixFmtInfo system defined in libavcodec/imgconvert.c, and it may be used, once completed, at least by lavfi and lsws code.
Since now mainly just Micheal and me worked on it, before pixdescs API can be published, we need, as suggested by Michael, a review of the new API from some other developer, especially to get sure that it is clear enough and we are not missing pieces.
See the thread: http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/99224
In particular I plan to move it back to lavc and start to replace the functions using PixFmtInfo with corresponding functions using pixdescs, then once this will be done I plan to move it again to lavu and enable it.
Comments are very welcome.
Some considerations. * In attachment a patch to make more clear the use of the log2_chroma_w and log2_chroma_h fields. The doxy addition reflects a limitation we have in the API. This is not a problem with all the currently supported pixel formats, but could be a problem when supporting other possibly weird formats. I don't think this will be a problem, at least I have not experience of a pixel format which would break with our constraints, but I would like to hear the opinion of someone with more expertise with pixel formats than me. * I also wonder if: int av_get_bits_per_pixel(enum PixelFormat pix_fmt); would be preferable to the current: bits = av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt]); The first signature is easier to use in the most common scenario, when the user has the pix_fmt and she wants to extracts the bits: bits = av_get_bits_per_pixel(pix_fmt); which is far simpler than: bits = av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt]); * In order to prove that the API is expressive enough, I rewrote ff_fill_linesize() and ff_fill_pointer() in imgconvert.c to make use of pixdescs, the experiment resulted in code more generic and functionally equivalent to the old one (it requires some patches I posted today), sample patch attached. That said I consider the pixdesc API good enough to be exported. Regards. -- FFmpeg = Foolish & Frightening Magnificient Power Eccentric Gem
On Mon, Nov 16, 2009 at 12:43:02AM +0100, Stefano Sabatini wrote: [...]
pixdesc.h | 4 ++++ 1 file changed, 4 insertions(+) d60486d284ea2688ea83ef088ef8d858fbb1a367 clarify-log2-chroma.patch Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-16 00:09:44.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-16 00:11:10.000000000 +0100 @@ -62,6 +62,8 @@ * For YV12 this is 1 for example. * chroma_width = -((-luma_width) >> log2_chroma_w) * The note above is needed to ensure rounding up. + * This value only refers to the components 1 and 2 in the + * descriptor. */ uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
it refers to chroma as its name says, i think thats clear already [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
On date Tuesday 2009-11-17 14:51:09 +0100, Michael Niedermayer encoded:
On Mon, Nov 16, 2009 at 12:43:02AM +0100, Stefano Sabatini wrote: [...]
pixdesc.h | 4 ++++ 1 file changed, 4 insertions(+) d60486d284ea2688ea83ef088ef8d858fbb1a367 clarify-log2-chroma.patch Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-16 00:09:44.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-16 00:11:10.000000000 +0100 @@ -62,6 +62,8 @@ * For YV12 this is 1 for example. * chroma_width = -((-luma_width) >> log2_chroma_w) * The note above is needed to ensure rounding up. + * This value only refers to the components 1 and 2 in the + * descriptor. */ uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
it refers to chroma as its name says, i think thats clear already
But it's not immediately obvious that the chroma components are stored in comp[1] and comp[2]. Alternatively we could have a bit in the component telling if the component is a chroma component, what about it? Regards. -- FFmpeg = Funny and Fundamentalist Meaningful Puristic Elitarian Gorilla
On Tue, Nov 17, 2009 at 04:24:16PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-11-17 14:51:09 +0100, Michael Niedermayer encoded:
On Mon, Nov 16, 2009 at 12:43:02AM +0100, Stefano Sabatini wrote: [...]
pixdesc.h | 4 ++++ 1 file changed, 4 insertions(+) d60486d284ea2688ea83ef088ef8d858fbb1a367 clarify-log2-chroma.patch Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-16 00:09:44.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-16 00:11:10.000000000 +0100 @@ -62,6 +62,8 @@ * For YV12 this is 1 for example. * chroma_width = -((-luma_width) >> log2_chroma_w) * The note above is needed to ensure rounding up. + * This value only refers to the components 1 and 2 in the + * descriptor. */ uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
it refers to chroma as its name says, i think thats clear already
But it's not immediately obvious that the chroma components are stored in comp[1] and comp[2].
well, then commit that change [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle
On date Tuesday 2009-11-17 16:24:16 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-11-17 14:51:09 +0100, Michael Niedermayer encoded:
On Mon, Nov 16, 2009 at 12:43:02AM +0100, Stefano Sabatini wrote: [...]
pixdesc.h | 4 ++++ 1 file changed, 4 insertions(+) d60486d284ea2688ea83ef088ef8d858fbb1a367 clarify-log2-chroma.patch Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-16 00:09:44.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-16 00:11:10.000000000 +0100 @@ -62,6 +62,8 @@ * For YV12 this is 1 for example. * chroma_width = -((-luma_width) >> log2_chroma_w) * The note above is needed to ensure rounding up. + * This value only refers to the components 1 and 2 in the + * descriptor. */ uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
it refers to chroma as its name says, i think thats clear already
But it's not immediately obvious that the chroma components are stored in comp[1] and comp[2].
Alternatively we could have a bit in the component telling if the component is a chroma component, what about it?
I thought a little more about this other option, I have a slight preference for it since it provides more expressivity to the pixdesc, allowing to say for example if a pixel format contains chroma components. Also it *slightly* simplifies expressions of the kind: s = (i == 1 || i == 2) ? expr(log2_chroma) : 0; which become: s = pixdesc->comp[i]->is_chroma ? expr(log2_chroma) ? 0; or simply: s = comp->is_chroma ? expr(log2_chroma) : 0; I prefer the latter forms since are more explicit, and so more readable. Sample patch attached. Regards. -- FFmpeg = Fostering Fierce Moronic Pure Evanescent God
On Wed, Nov 18, 2009 at 12:47:00AM +0100, Stefano Sabatini wrote:
s = comp->is_chroma ? expr(log2_chroma) : 0;
If you're adding per-component type information, why don't you go all the way and say its full type (R, G, B, Y, U, V, etc). That would make the structure a full replacement of the constant in the aimed for 95% of the cases, instead of needing the constant to do the mapping. Makes a mostly generic convert-to-rgb possible. Also, I notice you can't handle 32-bits component values (I'm thinking floating point here). Intentional? OG.
On date Wednesday 2009-11-18 06:41:50 +0100, Olivier Galibert encoded: [...]
If you're adding per-component type information, why don't you go all the way and say its full type (R, G, B, Y, U, V, etc). That would make the structure a full replacement of the constant in the aimed for 95% of the cases, instead of needing the constant to do the mapping. Makes a mostly generic convert-to-rgb possible.
That was already discussed: http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/90053 [...] Regards. -- FFmpeg = Faithful and Fundamentalist Minimalistic Pitiless Elastic Game
On date Wednesday 2009-11-18 06:41:50 +0100, Olivier Galibert encoded: [...]
Also, I notice you can't handle 32-bits component values (I'm thinking floating point here). Intentional?
We have a current limit of 16 bits per value. We currently don't support pixel formats which require more than 16 bits per component values, this would require more space but then we'll be more future proof. Michael? Regards. -- FFmpeg = Forgiving Faboulous MultiPurpose Efficient Gadget
On Sat, Nov 21, 2009 at 04:43:10PM +0100, Stefano Sabatini wrote:
On date Wednesday 2009-11-18 06:41:50 +0100, Olivier Galibert encoded: [...]
Also, I notice you can't handle 32-bits component values (I'm thinking floating point here). Intentional?
We have a current limit of 16 bits per value.
We currently don't support pixel formats which require more than 16 bits per component values, this would require more space but then we'll be more future proof.
Michael?
which codecs in practice use >16bit ? (and no i dont care about computer rendered anything) I would like to avoid overshooting the goal and over abstracting things pixdesc should be useable, i dont want a get_line return double precission floats or some arbitrary precission stuff and thats where you end when you try to support everything. And yes i know linear 16bit and probably 32bit too arent enough to cover the human eyes dynamic range. I just think that going beyond 16bit is a too big step. i would suggest we try it with 16bit first (>8bit is still pretty new stuff) we can always increase it and introduce a pix desc2. But doing it now means additional weight on every piece of code that accesses pixels through this system because it all must handle the larger range. But iam open to reconsider this if there actually is a real usecase for
16bit. Allowing 32bit int would probably not be that much of an issue 32bit float though would be a big issue.
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
On date Sunday 2009-11-22 00:05:59 +0100, Michael Niedermayer encoded:
On Sat, Nov 21, 2009 at 04:43:10PM +0100, Stefano Sabatini wrote:
On date Wednesday 2009-11-18 06:41:50 +0100, Olivier Galibert encoded: [...]
Also, I notice you can't handle 32-bits component values (I'm thinking floating point here). Intentional?
We have a current limit of 16 bits per value.
We currently don't support pixel formats which require more than 16 bits per component values, this would require more space but then we'll be more future proof.
Michael?
which codecs in practice use >16bit ? (and no i dont care about computer rendered anything)
I would like to avoid overshooting the goal and over abstracting things pixdesc should be useable, i dont want a get_line return double precission floats or some arbitrary precission stuff and thats where you end when you try to support everything.
And yes i know linear 16bit and probably 32bit too arent enough to cover the human eyes dynamic range. I just think that going beyond 16bit is a too big step. i would suggest we try it with 16bit first (>8bit is still pretty new stuff) we can always increase it and introduce a pix desc2. But doing it now means additional weight on every piece of code that accesses pixels through this system because it all must handle the larger range.
But iam open to reconsider this if there actually is a real usecase for
16bit. Allowing 32bit int would probably not be that much of an issue 32bit float though would be a big issue.
I would mildly prefer to use 32 bit int but then I have no usecase for it, so I'm pretty happy with the current 16 bits. Regards. -- FFmpeg = Fiendish and Faithful Mere Peaceless Ecumenical Gymnast
On Wed, Nov 18, 2009 at 12:47:00AM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-11-17 16:24:16 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-11-17 14:51:09 +0100, Michael Niedermayer encoded:
On Mon, Nov 16, 2009 at 12:43:02AM +0100, Stefano Sabatini wrote: [...]
pixdesc.h | 4 ++++ 1 file changed, 4 insertions(+) d60486d284ea2688ea83ef088ef8d858fbb1a367 clarify-log2-chroma.patch Index: ffmpeg/libavutil/pixdesc.h =================================================================== --- ffmpeg.orig/libavutil/pixdesc.h 2009-11-16 00:09:44.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.h 2009-11-16 00:11:10.000000000 +0100 @@ -62,6 +62,8 @@ * For YV12 this is 1 for example. * chroma_width = -((-luma_width) >> log2_chroma_w) * The note above is needed to ensure rounding up. + * This value only refers to the components 1 and 2 in the + * descriptor. */ uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
it refers to chroma as its name says, i think thats clear already
But it's not immediately obvious that the chroma components are stored in comp[1] and comp[2].
Alternatively we could have a bit in the component telling if the component is a chroma component, what about it?
I thought a little more about this other option, I have a slight preference for it since it provides more expressivity to the pixdesc, allowing to say for example if a pixel format contains chroma components.
Also it *slightly* simplifies expressions of the kind: s = (i == 1 || i == 2) ? expr(log2_chroma) : 0;
which become: s = pixdesc->comp[i]->is_chroma ? expr(log2_chroma) ? 0;
thats not a simplification thats hugely worse code, the compiler can unroll and optimize away the first but not the second also it wastes the last spare bit in 16bits [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment.
On date Wednesday 2009-11-18 18:14:30 +0100, Michael Niedermayer encoded:
On Wed, Nov 18, 2009 at 12:47:00AM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-11-17 16:24:16 +0100, Stefano Sabatini encoded: [...]
Alternatively we could have a bit in the component telling if the component is a chroma component, what about it?
I thought a little more about this other option, I have a slight preference for it since it provides more expressivity to the pixdesc, allowing to say for example if a pixel format contains chroma components.
Also it *slightly* simplifies expressions of the kind: s = (i == 1 || i == 2) ? expr(log2_chroma) : 0;
which become: s = pixdesc->comp[i]->is_chroma ? expr(log2_chroma) ? 0;
thats not a simplification thats hugely worse code, the compiler can unroll and optimize away the first but not the second also it wastes the last spare bit in 16bits
So another attempt at clarifying docs. Regards. -- FFmpeg = Furious Fundamental Mere Portable Enigmatic Ghost
On Wed, Nov 18, 2009 at 08:35:24PM +0100, Stefano Sabatini wrote:
On date Wednesday 2009-11-18 18:14:30 +0100, Michael Niedermayer encoded:
On Wed, Nov 18, 2009 at 12:47:00AM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-11-17 16:24:16 +0100, Stefano Sabatini encoded: [...]
Alternatively we could have a bit in the component telling if the component is a chroma component, what about it?
I thought a little more about this other option, I have a slight preference for it since it provides more expressivity to the pixdesc, allowing to say for example if a pixel format contains chroma components.
Also it *slightly* simplifies expressions of the kind: s = (i == 1 || i == 2) ? expr(log2_chroma) : 0;
which become: s = pixdesc->comp[i]->is_chroma ? expr(log2_chroma) ? 0;
thats not a simplification thats hugely worse code, the compiler can unroll and optimize away the first but not the second also it wastes the last spare bit in 16bits
So another attempt at clarifying docs.
Regards. -- FFmpeg = Furious Fundamental Mere Portable Enigmatic Ghost
pixdesc.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 02afdc28486127adab09ff324f159f3f649b54e5 clarify-docs-for-chroma-comp.patch
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I wish the Xiph folks would stop pretending they've got something they do not. Somehow I fear this will remain a wish. -- M?ns Rullg?rd
On date Wednesday 2009-11-18 22:50:10 +0100, Michael Niedermayer encoded:
On Wed, Nov 18, 2009 at 08:35:24PM +0100, Stefano Sabatini wrote: [...]
So another attempt at clarifying docs.
Regards. -- FFmpeg = Furious Fundamental Mere Portable Enigmatic Ghost
pixdesc.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 02afdc28486127adab09ff324f159f3f649b54e5 clarify-docs-for-chroma-comp.patch
ok
Applied. -- FFmpeg = Fierce Fundamentalist Mystic Prodigious Elitarian God
On date Monday 2009-11-16 00:43:02 +0100, Stefano Sabatini encoded:
On date Sunday 2009-11-08 18:35:43 +0100, Stefano Sabatini encoded: [...] * In order to prove that the API is expressive enough, I rewrote ff_fill_linesize() and ff_fill_pointer() in imgconvert.c to make use of pixdescs, the experiment resulted in code more generic and functionally equivalent to the old one (it requires some patches I posted today), sample patch attached.
Some more consideration about expressivity. PixFmtInfo contains the color_type value which can assume these values: FF_COLOR_RGB FF_COLOR_GRAY FF_COLOR_YUV FF_COLOR_YUV_JPEG FF_PIXEL_PLANAR FF_PIXEL_PACKED we came to the conclusion that colorspace information don't belong to pixdesc, so some of these informations cannot be put in the pixdesc, we could still add some macros in imgconvert.c and use them and still be able to dump PixFmtInfo, would be this acceptable? Similarly for the PixFmtInfo.is_alpha field we could either use a PIX_FMT_ALPHA flag (not sure this is a good idea, afterall this may be considered as a colorspace info) or use some macro. Comments are welcome. -- FFmpeg = Fast Fundamental Murdering Problematic Earthshaking God
On date Saturday 2009-11-21 17:00:58 +0100, Stefano Sabatini encoded: [...]
PixFmtInfo contains the color_type value which can assume these values: FF_COLOR_RGB FF_COLOR_GRAY FF_COLOR_YUV FF_COLOR_YUV_JPEG FF_PIXEL_PLANAR FF_PIXEL_PACKED
we came to the conclusion that colorspace information don't belong to pixdesc, so some of these informations cannot be put in the pixdesc, we could still add some macros in imgconvert.c and use them and still be able to dump PixFmtInfo, would be this acceptable?
Similarly for the PixFmtInfo.is_alpha field we could either use a PIX_FMT_ALPHA flag (not sure this is a good idea, afterall this may be considered as a colorspace info) or use some macro.
I just want to add that of course we can keep the PixFmtInfo struct, so no need to remove that, we can just remove what will result useless when the pixdescs will be used. Regards. -- FFmpeg = Fostering & Funny Mind-dumbing Plastic Enlightening Gadget
On date Monday 2009-11-16 00:43:02 +0100, Stefano Sabatini encoded: [...]
* I also wonder if: int av_get_bits_per_pixel(enum PixelFormat pix_fmt);
would be preferable to the current: bits = av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt]);
The first signature is easier to use in the most common scenario, when the user has the pix_fmt and she wants to extracts the bits: bits = av_get_bits_per_pixel(pix_fmt);
which is far simpler than: bits = av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt]);
First of all note that I consider this a very minor issue, after some thought I concluded that I like the best av_get_bits_per_pixel(pix_desc) since it is more flexible (for example it allows to compute the bits-per-pixel value of a pixdesc not defined in the av_pix_fmt_descriptors array). But at the same time maybe would be useful a function of the kind: int av_get_bits_per_pixel2(enum PixelFormat pix_fmt) { return av_get_bits_per_pixel(&av_pix_fmt_descriptors[pix_fmt]); } which is easier to use for most use cases. But then as I said this is a very minor minor issue, so I'm reasonably happy also without it and someone (hi michael) may say that such an av_get_bits_per_pixel2 stuff is only good for bloating the API. Regards. -- FFmpeg = Faithful and Fierce Mere Pitiful Exxagerate Guide
On date Sunday 2009-11-08 18:35:43 +0100, Stefano Sabatini encoded:
Hi,
we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}.
pixdescs API is the designated replacement for the hackish PixFmtInfo system defined in libavcodec/imgconvert.c, and it may be used, once completed, at least by lavfi and lsws code.
Since now mainly just Micheal and me worked on it, before pixdescs API can be published, we need, as suggested by Michael, a review of the new API from some other developer, especially to get sure that it is clear enough and we are not missing pieces. [...]
If there are no further comments then maybe it's come the time to make pixdescs public. Is OK to apply the attached patch? -- FFmpeg = Foolish and Fantastic Magnificient Puritan Erratic Gospel
On Sun, Nov 22, 2009 at 12:59:38AM +0100, Stefano Sabatini wrote:
On date Sunday 2009-11-08 18:35:43 +0100, Stefano Sabatini encoded:
Hi,
we recently got completed all the definitions for the pixel format descriptors in libavutil/pixdesc.{h,c}.
pixdescs API is the designated replacement for the hackish PixFmtInfo system defined in libavcodec/imgconvert.c, and it may be used, once completed, at least by lavfi and lsws code.
Since now mainly just Micheal and me worked on it, before pixdescs API can be published, we need, as suggested by Michael, a review of the new API from some other developer, especially to get sure that it is clear enough and we are not missing pieces. [...]
If there are no further comments then maybe it's come the time to make pixdescs public.
Is OK to apply the attached patch? -- FFmpeg = Foolish and Fantastic Magnificient Puritan Erratic Gospel
Makefile | 2 ++ avutil.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) a468fc34a0c0c68785dd808f119b228efa353e1e make-pixdesc-api-public.patch
ok, unless i missed some objections from anyone [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
On date Monday 2009-11-23 00:55:12 +0100, Michael Niedermayer encoded:
On Sun, Nov 22, 2009 at 12:59:38AM +0100, Stefano Sabatini wrote: [...]
If there are no further comments then maybe it's come the time to make pixdescs public.
Is OK to apply the attached patch? [...] ok, unless i missed some objections from anyone
Applied. -- FFmpeg = Faboulous and Fostering Muttering Philosofic Exciting Geisha
participants (4)
-
galibert@pobox.com -
michaelni@gmx.at -
rsbultje@gmail.com -
stefano.sabatini-lala@poste.it