[FFmpeg-soc] [PATCH] Move format from AVFilterBuffer to AVFilterPicRef

Stefano Sabatini stefano.sabatini-lala at poste.it
Mon Aug 2 10:58:13 CEST 2010


On date Sunday 2010-08-01 23:41:09 -0700, S.N. Hemanth Meenakshisundaram encoded:
> 
> ---
>  ffplay.c                  |    8 ++++----
>  libavfilter/avfilter.h    |    2 +-
>  libavfilter/defaults.c    |    8 ++++----
>  libavfilter/vf_overlay.c  |   12 ++++++------
>  libavfilter/vsrc_buffer.c |    2 +-
>  libavfilter/vsrc_movie.c  |    2 +-
>  6 files changed, 17 insertions(+), 17 deletions(-)
> 
> 
> 

> diff --git a/ffplay.c b/ffplay.c
> index c200119..c976f09 100644
> --- a/ffplay.c
> +++ b/ffplay.c
> @@ -1585,8 +1585,8 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic)
>      ref->w = codec->width;
>      ref->h = codec->height;
>      for(i = 0; i < 4; i ++) {
> -        unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->pic->format].log2_chroma_w : 0;
> -        unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h : 0;
> +        unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;
> +        unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;
>  
>          if (ref->data[i]) {
>              ref->data[i]    += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift);
> @@ -1617,7 +1617,7 @@ static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic)
>      }
>  
>      if ((codec->width != ref->w) || (codec->height != ref->h) ||
> -        (codec->pix_fmt != ref->pic->format)) {
> +        (codec->pix_fmt != ref->format)) {
>          av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n");
>          return -1;
>      }
> @@ -1671,7 +1671,7 @@ static int input_request_frame(AVFilterLink *link)
>      } else {
>          picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h);
>          av_picture_copy((AVPicture *)&picref->data, (AVPicture *)priv->frame,
> -                        picref->pic->format, link->w, link->h);
> +                        picref->format, link->w, link->h);
>      }
>      av_free_packet(&pkt);
>  
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index 45340b2..6625052 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -68,7 +68,6 @@ typedef struct AVFilterBuffer
>  {
>      uint8_t *data[8];           ///< buffer data for each plane
>      int linesize[8];            ///< number of bytes per line
> -    int format;                 ///< media format
>  
>      unsigned refcount;          ///< number of references to this buffer
>  
> @@ -104,6 +103,7 @@ typedef struct AVFilterPicRef
>      int linesize[4];            ///< number of bytes per line
>      int w;                      ///< image width
>      int h;                      ///< image height
> +    int format;                 ///< media format
>  
>      int64_t pts;                ///< presentation timestamp in units of 1/AV_TIME_BASE
>      int64_t pos;                ///< byte position in stream, -1 if unknown
> diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
> index 8deef93..ab7be77 100644
> --- a/libavfilter/defaults.c
> +++ b/libavfilter/defaults.c
> @@ -47,17 +47,17 @@ AVFilterPicRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms,
>      ref->perms = perms | AV_PERM_READ;
>  
>      pic->refcount = 1;
> -    pic->format   = link->format;
> +    ref->format   = link->format;
>      pic->free     = avfilter_default_free_buffer;
> -    av_fill_image_linesizes(pic->linesize, pic->format, ref->w);
> +    av_fill_image_linesizes(pic->linesize, ref->format, ref->w);
>  
>      for (i=0; i<4;i++)
>          pic->linesize[i] = FFALIGN(pic->linesize[i], 16);
>  
> -    tempsize = av_fill_image_pointers(pic->data, pic->format, ref->h, NULL, pic->linesize);
> +    tempsize = av_fill_image_pointers(pic->data, ref->format, ref->h, NULL, pic->linesize);
>      buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
>                                      // SIMD-friendly
> -    av_fill_image_pointers(pic->data, pic->format, ref->h, buf, pic->linesize);
> +    av_fill_image_pointers(pic->data, ref->format, ref->h, buf, pic->linesize);
>  
>      memcpy(ref->data,     pic->data,     sizeof(pic->data));
>      memcpy(ref->linesize, pic->linesize, sizeof(pic->linesize));
> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> index 26b9d4f..defc5b8 100644
> --- a/libavfilter/vf_overlay.c
> +++ b/libavfilter/vf_overlay.c
> @@ -210,7 +210,7 @@ static void copy_image_rgb(AVFilterPicRef *dst, int x, int y,
>      pic.data[0] += x * bpp;
>      pic.data[0] += y * pic.linesize[0];
>  
> -    if (src->pic->format == PIX_FMT_BGRA) {
> +    if (src->format == PIX_FMT_BGRA) {
>          for (y = 0; y < h; y++) {
>                    uint8_t *optr = pic.data[0]  + y * pic.linesize[0];
>              const uint8_t *iptr = src->data[0] + y * src->linesize[0];
> @@ -224,7 +224,7 @@ static void copy_image_rgb(AVFilterPicRef *dst, int x, int y,
>              }
>          }
>      } else {
> -        av_picture_copy(&pic, (AVPicture *)src->data, dst->pic->format, w, h);
> +        av_picture_copy(&pic, (AVPicture *)src->data, dst->format, w, h);
>      }
>  }
>  
> @@ -270,15 +270,15 @@ static void copy_image_yuv(AVFilterPicRef *dst, int x, int y,
>          }
>      }
>  
> -    if (src->pic->format == PIX_FMT_YUVA420P) {
> +    if (src->format == PIX_FMT_YUVA420P) {
>          int chroma_w = w>>hsub;
>          int chroma_h = h>>vsub;
> -        assert(dst->pic->format == PIX_FMT_YUV420P);
> +        assert(dst->format == PIX_FMT_YUV420P);
>          copy_blended(pic.data[0], pic.linesize[0], src->data[0], src->linesize[0], src->data[3], src->linesize[3], w, h, 0, 0);
>          copy_blended(pic.data[1], pic.linesize[1], src->data[1], src->linesize[1], src->data[3], src->linesize[3], chroma_w, chroma_h, hsub, vsub);
>          copy_blended(pic.data[2], pic.linesize[2], src->data[2], src->linesize[2], src->data[3], src->linesize[3], chroma_w, chroma_h, hsub, vsub);
>      } else {
> -        av_picture_copy(&pic, (AVPicture *)src->data, dst->pic->format, w, h);
> +        av_picture_copy(&pic, (AVPicture *)src->data, dst->format, w, h);
>      }
>  }
>  
> @@ -286,7 +286,7 @@ static void copy_image(AVFilterPicRef *dst, int x, int y,
>                         AVFilterPicRef *src, int w, int h,
>                         int bpp, int hsub, int vsub)
>  {
> -    if (dst->pic->format == PIX_FMT_YUV420P)
> +    if (dst->format == PIX_FMT_YUV420P)
>          return copy_image_yuv(dst, x, y, src, w, h, bpp, hsub, vsub);
>      else
>          return copy_image_rgb(dst, x, y, src, w, h, bpp);
> diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
> index 9e84c27..57dea94 100644
> --- a/libavfilter/vsrc_buffer.c
> +++ b/libavfilter/vsrc_buffer.c
> @@ -120,7 +120,7 @@ static int request_frame(AVFilterLink *link)
>                                         link->w, link->h);
>  
>      av_picture_copy((AVPicture *)&picref->data, (AVPicture *)&c->frame,
> -                    picref->pic->format, link->w, link->h);
> +                    picref->format, link->w, link->h);
>  
>      picref->pts             = c->pts;
>      picref->pixel_aspect    = c->pixel_aspect;
> diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
> index 5280d9d..8286535 100644
> --- a/libavfilter/vsrc_movie.c
> +++ b/libavfilter/vsrc_movie.c
> @@ -190,7 +190,7 @@ static int movie_get_frame(AVFilterLink *link)
>              // Did we get a video frame?
>              if(frame_finished) {
>                  av_picture_copy((AVPicture *)&mv->pic->data, (AVPicture *)mv->frame,
> -                                mv->pic->pic->format, link->w, link->h);
> +                                mv->pic->format, link->w, link->h);
>  
>                  // Advance in the time line
>                  mv->pic->pts = av_rescale_q(packet.pts,
> 

Looks fine.

Please post patches on ffmpeg-devel and against the main SVN, this
will simplify commit as they are meant to be applied there.

Regards. 


More information about the FFmpeg-soc mailing list