69 case X: max_value = inlink->
w;
break;
70 case Y: max_value = inlink->
h;
break;
71 case W: max_value = inlink->
w - ctx->
region[
X];
break;
72 case H: max_value = inlink->
h - ctx->
region[
Y];
break;
78 "less than zero - using zero instead.\n", val,
81 }
else if (val > max_value) {
83 "greater than maximum allowed value %d - " 85 max_value, max_value);
111 uint32_t old_roi_size;
118 nb_roi = sd->
size / old_roi_size + 1;
127 for (i = 0; i < nb_roi - 1; i++) {
129 (sd->
data + old_roi_size * i);
134 .bottom = old_roi->
bottom,
135 .left = old_roi->
left,
136 .right = old_roi->
right,
197 "Error parsing %c expression '%s'.\n",
217 #define OFFSET(x) offsetof(AddROIContext, x) 218 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM 220 {
"x",
"Region distance from left edge of frame.",
222 {
"y",
"Region distance from top edge of frame.",
224 {
"w",
"Region width.",
226 {
"h",
"Region height.",
229 {
"qoffset",
"Quantisation offset to apply in the region.",
232 {
"clear",
"Remove any existing regions of interest before adding the new one.",
265 .priv_class = &addroi_class,
int top
Distance in pixels from the top edge of the frame to the top and bottom edges and from the left edge ...
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
int h
agreed upon image height
static const AVOption addroi_options[]
static av_cold void addroi_uninit(AVFilterContext *avctx)
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.
static int addroi_filter_frame(AVFilterLink *inlink, AVFrame *frame)
AVExpr * region_expr[NB_PARAMS]
AVRational qoffset
Quantisation offset.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
const char * name
Pad name.
#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.
Structure to hold side data for an AVFrame.
uint32_t self_size
Must be set to the size of this data structure (that is, sizeof(AVRegionOfInterest)).
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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
simple assert() macros that are a bit more flexible than ISO C assert().
int w
agreed upon image width
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
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Structure describing a single Region Of Interest.
static const AVFilterPad outputs[]
static const uint8_t vars[2][12]
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
AVBufferRef * av_buffer_alloc(buffer_size_t size)
Allocate an AVBuffer of the given size using av_malloc().
AVFILTER_DEFINE_CLASS(addroi)
static const char *const addroi_var_names[]
uint8_t * data
The data buffer.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
Describe the class of an AVClass context structure.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, buffer_size_t size)
Add a new side data to a frame.
Rational number (pair of numerator and denominator).
Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is ...
static const AVFilterPad addroi_outputs[]
const char * name
Filter name.
char * region_str[NB_PARAMS]
AVFilterLink ** outputs
array of pointers to output links
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 av_cold int addroi_init(AVFilterContext *avctx)
A reference to a data buffer.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
static const char addroi_param_names[]
static int addroi_config_input(AVFilterLink *inlink)
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 double val(void *priv, double ch)
simple arithmetic expression evaluator
static const AVFilterPad addroi_inputs[]