[Ffmpeg-devel] PATCH: H264 YUVJ420P

Michael Niedermayer michaelni
Wed Oct 4 22:05:11 CEST 2006


On Wed, Oct 04, 2006 at 02:50:11PM +0200, elupus wrote:
> Hi, 
> I started diagnosing some color error on some h264 files in XBMC after some
> reports from users (very minor). Then I came across two features in h264,
> one that it can contain full range YUV values (jpeg style). Also that it
> contains the coefficients that should be used for yuv->rgb conversions. 
> Here is a small patch, currently just a RFC as it's not complete for the
> conversion coefficients. 
> What whould the the best way of getting the matrix_coefficients out from the
> decoder? Probably extending the avcodec structure, adding at the end to keep
> binary compatibility? If there is a chance for such a patch to get applied,
> i'll extend it to handle mpeg12 too. If so, should I let through the
> transfer_characteristics colour_primaries too then? They are less usefull
> normally thou. 

yes everything should be exported, though i would put all the stuff in a 
AVColorspace struct and put a pointer to it in AVCodecContext that way
we can add more fields to it later, we can share these structs and they
dont bloat AVCodecContext up by oo much ...

about the coeffs themselfs, they should be AVRationals where appropriate
to keep things exact

> +        if(h->sps.full_range_flag)
> +          s->avctx->pix_fmt = PIX_FMT_YUVJ420P;
> +        else
> +          s->avctx->pix_fmt = PIX_FMT_YUV420P;

indention in ffmpeg and h264.c is 4 spaces

> +        if(sps->vui_parameters_present_flag)
> +          av_log(h->s.avctx, AV_LOG_DEBUG, "range:%s mcoef:%d\n", sps->full_range_flag ? "FULL" : "LIM", sps->matrix_coefficients);

add this to the av_log above or print it in decode_vui_parameters()
and use a terse way to display the info

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is

More information about the ffmpeg-devel mailing list