78 s->fade_per_frame = (1 << 16) /
s->nb_frames;
79 s->fade_state = VF_FADE_WAITING;
81 if (
s->duration != 0) {
87 if (
s->start_frame ||
s->nb_frames) {
89 "type:%s start_frame:%d nb_frames:%d alpha:%d\n",
90 s->type ==
FADE_IN ?
"in" :
"out",
s->start_frame,
91 s->nb_frames,
s->alpha);
93 if (
s->start_time ||
s->duration) {
95 "type:%s start_time:%f duration:%f alpha:%d\n",
100 s->black_fade = !memcmp(
s->color_rgba,
"\x00\x00\x00\xff", 4);
154 const static int straight_alpha[] = {
160 int need_straight = 0;
205 int do_alpha,
int step)
208 const uint8_t r_idx =
s->rgba_map[
R];
209 const uint8_t g_idx =
s->rgba_map[
G];
210 const uint8_t b_idx =
s->rgba_map[
B];
211 const uint8_t a_idx =
s->rgba_map[
A];
212 const uint8_t *
c =
s->color_rgba;
215 uint8_t *p =
frame->data[0] +
i *
frame->linesize[0];
216 for (j = 0; j <
frame->width; j++) {
217#define INTERP(c_name, c_idx) av_clip_uint8(((c[c_idx]<<16) + ((int)p[c_name] - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)
218 p[r_idx] =
INTERP(r_idx, 0);
219 p[g_idx] =
INTERP(g_idx, 1);
220 p[b_idx] =
INTERP(b_idx, 2);
222 p[a_idx] =
INTERP(a_idx, 3);
233 const uint8_t *
c =
s->color_rgba;
236 uint8_t *pg =
frame->data[0] +
i *
frame->linesize[0];
237 uint8_t *pb =
frame->data[1] +
i *
frame->linesize[1];
238 uint8_t *pr =
frame->data[2] +
i *
frame->linesize[2];
239 uint8_t *pa =
frame->data[3] +
i *
frame->linesize[3];
240 for (j = 0; j <
frame->width; j++) {
241#define INTERPP(c_name, c_idx) av_clip_uint8(((c[c_idx]<<16) + ((int)c_name - (int)c[c_idx]) * s->factor + (1<<15)) >> 16)
259 if (
s->is_planar &&
s->alpha)
261 else if (
s->is_planar)
280 for (
int k = 0; k < 1 + 2 * (
s->is_planar &&
s->is_rgb); k++) {
282 uint8_t *p =
frame->data[k] +
i *
frame->linesize[k];
283 for (j = 0; j <
frame->width *
s->bpp; j++) {
287 *p = ((*p -
s->black_level) *
s->factor +
s->black_level_scaled) >> 16;
305 for (
int k = 0; k < 1 + 2 * (
s->is_planar &&
s->is_rgb); k++) {
307 uint16_t *p = (uint16_t *)(
frame->data[k] +
i *
frame->linesize[k]);
308 for (j = 0; j <
frame->width *
s->bpp; j++) {
312 *p = ((*p -
s->black_level) *
s->factor +
s->black_level_scaled) >> 16;
332 for (plane = 1; plane < 3; plane++) {
334 uint8_t *p =
frame->data[plane] +
i *
frame->linesize[plane];
335 for (j = 0; j <
width; j++) {
339 *p = ((*p - 128) *
s->factor + 8421367) >> 16;
356 const int mid = 1 << (
s->depth - 1);
357 const int add = ((mid << 1) + 1) << 15;
361 for (plane = 1; plane < 3; plane++) {
363 uint16_t *p = (uint16_t *)(
frame->data[plane] +
i *
frame->linesize[plane]);
364 for (j = 0; j <
width; j++) {
365 *p = ((*p - mid) *
s->factor + add) >> 16;
379 int plane =
s->is_packed_rgb ? 0 :
A;
385 uint8_t *p =
frame->data[plane] +
i *
frame->linesize[plane] +
s->is_packed_rgb*
s->rgba_map[
A];
386 int step =
s->is_packed_rgb ? 4 : 1;
387 for (j = 0; j <
frame->width; j++) {
391 *p = ((*p -
s->black_level) *
s->factor +
s->black_level_scaled) >> 16;
404 int plane =
s->is_packed_rgb ? 0 :
A;
410 uint16_t *p = (uint16_t *)(
frame->data[plane] +
i *
frame->linesize[plane]) +
s->is_packed_rgb*
s->rgba_map[
A];
411 int step =
s->is_packed_rgb ? 4 : 1;
412 for (j = 0; j <
frame->width; j++) {
416 *p = ((*p -
s->black_level) *
s->factor +
s->black_level_scaled) >> 16;
441 s->is_packed_rgb = !
s->is_planar &&
s->is_rgb;
453 s->black_level_scaled = (
s->black_level << 16) + 32768;
469 if (
s->fade_state == VF_FADE_WAITING) {
471 if (
frame->pts >=
s->start_time_pts
474 s->fade_state = VF_FADE_FADING;
477 if (
s->start_time_pts == 0 &&
s->start_frame != 0) {
478 s->start_time_pts =
frame->pts;
482 if (
s->start_time_pts != 0 &&
s->start_frame == 0) {
487 if (
s->fade_state == VF_FADE_FADING) {
488 if (
s->duration_pts == 0) {
492 s->fade_state = VF_FADE_DONE;
497 s->factor = (
frame->pts -
s->start_time_pts) * UINT16_MAX /
s->duration_pts;
498 if (
frame->pts >
s->start_time_pts +
s->duration_pts) {
499 s->fade_state = VF_FADE_DONE;
503 if (
s->fade_state == VF_FADE_DONE) {
504 s->factor=UINT16_MAX;
511 s->factor=UINT16_MAX-
s->factor;
514 if (
s->factor < UINT16_MAX) {
518 }
else if (
s->is_rgb && !
s->black_fade) {
526 if (
frame->data[1] &&
frame->data[2] && !
s->is_rgb) {
538#define OFFSET(x) offsetof(FadeContext, x)
539#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
546 {
"start_frame",
"Number of the first frame to which to apply the effect.",
548 {
"s",
"Number of the first frame to which to apply the effect.",
550 {
"nb_frames",
"Number of frames to which the effect should be applied.",
552 {
"n",
"Number of frames to which the effect should be applied.",
555 {
"start_time",
"Number of seconds of the beginning of the effect.",
557 {
"st",
"Number of seconds of the beginning of the effect.",
559 {
"duration",
"Duration of the effect in seconds.",
561 {
"d",
"Duration of the effect in seconds.",
583 .p.priv_class = &fade_class,
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_fade
static enum AVPixelFormat pix_fmts_rgb[3]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
int(* init)(AVBSFContext *ctx)
simple arithmetic expression evaluator
static int64_t start_time
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_LOG_VERBOSE
Detailed information.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_TIME_BASE
Internal time base represented as integer.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static const int16_t alpha[]
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
int ff_pixfmt_is_in(enum AVPixelFormat fmt, const enum AVPixelFormat *fmts)
Tell if a pixel format is contained in the provided AV_PIX_FMT_NONE-terminated list.
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUVA420P10
@ AVALPHA_MODE_STRAIGHT
Alpha channel is independent of color values.
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
#define AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
Describe the class of an AVClass context structure.
int depth
Number of bits in the component.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... flags.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
unsigned int black_level_scaled
enum FadeContext::@363326054352076225030000322234127320174027277125 fade_state
int black_fade
if color_rgba is black
int(* filter_slice_alpha)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int(* filter_slice_chroma)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int(* filter_slice_luma)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t color_rgba[4]
fade color
Link properties exposed to filter code, but not external callers.
static AVFormatContext * ctx
static enum AVPixelFormat pixel_fmts[]
static const AVFilterPad avfilter_vf_fade_inputs[]
static int filter_slice_chroma(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_chroma16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_rgb(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_always_inline void filter_rgb_planar(FadeContext *s, const AVFrame *frame, int slice_start, int slice_end, int do_alpha)
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static const AVOption fade_options[]
static av_always_inline void filter_rgb(FadeContext *s, const AVFrame *frame, int slice_start, int slice_end, int do_alpha, int step)
#define INTERP(c_name, c_idx)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const enum AVPixelFormat studio_level_pix_fmts[]
static int filter_slice_alpha(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_alpha16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_luma(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define INTERPP(c_name, c_idx)
static int filter_slice_luma16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
static void fade(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, int width, int height, int alpha, int beta)
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)