FFmpeg
Loading...
Searching...
No Matches
vf_eq.h
Go to the documentation of this file.
1/*
2 * Original MPlayer filters by Richard Felker, Hampa Hug, Daniel Moreno,
3 * and Michael Niedermeyer.
4 *
5 * Copyright (c) 2014 James Darnley <james.darnley@gmail.com>
6 * Copyright (c) 2015 Arwa Arif <arwaarif1994@gmail.com>
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
24
25#ifndef AVFILTER_EQ_H
26#define AVFILTER_EQ_H
27
28#include "avfilter.h"
29#include "libavutil/eval.h"
30
31static const char *const var_names[] = {
32 "n", // frame count
33 "r", // frame rate
34 "t", // timestamp expressed in seconds
35 NULL
36};
37
44
45typedef struct EQParameters {
46 void (*adjust)(struct EQParameters *eq, uint8_t *dst, int dst_stride,
47 const uint8_t *src, int src_stride, int w, int h);
48
49 uint8_t lut[256];
50
53
55
100
101static void process_c(EQParameters *param, uint8_t *dst, int dst_stride,
102 const uint8_t *src, int src_stride, int w, int h)
103{
104 int contrast = (int) (param->contrast * 256 * 16);
105 int brightness = ((int) (100.0 * param->brightness + 100.0) * 511) / 200 - 128 - contrast / 32;
106
107 for (int y = 0; y < h; y++) {
108 for (int x = 0; x < w; x++) {
109 int pel = ((src[y * src_stride + x] * contrast) >> 12) + brightness;
110
111 if (pel & ~255)
112 pel = (-pel) >> 31;
113
114 dst[y * dst_stride + x] = pel;
115 }
116 }
117}
118
120
122{
123 eq->process = process_c;
124#if ARCH_X86 && HAVE_X86ASM
126#endif
127}
128
129#endif /* AVFILTER_EQ_H */
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
@ VAR_T
Definition aeval.c:53
@ VAR_NB
Main libavfilter public API header.
#define NULL
Definition coverity.c:32
simple arithmetic expression evaluator
#define av_unused
Definition attributes.h:164
uint8_t w
Definition llvidencdsp.c:39
var_name
Definition noise.c:46
@ VAR_N
Definition noise.c:47
static const char *const var_names[]
Definition noise.c:30
Describe the class of an AVClass context structure.
Definition log.h:76
Definition eval.c:171
double gamma_b
Definition vf_eq.h:91
double gamma_g
Definition vf_eq.h:87
char * gamma_expr
Definition vf_eq.h:73
double contrast
Definition vf_eq.h:63
char * gamma_r_expr
Definition vf_eq.h:81
char * gamma_b_expr
Definition vf_eq.h:89
double gamma_r
Definition vf_eq.h:83
EQParameters param[3]
Definition vf_eq.h:59
enum EQContext::EvalMode eval_mode
char * brightness_expr
Definition vf_eq.h:65
AVExpr * gamma_weight_pexpr
Definition vf_eq.h:78
AVExpr * contrast_pexpr
Definition vf_eq.h:62
char * contrast_expr
Definition vf_eq.h:61
AVExpr * gamma_pexpr
Definition vf_eq.h:74
AVExpr * gamma_g_pexpr
Definition vf_eq.h:86
char * gamma_g_expr
Definition vf_eq.h:85
double gamma_weight
Definition vf_eq.h:79
AVExpr * gamma_b_pexpr
Definition vf_eq.h:90
AVExpr * brightness_pexpr
Definition vf_eq.h:66
char * saturation_expr
Definition vf_eq.h:69
char * gamma_weight_expr
Definition vf_eq.h:77
double gamma
Definition vf_eq.h:75
double brightness
Definition vf_eq.h:67
double var_values[VAR_NB]
Definition vf_eq.h:93
void(* process)(struct EQParameters *par, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
Definition vf_eq.h:95
double saturation
Definition vf_eq.h:71
AVExpr * gamma_r_pexpr
Definition vf_eq.h:82
@ EVAL_MODE_INIT
Definition vf_eq.h:98
@ EVAL_MODE_NB
Definition vf_eq.h:98
@ EVAL_MODE_FRAME
Definition vf_eq.h:98
AVExpr * saturation_pexpr
Definition vf_eq.h:70
double contrast
Definition vf_eq.h:51
double gamma_weight
Definition vf_eq.h:51
double gamma
Definition vf_eq.h:51
int lut_clean
Definition vf_eq.h:52
void(* adjust)(struct EQParameters *eq, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
Definition vf_eq.h:46
double brightness
Definition vf_eq.h:51
uint8_t lut[256]
Definition vf_eq.h:49
#define src
Definition vp8dsp.c:248
@ VAR_NB
Definition vf_eq.h:42
@ VAR_R
Definition vf_eq.h:40
static void process_c(EQParameters *param, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
Definition vf_eq.h:101
void ff_eq_init_x86(EQContext *eq)
Definition vf_eq_init.c:44
static av_unused void ff_eq_init(EQContext *eq)
Definition vf_eq.h:121
#define eq(A, B)
Definition vf_xbr.c:92