[FFmpeg-devel] [PATCH v9] lavc/rawdec: Remove monowhite switching code for 1 bpp AVI without a palette

Michael Niedermayer michael at niedermayer.cc
Sat Feb 13 00:51:00 CET 2016


On Fri, Feb 12, 2016 at 11:26:02AM +0100, Mats Peterson wrote:
> Now handles non-standard 8 bpp raw AVI files created with "-vcodec
> rawvideo" that contain the palette at the end of each frame, like
> nut.
> 
> 8 bpp raw QuickTime files created with "-vcodec rawvideo" won't work
> quite right, because they contain a palette both in the video sample
> description and at the end of each frame, which currently causes the
> stride to be calculated incorrectly. They are hugely non-standard
> anyway.
> 
> Original description follows:
> 
> This patch removes the monowhite switching code for 1 bpp raw AVI
> without a palette. I don't see any reason to keep it, since it's
> semantically incorrect to use monowhite for palettized data in my
> book, it adds unnecessary noise to the code, and it's inconsistent
> with the rest of the code in FFmpeg.
> 
> For black & white AVI or QuickTime files, in order to produce a
> monochrome nut file, force the pixel format with "-pix_fmt monow" or
> "-pix_fmt monob".
> 
> Another way is to use "ffmpeg -i 1bpp.avi -vcodec copy -vtag B1W0
> 1bpp.nut". The "-vtag" option is currently needed, otherwise FFmpeg
> will use a RGB[15] codec tag for some reason.
> 
> I have also updated the 1 bpp FATE test files (once again).
> 
> Mats
> 
> -- 
> Mats Peterson
> http://matsp888.no-ip.org/~mats/

>  libavcodec/rawdec.c               |   68 ++++++++++++++++----------------------
>  tests/ref/vsynth/vsynth1-bpp1     |    4 +-
>  tests/ref/vsynth/vsynth2-bpp1     |    4 +-
>  tests/ref/vsynth/vsynth3-bpp1     |    4 +-
>  tests/ref/vsynth/vsynth_lena-bpp1 |    4 +-
>  5 files changed, 37 insertions(+), 47 deletions(-)
> 2023febf5ae59cd14dd658c30cebeab2e10519fe  0001-lavc-rawdec-Remove-monowhite-switching-code-for-1-bp.patch
> From 1600eeb442b1ebfd56a7f8882b93db3f2076b006 Mon Sep 17 00:00:00 2001
> From: Mats Peterson <matsp888 at yahoo.com>
> Date: Fri, 12 Feb 2016 11:24:30 +0100
> Subject: [PATCH v9] lavc/rawdec: Remove monowhite switching code for 1 bpp AVI without a palette
[...]

> @@ -380,18 +365,23 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
>      }
>  
>      if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
> -        const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
> -                                                     NULL);
> -
> -        if (pal) {
> -            av_buffer_unref(&context->palette);
> -            context->palette = av_buffer_alloc(AVPALETTE_SIZE);
> -            if (!context->palette) {
> -                av_buffer_unref(&frame->buf[0]);
> -                return AVERROR(ENOMEM);
> -            }
> -            memcpy(context->palette->data, pal, AVPALETTE_SIZE);

> +        if (context->has_pkt_pal) {
> +            memcpy(context->palette->data,
> +                   avpkt->data + avpkt->size - AVPALETTE_SIZE, AVPALETTE_SIZE);

This is incorrect, the 8bit palette in nut can have any number of
entries up to 256, this assumes its fixed 256

ill try to split out some trivial parts from this patch and apply
them as seperate commits after some testing though

again, if you could help fix the bugs (which are not caused by your
patch but which interact with these changes in nasty ways)
that would be great

Thanks

[...]

-- 
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: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160213/74b75016/attachment.sig>


More information about the ffmpeg-devel mailing list