[FFmpeg-devel] sgi without rle

Michael Niedermayer michaelni
Wed Sep 30 17:40:52 CEST 2009


On Wed, Sep 30, 2009 at 10:56:08AM +0200, Anne-Laure de Smit wrote:
> On Wed, Sep 30, 2009 at 10:29 AM, Benoit Fouet <benoit.fouet at free.fr> wrote:
> 
> > Hi,
> >
> > On 2009-09-30 09:54, Anne-Laure de Smit wrote:
> > > On Thu, Sep 24, 2009 at 10:43 AM, Anne-Laure de Smit <
> > > annelaure.desmit at gmail.com> wrote:
> > >
> > >>
> > >> On Thu, Sep 17, 2009 at 11:40 PM, Vitor Sessak <vitor1001 at gmail.com
> > >wrote:
> > >>
> > >>> Anne-Laure de Smit wrote:
> > >>>
> > >>>> Hi,
> > >>>>
> > >>>> I want to modify sgienc.c for that image sgi are not compressed
> > (without
> > >>>> rle). How can I do this?
> > >>>>
> > >>> First of all, look at sgidec.c to see in what compressed and
> > uncompressed
> > >>> sgi images differs (and how uncompressed data is stored). Then, you
> > need a
> > >>> way to specify through the command line if the user want compression or
> > not.
> > >>> I suggest  "-compression_level" command line parameter that will set
> > >>> avctx->compression_level (as is done in tiffenc.c). Then, finally, in
> > >>> encode_frame(), just write the uncompressed data to the buffer if the
> > >>> avctx->compression_level is set to zero.
> > >>>
> > >>> -Vitor
> > >>>
> > >> Thank you very much for your help.
> > >> I propose the attached patch.
> > >> For use it:
> > >> Uncompressed images:
> > >> ffmpeg -i file.bmp -compression_level 0 out.sgi
> > >> RLE compressed images:
> > >> ffmpeg -i file.bmp -compression_level 1 out.sgi
> > >>
> > >> Anne-Laure
> > >>
> > >> Ping.
> >
> > > Index: libavcodec/sgienc.c
> > > ===================================================================
> > > --- libavcodec/sgienc.c       (revision 20008)
> > > +++ libavcodec/sgienc.c       (working copy)
> > > @@ -83,7 +83,7 @@
> > >
> > >      /* Encode header. */
> > >      bytestream_put_be16(&buf, SGI_MAGIC);
> > > -    bytestream_put_byte(&buf, 1); /* RLE */
> > > +    bytestream_put_byte(&buf, avctx->compression_level != 0); /* RLE
> > > 1 - VERBATIM 0*/
> >
> > 0 */
> >
> > > @@ -139,6 +140,20 @@
> > >      }
> > >
> > >      av_free(encode_buf);
> > > +    } else {
> > > +        for (z = 0; z < depth; z++) {
> > > +            in_buf = p->data[0] + p->linesize[0] * (height - 1) + z;
> > > +
> > > +            for (y = 0; y < height; y++) {
> > > +
> > > +                for (x = 0; x < width; x++)
> > > +                    bytestream_put_byte(&buf,in_buf[depth * x]);
> > > +
> > > +                in_buf -= p->linesize[0];
> >
> > how about the following:
> >
> > for (x = 0; x < width*depth; x += depth)
> >    bytestream_put_byte(&buf,in_buf[x]);
> >
> > Ben
> >
> 
> Yes you're right, it's the same thing but I used the same syntax that the
> code before. But Maybe your code is better, clearer. I changed my patch with
> your code.
> Anne-Laure
> 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at mplayerhq.hu
> > https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
> >

>  sgienc.c |   17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> f41298e71ed5b2eb8c72d01b3cd2aebc9d8de8b3  sgienc.patch
> Index: libavcodec/sgienc.c
> ===================================================================
> --- libavcodec/sgienc.c	(revision 20008)
> +++ libavcodec/sgienc.c	(working copy)
> @@ -83,7 +83,7 @@
>  
>      /* Encode header. */
>      bytestream_put_be16(&buf, SGI_MAGIC);
> -    bytestream_put_byte(&buf, 1); /* RLE */
> +    bytestream_put_byte(&buf, avctx->compression_level != 0); /* RLE 1 - VERBATIM 0*/

we have coder_type, FF_CODER_TYPE_RAW and FF_CODER_TYPE_RLE


[...]
> @@ -139,6 +140,20 @@
>      }
>  
>      av_free(encode_buf);
> +    } else {
> +        for (z = 0; z < depth; z++) {
> +            in_buf = p->data[0] + p->linesize[0] * (height - 1) + z;
> +
> +            for (y = 0; y < height; y++) {
> +

> +                for (x = 0; x < width; x++)
> +                    bytestream_put_byte(&buf,in_buf[depth * x]);

bytestream_put_buffer()

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

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090930/e867dfae/attachment.pgp>



More information about the ffmpeg-devel mailing list