Go to the documentation of this file.
56 ptrdiff_t slinesize, ptrdiff_t dlinesize,
61 #define OFFSET(x) offsetof(NegateContext, x)
62 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
110 ptrdiff_t slinesize, ptrdiff_t dlinesize,
114 for (
int y = 0; y <
h; y++) {
115 for (
int x = 0; x <
w; x++)
116 dst[x] = 255 -
src[x];
124 ptrdiff_t slinesize, ptrdiff_t dlinesize,
128 for (
int y = 0; y <
h; y++) {
129 const uint8_t *
src = ssrc + y * slinesize;
130 uint8_t *dst = ddst + y * dlinesize;
132 for (
int x = 0; x <
w; x++) {
134 case 4: dst[3] = components & 8 ? 255 -
src[3] :
src[3];
135 case 3: dst[2] = components & 4 ? 255 -
src[2] :
src[2];
136 case 2: dst[1] = components & 2 ? 255 -
src[1] :
src[1];
137 default: dst[0] = components & 1 ? 255 -
src[0] :
src[0];
146 static void negate16(
const uint8_t *ssrc, uint8_t *ddst,
147 ptrdiff_t slinesize, ptrdiff_t dlinesize,
151 const uint16_t *
src = (
const uint16_t *)ssrc;
152 uint16_t *dst = (uint16_t *)ddst;
157 for (
int y = 0; y <
h; y++) {
158 for (
int x = 0; x <
w; x++)
167 ptrdiff_t slinesize, ptrdiff_t dlinesize,
171 for (
int y = 0; y <
h; y++) {
172 const uint16_t *
src = (
const uint16_t *)(ssrc + y * slinesize);
173 uint16_t *dst = (uint16_t *)(ddst + y * dlinesize);
175 for (
int x = 0; x <
w; x++) {
177 case 4: dst[3] = components & 8 ?
max -
src[3] :
src[3];
178 case 3: dst[2] = components & 4 ?
max -
src[2] :
src[2];
179 case 2: dst[1] = components & 2 ?
max -
src[1] :
src[1];
180 default: dst[0] = components & 1 ?
max -
src[0] :
src[0];
194 int depth, vsub,
hsub,
ret, is_packed;
197 s->planes =
s->negate_alpha ? 0xF : 0x7;
199 (
desc->nb_components > 1);
200 if (
s->requested_components != 0x77) {
205 if (
s->requested_components & ~comp_avail) {
212 if (
s->requested_components &
COMP_Y)
214 if (
s->requested_components &
COMP_U)
216 if (
s->requested_components &
COMP_V)
218 if (
s->requested_components &
COMP_A)
221 if (
s->requested_components &
COMP_R)
223 if (
s->requested_components &
COMP_G)
225 if (
s->requested_components &
COMP_B)
227 if (
s->requested_components &
COMP_A)
237 if (
s->requested_components &
COMP_R)
238 s->components |= 1 <<
s->rgba_map[0];
239 if (
s->requested_components &
COMP_G)
240 s->components |= 1 <<
s->rgba_map[1];
241 if (
s->requested_components &
COMP_B)
242 s->components |= 1 <<
s->rgba_map[2];
243 if (
s->requested_components &
COMP_A)
244 s->components |= 1 <<
s->rgba_map[3];
250 depth =
desc->comp[0].depth;
252 vsub =
desc->log2_chroma_h;
254 s->height[0] =
s->height[3] =
inlink->h;
256 s->width[0] =
s->width[3] =
inlink->w;
263 s->max = (1 << depth) - 1;
266 s->step =
s->step >> 1;
278 for (
int p = 0; p <
s->nb_planes; p++) {
279 const int h =
s->height[p];
280 const int slice_start = (
h * jobnr) / nb_jobs;
281 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
283 if (!((1 << p) &
s->planes)) {
294 out->data[p] + slice_start *
out->linesize[p],
297 s->max,
s->step,
s->components);
333 char *res,
int res_len,
int flags)
336 int old_planes =
s->planes;
345 s->planes = old_planes;
362 .priv_class = &negate_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRAP16
AVFILTER_DEFINE_CLASS(negate)
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 config_input(AVFilterLink *inlink)
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)
#define FILTER_PIXFMTS_ARRAY(array)
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
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.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
const AVFilter ff_vf_negate
#define AV_PIX_FMT_GRAY16
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_GBRAP10
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
#define AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static void negate16(const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t slinesize, ptrdiff_t dlinesize, int w, int h, int max, int step, int components)
void(* negate)(const uint8_t *src, uint8_t *dst, ptrdiff_t slinesize, ptrdiff_t dlinesize, int w, int h, int max, int step, int components)
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_GRAY14
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ 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 AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_RGBA64
Describe the class of an AVClass context structure.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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...
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_YUV422P12
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static enum AVPixelFormat pix_fmts[]
static void negate_packed16(const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t slinesize, ptrdiff_t dlinesize, int w, int h, int max, int step, int components)
#define AV_PIX_FMT_YUV444P12
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_PIX_FMT_BGRA64
int w
agreed upon image width
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
@ 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.
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
static void negate_packed8(const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t slinesize, ptrdiff_t dlinesize, int w, int h, int max, int step, int components)
int h
agreed upon image height
static void negate8(const uint8_t *src, uint8_t *dst, ptrdiff_t slinesize, ptrdiff_t dlinesize, int w, int h, int max, int step, int components)
#define AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
@ 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
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GRAY12
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static const AVOption negate_options[]
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
static const AVFilterPad inputs[]