[FFmpeg-devel] [PATCH] h264 - Fix PCM intra coded blocks in monochrome case

Michael Niedermayer michaelni at gmx.at
Sun Jul 10 00:30:26 CEST 2011


On Tue, Jul 05, 2011 at 01:50:32PM -0400, Jeff Downs wrote:
> Right now, in monochrome bitstreams, u & v channels in pcm intra coded
> blocks are not set to neutral values, resulting in color where there 
> should not be.
> 
> I only have an 8-bit test file, which this fixes;  extra scrutiny welcome 
> on the second hunk, which deals with >8 bit -- I think it is correct but 
> not certain.
> 
> 
> ---
>  libavcodec/h264.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)
> 
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 9265e0a..5b5895c 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -1827,8 +1827,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i
>      }
>  
>      if (!simple && IS_INTRA_PCM(mb_type)) {
> +        const int bit_depth = h->sps.bit_depth_luma;
>          if (pixel_shift) {
> -            const int bit_depth = h->sps.bit_depth_luma;
>              int j;
>              GetBitContext gb;
>              init_get_bits(&gb, (uint8_t*)h->mb, 384*bit_depth);
> @@ -1839,6 +1839,15 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i
>                      tmp_y[j] = get_bits(&gb, bit_depth);
>              }
>              if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
> +                if (!h->sps.chroma_format_idc) {
> +                    for (i = 0; i < 8; i++) {
> +                        uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize);
> +                        uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize);
> +                        for (j = 0; j < 8; j++) {
> +                            tmp_cb[j] = tmp_cr[j] = 1 << (bit_depth - 1);
> +                        }
> +                    }
> +                } else {

I think if the stream doesnt contain chroma, then PIX_FMT_GRAY* should
be used
This then woulndt contain chroma planes and wouldnt need to be cleared


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110710/04c95d9d/attachment.asc>


More information about the ffmpeg-devel mailing list