avfilter/vf_framerate: add SIMD functions for frame blending
Blend function speedups on x86_64 Core i5 4460:
ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
C: 447548411 decicycles in Blend, 2048 runs, 0 skips
SSSE3: 130020087 decicycles in Blend, 2048 runs, 0 skips
AVX2: 128508221 decicycles in Blend, 2048 runs, 0 skips
ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null none
C: 228932745 decicycles in Blend, 2048 runs, 0 skips
SSE4: 123357781 decicycles in Blend, 2048 runs, 0 skips
AVX2: 121215353 decicycles in Blend, 2048 runs, 0 skips
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-08 02:05:45 +02:00
|
|
|
/*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVFILTER_FRAMERATE_H
|
|
|
|
#define AVFILTER_FRAMERATE_H
|
|
|
|
|
2018-04-05 01:37:25 +02:00
|
|
|
#include "scene_sad.h"
|
avfilter/vf_framerate: add SIMD functions for frame blending
Blend function speedups on x86_64 Core i5 4460:
ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
C: 447548411 decicycles in Blend, 2048 runs, 0 skips
SSSE3: 130020087 decicycles in Blend, 2048 runs, 0 skips
AVX2: 128508221 decicycles in Blend, 2048 runs, 0 skips
ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null none
C: 228932745 decicycles in Blend, 2048 runs, 0 skips
SSE4: 123357781 decicycles in Blend, 2048 runs, 0 skips
AVX2: 121215353 decicycles in Blend, 2048 runs, 0 skips
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-08 02:05:45 +02:00
|
|
|
#include "avfilter.h"
|
|
|
|
|
|
|
|
#define BLEND_FUNC_PARAMS const uint8_t *src1, ptrdiff_t src1_linesize, \
|
|
|
|
const uint8_t *src2, ptrdiff_t src2_linesize, \
|
|
|
|
uint8_t *dst, ptrdiff_t dst_linesize, \
|
|
|
|
ptrdiff_t width, ptrdiff_t height, \
|
|
|
|
int factor1, int factor2, int half
|
|
|
|
|
2019-09-24 12:18:09 +02:00
|
|
|
#define BLEND_FACTOR_DEPTH(n) (n-1)
|
avfilter/vf_framerate: add SIMD functions for frame blending
Blend function speedups on x86_64 Core i5 4460:
ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
C: 447548411 decicycles in Blend, 2048 runs, 0 skips
SSSE3: 130020087 decicycles in Blend, 2048 runs, 0 skips
AVX2: 128508221 decicycles in Blend, 2048 runs, 0 skips
ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null none
C: 228932745 decicycles in Blend, 2048 runs, 0 skips
SSE4: 123357781 decicycles in Blend, 2048 runs, 0 skips
AVX2: 121215353 decicycles in Blend, 2048 runs, 0 skips
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-08 02:05:45 +02:00
|
|
|
|
|
|
|
typedef void (*blend_func)(BLEND_FUNC_PARAMS);
|
|
|
|
|
|
|
|
typedef struct FrameRateContext {
|
|
|
|
const AVClass *class;
|
|
|
|
// parameters
|
|
|
|
AVRational dest_frame_rate; ///< output frames per second
|
|
|
|
int flags; ///< flags affecting frame rate conversion algorithm
|
|
|
|
double scene_score; ///< score that denotes a scene change has happened
|
|
|
|
int interp_start; ///< start 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
|
2019-09-24 12:18:08 +02:00
|
|
|
int height[4]; ///< height of each plane
|
avfilter/vf_framerate: add SIMD functions for frame blending
Blend function speedups on x86_64 Core i5 4460:
ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
C: 447548411 decicycles in Blend, 2048 runs, 0 skips
SSSE3: 130020087 decicycles in Blend, 2048 runs, 0 skips
AVX2: 128508221 decicycles in Blend, 2048 runs, 0 skips
ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null none
C: 228932745 decicycles in Blend, 2048 runs, 0 skips
SSE4: 123357781 decicycles in Blend, 2048 runs, 0 skips
AVX2: 121215353 decicycles in Blend, 2048 runs, 0 skips
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-08 02:05:45 +02:00
|
|
|
int vsub;
|
|
|
|
|
|
|
|
AVRational srce_time_base; ///< timebase of source
|
|
|
|
AVRational dest_time_base; ///< timebase of destination
|
|
|
|
|
2018-04-05 01:37:25 +02:00
|
|
|
ff_scene_sad_fn sad; ///< Sum of the absolute difference function (scene detect only)
|
avfilter/vf_framerate: add SIMD functions for frame blending
Blend function speedups on x86_64 Core i5 4460:
ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
C: 447548411 decicycles in Blend, 2048 runs, 0 skips
SSSE3: 130020087 decicycles in Blend, 2048 runs, 0 skips
AVX2: 128508221 decicycles in Blend, 2048 runs, 0 skips
ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null none
C: 228932745 decicycles in Blend, 2048 runs, 0 skips
SSE4: 123357781 decicycles in Blend, 2048 runs, 0 skips
AVX2: 121215353 decicycles in Blend, 2048 runs, 0 skips
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-08 02:05:45 +02:00
|
|
|
double prev_mafd; ///< previous MAFD (scene detect only)
|
|
|
|
|
|
|
|
int blend_factor_max;
|
|
|
|
int bitdepth;
|
|
|
|
AVFrame *work;
|
|
|
|
|
|
|
|
AVFrame *f0; ///< last frame
|
|
|
|
AVFrame *f1; ///< current frame
|
|
|
|
int64_t pts0; ///< last frame pts in dest_time_base
|
|
|
|
int64_t pts1; ///< current frame pts in dest_time_base
|
|
|
|
int64_t delta; ///< pts1 to pts0 delta
|
|
|
|
double score; ///< scene change score (f0 to f1)
|
|
|
|
int flush; ///< 1 if the filter is being flushed
|
|
|
|
int64_t start_pts; ///< pts of the first output frame
|
|
|
|
int64_t n; ///< output frame counter
|
|
|
|
|
|
|
|
blend_func blend;
|
|
|
|
} FrameRateContext;
|
|
|
|
|
|
|
|
void ff_framerate_init(FrameRateContext *s);
|
|
|
|
void ff_framerate_init_x86(FrameRateContext *s);
|
|
|
|
|
|
|
|
#endif /* AVFILTER_FRAMERATE_H */
|