[Ffmpeg-devel] [PATCH] BMP encoder

Michael Niedermayer michaelni
Mon Oct 30 16:56:54 CET 2006


Hi

On Mon, Oct 30, 2006 at 04:05:39PM +0100, Michel Bardiaux wrote:
> Currently, only straight RGB.
[...]
> +    init_put_bits(&s->pb, buf, buf_size);
> +    // STRUCTURE.field refer to the MSVC documentation
> +    // BITMAPFILEHEADER.bfType
> +    put_bits(&s->pb, 8, 'B');
> +    put_bits(&s->pb, 8, 'M');
> +    // BITMAPFILEHEADER.bfSize
> +    write32(&s->pb, n_bytes);
> +    // BITMAPFILEHEADER.bfReserved1
> +    write16(&s->pb, 0);
> +    // BITMAPFILEHEADER.bfReserved2
> +    write16(&s->pb, 0);
> +    // BITMAPFILEHEADER.bfOffBits
> +    write32(&s->pb, 14 /* BITMAPFILEHEADER */ + 40);
> +    // BITMAPINFOHEADER.biSize
> +    write32(&s->pb, 40);
> +    // BITMAPINFOHEADER.biWidth
> +    write32(&s->pb, avctx->width);
> +    // BITMAPINFOHEADER.biHeight
> +    write32(&s->pb, avctx->height);
> +    // BITMAPINFOHEADER.biPlanes
> +    write16(&s->pb, 1);
> +    // BITMAPINFOHEADER.biBitCount
> +    write16(&s->pb, 24);
> +    // BITMAPINFOHEADER.biCompression
> +    write32(&s->pb, BMP_RGB);
> +    // BITMAPINFOHEADER.biSizeImage
> +    write32(&s->pb, n_bytes_image);
> +    // BITMAPINFOHEADER.biXPelsPerMeter
> +    write32(&s->pb, 0);
> +    // BITMAPINFOHEADER.biYPelsPerMeter
> +    write32(&s->pb, 0);
> +    // BITMAPINFOHEADER.biClrUsed
> +    write32(&s->pb, 0);
> +    // BITMAPINFOHEADER.biClrImportant

see put_bmp_header()


> +    write32(&s->pb, 0);
> +    // BMP files are bottom-to-top
> +    ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
> +    linesize = -p->linesize[0];
> +    for(i = 0; i < avctx->height; i++){
> +        uint8_t *src = ptr;
> +        int n = 0;
> +        for(j=0;j<avctx->width;j++) {
> +            put_bits(&s->pb, 8, src[0]);
> +            put_bits(&s->pb, 8, src[1]);
> +            put_bits(&s->pb, 8, src[2]);

using the bitstream reader for a purely byte based format is unacceptable
(reason is that its several times slower and more complex)


> +            src += 3;
> +            n += 3;
> +        }
> +        for(;n<n_bytes_per_row;n++) put_bits(&s->pb, 8, 0);
> +        ptr += linesize;
> +    }
> +    return n_bytes;
> +}

[...]

> Index: libavcodec/amr.c
> ===================================================================
> --- libavcodec/amr.c	(revision 6838)
> +++ libavcodec/amr.c	(working copy)
> @@ -57,6 +57,8 @@
>  
>  #include "avcodec.h"
>  
> +#if defined(CONFIG_AMR_NB) || defined(CONFIG_AMR_NB_FIXED)
> +
>  #ifdef CONFIG_AMR_NB_FIXED
>  
>  #define MMS_IO
> @@ -494,8 +496,6 @@
>  
>  #endif
>  
> -#if defined(CONFIG_AMR_NB) || defined(CONFIG_AMR_NB_FIXED)
> -
>  AVCodec amr_nb_decoder =
>  {
>      "amr_nb",

huh? what is this?

[...]

-- 
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