FFmpeg
Loading...
Searching...
No Matches
vf_tonemap_vaapi.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#include <string.h>
19
20#include "libavutil/opt.h"
21#include "libavutil/pixdesc.h"
23
24#include "avfilter.h"
25#include "filters.h"
26#include "vaapi_vpp.h"
27#include "video.h"
28
51
52static int tonemap_vaapi_save_metadata(AVFilterContext *avctx, AVFrame *input_frame)
53{
54 HDRVAAPIContext *ctx = avctx->priv;
56 AVContentLightMetadata *light_meta;
57
58 if (input_frame->color_trc != AVCOL_TRC_SMPTE2084) {
59 av_log(avctx, AV_LOG_WARNING, "Only support HDR10 as input for vaapi tone-mapping\n");
60 }
61
62 ctx->src_display = av_frame_get_side_data(input_frame,
64 if (ctx->src_display) {
65 hdr_meta = (AVMasteringDisplayMetadata *)ctx->src_display->data;
66 if (!hdr_meta) {
67 av_log(avctx, AV_LOG_ERROR, "No mastering display data\n");
68 return AVERROR(EINVAL);
69 }
70
71 if (hdr_meta->has_luminance) {
72 const int luma_den = 10000;
73 ctx->in_metadata.max_display_mastering_luminance =
74 lrint(luma_den * av_q2d(hdr_meta->max_luminance));
75 ctx->in_metadata.min_display_mastering_luminance =
76 FFMIN(lrint(luma_den * av_q2d(hdr_meta->min_luminance)),
77 ctx->in_metadata.max_display_mastering_luminance);
78
79 av_log(avctx, AV_LOG_DEBUG,
80 "Mastering Display Metadata(in luminance):\n");
81 av_log(avctx, AV_LOG_DEBUG,
82 "min_luminance=%u, max_luminance=%u\n",
83 ctx->in_metadata.min_display_mastering_luminance,
84 ctx->in_metadata.max_display_mastering_luminance);
85 }
86
87 if (hdr_meta->has_primaries) {
88 int i;
89 const int mapping[3] = {1, 2, 0}; //green, blue, red
90 const int chroma_den = 50000;
91
92 for (i = 0; i < 3; i++) {
93 const int j = mapping[i];
94 ctx->in_metadata.display_primaries_x[i] =
95 FFMIN(lrint(chroma_den *
96 av_q2d(hdr_meta->display_primaries[j][0])),
97 chroma_den);
98 ctx->in_metadata.display_primaries_y[i] =
99 FFMIN(lrint(chroma_den *
100 av_q2d(hdr_meta->display_primaries[j][1])),
101 chroma_den);
102 }
103
104 ctx->in_metadata.white_point_x =
105 FFMIN(lrint(chroma_den * av_q2d(hdr_meta->white_point[0])),
106 chroma_den);
107 ctx->in_metadata.white_point_y =
108 FFMIN(lrint(chroma_den * av_q2d(hdr_meta->white_point[1])),
109 chroma_den);
110
111 av_log(avctx, AV_LOG_DEBUG,
112 "Mastering Display Metadata(in primaries):\n");
113 av_log(avctx, AV_LOG_DEBUG,
114 "G(%u,%u) B(%u,%u) R(%u,%u) WP(%u,%u)\n",
115 ctx->in_metadata.display_primaries_x[0],
116 ctx->in_metadata.display_primaries_y[0],
117 ctx->in_metadata.display_primaries_x[1],
118 ctx->in_metadata.display_primaries_y[1],
119 ctx->in_metadata.display_primaries_x[2],
120 ctx->in_metadata.display_primaries_y[2],
121 ctx->in_metadata.white_point_x,
122 ctx->in_metadata.white_point_y);
123 }
124 } else {
125 av_log(avctx, AV_LOG_ERROR, "No mastering display data from input\n");
126 return AVERROR(EINVAL);
127 }
128
129 ctx->src_light = av_frame_get_side_data(input_frame,
131 if (ctx->src_light) {
132 light_meta = (AVContentLightMetadata *)ctx->src_light->data;
133 if (!light_meta) {
134 av_log(avctx, AV_LOG_ERROR, "No light metadata\n");
135 return AVERROR(EINVAL);
136 }
137
138 ctx->in_metadata.max_content_light_level = light_meta->MaxCLL;
139 ctx->in_metadata.max_pic_average_light_level = light_meta->MaxFALL;
140
141 av_log(avctx, AV_LOG_DEBUG,
142 "Mastering Content Light Level (in):\n");
143 av_log(avctx, AV_LOG_DEBUG,
144 "MaxCLL(%u) MaxFALL(%u)\n",
145 ctx->in_metadata.max_content_light_level,
146 ctx->in_metadata.max_pic_average_light_level);
147 } else {
148 av_log(avctx, AV_LOG_DEBUG, "No content light level from input\n");
149 }
150 return 0;
151}
152
154{
155 HDRVAAPIContext *ctx = avctx->priv;
158 AVFrameSideData *metadata_lt;
159 AVContentLightMetadata *hdr_meta_lt;
160 int i;
161 const int mapping[3] = {1, 2, 0}; //green, blue, red
162 const int chroma_den = 50000;
163 const int luma_den = 10000;
164
168 if (!metadata)
169 return AVERROR(ENOMEM);
170
171 hdr_meta = (AVMasteringDisplayMetadata *)metadata->data;
172
173 for (i = 0; i < 3; i++) {
174 const int j = mapping[i];
175 hdr_meta->display_primaries[j][0].num = ctx->out_metadata.display_primaries_x[i];
176 hdr_meta->display_primaries[j][0].den = chroma_den;
177
178 hdr_meta->display_primaries[j][1].num = ctx->out_metadata.display_primaries_y[i];
179 hdr_meta->display_primaries[j][1].den = chroma_den;
180 }
181
182 hdr_meta->white_point[0].num = ctx->out_metadata.white_point_x;
183 hdr_meta->white_point[0].den = chroma_den;
184
185 hdr_meta->white_point[1].num = ctx->out_metadata.white_point_y;
186 hdr_meta->white_point[1].den = chroma_den;
187 hdr_meta->has_primaries = 1;
188
189 hdr_meta->max_luminance.num = ctx->out_metadata.max_display_mastering_luminance;
190 hdr_meta->max_luminance.den = luma_den;
191
192 hdr_meta->min_luminance.num = ctx->out_metadata.min_display_mastering_luminance;
193 hdr_meta->min_luminance.den = luma_den;
194 hdr_meta->has_luminance = 1;
195
196 av_log(avctx, AV_LOG_DEBUG,
197 "Mastering display colour volume(out):\n");
198 av_log(avctx, AV_LOG_DEBUG,
199 "G(%u,%u) B(%u,%u) R(%u,%u) WP(%u,%u)\n",
200 ctx->out_metadata.display_primaries_x[0],
201 ctx->out_metadata.display_primaries_y[0],
202 ctx->out_metadata.display_primaries_x[1],
203 ctx->out_metadata.display_primaries_y[1],
204 ctx->out_metadata.display_primaries_x[2],
205 ctx->out_metadata.display_primaries_y[2],
206 ctx->out_metadata.white_point_x,
207 ctx->out_metadata.white_point_y);
208 av_log(avctx, AV_LOG_DEBUG,
209 "max_display_mastering_luminance=%u, min_display_mastering_luminance=%u\n",
210 ctx->out_metadata.max_display_mastering_luminance,
211 ctx->out_metadata.min_display_mastering_luminance);
212
215 sizeof(AVContentLightMetadata));
216 if (!metadata_lt)
217 return AVERROR(ENOMEM);
218
219 hdr_meta_lt = (AVContentLightMetadata *)metadata_lt->data;
220
221 hdr_meta_lt->MaxCLL = FFMIN(ctx->out_metadata.max_content_light_level, 65535);
222 hdr_meta_lt->MaxFALL = FFMIN(ctx->out_metadata.max_pic_average_light_level, 65535);
223
224 av_log(avctx, AV_LOG_DEBUG,
225 "Content light level information(out):\n");
226 av_log(avctx, AV_LOG_DEBUG,
227 "MaxCLL(%u) MaxFALL(%u)\n",
228 ctx->out_metadata.max_content_light_level,
229 ctx->out_metadata.max_pic_average_light_level);
230
231 return 0;
232}
233
235{
236 VAAPIVPPContext *vpp_ctx = avctx->priv;
237 HDRVAAPIContext *ctx = avctx->priv;
238 VAStatus vas;
239 VAProcFilterParameterBufferHDRToneMapping *hdrtm_param;
240
241 vas = vaMapBuffer(vpp_ctx->hwctx->display, vpp_ctx->filter_buffers[0],
242 (void**)&hdrtm_param);
243 if (vas != VA_STATUS_SUCCESS) {
244 av_log(avctx, AV_LOG_ERROR, "Failed to map "
245 "buffer (%d): %d (%s).\n",
246 vpp_ctx->filter_buffers[0], vas, vaErrorStr(vas));
247 return AVERROR(EIO);
248 }
249
250 memcpy(hdrtm_param->data.metadata, &ctx->in_metadata, sizeof(VAHdrMetaDataHDR10));
251
252 vas = vaUnmapBuffer(vpp_ctx->hwctx->display, vpp_ctx->filter_buffers[0]);
253 if (vas != VA_STATUS_SUCCESS) {
254 av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "
255 "%d (%s).\n", vas, vaErrorStr(vas));
256 return AVERROR(EIO);
257 }
258
259 return 0;
260}
261
263{
264 VAAPIVPPContext *vpp_ctx = avctx->priv;
265 HDRVAAPIContext *ctx = avctx->priv;
266 VAStatus vas;
267 VAProcFilterParameterBufferHDRToneMapping hdrtm_param;
268 VAProcFilterCapHighDynamicRange hdr_cap[VAProcHighDynamicRangeMetadataTypeCount];
269 int num_query_caps;
270 int i;
271
272 memset(&hdrtm_param, 0, sizeof(hdrtm_param));
273 memset(&ctx->in_metadata, 0, sizeof(ctx->in_metadata));
274
275 num_query_caps = VAProcHighDynamicRangeMetadataTypeCount;
276 vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display,
277 vpp_ctx->va_context,
278 VAProcFilterHighDynamicRangeToneMapping,
279 &hdr_cap, &num_query_caps);
280 if (vas != VA_STATUS_SUCCESS) {
281 av_log(avctx, AV_LOG_ERROR, "Failed to query HDR caps "
282 "context: %d (%s).\n", vas, vaErrorStr(vas));
283 return AVERROR(EIO);
284 }
285
286 for (i = 0; i < num_query_caps; i++) {
287 if (hdr_cap[i].metadata_type != VAProcHighDynamicRangeMetadataNone)
288 break;
289 }
290
291 if (i >= num_query_caps) {
292 av_log(avctx, AV_LOG_ERROR, "VAAPI driver doesn't support HDR\n");
293 return AVERROR(EINVAL);
294 }
295
296 if (ctx->mastering_display) {
297 for (i = 0; i < num_query_caps; i++) {
298 if (VA_TONE_MAPPING_HDR_TO_HDR & hdr_cap[i].caps_flag)
299 break;
300 }
301 if (i >= num_query_caps) {
302 av_log(avctx, AV_LOG_ERROR,
303 "VAAPI driver doesn't support HDR to HDR\n");
304 return AVERROR(EINVAL);
305 }
306 } else {
307 for (i = 0; i < num_query_caps; i++) {
308 if (VA_TONE_MAPPING_HDR_TO_SDR & hdr_cap[i].caps_flag)
309 break;
310 }
311 if (i >= num_query_caps) {
312 av_log(avctx, AV_LOG_ERROR,
313 "VAAPI driver doesn't support HDR to SDR\n");
314 return AVERROR(EINVAL);
315 }
316 }
317
318 hdrtm_param.type = VAProcFilterHighDynamicRangeToneMapping;
319 hdrtm_param.data.metadata_type = VAProcHighDynamicRangeMetadataHDR10;
320 hdrtm_param.data.metadata = &ctx->in_metadata;
321 hdrtm_param.data.metadata_size = sizeof(VAHdrMetaDataHDR10);
322
324 VAProcFilterParameterBufferType,
325 &hdrtm_param, sizeof(hdrtm_param), 1);
326}
327
328static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
329{
330 AVFilterContext *avctx = inlink->dst;
331 AVFilterLink *outlink = avctx->outputs[0];
332 VAAPIVPPContext *vpp_ctx = avctx->priv;
333 HDRVAAPIContext *ctx = avctx->priv;
335 VASurfaceID input_surface, output_surface;
336
337 VAProcPipelineParameterBuffer params;
338 int err;
339
340 VAHdrMetaData out_hdr_metadata;
341
342 av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
343 av_get_pix_fmt_name(input_frame->format),
344 input_frame->width, input_frame->height, input_frame->pts);
345
346 if (vpp_ctx->va_context == VA_INVALID_ID){
347 av_frame_free(&input_frame);
348 return AVERROR(EINVAL);
349 }
350
351 err = tonemap_vaapi_save_metadata(avctx, input_frame);
352 if (err < 0)
353 goto fail;
354
355 err = tonemap_vaapi_set_filter_params(avctx, input_frame);
356 if (err < 0)
357 goto fail;
358
359 input_surface = (VASurfaceID)(uintptr_t)input_frame->data[3];
360 av_log(avctx, AV_LOG_DEBUG, "Using surface %#x for tonemap vpp input.\n",
361 input_surface);
362
364 vpp_ctx->output_height);
365 if (!output_frame) {
366 err = AVERROR(ENOMEM);
367 goto fail;
368 }
369
370 output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
371 av_log(avctx, AV_LOG_DEBUG, "Using surface %#x for tonemap vpp output.\n",
372 output_surface);
373 memset(&params, 0, sizeof(params));
374
375 err = av_frame_copy_props(output_frame, input_frame);
376 if (err < 0)
377 goto fail;
378
381
382 if (!ctx->mastering_display) {
383 /* Use BT709 by default for HDR to SDR output frame */
384 output_frame->color_primaries = AVCOL_PRI_BT709;
385 output_frame->color_trc = AVCOL_TRC_BT709;
386 output_frame->colorspace = AVCOL_SPC_BT709;
387 }
388
389 if (ctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
390 output_frame->color_primaries = ctx->color_primaries;
391
392 if (ctx->color_transfer != AVCOL_TRC_UNSPECIFIED)
393 output_frame->color_trc = ctx->color_transfer;
394
395 if (ctx->color_matrix != AVCOL_SPC_UNSPECIFIED)
396 output_frame->colorspace = ctx->color_matrix;
397
398 if (ctx->mastering_display) {
400 if (err < 0)
401 goto fail;
402 }
403
404 err = ff_vaapi_vpp_init_params(avctx, &params,
405 input_frame, output_frame);
406 if (err < 0)
407 goto fail;
408
409 if (ctx->mastering_display) {
410 out_hdr_metadata.metadata_type = VAProcHighDynamicRangeMetadataHDR10;
411 out_hdr_metadata.metadata = &ctx->out_metadata;
412 out_hdr_metadata.metadata_size = sizeof(VAHdrMetaDataHDR10);
413 params.output_hdr_metadata = &out_hdr_metadata;
414 }
415
416 if (vpp_ctx->nb_filter_buffers) {
417 params.filters = &vpp_ctx->filter_buffers[0];
418 params.num_filters = vpp_ctx->nb_filter_buffers;
419 }
420
422 if (err < 0)
423 goto fail;
424
425 av_frame_free(&input_frame);
426
427 av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
429 output_frame->width, output_frame->height, output_frame->pts);
430
431 return ff_filter_frame(outlink, output_frame);
432
433fail:
434 av_frame_free(&input_frame);
436 return err;
437}
438
440{
441 VAAPIVPPContext *vpp_ctx = avctx->priv;
442 HDRVAAPIContext *ctx = avctx->priv;
443
447
448 if (ctx->output_format_string) {
449 vpp_ctx->output_format = av_get_pix_fmt(ctx->output_format_string);
450 } else {
451 if (ctx->mastering_display) {
453 av_log(avctx, AV_LOG_VERBOSE, "Output format not set, use default format P010 for HDR to HDR tone mapping.\n");
454 } else {
456 av_log(avctx, AV_LOG_VERBOSE, "Output format not set, use default format NV12 for HDR to SDR tone mapping.\n");
457 }
458 }
459
460#define STRING_OPTION(var_name, func_name, default_value) do { \
461 if (ctx->var_name ## _string) { \
462 int var = av_ ## func_name ## _from_name(ctx->var_name ## _string); \
463 if (var < 0) { \
464 av_log(avctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \
465 return AVERROR(EINVAL); \
466 } \
467 ctx->var_name = var; \
468 } else { \
469 ctx->var_name = default_value; \
470 } \
471 } while (0)
472
474 STRING_OPTION(color_transfer, color_transfer, AVCOL_TRC_UNSPECIFIED);
475 STRING_OPTION(color_matrix, color_space, AVCOL_SPC_UNSPECIFIED);
476
477 if (ctx->mastering_display) {
478 if (10 != sscanf(ctx->mastering_display,
479 "%hu %hu|%hu %hu|%hu %hu|%hu %hu|%u %u",
480 &ctx->out_metadata.display_primaries_x[0],
481 &ctx->out_metadata.display_primaries_y[0],
482 &ctx->out_metadata.display_primaries_x[1],
483 &ctx->out_metadata.display_primaries_y[1],
484 &ctx->out_metadata.display_primaries_x[2],
485 &ctx->out_metadata.display_primaries_y[2],
486 &ctx->out_metadata.white_point_x,
487 &ctx->out_metadata.white_point_y,
488 &ctx->out_metadata.min_display_mastering_luminance,
489 &ctx->out_metadata.max_display_mastering_luminance)) {
490 av_log(avctx, AV_LOG_ERROR,
491 "Option mastering-display input invalid\n");
492 return AVERROR(EINVAL);
493 }
494
495 if (!ctx->content_light) {
496 ctx->out_metadata.max_content_light_level = 0;
497 ctx->out_metadata.max_pic_average_light_level = 0;
498 } else if (2 != sscanf(ctx->content_light,
499 "%hu %hu",
500 &ctx->out_metadata.max_content_light_level,
501 &ctx->out_metadata.max_pic_average_light_level)) {
502 av_log(avctx, AV_LOG_ERROR,
503 "Option content-light input invalid\n");
504 return AVERROR(EINVAL);
505 }
506 }
507
508 return 0;
509}
510
511#define OFFSET(x) offsetof(HDRVAAPIContext, x)
512#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
514 { "format", "Output pixel format set", OFFSET(output_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS, .unit = "format" },
515 { "matrix", "Output color matrix coefficient set",
516 OFFSET(color_matrix_string), AV_OPT_TYPE_STRING,
517 { .str = NULL }, .flags = FLAGS, .unit = "matrix" },
518 { "m", "Output color matrix coefficient set",
519 OFFSET(color_matrix_string), AV_OPT_TYPE_STRING,
520 { .str = NULL }, .flags = FLAGS, .unit = "matrix" },
521 { "primaries", "Output color primaries set",
522 OFFSET(color_primaries_string), AV_OPT_TYPE_STRING,
523 { .str = NULL }, .flags = FLAGS, .unit = "primaries" },
524 { "p", "Output color primaries set",
525 OFFSET(color_primaries_string), AV_OPT_TYPE_STRING,
526 { .str = NULL }, .flags = FLAGS, .unit = "primaries" },
527 { "transfer", "Output color transfer characteristics set",
528 OFFSET(color_transfer_string), AV_OPT_TYPE_STRING,
529 { .str = NULL }, .flags = FLAGS, .unit = "transfer" },
530 { "t", "Output color transfer characteristics set",
531 OFFSET(color_transfer_string), AV_OPT_TYPE_STRING,
532 { .str = NULL }, .flags = FLAGS, .unit = "transfer" },
533 { "display", "set mastering display colour volume",
534 OFFSET(mastering_display), AV_OPT_TYPE_STRING,
535 { .str = NULL }, .flags = FLAGS },
536 { "light", "set content light level information",
537 OFFSET(content_light), AV_OPT_TYPE_STRING,
538 { .str = NULL }, .flags = FLAGS },
539 { NULL }
540};
541
542
544
546 {
547 .name = "default",
548 .type = AVMEDIA_TYPE_VIDEO,
549 .filter_frame = &tonemap_vaapi_filter_frame,
550 .config_props = &ff_vaapi_vpp_config_input,
551 },
552};
553
555 {
556 .name = "default",
557 .type = AVMEDIA_TYPE_VIDEO,
558 .config_props = &ff_vaapi_vpp_config_output,
559 },
560};
561
563 .p.name = "tonemap_vaapi",
564 .p.description = NULL_IF_CONFIG_SMALL("VAAPI VPP for tone-mapping"),
565 .p.priv_class = &tonemap_vaapi_class,
566 .priv_size = sizeof(HDRVAAPIContext),
572 .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
573};
SwsAArch64OpImplParams params
Definition ops.c:51
const FFFilter ff_vf_tonemap_vaapi
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
Main libavfilter public API header.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition csp.c:76
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define fail
Definition test.h:479
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define AVERROR(e)
Definition error.h:45
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition frame.c:659
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
Definition frame.c:725
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition frame.c:647
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition frame.h:137
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition frame.h:120
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition rational.h:104
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
Definition h264dec.c:860
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition filters.h:208
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
#define FFMIN(a, b)
Definition macros.h:49
AVOptions.
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.
Definition pixdesc.c:3380
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition pixdesc.c:3392
#define AV_PIX_FMT_P010
Definition pixfmt.h:608
@ 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...
Definition pixfmt.h:96
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:642
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition pixfmt.h:644
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:645
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:672
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition pixfmt.h:689
@ AVCOL_TRC_UNSPECIFIED
Definition pixfmt.h:675
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition pixfmt.h:674
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:706
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition pixfmt.h:708
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:709
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
An instance of a filter.
Definition avfilter.h:273
void * priv
private data for use by the filter
Definition avfilter.h:288
AVFilterLink ** outputs
array of pointers to output links
Definition avfilter.h:285
A filter pad used for either input or output.
Definition filters.h:40
Structure to hold side data for an AVFrame.
Definition frame.h:327
uint8_t * data
Definition frame.h:329
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:574
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
int width
Definition frame.h:544
int height
Definition frame.h:544
enum AVColorTransferCharacteristic color_trc
Definition frame.h:727
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition frame.h:559
Mastering display metadata capable of representing the color volume of the display used to master the...
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
AVOption.
Definition opt.h:428
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
VADisplay display
The VADisplay handle, to be filled by the user.
enum AVColorSpace color_matrix
VAHdrMetaDataHDR10 out_metadata
enum AVColorPrimaries color_primaries
char * color_primaries_string
enum AVColorTransferCharacteristic color_transfer
AVFrameSideData * src_light
AVFrameSideData * src_display
VAAPIVPPContext vpp_ctx
VAHdrMetaDataHDR10 in_metadata
VABufferID filter_buffers[VAProcFilterCount]
Definition vaapi_vpp.h:56
int nb_filter_buffers
Definition vaapi_vpp.h:57
void(* pipeline_uninit)(AVFilterContext *avctx)
Definition vaapi_vpp.h:63
enum AVPixelFormat output_format
Definition vaapi_vpp.h:52
int(* build_filter_params)(AVFilterContext *avctx)
Definition vaapi_vpp.h:61
VAContextID va_context
Definition vaapi_vpp.h:46
AVVAAPIDeviceContext * hwctx
Definition vaapi_vpp.h:41
#define lrint
Definition tablegen.h:53
#define av_log(a,...)
static AVFormatContext * ctx
Definition movenc.c:49
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
Definition vaapi_vpp.c:97
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
Definition vaapi_vpp.c:71
int ff_vaapi_vpp_query_formats(const AVFilterContext *avctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition vaapi_vpp.c:29
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
Definition vaapi_vpp.c:45
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
Definition vaapi_vpp.c:714
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
Definition vaapi_vpp.c:582
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
Definition vaapi_vpp.c:533
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
Definition vaapi_vpp.c:707
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
Definition vaapi_vpp.c:728
static int tonemap_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
static int tonemap_vaapi_build_filter_params(AVFilterContext *avctx)
static const AVFilterPad tonemap_vaapi_outputs[]
static av_cold int tonemap_vaapi_init(AVFilterContext *avctx)
static int tonemap_vaapi_save_metadata(AVFilterContext *avctx, AVFrame *input_frame)
static const AVFilterPad tonemap_vaapi_inputs[]
static int tonemap_vaapi_set_filter_params(AVFilterContext *avctx, AVFrame *input_frame)
#define OFFSET(x)
static int tonemap_vaapi_update_sidedata(AVFilterContext *avctx, AVFrame *output_frame)
static const AVOption tonemap_vaapi_options[]
#define STRING_OPTION(var_name, func_name, default_value)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89