Go to the documentation of this file.
60 if (
ctx->src_display) {
68 const int luma_den = 10000;
69 ctx->in_metadata.max_display_mastering_luminance =
71 ctx->in_metadata.min_display_mastering_luminance =
73 ctx->in_metadata.max_display_mastering_luminance);
76 "Mastering Display Metadata(in luminance):\n");
78 "min_luminance=%u, max_luminance=%u\n",
79 ctx->in_metadata.min_display_mastering_luminance,
80 ctx->in_metadata.max_display_mastering_luminance);
85 const int mapping[3] = {1, 2, 0};
86 const int chroma_den = 50000;
88 for (
i = 0;
i < 3;
i++) {
89 const int j = mapping[
i];
90 ctx->in_metadata.display_primaries_x[
i] =
94 ctx->in_metadata.display_primaries_y[
i] =
100 ctx->in_metadata.white_point_x =
103 ctx->in_metadata.white_point_y =
108 "Mastering Display Metadata(in primaries):\n");
110 "G(%u,%u) B(%u,%u) R(%u,%u) WP(%u,%u)\n",
111 ctx->in_metadata.display_primaries_x[0],
112 ctx->in_metadata.display_primaries_y[0],
113 ctx->in_metadata.display_primaries_x[1],
114 ctx->in_metadata.display_primaries_y[1],
115 ctx->in_metadata.display_primaries_x[2],
116 ctx->in_metadata.display_primaries_y[2],
117 ctx->in_metadata.white_point_x,
118 ctx->in_metadata.white_point_y);
127 if (
ctx->src_light) {
134 ctx->in_metadata.max_content_light_level = light_meta->
MaxCLL;
135 ctx->in_metadata.max_pic_average_light_level = light_meta->
MaxFALL;
138 "Mastering Content Light Level (in):\n");
140 "MaxCLL(%u) MaxFALL(%u)\n",
141 ctx->in_metadata.max_content_light_level,
142 ctx->in_metadata.max_pic_average_light_level);
154 VAProcFilterParameterBufferHDRToneMapping *hdrtm_param;
157 (
void**)&hdrtm_param);
158 if (vas != VA_STATUS_SUCCESS) {
160 "buffer (%d): %d (%s).\n",
165 memcpy(hdrtm_param->data.metadata, &
ctx->in_metadata,
sizeof(VAHdrMetaDataHDR10));
168 if (vas != VA_STATUS_SUCCESS) {
170 "%d (%s).\n", vas, vaErrorStr(vas));
182 VAProcFilterParameterBufferHDRToneMapping hdrtm_param;
183 VAProcFilterCapHighDynamicRange hdr_cap[VAProcHighDynamicRangeMetadataTypeCount];
187 memset(&hdrtm_param, 0,
sizeof(hdrtm_param));
188 memset(&
ctx->in_metadata, 0,
sizeof(
ctx->in_metadata));
190 num_query_caps = VAProcHighDynamicRangeMetadataTypeCount;
191 vas = vaQueryVideoProcFilterCaps(vpp_ctx->
hwctx->
display,
193 VAProcFilterHighDynamicRangeToneMapping,
194 &hdr_cap, &num_query_caps);
195 if (vas != VA_STATUS_SUCCESS) {
197 "context: %d (%s).\n", vas, vaErrorStr(vas));
201 for (
i = 0;
i < num_query_caps;
i++) {
202 if (hdr_cap[
i].metadata_type != VAProcHighDynamicRangeMetadataNone)
206 if (
i >= num_query_caps) {
211 for (
i = 0;
i < num_query_caps;
i++) {
212 if (VA_TONE_MAPPING_HDR_TO_SDR & hdr_cap[
i].caps_flag)
216 if (
i >= num_query_caps) {
218 "VAAPI driver doesn't support HDR to SDR\n");
222 hdrtm_param.type = VAProcFilterHighDynamicRangeToneMapping;
223 hdrtm_param.data.metadata_type = VAProcHighDynamicRangeMetadataHDR10;
224 hdrtm_param.data.metadata = &
ctx->in_metadata;
225 hdrtm_param.data.metadata_size =
sizeof(VAHdrMetaDataHDR10);
228 VAProcFilterParameterBufferType,
229 &hdrtm_param,
sizeof(hdrtm_param), 1);
239 VASurfaceID input_surface, output_surface;
241 VAProcPipelineParameterBuffer params;
261 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
272 output_surface = (VASurfaceID)(uintptr_t)
output_frame->data[3];
275 memset(¶ms, 0,
sizeof(params));
329 if (
ctx->output_format_string) {
344 #define STRING_OPTION(var_name, func_name, default_value) do { \
345 if (ctx->var_name ## _string) { \
346 int var = av_ ## func_name ## _from_name(ctx->var_name ## _string); \
348 av_log(avctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \
349 return AVERROR(EINVAL); \
351 ctx->var_name = var; \
353 ctx->var_name = default_value; \
364 #define OFFSET(x) offsetof(HDRVAAPIContext, x)
365 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
368 {
"matrix",
"Output color matrix coefficient set",
370 { .str =
NULL }, .flags =
FLAGS,
"matrix" },
371 {
"m",
"Output color matrix coefficient set",
373 { .str =
NULL }, .flags =
FLAGS,
"matrix" },
374 {
"primaries",
"Output color primaries set",
376 { .str =
NULL }, .flags =
FLAGS,
"primaries" },
377 {
"p",
"Output color primaries set",
379 { .str =
NULL }, .flags =
FLAGS,
"primaries" },
380 {
"transfer",
"Output color transfer characteristics set",
382 { .str =
NULL }, .flags =
FLAGS,
"transfer" },
383 {
"t",
"Output color transfer characteristics set",
385 { .str =
NULL }, .flags =
FLAGS,
"transfer" },
410 .
name =
"tonemap_vaapi",
418 .priv_class = &tonemap_vaapi_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
enum AVColorTransferCharacteristic color_trc
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVColorSpace color_matrix
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
AVColorTransferCharacteristic
Color Transfer Characteristic.
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
unsigned MaxCLL
Max content light level (cd/m^2).
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int tonemap_vaapi_save_metadata(AVFilterContext *avctx, AVFrame *input_frame)
char * color_primaries_string
#define FILTER_QUERY_FUNC(func)
VADisplay display
The VADisplay handle, to be filled by the user.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVFrameSideData * src_light
int(* build_filter_params)(AVFilterContext *avctx)
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
void * priv
private data for use by the filter
enum AVColorPrimaries color_primaries
enum AVColorTransferCharacteristic color_transfer
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVPixelFormat output_format
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
AVVAAPIDeviceContext * hwctx
char * color_transfer_string
#define FILTER_INPUTS(array)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFILTER_DEFINE_CLASS(tonemap_vaapi)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
static int tonemap_vaapi_build_filter_params(AVFilterContext *avctx)
static const AVOption tonemap_vaapi_options[]
const AVFilter ff_vf_tonemap_vaapi
@ AVCOL_TRC_BT709
also ITU-R BT1361
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
#define STRING_OPTION(var_name, func_name, default_value)
#define i(width, name, range_min, range_max)
AVColorSpace
YUV colorspace type.
VABufferID filter_buffers[VAProcFilterCount]
static const AVFilterPad tonemap_vaapi_outputs[]
const char * name
Pad name.
static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
char * output_format_string
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
AVFrameSideData * src_display
void(* pipeline_uninit)(AVFilterContext *avctx)
static av_cold int tonemap_vaapi_init(AVFilterContext *avctx)
VAHdrMetaDataHDR10 in_metadata
Structure to hold side data for an AVFrame.
unsigned MaxFALL
Max average light level per frame (cd/m^2).
#define FILTER_OUTPUTS(array)
static av_cold int uninit(AVCodecContext *avctx)
static int tonemap_vaapi_set_filter_params(AVFilterContext *avctx, AVFrame *input_frame)
char * color_matrix_string
static const AVFilterPad tonemap_vaapi_inputs[]
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 ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
AVFilterLink ** outputs
array of pointers to output links