107 #define OFFSET(x) offsetof(NormalizeContext, x)
108 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
111 {
"blackpt",
"output color to which darkest input color is mapped",
OFFSET(blackpt),
AV_OPT_TYPE_COLOR, { .str =
"black" }, CHAR_MIN, CHAR_MAX,
FLAGS },
112 {
"whitept",
"output color to which brightest input color is mapped",
OFFSET(whitept),
AV_OPT_TYPE_COLOR, { .str =
"white" }, CHAR_MIN, CHAR_MAX,
FLAGS },
113 {
"smoothing",
"amount of temporal smoothing of the input range, to reduce flicker",
OFFSET(smoothing),
AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX/8,
FLAGS },
114 {
"independence",
"proportion of independent to linked channel normalization",
OFFSET(independence),
AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 1.0,
FLAGS },
115 {
"strength",
"strength of filter, from no effect to full normalization",
OFFSET(strength),
AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 1.0,
FLAGS },
133 float rgb_min_smoothed;
134 float rgb_max_smoothed;
140 for (c = 0; c < 3; c++)
141 min[c].in = max[c].in = in->
data[0][s->
co[c]];
145 for (x = 0; x < in->
width; x++) {
146 for (c = 0; c < 3; c++) {
148 max[
c].in =
FFMAX(max[c].in, inp[s->
co[c]]);
164 for (c = 0; c < 3; c++) {
172 for (c = 0; c < 3; c++) {
183 rgb_min_smoothed =
FFMIN3(
min[0].smoothed,
min[1].smoothed,
min[2].smoothed);
184 rgb_max_smoothed =
FFMAX3(max[0].smoothed, max[1].smoothed, max[2].smoothed);
188 for (c = 0; c < 3; c++) {
204 + (max[c].in * (1.0f - s->
strength));
211 if (
min[c].smoothed == max[c].smoothed) {
213 for (in_val =
min[c].in; in_val <= max[
c].in; in_val++)
214 lut[c][in_val] =
min[c].out;
220 float scale = (max[
c].out -
min[
c].out) / (max[c].smoothed -
min[c].smoothed);
221 for (in_val =
min[c].in; in_val <= max[
c].in; in_val++) {
222 int out_val = (in_val -
min[
c].smoothed) * scale +
min[c].out + 0.5f;
223 out_val =
FFMAX(out_val, 0);
224 out_val =
FFMIN(out_val, 255);
225 lut[
c][in_val] = out_val;
231 for (y = 0; y < in->
height; y++) {
234 for (x = 0; x < in->
width; x++) {
235 for (c = 0; c < 3; c++)
236 outp[s->
co[c]] = lut[c][inp[s->
co[c]]];
239 outp[s->
co[3]] = inp[s->
co[3]];
289 for (c = 0; c < 4; ++
c)
305 for (c = 0; c < 3; c++) {
381 .priv_class = &normalize_class,
AVFILTER_DEFINE_CLASS(normalize)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
int h
agreed upon image height
static const AVOption normalize_options[]
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int is_disabled
the enabled state from the last expression evaluation
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
struct NormalizeContext::@198 min[3]
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static int query_formats(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
static const AVFilterPad outputs[]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
static const AVFilterPad inputs[]
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
uint8_t nb_components
The number of components each pixel has, (1-4)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static av_cold void uninit(AVFilterContext *ctx)
packed RGB 8:8:8, 24bpp, BGRBGR...
int format
agreed upon media format
static int config_input(AVFilterLink *inlink)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out)
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
int offset
Number of elements before the component of the first pixel.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
struct NormalizeContext::@198 max[3]
AVFilterContext * dst
dest filter
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.