36 #define MAX_NB_THREADS 32
45 static const char *
const var_names[] = {
"X",
"Y",
"W",
"H",
"N",
"SW",
"SH",
"T",
NULL };
68 #define OFFSET(x) offsetof(GEQContext, x)
69 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
97 static inline double getpix(
void *priv,
double x,
double y,
int plane)
103 int linesize = picref->
linesize[plane];
118 const uint16_t *src16 = (
const uint16_t*)
src;
121 return (1-y)*((1-x)*src16[
xi + yi * linesize] + x*src16[
xi + 1 + yi * linesize])
122 + y *((1-x)*src16[
xi + (yi+1) * linesize] + x*src16[
xi + 1 + (yi+1) * linesize]);
124 return (1-y)*((1-x)*
src[
xi + yi * linesize] + x*
src[
xi + 1 + yi * linesize])
125 + y *((1-x)*
src[
xi + (yi+1) * linesize] + x*
src[
xi + 1 + (yi+1) * linesize]);
132 const uint16_t *src16 = (
const uint16_t*)
src;
135 return src16[
xi + yi * linesize];
137 return src[
xi + yi * linesize];
147 int linesize = picref->
linesize[plane];
155 for (yi = 0; yi <
h; yi ++) {
157 const uint16_t *src16 = (
const uint16_t*)
src;
161 linesum += src16[
xi + yi * linesize];
168 linesum +=
src[
xi + yi * linesize];
185 }
else if (y >
h - 1) {
189 if (x == -1)
return 0;
192 if (y == -1)
return 0;
214 static double lum(
void *priv,
double x,
double y) {
return getpix(priv, x, y, 0); }
215 static double cb(
void *priv,
double x,
double y) {
return getpix(priv, x, y, 1); }
216 static double cr(
void *priv,
double x,
double y) {
return getpix(priv, x, y, 2); }
217 static double alpha(
void *priv,
double x,
double y) {
return getpix(priv, x, y, 3); }
254 snprintf(bps_string,
sizeof(bps_string),
"%d", (1<<geq->
bps) - 1);
272 for (plane = 0; plane <
NB_PLANES; plane++) {
273 static double (*
const p[])(
void *, double, double) = {
277 static const char *
const func2_yuv_names[] = {
278 "lum" ,
"cb" ,
"cr" ,
"alpha" ,
"p",
279 "lumsum",
"cbsum",
"crsum",
"alphasum",
"psum",
281 static const char *
const func2_rgb_names[] = {
282 "g" ,
"b" ,
"r" ,
"alpha" ,
"p",
283 "gsum",
"bsum",
"rsum",
"alphasum",
"psum",
285 const char *
const *
func2_names = geq->
is_rgb ? func2_rgb_names : func2_yuv_names;
286 double (*
const func2[])(
void *, double, double) = {
290 int counter[10] = {0};
300 geq->
needs_sum[plane] = counter[5] + counter[6] + counter[7] + counter[8] + counter[9];
358 geq->
bps =
desc->comp[0].depth;
376 const int plane =
td->plane;
377 const int linesize =
td->linesize;
378 const int slice_start = (
height * jobnr) / nb_jobs;
391 uint8_t *ptr = geq->
dst + linesize * slice_start;
392 for (y = slice_start; y <
slice_end; y++) {
395 for (x = 0; x <
width; x++) {
402 uint16_t *ptr16 = geq->
dst16 + (linesize/2) * slice_start;
403 for (y = slice_start; y <
slice_end; y++) {
405 for (x = 0; x <
width; x++) {
436 for (plane = 0; plane < geq->
planes &&
out->data[plane]; plane++) {
439 const int linesize =
out->linesize[plane];
442 geq->
dst =
out->data[plane];
443 geq->
dst16 = (uint16_t*)
out->data[plane];
453 td.linesize = linesize;
504 .priv_class = &geq_class,
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static int interpolation(DeclickChannel *c, const double *src, int ar_order, double *acoefficients, int *index, int nb_errors, double *auxiliary, double *interpolated)
static double(*const func2[])(void *, double, double)
static const char *const func2_names[]
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
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_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
static av_cold int init(AVCodecContext *avctx)
#define flags(name, subs,...)
#define xi(width, name, var, range_min, range_max, subs,...)
#define AV_CEIL_RSHIFT(a, b)
static av_cold int uninit(AVCodecContext *avctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg)
Track the presence of user provided functions and their number of occurrences in a parsed expression.
simple arithmetic expression evaluator
#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...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
char * av_strdup(const char *s)
Duplicate a string.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static enum AVPixelFormat rgb_pix_fmts[]
static enum AVPixelFormat yuv_pix_fmts[]
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_GBRAP16
#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
#define AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GBRP12
#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_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_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ 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_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_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
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.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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...
AVFrame * picref
current input buffer
AVExpr * e[NB_PLANES][MAX_NB_THREADS]
expressions for each plane and thread
int vsub
chroma subsampling
double values[VAR_VARS_NB]
expression values
uint16_t * dst16
reference pointer to the 16bits output
uint8_t * dst
reference pointer to the 8bits output
int planes
number of planes
double * pixel_sums[NB_PLANES]
char * expr_str[4+3]
expression strings for each plane
Used for passing data between threads.
#define av_malloc_array(a, b)
static double crsub(void *priv, double x, double y)
static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVFILTER_DEFINE_CLASS(geq)
static av_cold void geq_uninit(AVFilterContext *ctx)
static double getpix(void *priv, double x, double y, int plane)
static int calculate_sums(GEQContext *geq, int plane, int w, int h)
static double alphasum(void *priv, double x, double y)
static int geq_config_props(AVFilterLink *inlink)
static double cbsum(void *priv, double x, double y)
static double alpha(void *priv, double x, double y)
static double getpix_integrate(void *priv, double x, double y, int plane)
static const AVFilterPad geq_inputs[]
static double getpix_integrate_internal(GEQContext *geq, int x, int y, int plane, int w, int h)
static double lum(void *priv, double x, double y)
static double cr(void *priv, double x, double y)
static const char *const var_names[]
static double lumsum(void *priv, double x, double y)
static int geq_filter_frame(AVFilterLink *inlink, AVFrame *in)
static int geq_query_formats(AVFilterContext *ctx)
static const AVFilterPad geq_outputs[]
static const AVOption geq_options[]
static av_cold int geq_init(AVFilterContext *ctx)
static double cb(void *priv, double x, double y)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.