[FFmpeg-devel] [PATCH 1/2] avfilter/vf_histogram: clean up code
zhilizhao
quinkblack at foxmail.com
Sat Dec 14 09:28:11 EET 2019
Hi Paul,
> On Dec 13, 2019, at 10:00 PM, Paul B Mahol <onemda at gmail.com> wrote:
>
> Please provide some explanation.
No functional changes, just use temporary variables to make code more readable,
and may improve a little bit of performance.
>
> 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".
> _______________________________________________
> 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