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
43 int interp_end; ///< end of range to apply linear interpolation43 int interp_end; ///< end of range to apply linear interpolation
44 44
45 int line_size[4]; ///< bytes of pixel data per line for each plane45 int line_size[4]; ///< bytes of pixel data per line for each plane
46 int height[4]; ///< height of each plane
46 int vsub;47 int vsub;
47 48
48 AVRational srce_time_base; ///< timebase of source49 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
95{95{
96 FrameRateContext *s = ctx->priv;96 FrameRateContext *s = ctx->priv;
97 ThreadData *td = arg;97 ThreadData *td = arg;
98 AVFrame *work = s->work;
99 AVFrame *src1 = td->copy_src1;
100 AVFrame *src2 = td->copy_src2;
98 uint16_t src1_factor = td->src1_factor;101 uint16_t src1_factor = td->src1_factor;
99 uint16_t src2_factor = td->src2_factor;102 uint16_t src2_factor = td->src2_factor;
100 int plane;103 int plane;
101 104
102 for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {105 for (plane = 0; plane < 4 && src1->data[plane] && src2->data[plane]; plane++) {
103 int cpy_line_width = s->line_size[plane];106 const int start = (s->height[plane] * job ) / nb_jobs;
104 uint8_t *cpy_src1_data = td->copy_src1->data[plane];107 const int end = (s->height[plane] * (job+1)) / nb_jobs;
105 int cpy_src1_line_size = td->copy_src1->linesize[plane];108 uint8_t *src1_data = src1->data[plane] + start * src1->linesize[plane];
106 uint8_t *cpy_src2_data = td->copy_src2->data[plane];109 uint8_t *src2_data = src2->data[plane] + start * src2->linesize[plane];
107 int cpy_src2_line_size = td->copy_src2->linesize[plane];110 uint8_t *dst_data = work->data[plane] + start * work->linesize[plane];
108 int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);111
109 uint8_t *cpy_dst_data = s->work->data[plane];112 s->blend(src1_data, src1->linesize[plane], src2_data, src2->linesize[plane],
110 int cpy_dst_line_size = s->work->linesize[plane];113 dst_data, work->linesize[plane], s->line_size[plane], end - start,
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,
121 src1_factor, src2_factor, s->blend_factor_max >> 1);114 src1_factor, src2_factor, s->blend_factor_max >> 1);
122 }115 }
123 116
@@ -293,13 +286,13 @@ static int config_input(AVFilterLink *inlink) · 169 unmodified lines
293 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);286 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
294 int plane;287 int plane;
295 288
289 s->vsub = pix_desc->log2_chroma_h;
296 for (plane = 0; plane < 4; plane++) {290 for (plane = 0; plane < 4; plane++) {
297 s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,291 s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w, plane);
298 plane);292 s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? s->vsub : 0);
299 }293 }
300 294
301 s->bitdepth = pix_desc->comp[0].depth;295 s->bitdepth = pix_desc->comp[0].depth;
302 s->vsub = pix_desc->log2_chroma_h;
303 296
304 s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);297 s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
305 if (!s->sad)298 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