History

avfilter/vf_libplacebo: update metadata stripping logic

Switches to av_frame_side_data_remove_by_props(), covering a number of cases that we previously ignored. Additionally, stop stripping metadata when merely changing colorspace or color range, since these do not affect the actual color volume of the image data, only the encoding.

Niklas Haas committed 2 years ago

Commit 0d468731 parent d1eadc41 file · +9 −15Browse files

Unified · Split

libavfilter/vf_libplacebo.c+9−15
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include "libavutil/eval.h"
2121 #include "libavutil/fifo.h"
2222 #include "libavutil/file.h"
23+#include "libavutil/frame.h"
2324 #include "libavutil/mem.h"
2425 #include "libavutil/opt.h"
2526 #include "libavutil/parseutils.h"
@@ -817,7 +818,7 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, · 791 unmodified lines
817818 /* Construct and emit an output frame for a given timestamp */
818819 static int output_frame(AVFilterContext *ctx, int64_t pts)
819820 {
820− int err = 0, ok, changed_csp;
821+ int err = 0, ok, changed;
821822 LibplaceboContext *s = ctx->priv;
822823 pl_options opts = s->opts;
823824 AVFilterLink *outlink = ctx->outputs[0];
@@ -853,6 +854,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) · 29 unmodified lines
853854 * output colorspace defaults */
854855 out->color_primaries = AVCOL_PRI_BT2020;
855856 out->color_trc = AVCOL_TRC_SMPTE2084;
857+ changed |= AV_SIDE_DATA_PROP_COLOR_DEPENDENT;
856858 }
857859
858860 if (s->color_trc >= 0)
@@ -860,21 +862,13 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) · 1 unmodified line
860862 if (s->color_primaries >= 0)
861863 out->color_primaries = s->color_primaries;
862864
863− changed_csp = ref->colorspace != out->colorspace ||
864− ref->color_range != out->color_range ||
865− ref->color_trc != out->color_trc ||
866− ref->color_primaries != out->color_primaries;
867−
868865 /* Strip side data if no longer relevant */
869− if (changed_csp) {
870− av_frame_remove_side_data(out, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
871− av_frame_remove_side_data(out, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
872− av_frame_remove_side_data(out, AV_FRAME_DATA_ICC_PROFILE);
873− }
874− if (s->apply_dovi || changed_csp) {
875− av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_RPU_BUFFER);
876− av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_METADATA);
877− }
866+ if (out->width != ref->width || out->height != ref->height)
867+ changed |= AV_SIDE_DATA_PROP_SIZE_DEPENDENT;
868+ if (ref->color_trc != out->color_trc || ref->color_primaries != out->color_primaries)
869+ changed |= AV_SIDE_DATA_PROP_COLOR_DEPENDENT;
870+ av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data, changed);
871+
878872 if (s->apply_filmgrain)
879873 av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
880874

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t