[FFmpeg-devel] [PATCH]Fix 1bit bmp decoding

Michael Niedermayer michaelni at gmx.at
Thu Nov 10 20:26:28 CET 2011


On Thu, Nov 10, 2011 at 08:21:50PM +0100, Reimar Döffinger wrote:
> On Thu, Nov 10, 2011 at 08:12:42PM +0100, Michael Niedermayer wrote:
> > On Thu, Nov 10, 2011 at 06:10:04PM +0100, Carl Eugen Hoyos wrote:
> > > Hi!
> > > 
> > > Attached fixes ticket #632 for me, it does not break the output of
> > > ffmpeg -i tests/lena.pnm -pix_fmt monob out.bmp
> > > but I don't know if 1-bit bmp without palette exists / how it can be created.
> > > 
> > > Please comment, Carl Eugen
> > 
> > >  bmp.c |   22 ++++++++++++++++++----
> > >  1 file changed, 18 insertions(+), 4 deletions(-)
> > > a86b7387b0e8439d7177dafba9004482cf1b7431  patch1bitbmp.diff
> > > diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
> > > index 0b38724..22973aa 100644
> > > --- a/libavcodec/bmp.c
> > > +++ b/libavcodec/bmp.c
> > > @@ -171,17 +171,15 @@ static int bmp_decode_frame(AVCodecContext *avctx,
> > >          else
> > >              avctx->pix_fmt = PIX_FMT_GRAY8;
> > >          break;
> > > +    case 1:
> > >      case 4:
> > >          if(hsize - ihsize - 14 > 0){
> > >              avctx->pix_fmt = PIX_FMT_PAL8;
> > >          }else{
> > > -            av_log(avctx, AV_LOG_ERROR, "Unknown palette for 16-colour BMP\n");
> > > +            av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth);
> > >              return -1;
> > >          }
> > >          break;
> > > -    case 1:
> > > -        avctx->pix_fmt = PIX_FMT_MONOBLACK;
> > 
> > can the palette be analyzed and MONOWHITE / BLACK be used ?
> > if so, it would be simpler
> 
> I agree that it would be nicer in principle, however it
> unfortunately is not a proper, final solution since the
> palette can just as well be red/green or whatever, not necessarily
> either black and white or white and black.

i expected that already :(
the patch is fine then.
black/white detection could be added afterwards though if someone
wants

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

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please
-------------- 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/20111110/67a36f4e/attachment.asc>


More information about the ffmpeg-devel mailing list