avfilter/vf_framerate: refine the filter_slice code for better readiablity
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
b4e7d3a0db
commit
fd5fdca953
@ -43,6 +43,7 @@ typedef struct FrameRateContext {
|
|||||||
int interp_end; ///< end of range to apply linear interpolation
|
int interp_end; ///< end of range to apply linear interpolation
|
||||||
|
|
||||||
int line_size[4]; ///< bytes of pixel data per line for each plane
|
int line_size[4]; ///< bytes of pixel data per line for each plane
|
||||||
|
int height[4]; ///< height of each plane
|
||||||
int vsub;
|
int vsub;
|
||||||
|
|
||||||
AVRational srce_time_base; ///< timebase of source
|
AVRational srce_time_base; ///< timebase of source
|
||||||
|
@ -95,29 +95,22 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
|
|||||||
{
|
{
|
||||||
FrameRateContext *s = ctx->priv;
|
FrameRateContext *s = ctx->priv;
|
||||||
ThreadData *td = arg;
|
ThreadData *td = arg;
|
||||||
|
AVFrame *work = s->work;
|
||||||
|
AVFrame *src1 = td->copy_src1;
|
||||||
|
AVFrame *src2 = td->copy_src2;
|
||||||
uint16_t src1_factor = td->src1_factor;
|
uint16_t src1_factor = td->src1_factor;
|
||||||
uint16_t src2_factor = td->src2_factor;
|
uint16_t src2_factor = td->src2_factor;
|
||||||
int plane;
|
int plane;
|
||||||
|
|
||||||
for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
|
for (plane = 0; plane < 4 && src1->data[plane] && src2->data[plane]; plane++) {
|
||||||
int cpy_line_width = s->line_size[plane];
|
const int start = (s->height[plane] * job ) / nb_jobs;
|
||||||
uint8_t *cpy_src1_data = td->copy_src1->data[plane];
|
const int end = (s->height[plane] * (job+1)) / nb_jobs;
|
||||||
int cpy_src1_line_size = td->copy_src1->linesize[plane];
|
uint8_t *src1_data = src1->data[plane] + start * src1->linesize[plane];
|
||||||
uint8_t *cpy_src2_data = td->copy_src2->data[plane];
|
uint8_t *src2_data = src2->data[plane] + start * src2->linesize[plane];
|
||||||
int cpy_src2_line_size = td->copy_src2->linesize[plane];
|
uint8_t *dst_data = work->data[plane] + start * work->linesize[plane];
|
||||||
int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
|
|
||||||
uint8_t *cpy_dst_data = s->work->data[plane];
|
|
||||||
int cpy_dst_line_size = s->work->linesize[plane];
|
|
||||||
const int start = (cpy_src_h * job ) / nb_jobs;
|
|
||||||
const int end = (cpy_src_h * (job+1)) / nb_jobs;
|
|
||||||
cpy_src1_data += start * cpy_src1_line_size;
|
|
||||||
cpy_src2_data += start * cpy_src2_line_size;
|
|
||||||
cpy_dst_data += start * cpy_dst_line_size;
|
|
||||||
|
|
||||||
s->blend(cpy_src1_data, cpy_src1_line_size,
|
s->blend(src1_data, src1->linesize[plane], src2_data, src2->linesize[plane],
|
||||||
cpy_src2_data, cpy_src2_line_size,
|
dst_data, work->linesize[plane], s->line_size[plane], end - start,
|
||||||
cpy_dst_data, cpy_dst_line_size,
|
|
||||||
cpy_line_width, end - start,
|
|
||||||
src1_factor, src2_factor, s->blend_factor_max >> 1);
|
src1_factor, src2_factor, s->blend_factor_max >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,13 +286,13 @@ static int config_input(AVFilterLink *inlink)
|
|||||||
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
|
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
|
||||||
int plane;
|
int plane;
|
||||||
|
|
||||||
|
s->vsub = pix_desc->log2_chroma_h;
|
||||||
for (plane = 0; plane < 4; plane++) {
|
for (plane = 0; plane < 4; plane++) {
|
||||||
s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,
|
s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w, plane);
|
||||||
plane);
|
s->height[plane] = inlink->h >> ((plane == 1 || plane == 2) ? s->vsub : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->bitdepth = pix_desc->comp[0].depth;
|
s->bitdepth = pix_desc->comp[0].depth;
|
||||||
s->vsub = pix_desc->log2_chroma_h;
|
|
||||||
|
|
||||||
s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
|
s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
|
||||||
if (!s->sad)
|
if (!s->sad)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user