History

avfilter/vf_framerate: refine the filter_slice code for better readiablity

Limin Wang committed 7 years ago

Commit fd5fdca1 parent b4e7d3a2 files · +16 −22Browse files

Showing the changes to libavfilter (2 of 2 files). Show all

Unified · Split

2 files
  1. libavfilter/framerate.h +1 −0
  2. libavfilter/vf_framerate.c +15 −22
libavfilter/framerate.h+1−0
@@ -43,6 +43,7 @@ typedef struct FrameRateContext { · 42 unmodified lines
4343 int interp_end; ///< end of range to apply linear interpolation
4444
4545 int line_size[4]; ///< bytes of pixel data per line for each plane
46+ int height[4]; ///< height of each plane
4647 int vsub;
4748
4849 AVRational srce_time_base; ///< timebase of source
libavfilter/vf_framerate.c+15−22
@@ -95,29 +95,22 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) · 94 unmodified lines
9595 {
9696 FrameRateContext *s = ctx->priv;
9797 ThreadData *td = arg;
98+ AVFrame *work = s->work;
99+ AVFrame *src1 = td->copy_src1;
100+ AVFrame *src2 = td->copy_src2;
98101 uint16_t src1_factor = td->src1_factor;
99102 uint16_t src2_factor = td->src2_factor;
100103 int plane;
101104
102− for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
103− int cpy_line_width = s->line_size[plane];
104− uint8_t *cpy_src1_data = td->copy_src1->data[plane];
105− int cpy_src1_line_size = td->copy_src1->linesize[plane];
106− uint8_t *cpy_src2_data = td->copy_src2->data[plane];
107− int cpy_src2_line_size = td->copy_src2->linesize[plane];
108− int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
109− uint8_t *cpy_dst_data = s->work->data[plane];
110− int cpy_dst_line_size = s->work->linesize[plane];
111− const int start = (cpy_src_h * job ) / nb_jobs;
112− const int end = (cpy_src_h * (job+1)) / nb_jobs;
113− cpy_src1_data += start * cpy_src1_line_size;
114− cpy_src2_data += start * cpy_src2_line_size;
115− cpy_dst_data += start * cpy_dst_line_size;
116−
117− s->blend(cpy_src1_data, cpy_src1_line_size,
118− cpy_src2_data, cpy_src2_line_size,
119− cpy_dst_data, cpy_dst_line_size,
120− cpy_line_width, end - start,
105+ for (plane = 0; plane < 4 && src1->data[plane] && src2->data[plane]; plane++) {
106+ const int start = (s->height[plane] * job ) / nb_jobs;
107+ const int end = (s->height[plane] * (job+1)) / nb_jobs;
108+ uint8_t *src1_data = src1->data[plane] + start * src1->linesize[plane];
109+ uint8_t *src2_data = src2->data[plane] + start * src2->linesize[plane];
110+ uint8_t *dst_data = work->data[plane] + start * work->linesize[plane];
111+
112+ s->blend(src1_data, src1->linesize[plane], src2_data, src2->linesize[plane],
113+ dst_data, work->linesize[plane], s->line_size[plane], end - start,
121114 src1_factor, src2_factor, s->blend_factor_max >> 1);
122115 }
123116
@@ -293,13 +286,13 @@ static int config_input(AVFilterLink *inlink) · 169 unmodified lines
293286 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
294287 int plane;
295288
289+ s->vsub = pix_desc->log2_chroma_h;
296290 for (plane = 0; plane < 4; plane++) {
297− s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,
298− plane);
291+ s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w, plane);
292+ s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? s->vsub : 0);
299293 }
300294
301295 s->bitdepth = pix_desc->comp[0].depth;
302− s->vsub = pix_desc->log2_chroma_h;
303296
304297 s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
305298 if (!s->sad)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t