[FFmpeg-devel] [PATCH 1/2] avfilter/vf_histogram: clean up code

Paul B Mahol onemda at gmail.com
Fri Dec 13 16:00:47 EET 2019


Please provide some explanation.

On 12/13/19, quinkblack at foxmail.com <quinkblack at foxmail.com> wrote:
> From: Zhao Zhili <zhilizhao at tencent.com>
>
> ---
>  libavfilter/vf_histogram.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
> index 5185992de6..0d2d087beb 100644
> --- a/libavfilter/vf_histogram.c
> +++ b/libavfilter/vf_histogram.c
> @@ -266,20 +266,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>          const int is_chroma = (k == 1 || k == 2);
>          const int dst_h = AV_CEIL_RSHIFT(outlink->h, (is_chroma ?
> h->odesc->log2_chroma_h : 0));
>          const int dst_w = AV_CEIL_RSHIFT(outlink->w, (is_chroma ?
> h->odesc->log2_chroma_w : 0));
> +        const int plane = h->odesc->comp[k].plane;
> +        uint8_t *const data = out->data[plane];
> +        const int linesize = out->linesize[plane];
>
>          if (h->histogram_size <= 256) {
>              for (i = 0; i < dst_h ; i++)
> -                memset(out->data[h->odesc->comp[k].plane] +
> -                       i * out->linesize[h->odesc->comp[k].plane],
> -                       h->bg_color[k], dst_w);
> +                memset(data + i * linesize, h->bg_color[k], dst_w);
>          } else {
>              const int mult = h->mult;
>
> -            for (i = 0; i < dst_h ; i++)
> -                for (j = 0; j < dst_w; j++)
> -                    AV_WN16(out->data[h->odesc->comp[k].plane] +
> -                        i * out->linesize[h->odesc->comp[k].plane] + j * 2,
> -                        h->bg_color[k] * mult);
> +            for (j = 0; j < dst_w; j++)
> +                AV_WN16(data + j * 2, h->bg_color[k] * mult);
> +            for (i = 1; i < dst_h; i++)
> +                memcpy(data + i * linesize, data, dst_w * 2);
>          }
>      }
>
> --
> 2.22.0
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list