Go to the documentation of this file.
62 if (
ctx->src_display) {
70 const int luma_den = 10000;
71 ctx->in_metadata.max_display_mastering_luminance =
73 ctx->in_metadata.min_display_mastering_luminance =
75 ctx->in_metadata.max_display_mastering_luminance);
78 "Mastering Display Metadata(in luminance):\n");
80 "min_luminance=%u, max_luminance=%u\n",
81 ctx->in_metadata.min_display_mastering_luminance,
82 ctx->in_metadata.max_display_mastering_luminance);
87 const int mapping[3] = {1, 2, 0};
88 const int chroma_den = 50000;
90 for (
i = 0;
i < 3;
i++) {
91 const int j = mapping[
i];
92 ctx->in_metadata.display_primaries_x[
i] =
96 ctx->in_metadata.display_primaries_y[
i] =
102 ctx->in_metadata.white_point_x =
105 ctx->in_metadata.white_point_y =
110 "Mastering Display Metadata(in primaries):\n");
112 "G(%u,%u) B(%u,%u) R(%u,%u) WP(%u,%u)\n",
113 ctx->in_metadata.display_primaries_x[0],
114 ctx->in_metadata.display_primaries_y[0],
115 ctx->in_metadata.display_primaries_x[1],
116 ctx->in_metadata.display_primaries_y[1],
117 ctx->in_metadata.display_primaries_x[2],
118 ctx->in_metadata.display_primaries_y[2],
119 ctx->in_metadata.white_point_x,
120 ctx->in_metadata.white_point_y);
129 if (
ctx->src_light) {
136 ctx->in_metadata.max_content_light_level = light_meta->
MaxCLL;
137 ctx->in_metadata.max_pic_average_light_level = light_meta->
MaxFALL;
140 "Mastering Content Light Level (in):\n");
142 "MaxCLL(%u) MaxFALL(%u)\n",
143 ctx->in_metadata.max_content_light_level,
144 ctx->in_metadata.max_pic_average_light_level);
156 VAProcFilterParameterBufferHDRToneMapping *hdrtm_param;
159 (
void**)&hdrtm_param);
160 if (vas != VA_STATUS_SUCCESS) {
162 "buffer (%d): %d (%s).\n",
167 memcpy(hdrtm_param->data.metadata, &
ctx->in_metadata,
sizeof(VAHdrMetaDataHDR10));
170 if (vas != VA_STATUS_SUCCESS) {
172 "%d (%s).\n", vas, vaErrorStr(vas));
184 VAProcFilterParameterBufferHDRToneMapping hdrtm_param;
185 VAProcFilterCapHighDynamicRange hdr_cap[VAProcHighDynamicRangeMetadataTypeCount];
189 memset(&hdrtm_param, 0,
sizeof(hdrtm_param));
190 memset(&
ctx->in_metadata, 0,
sizeof(
ctx->in_metadata));
192 num_query_caps = VAProcHighDynamicRangeMetadataTypeCount;
193 vas = vaQueryVideoProcFilterCaps(vpp_ctx->
hwctx->
display,
195 VAProcFilterHighDynamicRangeToneMapping,
196 &hdr_cap, &num_query_caps);
197 if (vas != VA_STATUS_SUCCESS) {
199 "context: %d (%s).\n", vas, vaErrorStr(vas));
203 for (
i = 0;
i < num_query_caps;
i++) {
204 if (hdr_cap[
i].metadata_type != VAProcHighDynamicRangeMetadataNone)
208 if (
i >= num_query_caps) {
213 for (
i = 0;
i < num_query_caps;
i++) {
214 if (VA_TONE_MAPPING_HDR_TO_SDR & hdr_cap[
i].caps_flag)
218 if (
i >= num_query_caps) {
220 "VAAPI driver doesn't support HDR to SDR\n");
224 hdrtm_param.type = VAProcFilterHighDynamicRangeToneMapping;
225 hdrtm_param.data.metadata_type = VAProcHighDynamicRangeMetadataHDR10;
226 hdrtm_param.data.metadata = &
ctx->in_metadata;
227 hdrtm_param.data.metadata_size =
sizeof(VAHdrMetaDataHDR10);
230 VAProcFilterParameterBufferType,
231 &hdrtm_param,
sizeof(hdrtm_param), 1);
241 VASurfaceID input_surface, output_surface;
243 VAProcPipelineParameterBuffer params;
263 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
274 output_surface = (VASurfaceID)(uintptr_t)
output_frame->data[3];
277 memset(¶ms, 0,
sizeof(params));
326 if (
ctx->output_format_string) {
341 #define STRING_OPTION(var_name, func_name, default_value) do { \
342 if (ctx->var_name ## _string) { \
343 int var = av_ ## func_name ## _from_name(ctx->var_name ## _string); \
345 av_log(avctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \
346 return AVERROR(EINVAL); \
348 ctx->var_name = var; \
350 ctx->var_name = default_value; \
361 #define OFFSET(x) offsetof(HDRVAAPIContext, x)
362 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
365 {
"matrix",
"Output color matrix coefficient set",
367 { .str =
NULL }, .flags =
FLAGS,
"matrix" },
368 {
"m",
"Output color matrix coefficient set",
370 { .str =
NULL }, .flags =
FLAGS,
"matrix" },
371 {
"primaries",
"Output color primaries set",
373 { .str =
NULL }, .flags =
FLAGS,
"primaries" },
374 {
"p",
"Output color primaries set",
376 { .str =
NULL }, .flags =
FLAGS,
"primaries" },
377 {
"transfer",
"Output color transfer characteristics set",
379 { .str =
NULL }, .flags =
FLAGS,
"transfer" },
380 {
"t",
"Output color transfer characteristics set",
382 { .str =
NULL }, .flags =
FLAGS,
"transfer" },
409 .
name =
"tonemap_vaapi",
417 .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.
static av_cold int init(AVCodecContext *avctx)
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
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.
static const AVFilterPad outputs[]
#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
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)
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
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
@ 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[]
@ 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.
AVFilter ff_vf_tonemap_vaapi
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).
static int query_formats(AVFilterContext *ctx)
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 struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
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