31 #define BRIGHTNESS_MIN -100.0F 32 #define BRIGHTNESS_MAX 100.0F 33 #define BRIGHTNESS_DEFAULT 0.0F 35 #define CONTRAST_MIN 0.0F 36 #define CONTRAST_MAX 10.0F 37 #define CONTRAST_DEFAULT 1.0F 39 #define HUE_MIN -180.0F 40 #define HUE_MAX 180.0F 41 #define HUE_DEFAULT 0.0F 43 #define SATURATION_MIN 0.0F 44 #define SATURATION_MAX 10.0F 45 #define SATURATION_DEFAULT 1.0F 56 static float map(
float x,
float in_min,
float in_max,
float out_min,
float out_max)
60 slope = 1.0 * (out_max - out_min) / (in_max - in_min);
61 output = out_min + slope * (x - in_min);
71 VAProcFilterParameterBufferColorBalance procamp_params[4];
72 VAProcFilterCapColorBalance procamp_caps[VAProcColorBalanceCount];
76 memset(&procamp_params, 0,
sizeof(procamp_params));
77 memset(&procamp_caps, 0,
sizeof(procamp_caps));
79 num_caps = VAProcColorBalanceCount;
81 VAProcFilterColorBalance, &procamp_caps, &num_caps);
83 if (vas != VA_STATUS_SUCCESS) {
85 "filter caps: %d (%s).\n", vas, vaErrorStr(vas));
90 procamp_params[
i].type = VAProcFilterColorBalance;
91 procamp_params[
i].attrib = VAProcColorBalanceBrightness;
93 procamp_caps[VAProcColorBalanceBrightness-1].range.min_value,
94 procamp_caps[VAProcColorBalanceBrightness-1].range.max_value);
98 procamp_params[
i].type = VAProcFilterColorBalance;
99 procamp_params[
i].attrib = VAProcColorBalanceContrast;
101 procamp_caps[VAProcColorBalanceContrast-1].range.min_value,
102 procamp_caps[VAProcColorBalanceContrast-1].range.max_value);
106 procamp_params[
i].type = VAProcFilterColorBalance;
107 procamp_params[
i].attrib = VAProcColorBalanceHue;
109 procamp_caps[VAProcColorBalanceHue-1].range.min_value,
110 procamp_caps[VAProcColorBalanceHue-1].range.max_value);
114 procamp_params[
i].type = VAProcFilterColorBalance;
115 procamp_params[
i].attrib = VAProcColorBalanceSaturation;
117 procamp_caps[VAProcColorBalanceSaturation-1].range.min_value,
118 procamp_caps[VAProcColorBalanceSaturation-1].range.max_value);
122 VAProcFilterParameterBufferType,
124 sizeof(procamp_params[0]),
134 VAProcPipelineParameterBuffer
params;
156 input_frame, output_frame);
161 params.num_filters = 1;
193 #define OFFSET(x) offsetof(ProcampVAAPIContext, x) 194 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM) 196 {
"b",
"Output video brightness",
198 {
"brightness",
"Output video brightness",
200 {
"s",
"Output video saturation",
202 {
"saturatio",
"Output video saturation",
204 {
"c",
"Output video contrast",
206 {
"contrast",
"Output video contrast",
208 {
"h",
"Output video hue",
210 {
"hue",
"Output video hue",
237 .
name =
"procamp_vaapi",
238 .description =
NULL_IF_CONFIG_SMALL(
"ProcAmp (color balance) adjustments for hue, saturation, brightness, contrast"),
243 .
inputs = procamp_vaapi_inputs,
244 .
outputs = procamp_vaapi_outputs,
245 .priv_class = &procamp_vaapi_class,
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
This structure describes decoded (raw) audio or video data.
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
Main libavfilter public API header.
Memory handling functions.
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
static av_cold int init(AVCodecContext *avctx)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
static av_cold int uninit(AVCodecContext *avctx)
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static float map(float x, float in_min, float in_max, float out_min, float out_max)
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.
static int procamp_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
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 AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
static av_cold int procamp_vaapi_init(AVFilterContext *avctx)
#define BRIGHTNESS_DEFAULT
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
AVFilter ff_vf_procamp_vaapi
static const AVOption procamp_vaapi_options[]
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
static const AVFilterPad procamp_vaapi_outputs[]
AVFILTER_DEFINE_CLASS(procamp_vaapi)
static const AVFilterPad outputs[]
VADisplay display
The VADisplay handle, to be filled by the user.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
VABufferID filter_buffers[VAProcFilterCount]
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
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum AVPixelFormat output_format
AVVAAPIDeviceContext * hwctx
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
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
#define SATURATION_DEFAULT
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
static int query_formats(AVFilterContext *ctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
static const AVFilterPad procamp_vaapi_inputs[]
AVFilterContext * dst
dest filter
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int(* build_filter_params)(AVFilterContext *avctx)
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
void(* pipeline_uninit)(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.