[FFmpeg-devel] [PATCH 2/2] lavc/gif: make possible to disable cropping.

Clément Bœsch ubitux at gmail.com
Sat Apr 20 00:44:19 CEST 2013


On Fri, Apr 19, 2013 at 01:48:13PM +0200, Clément Bœsch wrote:
> ---
>  libavcodec/gif.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/gif.c b/libavcodec/gif.c
> index 92c7e59..ad4f08b 100644
> --- a/libavcodec/gif.c
> +++ b/libavcodec/gif.c
> @@ -50,7 +50,8 @@ typedef struct {
>  } GIFContext;
>  
>  enum {
> -    GF_LZW = 1<<0,
> +    GF_LZW  = 1<<0,
> +    GF_CROP = 1<<1,
>  };
>  
>  static int gif_image_write_image(AVCodecContext *avctx,
> @@ -65,7 +66,7 @@ static int gif_image_write_image(AVCodecContext *avctx,
>  
>      /* Crop image */
>      // TODO support with palette change
> -    if (s->last_frame && !palette) {
> +    if ((s->flags & GF_CROP) && s->last_frame && !palette) {
>          const uint8_t *ref = s->last_frame->data[0];
>          const int ref_linesize = s->last_frame->linesize[0];
>          int x_end = avctx->width  - 1,
> @@ -270,8 +271,9 @@ static int gif_encode_close(AVCodecContext *avctx)
>  #define OFFSET(x) offsetof(GIFContext, x)
>  #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
>  static const AVOption gif_options[] = {
> -    { "gifflags", "set GIF flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = GF_LZW}, 0, INT_MAX, FLAGS, "flags" },
> +    { "gifflags", "set GIF flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = GF_LZW|GF_CROP}, 0, INT_MAX, FLAGS, "flags" },
>          { "lzw", "enable LZW compression", 0, AV_OPT_TYPE_CONST, {.i64=GF_LZW}, INT_MIN, INT_MAX, FLAGS, "flags" },
> +        { "crop", "enable crop detection", 0, AV_OPT_TYPE_CONST, {.i64=GF_CROP}, INT_MIN, INT_MAX, FLAGS, "flags" },
>      { NULL }
>  };
>  

Patch applied, with the naming "offsetting" instead since it seems more
common.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130420/bbd1833e/attachment.asc>


More information about the ffmpeg-devel mailing list