[RFC] Handling 8 < bit depth < 16
Bit depths greater than 8 and less than 16 are inherently problematic. We only have pixel formats for 8 and 16, but in practice, many encoders want numbers like 10. Furthermore, a proper converter between these numbers should dither, making conversion slightly less than trivial. Thus, imagine the following situation: Decode 16-bit RGB files from camera Convert to 16-bit YUV Pass to 10-bit x264 Encode Somewhere in here, we have to go from 16 bit to 10 bit, but there's no pixel format for these, nor is there a way for libx264.c in ffmpeg to tell ffmpeg that it needs 10-bit. But it would be stupid, ugly, and hacky to have libx264 itself perform the conversion -- pixel format conversions should stay out of an encoder. And this doesn't solve the problem of other encoders; x264 isn't the only encoder that does or we want to have >8-bit support for. What's the best approach here? Dark Shikari
On Sat, Sep 04, 2010 at 07:25:12PM -0700, Jason Garrett-Glaser wrote:
Bit depths greater than 8 and less than 16 are inherently problematic. We only have pixel formats for 8 and 16, but in practice, many encoders want numbers like 10. Furthermore, a proper converter between these numbers should dither, making conversion slightly less than trivial. Thus, imagine the following situation:
Decode 16-bit RGB files from camera Convert to 16-bit YUV Pass to 10-bit x264 Encode
Somewhere in here, we have to go from 16 bit to 10 bit, but there's no pixel format for these, nor is there a way for libx264.c in ffmpeg to tell ffmpeg that it needs 10-bit. But it would be stupid, ugly, and hacky to have libx264 itself perform the conversion -- pixel format conversions should stay out of an encoder. And this doesn't solve the problem of other encoders; x264 isn't the only encoder that does or we want to have >8-bit support for.
What's the best approach here?
Introduce new format and join bikeshedding about 10-bit format representation (IIRC we have two different raw 10-bpp decoders already).
Dark Shikari
On date Sunday 2010-09-05 08:53:29 +0300, Kostya encoded:
On Sat, Sep 04, 2010 at 07:25:12PM -0700, Jason Garrett-Glaser wrote:
Bit depths greater than 8 and less than 16 are inherently problematic. We only have pixel formats for 8 and 16, but in practice, many encoders want numbers like 10. Furthermore, a proper converter between these numbers should dither, making conversion slightly less than trivial. Thus, imagine the following situation:
Decode 16-bit RGB files from camera Convert to 16-bit YUV Pass to 10-bit x264 Encode
Somewhere in here, we have to go from 16 bit to 10 bit, but there's no pixel format for these, nor is there a way for libx264.c in ffmpeg to tell ffmpeg that it needs 10-bit. But it would be stupid, ugly, and hacky to have libx264 itself perform the conversion -- pixel format conversions should stay out of an encoder. And this doesn't solve the problem of other encoders; x264 isn't the only encoder that does or we want to have >8-bit support for.
What's the best approach here?
Introduce new format and join bikeshedding about 10-bit format representation (IIRC we have two different raw 10-bpp decoders already).
Yes, if these formats can be represented by a pixel format descriptor then they should be defined in pixfmt.h/pixdesc.h and convertion utilities added to libswscale, otherwise they should be considered like coded formats. Regards. -- FFmpeg = Fancy Fascinating Most Portable Elected Governor
On Sat, Sep 04, 2010 at 07:25:12PM -0700, Jason Garrett-Glaser wrote:
Somewhere in here, we have to go from 16 bit to 10 bit, but there's no pixel format for these, nor is there a way for libx264.c in ffmpeg to tell ffmpeg that it needs 10-bit.
Well, if we can manage, provide an extra API that not only allows selecting a pixel format but also allows selecting bits_per_raw_sample. I'm not sure a extra 10-bit pixel format is a good idea, since often just considering 10 bit == 16 bit would be good enough and a lot faster. Also since no memory layout change is involved and there's a lot of different methods you may or may not want to use in that conversion I think it would be better to do this via libavfilter. Does libavfilter have a bits_per_raw_sample already in each place where it uses a pixel format? Of course for the start it would be possible to just have a filter like e.g. dither=source_bits:dst_bits.
On Sun, Sep 05, 2010 at 11:30:14AM +0200, Reimar D?ffinger wrote:
On Sat, Sep 04, 2010 at 07:25:12PM -0700, Jason Garrett-Glaser wrote:
Somewhere in here, we have to go from 16 bit to 10 bit, but there's no pixel format for these, nor is there a way for libx264.c in ffmpeg to tell ffmpeg that it needs 10-bit.
Well, if we can manage, provide an extra API that not only allows selecting a pixel format but also allows selecting bits_per_raw_sample.
yes, thats my oppinion too [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus
participants (5)
-
darkshikari@gmail.com -
kostya.shishkov@gmail.com -
michaelni@gmx.at -
Reimar.Doeffinger@gmx.de -
stefano.sabatini-lala@poste.it