33 #define OFFSET(x) offsetof(RemoveGrainContext, x)
34 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
65 #define REMOVE_GRAIN_SORT_AXIS \
66 const int ma1 = FFMAX(a1, a8); \
67 const int mi1 = FFMIN(a1, a8); \
68 const int ma2 = FFMAX(a2, a7); \
69 const int mi2 = FFMIN(a2, a7); \
70 const int ma3 = FFMAX(a3, a6); \
71 const int mi3 = FFMIN(a3, a6); \
72 const int ma4 = FFMAX(a4, a5); \
73 const int mi4 = FFMIN(a4, a5);
80 return av_clip(c, mi, ma);
83 static int cmp_int(
const void *p1,
const void *p2)
85 int left = *(
const int *)p1;
86 int right = *(
const int *)p2;
88 return ((left > right) - (left < right));
95 qsort(&a, 8,
sizeof(a[0]),
cmp_int);
97 return av_clip(c, a[2 - 1 ], a[7 - 1]);
104 qsort(&a, 8,
sizeof(a[0]),
cmp_int);
106 return av_clip(c, a[3 - 1 ], a[6 - 1]);
113 qsort(&a, 8,
sizeof(a[0]),
cmp_int);
115 return av_clip(c, a[4 - 1 ], a[5 - 1]);
122 const int c1 =
FFABS(c - av_clip(c, mi1, ma1));
123 const int c2 =
FFABS(c - av_clip(c, mi2, ma2));
124 const int c3 =
FFABS(c - av_clip(c, mi3, ma3));
125 const int c4 =
FFABS(c - av_clip(c, mi4, ma4));
131 return av_clip(c, mi4, ma4);
132 }
else if (mindiff == c2) {
133 return av_clip(c, mi2, ma2);
134 }
else if (mindiff == c3) {
135 return av_clip(c, mi3, ma3);
138 return av_clip(c, mi1, ma1);
145 const int d1 = ma1 - mi1;
146 const int d2 = ma2 - mi2;
147 const int d3 = ma3 - mi3;
148 const int d4 = ma4 - mi4;
150 const int cli1 = av_clip(c, mi1, ma1);
151 const int cli2 = av_clip(c, mi2, ma2);
152 const int cli3 = av_clip(c, mi3, ma3);
153 const int cli4 = av_clip(c, mi4, ma4);
155 const int c1 = av_clip_uint16((
FFABS(c - cli1) << 1) + d1);
156 const int c2 = av_clip_uint16((
FFABS(c - cli2) << 1) + d2);
157 const int c3 = av_clip_uint16((
FFABS(c - cli3) << 1) + d3);
158 const int c4 = av_clip_uint16((
FFABS(c - cli4) << 1) + d4);
164 }
else if (mindiff == c2) {
166 }
else if (mindiff == c3) {
177 const int d1 = ma1 - mi1;
178 const int d2 = ma2 - mi2;
179 const int d3 = ma3 - mi3;
180 const int d4 = ma4 - mi4;
182 const int cli1 = av_clip(c, mi1, ma1);
183 const int cli2 = av_clip(c, mi2, ma2);
184 const int cli3 = av_clip(c, mi3, ma3);
185 const int cli4 = av_clip(c, mi4, ma4);
187 const int c1 =
FFABS(c - cli1) + d1;
188 const int c2 =
FFABS(c - cli2) + d2;
189 const int c3 =
FFABS(c - cli3) + d3;
190 const int c4 =
FFABS(c - cli4) + d4;
196 }
else if (mindiff == c2) {
198 }
else if (mindiff == c3) {
209 const int d1 = ma1 - mi1;
210 const int d2 = ma2 - mi2;
211 const int d3 = ma3 - mi3;
212 const int d4 = ma4 - mi4;
214 const int cli1 = av_clip(c, mi1, ma1);
215 const int cli2 = av_clip(c, mi2, ma2);
216 const int cli3 = av_clip(c, mi3, ma3);
217 const int cli4 = av_clip(c, mi4, ma4);
219 const int c1 = av_clip_uint16(
FFABS(c - cli1) + (d1 << 1));
220 const int c2 = av_clip_uint16(
FFABS(c - cli2) + (d2 << 1));
221 const int c3 = av_clip_uint16(
FFABS(c - cli3) + (d3 << 1));
222 const int c4 = av_clip_uint16(
FFABS(c - cli4) + (d4 << 1));
228 }
else if (mindiff == c2) {
230 }
else if (mindiff == c3) {
241 const int d1 = ma1 - mi1;
242 const int d2 = ma2 - mi2;
243 const int d3 = ma3 - mi3;
244 const int d4 = ma4 - mi4;
249 return av_clip(c, mi4, ma4);
250 }
else if (mindiff == d2) {
251 return av_clip(c, mi2, ma2);
252 }
else if (mindiff == d3) {
253 return av_clip(c, mi3, ma3);
256 return av_clip(c, mi1, ma1);
261 const int d1 =
FFABS(c - a1);
262 const int d2 =
FFABS(c - a2);
263 const int d3 =
FFABS(c - a3);
264 const int d4 =
FFABS(c - a4);
265 const int d5 =
FFABS(c - a5);
266 const int d6 =
FFABS(c - a6);
267 const int d7 =
FFABS(c - a7);
268 const int d8 =
FFABS(c - a8);
273 if (mindiff == d7)
return a7;
274 if (mindiff == d8)
return a8;
275 if (mindiff == d6)
return a6;
276 if (mindiff == d2)
return a2;
277 if (mindiff == d3)
return a3;
278 if (mindiff == d1)
return a1;
279 if (mindiff == d5)
return a5;
286 const int sum = 4 * c + 2 * (a2 + a4 + a5 + a7) + a1 + a3 + a6 + a8;
287 const int val = (sum + 8) >> 4;
294 const int d1 =
FFABS(a1 - a8);
295 const int d2 =
FFABS(a2 - a7);
296 const int d3 =
FFABS(a3 - a6);
301 return (a2 + a7 + 1) >> 1;
304 return (a3 + a6 + 1) >> 1;
307 return (a1 + a8 + 1) >> 1;
312 const int d1 =
FFABS(a1 - a8);
313 const int d2 =
FFABS(a2 - a7);
314 const int d3 =
FFABS(a3 - a6);
317 const int average = (2 * (a2 + a7) + a1 + a3 + a6 + a8 + 4) >> 3;
320 return av_clip(average,
FFMIN(a2, a7),
FFMAX(a2, a7));
323 return av_clip(average,
FFMIN(a3, a6),
FFMAX(a3, a6));
326 return av_clip(average,
FFMIN(a1, a8),
FFMAX(a1, a8));
349 return av_clip(c,
FFMIN(a4, a5),
FFMAX(a4, a5));
352 return av_clip(c,
FFMIN(a2, a7),
FFMAX(a2, a7));
355 return av_clip(c,
FFMIN(a3, a6),
FFMAX(a3, a6));
358 return av_clip(c,
FFMIN(a1, a8),
FFMAX(a1, a8));
363 const int sum = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
364 const int val = (sum + 4) >> 3;
371 const int sum = a1 + a2 + a3 + a4 + c + a5 + a6 + a7 + a8;
372 const int val = (sum + 4) / 9;
379 const int l1l = (a1 + a8) >> 1;
380 const int l2l = (a2 + a7) >> 1;
381 const int l3l = (a3 + a6) >> 1;
382 const int l4l = (a4 +
a5) >> 1;
384 const int l1h = (a1 + a8 + 1) >> 1;
385 const int l2h = (a2 + a7 + 1) >> 1;
386 const int l3h = (a3 + a6 + 1) >> 1;
387 const int l4h = (a4 + a5 + 1) >> 1;
392 return av_clip(c, mi, ma);
397 const int l1 = (a1 + a8 + 1) >> 1;
398 const int l2 = (a2 + a7 + 1) >> 1;
399 const int l3 = (a3 + a6 + 1) >> 1;
400 const int l4 = (a4 + a5 + 1) >> 1;
405 return av_clip(c, mi, ma);
412 const int linediff1 = ma1 - mi1;
413 const int linediff2 = ma2 - mi2;
414 const int linediff3 = ma3 - mi3;
415 const int linediff4 = ma4 - mi4;
417 const int u1 =
FFMIN(c - ma1, linediff1);
418 const int u2 =
FFMIN(c - ma2, linediff2);
419 const int u3 =
FFMIN(c - ma3, linediff3);
420 const int u4 =
FFMIN(c - ma4, linediff4);
423 const int d1 =
FFMIN(mi1 - c, linediff1);
424 const int d2 =
FFMIN(mi2 - c, linediff2);
425 const int d3 =
FFMIN(mi3 - c, linediff3);
426 const int d4 =
FFMIN(mi4 - c, linediff4);
436 const int linediff1 = ma1 - mi1;
437 const int linediff2 = ma2 - mi2;
438 const int linediff3 = ma3 - mi3;
439 const int linediff4 = ma4 - mi4;
441 const int tu1 = c - ma1;
442 const int tu2 = c - ma2;
443 const int tu3 = c - ma3;
444 const int tu4 = c - ma4;
446 const int u1 =
FFMIN(tu1, linediff1 - tu1);
447 const int u2 =
FFMIN(tu2, linediff2 - tu2);
448 const int u3 =
FFMIN(tu3, linediff3 - tu3);
449 const int u4 =
FFMIN(tu4, linediff4 - tu4);
452 const int td1 = mi1 -
c;
453 const int td2 = mi2 -
c;
454 const int td3 = mi3 -
c;
455 const int td4 = mi4 -
c;
457 const int d1 =
FFMIN(td1, linediff1 - td1);
458 const int d2 =
FFMIN(td2, linediff2 - td2);
459 const int d3 =
FFMIN(td3, linediff3 - td3);
460 const int d4 =
FFMIN(td4, linediff4 - td4);
480 switch (s->
mode[i]) {
529 const int i = td->
plane;
534 int start = (height * jobnr ) / nb_jobs;
535 int end = (height * (jobnr+1)) / nb_jobs;
538 start =
FFMAX(1, start);
539 end =
FFMIN(height-1, end);
540 for (y = start; y <
end; y++) {
570 const int a1 = src[-
op];
571 const int a2 = src[-o0];
572 const int a3 = src[-om];
573 const int a4 = src[-1 ];
574 const int c = src[ 0 ];
575 const int a5 = src[ 1 ];
576 const int a6 = src[ om];
577 const int a7 = src[ o0];
578 const int a8 = src[
op];
611 if (s->
mode[i] == 0) {
652 .
name =
"removegrain",
656 .
inputs = removegrain_inputs,
657 .
outputs = removegrain_outputs,
658 .priv_class = &removegrain_class,
const char const char void * val
void ff_removegrain_init_x86(RemoveGrainContext *rg)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static int mode08(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad outputs[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Main libavfilter public API header.
int h
agreed upon image height
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVFilter ff_vf_removegrain
int(* rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int mode24(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
struct AVFilterGraph * graph
filtergraph this filter belongs to
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static const AVOption removegrain_options[]
static int mode19(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static av_cold int end(AVCodecContext *avctx)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
int nb_threads
Maximum number of threads used by filters in this graph.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static int mode23(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static int mode04(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static int query_formats(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static int mode20(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
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. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
static int mode1112(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static int mode1314(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static int cmp_int(const void *p1, const void *p2)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static int mode09(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
#define FF_CEIL_RSHIFT(a, b)
#define REMOVE_GRAIN_SORT_AXIS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static int mode07(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static const AVFilterPad removegrain_inputs[]
int format
agreed upon media format
static int mode01(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static int config_input(AVFilterLink *inlink)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int mode21(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
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
BYTE int const BYTE int int int height
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVFilterPad inputs[]
static const AVFilterPad removegrain_outputs[]
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static int mode06(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
static int mode18(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int mode10(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int mode17(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
static int mode03(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
planar GBRA 4:4:4:4 32bpp
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
avfilter_execute_func * execute
static int mode1516(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
AVFilterContext * dst
dest filter
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
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-> out
static int mode22(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static int mode02(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
AVFILTER_DEFINE_CLASS(removegrain)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
static int mode05(int c, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void(* fl[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels)