70 const int luma_den = 10000;
78 "Mastering Display Metadata(in luminance):\n");
80 "min_luminance=%u, max_luminance=%u\n",
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];
110 "Mastering Display Metadata(in primaries):\n");
112 "G(%u,%u) B(%u,%u) R(%u,%u) WP(%u,%u)\n",
140 "Mastering Content Light Level (in):\n");
142 "MaxCLL(%u) MaxFALL(%u)\n",
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));
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;
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));
295 input_frame, output_frame);
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",
415 .
inputs = tonemap_vaapi_inputs,
416 .
outputs = tonemap_vaapi_outputs,
417 .priv_class = &tonemap_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.
unsigned MaxCLL
Max content light level (cd/m^2).
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
Memory handling functions.
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
static av_cold int init(AVCodecContext *avctx)
static int tonemap_vaapi_build_filter_params(AVFilterContext *avctx)
static const AVOption tonemap_vaapi_options[]
Content light level (based on CTA-861.3).
AVFILTER_DEFINE_CLASS(tonemap_vaapi)
Mastering display metadata associated with a video frame.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const AVFilterPad tonemap_vaapi_outputs[]
AVColorTransferCharacteristic
Color Transfer Characteristic.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
const char * name
Pad name.
VAHdrMetaDataHDR10 in_metadata
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define STRING_OPTION(var_name, func_name, default_value)
static av_cold int uninit(AVCodecContext *avctx)
AVFrameSideData * src_light
AVColorSpace
YUV colorspace type.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Structure to hold side data for an AVFrame.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
AVColorPrimaries
Chromaticity coordinates of the source primaries.
char * color_matrix_string
AVFilter ff_vf_tonemap_vaapi
A filter pad used for either input or output.
A link between two filters.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
char * color_transfer_string
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int tonemap_vaapi_init(AVFilterContext *avctx)
enum AVColorSpace color_matrix
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.
enum AVColorSpace colorspace
YUV colorspace type.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
simple assert() macros that are a bit more flexible than ISO C assert().
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
static int tonemap_vaapi_set_filter_params(AVFilterContext *avctx, AVFrame *input_frame)
char * color_primaries_string
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
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_pipeline_uninit(AVFilterContext *avctx)
static const AVFilterPad tonemap_vaapi_inputs[]
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]
static int tonemap_vaapi_save_metadata(AVFilterContext *avctx, AVFrame *input_frame)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
AVFrameSideData * src_display
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum AVPixelFormat output_format
AVVAAPIDeviceContext * hwctx
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
static int query_formats(AVFilterContext *ctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
char * output_format_string
AVFilterContext * dst
dest filter
enum AVColorPrimaries color_primaries
enum AVColorPrimaries color_primaries
enum AVColorTransferCharacteristic color_transfer
enum AVColorTransferCharacteristic color_trc
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
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
unsigned MaxFALL
Max average light level per frame (cd/m^2).
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.