Unified · Split
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/display.h" |
| 30 | 30 | #include "libavutil/imgutils.h" |
| 31 | 31 | #include "libavutil/internal.h" |
| 32 | +#include "libavutil/film_grain_params.h" | |
| 32 | 33 | #include "libavutil/hdr_dynamic_metadata.h" |
| 33 | 34 | #include "libavutil/opt.h" |
| 34 | 35 | #include "libavutil/pixdesc.h" |
| @@ -361,6 +362,73 @@ static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSi · 326 unmodified lines | ||
| 361 | 362 | av_log(ctx, AV_LOG_INFO, "\n"); |
| 362 | 363 | } |
| 363 | 364 | |
| 365 | +static void dump_sei_film_grain_params_metadata(AVFilterContext *ctx, const AVFrameSideData *sd) | |
| 366 | +{ | |
| 367 | + const AVFilmGrainParams *fgp = (const AVFilmGrainParams *)sd->data; | |
| 368 | + const char *const film_grain_type_names[] = { | |
| 369 | + [AV_FILM_GRAIN_PARAMS_NONE] = "none", | |
| 370 | + [AV_FILM_GRAIN_PARAMS_AV1] = "av1", | |
| 371 | + [AV_FILM_GRAIN_PARAMS_H274] = "h274", | |
| 372 | + }; | |
| 373 | + | |
| 374 | + if (fgp->type >= FF_ARRAY_ELEMS(film_grain_type_names)) { | |
| 375 | + av_log(ctx, AV_LOG_ERROR, "invalid data\n"); | |
| 376 | + return; | |
| 377 | + } | |
| 378 | + | |
| 379 | + av_log(ctx, AV_LOG_INFO, "film grain parameters: type %s; ", film_grain_type_names[fgp->type]); | |
| 380 | + av_log(ctx, AV_LOG_INFO, "seed=%"PRIu64"; ", fgp->seed); | |
| 381 | + | |
| 382 | + switch (fgp->type) { | |
| 383 | + case AV_FILM_GRAIN_PARAMS_NONE: | |
| 384 | + case AV_FILM_GRAIN_PARAMS_AV1: | |
| 385 | + return; | |
| 386 | + case AV_FILM_GRAIN_PARAMS_H274: { | |
| 387 | + const AVFilmGrainH274Params *h274 = &fgp->codec.h274; | |
| 388 | + const char *color_range_str = av_color_range_name(h274->color_range); | |
| 389 | + const char *color_primaries_str = av_color_primaries_name(h274->color_primaries); | |
| 390 | + const char *color_trc_str = av_color_transfer_name(h274->color_trc); | |
| 391 | + const char *colorspace_str = av_color_space_name(h274->color_space); | |
| 392 | + | |
| 393 | + av_log(ctx, AV_LOG_INFO, "model_id=%d; ", h274->model_id); | |
| 394 | + av_log(ctx, AV_LOG_INFO, "bit_depth_luma=%d; ", h274->bit_depth_luma); | |
| 395 | + av_log(ctx, AV_LOG_INFO, "bit_depth_chroma=%d; ", h274->bit_depth_chroma); | |
| 396 | + av_log(ctx, AV_LOG_INFO, "color_range=%s; ", color_range_str ? color_range_str : "unknown"); | |
| 397 | + av_log(ctx, AV_LOG_INFO, "color_primaries=%s; ", color_primaries_str ? color_primaries_str : "unknown"); | |
| 398 | + av_log(ctx, AV_LOG_INFO, "color_trc=%s; ", color_trc_str ? color_trc_str : "unknown"); | |
| 399 | + av_log(ctx, AV_LOG_INFO, "color_space=%s; ", colorspace_str ? colorspace_str : "unknown"); | |
| 400 | + av_log(ctx, AV_LOG_INFO, "blending_mode_id=%d; ", h274->blending_mode_id); | |
| 401 | + av_log(ctx, AV_LOG_INFO, "log2_scale_factor=%d; ", h274->log2_scale_factor); | |
| 402 | + | |
| 403 | + for (int c = 0; c < 3; c++) | |
| 404 | + if (h274->component_model_present[c] && (h274->num_model_values[c] > 6 || | |
| 405 | + h274->num_intensity_intervals[c] < 1 || | |
| 406 | + h274->num_intensity_intervals[c] > 256)) { | |
| 407 | + av_log(ctx, AV_LOG_ERROR, "invalid data\n"); | |
| 408 | + return; | |
| 409 | + } | |
| 410 | + | |
| 411 | + for (int c = 0; c < 3; c++) { | |
| 412 | + if (!h274->component_model_present[c]) | |
| 413 | + continue; | |
| 414 | + | |
| 415 | + av_log(ctx, AV_LOG_INFO, "num_intensity_intervals[%d]=%u; ", c, h274->num_intensity_intervals[c]); | |
| 416 | + av_log(ctx, AV_LOG_INFO, "num_model_values[%d]=%u; ", c, h274->num_model_values[c]); | |
| 417 | + for (int i = 0; i < h274->num_intensity_intervals[c]; i++) { | |
| 418 | + av_log(ctx, AV_LOG_INFO, "intensity_interval_lower_bound[%d][%d]=%u; ", | |
| 419 | + c, i, h274->intensity_interval_lower_bound[c][i]); | |
| 420 | + av_log(ctx, AV_LOG_INFO, "intensity_interval_upper_bound[%d][%d]=%u; ", | |
| 421 | + c, i, h274->intensity_interval_upper_bound[c][i]); | |
| 422 | + for (int j = 0; j < h274->num_model_values[c]; j++) | |
| 423 | + av_log(ctx, AV_LOG_INFO, "comp_model_value[%d][%d][%d]=%d; ", | |
| 424 | + c, i, j, h274->comp_model_value[c][i][j]); | |
| 425 | + } | |
| 426 | + } | |
| 427 | + break; | |
| 428 | + } | |
| 429 | + } | |
| 430 | +} | |
| 431 | + | |
| 364 | 432 | static void dump_color_property(AVFilterContext *ctx, AVFrame *frame) |
| 365 | 433 | { |
| 366 | 434 | const char *color_range_str = av_color_range_name(frame->color_range); |
| @@ -546,6 +614,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 179 unmodified lines | ||
| 546 | 614 | case AV_FRAME_DATA_SEI_UNREGISTERED: |
| 547 | 615 | dump_sei_unregistered_metadata(ctx, sd); |
| 548 | 616 | break; |
| 617 | + case AV_FRAME_DATA_FILM_GRAIN_PARAMS: | |
| 618 | + dump_sei_film_grain_params_metadata(ctx, sd); | |
| 619 | + break; | |
| 549 | 620 | default: |
| 550 | 621 | av_log(ctx, AV_LOG_WARNING, "unknown side data type %d " |
| 551 | 622 | "(%"SIZE_SPECIFIER" bytes)\n", sd->type, sd->size); |