Go to the documentation of this file.
49 #if FF_API_CHILD_CLASS_NEXT
59 *iter = (
void*)(uintptr_t)
c;
66 return prev ?
NULL :
s->dct;
69 #define OFFSET(x) offsetof(SPPContext, x)
70 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
71 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
88 #if FF_API_CHILD_CLASS_NEXT
89 .child_class_next = child_class_next,
97 { 0, 48, 12, 60, 3, 51, 15, 63 },
98 { 32, 16, 44, 28, 35, 19, 47, 31 },
99 { 8, 56, 4, 52, 11, 59, 7, 55 },
100 { 40, 24, 36, 20, 43, 27, 39, 23 },
101 { 2, 50, 14, 62, 1, 49, 13, 61 },
102 { 34, 18, 46, 30, 33, 17, 45, 29 },
103 { 10, 58, 6, 54, 9, 57, 5, 53 },
104 { 42, 26, 38, 22, 41, 25, 37, 21 },
110 {0,0}, {2,2}, {6,4}, {4,6},
111 {0,0}, {5,1}, {2,2}, {7,3}, {4,4}, {1,5}, {6,6}, {3,7},
113 {0,0}, {4,0}, {1,1}, {5,1}, {3,2}, {7,2}, {2,3}, {6,3},
114 {0,4}, {4,4}, {1,5}, {5,5}, {3,6}, {7,6}, {2,7}, {6,7},
116 {0,0}, {0,2}, {0,4}, {0,6}, {1,1}, {1,3}, {1,5}, {1,7},
117 {2,0}, {2,2}, {2,4}, {2,6}, {3,1}, {3,3}, {3,5}, {3,7},
118 {4,0}, {4,2}, {4,4}, {4,6}, {5,1}, {5,3}, {5,5}, {5,7},
119 {6,0}, {6,2}, {6,4}, {6,6}, {7,1}, {7,3}, {7,5}, {7,7},
121 {0,0}, {4,4}, {0,4}, {4,0}, {2,2}, {6,6}, {2,6}, {6,2},
122 {0,2}, {4,6}, {0,6}, {4,2}, {2,0}, {6,4}, {2,4}, {6,0},
123 {1,1}, {5,5}, {1,5}, {5,1}, {3,3}, {7,7}, {3,7}, {7,3},
124 {1,3}, {5,7}, {1,7}, {5,3}, {3,1}, {7,5}, {3,5}, {7,1},
125 {0,1}, {4,5}, {0,5}, {4,1}, {2,3}, {6,7}, {2,7}, {6,3},
126 {0,3}, {4,7}, {0,7}, {4,3}, {2,1}, {6,5}, {2,5}, {6,1},
127 {1,0}, {5,4}, {1,4}, {5,0}, {3,2}, {7,6}, {3,6}, {7,2},
128 {1,2}, {5,6}, {1,6}, {5,2}, {3,0}, {7,4}, {3,4}, {7,0},
132 int qp,
const uint8_t *permutation)
137 unsigned threshold1 = qp * ((1<<4) - bias) - 1;
138 unsigned threshold2 = threshold1 << 1;
140 memset(dst, 0, 64 *
sizeof(dst[0]));
141 dst[0] = (
src[0] + 4) >> 3;
143 for (
i = 1;
i < 64;
i++) {
145 if (((
unsigned)(
level + threshold1)) > threshold2) {
146 const int j = permutation[
i];
147 dst[j] = (
level + 4) >> 3;
153 int qp,
const uint8_t *permutation)
158 unsigned threshold1 = qp * ((1<<4) - bias) - 1;
159 unsigned threshold2 = threshold1 << 1;
161 memset(dst, 0, 64 *
sizeof(dst[0]));
162 dst[0] = (
src[0] + 4) >> 3;
164 for (
i = 1;
i < 64;
i++) {
166 if (((
unsigned)(
level + threshold1)) > threshold2) {
167 const int j = permutation[
i];
168 if (
level > 0) dst[j] = (
level - threshold1 + 4) >> 3;
169 else dst[j] = (
level + threshold1 + 4) >> 3;
175 int dst_linesize,
int src_linesize,
181 #define STORE(pos) do { \
182 temp = ((src[x + y*src_linesize + pos] << log2_scale) + d[pos]) >> 6; \
184 temp = ~(temp >> 31); \
185 dst[x + y*dst_linesize + pos] = temp; \
188 for (y = 0; y <
height; y++) {
190 for (x = 0; x <
width; x += 8) {
205 int dst_linesize,
int src_linesize,
210 unsigned int mask = -1<<depth;
212 #define STORE16(pos) do { \
213 temp = ((src[x + y*src_linesize + pos] << log2_scale) + (d[pos]>>1)) >> 5; \
215 temp = ~(temp >> 31); \
216 dst[x + y*dst_linesize + pos] = temp; \
219 for (y = 0; y <
height; y++) {
221 for (x = 0; x <
width; x += 8) {
235 static inline void add_block(uint16_t *dst,
int linesize,
const int16_t
block[64])
239 for (y = 0; y < 8; y++) {
240 dst[0 + y*linesize] +=
block[0 + y*8];
241 dst[1 + y*linesize] +=
block[1 + y*8];
242 dst[2 + y*linesize] +=
block[2 + y*8];
243 dst[3 + y*linesize] +=
block[3 + y*8];
244 dst[4 + y*linesize] +=
block[4 + y*8];
245 dst[5 + y*linesize] +=
block[5 + y*8];
246 dst[6 + y*linesize] +=
block[6 + y*8];
247 dst[7 + y*linesize] +=
block[7 + y*8];
252 int dst_linesize,
int src_linesize,
int width,
int height,
253 const uint8_t *qp_table,
int qp_stride,
int is_luma,
int depth)
259 int16_t *
block = (int16_t *)block_align;
260 int16_t *block2 = (int16_t *)(block_align + 16);
261 uint16_t *psrc16 = (uint16_t*)p->
src;
262 const int sample_bytes = (depth+7) / 8;
264 for (y = 0; y <
height; y++) {
265 int index = 8 + 8*linesize + y*linesize;
266 memcpy(p->
src +
index*sample_bytes,
src + y*src_linesize,
width*sample_bytes);
267 if (sample_bytes == 1) {
268 for (x = 0; x < 8; x++) {
273 for (x = 0; x < 8; x++) {
279 for (y = 0; y < 8; y++) {
280 memcpy(p->
src + ( 7-y)*linesize * sample_bytes, p->
src + ( y+8)*linesize * sample_bytes, linesize * sample_bytes);
281 memcpy(p->
src + (
height+8+y)*linesize * sample_bytes, p->
src + (
height-y+7)*linesize * sample_bytes, linesize * sample_bytes);
284 for (y = 0; y <
height + 8; y += 8) {
285 memset(p->
temp + (8 + y) * linesize, 0, 8 * linesize *
sizeof(*p->
temp));
286 for (x = 0; x <
width + 8; x += 8) {
292 const int qps = 3 + is_luma;
296 for (
i = 0;
i < count;
i++) {
297 const int x1 = x +
offset[
i + count - 1][0];
298 const int y1 = y +
offset[
i + count - 1][1];
299 const int index = x1 + y1*linesize;
308 if (sample_bytes == 1) {
310 dst_linesize, linesize,
width,
315 dst_linesize/2, linesize,
width,
353 const int bps =
desc->comp[0].depth;
361 s->hsub =
desc->log2_chroma_w;
362 s->vsub =
desc->log2_chroma_h;
367 if (!
s->temp || !
s->src)
379 int8_t *qp_table =
NULL;
381 const int depth =
desc->comp[0].depth;
397 s->non_b_qp_table = qp_table;
398 s->non_b_qp_stride = qp_stride;
402 if (
s->log2_count && !
ctx->is_disabled) {
403 if (!
s->use_bframe_qp &&
s->non_b_qp_table) {
404 qp_table =
s->non_b_qp_table;
405 qp_stride =
s->non_b_qp_stride;
408 if (qp_table ||
s->qp) {
425 out->width =
in->width;
426 out->height =
in->height;
429 filter(
s,
out->data[0],
in->data[0],
out->linesize[0],
in->linesize[0],
inlink->w,
inlink->h, qp_table, qp_stride, 1, depth);
432 filter(
s,
out->data[1],
in->data[1],
out->linesize[1],
in->linesize[1], cw, ch, qp_table, qp_stride, 0, depth);
433 filter(
s,
out->data[2],
in->data[2],
out->linesize[2],
in->linesize[2], cw, ch, qp_table, qp_stride, 0, depth);
442 in ->data[3],
in ->linesize[3],
448 if (qp_table !=
s->non_b_qp_table)
454 char *res,
int res_len,
int flags)
458 if (!strcmp(cmd,
"level") || !strcmp(cmd,
"quality")) {
459 if (!strcmp(args,
"max"))
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static const AVOption spp_options[]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static const uint8_t ldither[8][8]
#define AV_PIX_FMT_YUV420P10
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static void add_block(uint16_t *dst, int linesize, const int16_t block[64])
const char * name
Filter name.
static void store_slice16_c(uint16_t *dst, const int16_t *src, int dst_linesize, int src_linesize, int width, int height, int log2_scale, const uint8_t dither[8][8], int depth)
A link between two filters.
void(* fdct)(int16_t *block)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
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 query_formats(AVFilterContext *ctx)
void(* requantize)(int16_t dst[64], const int16_t src[64], int qp, const uint8_t *permutation)
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P9
static const AVClass * child_class_iterate(void **iter)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
uint8_t idct_permutation[64]
IDCT input permutation.
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
static const AVClass spp_class
static const uint16_t mask[17]
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static av_cold void uninit(AVFilterContext *ctx)
#define AV_CEIL_RSHIFT(a, b)
static const AVFilterPad outputs[]
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV420P9
static const uint8_t offset[127][2]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
const char * av_default_item_name(void *ptr)
Return the context name.
static void hardthresh_c(int16_t dst[64], const int16_t src[64], int qp, const uint8_t *permutation)
int avcodec_dct_init(AVDCT *dsp)
#define AV_PIX_FMT_YUV422P10
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
void(* idct)(int16_t *block)
void(* store_slice)(uint8_t *dst, const int16_t *src, int dst_stride, int src_stride, int width, int height, int log2_scale, const uint8_t dither[8][8])
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
@ AV_CLASS_CATEGORY_FILTER
AVDCT * avcodec_dct_alloc(void)
Allocates a AVDCT context.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
static int ff_norm_qscale(int qscale, int type)
Normalize the qscale factor FIXME the H264 qscale is a log based scale, mpeg1/2 is not,...
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
void(* get_pixels_unaligned)(int16_t *block, const uint8_t *pixels, ptrdiff_t line_size)
#define DECLARE_ALIGNED(n, t, v)
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
static int config_input(AVFilterLink *inlink)
#define av_malloc_array(a, b)
const AVClass * avcodec_dct_get_class(void)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static const AVFilterPad spp_inputs[]
static void store_slice_c(uint8_t *dst, const int16_t *src, int dst_linesize, int src_linesize, int width, int height, int log2_scale, const uint8_t dither[8][8])
static void filter(SPPContext *p, uint8_t *dst, uint8_t *src, int dst_linesize, int src_linesize, int width, int height, const uint8_t *qp_table, int qp_stride, int is_luma, int depth)
static const AVFilterPad spp_outputs[]
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h, int *qscale_type)
Extract a libpostproc-compatible QP table - an 8-bit QP value per 16x16 macroblock,...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
The exact code depends on how similar the blocks are and how related they are to the block
static void * child_next(void *obj, void *prev)
av_cold void ff_spp_init_x86(SPPContext *s)
static void softthresh_c(int16_t dst[64], const int16_t src[64], int qp, const uint8_t *permutation)
static const uint8_t dither[8][8]