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.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -20,6 +20,7 @@ · 19 unmodified lines | |||
| 20 | #include "libavutil/eval.h" | 20 | #include "libavutil/eval.h" |
| 21 | #include "libavutil/fifo.h" | 21 | #include "libavutil/fifo.h" |
| 22 | #include "libavutil/file.h" | 22 | #include "libavutil/file.h" |
| 23 | #include "libavutil/frame.h" | ||
| 23 | #include "libavutil/mem.h" | 24 | #include "libavutil/mem.h" |
| 24 | #include "libavutil/opt.h" | 25 | #include "libavutil/opt.h" |
| 25 | #include "libavutil/parseutils.h" | 26 | #include "libavutil/parseutils.h" |
| @@ -817,7 +818,7 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, · 791 unmodified lines | |||
| 817 | /* Construct and emit an output frame for a given timestamp */ | 818 | /* Construct and emit an output frame for a given timestamp */ |
| 818 | static int output_frame(AVFilterContext *ctx, int64_t pts) | 819 | static int output_frame(AVFilterContext *ctx, int64_t pts) |
| 819 | { | 820 | { |
| 820 | int err = 0, ok, changed_csp; | 821 | int err = 0, ok, changed; |
| 821 | LibplaceboContext *s = ctx->priv; | 822 | LibplaceboContext *s = ctx->priv; |
| 822 | pl_options opts = s->opts; | 823 | pl_options opts = s->opts; |
| 823 | AVFilterLink *outlink = ctx->outputs[0]; | 824 | AVFilterLink *outlink = ctx->outputs[0]; |
| @@ -853,6 +854,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) · 29 unmodified lines | |||
| 853 | * output colorspace defaults */ | 854 | * output colorspace defaults */ |
| 854 | out->color_primaries = AVCOL_PRI_BT2020; | 855 | out->color_primaries = AVCOL_PRI_BT2020; |
| 855 | out->color_trc = AVCOL_TRC_SMPTE2084; | 856 | out->color_trc = AVCOL_TRC_SMPTE2084; |
| 857 | changed |= AV_SIDE_DATA_PROP_COLOR_DEPENDENT; | ||
| 856 | } | 858 | } |
| 857 | 859 | ||
| 858 | if (s->color_trc >= 0) | 860 | if (s->color_trc >= 0) |
| @@ -860,21 +862,13 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) · 1 unmodified line | |||
| 860 | if (s->color_primaries >= 0) | 862 | if (s->color_primaries >= 0) |
| 861 | out->color_primaries = s->color_primaries; | 863 | out->color_primaries = s->color_primaries; |
| 862 | 864 | ||
| 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 | |||
| 868 | /* Strip side data if no longer relevant */ | 865 | /* Strip side data if no longer relevant */ |
| 869 | if (changed_csp) { | 866 | if (out->width != ref->width || out->height != ref->height) |
| 870 | av_frame_remove_side_data(out, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); | 867 | changed |= AV_SIDE_DATA_PROP_SIZE_DEPENDENT; |
| 871 | av_frame_remove_side_data(out, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); | 868 | if (ref->color_trc != out->color_trc || ref->color_primaries != out->color_primaries) |
| 872 | av_frame_remove_side_data(out, AV_FRAME_DATA_ICC_PROFILE); | 869 | changed |= AV_SIDE_DATA_PROP_COLOR_DEPENDENT; |
| 873 | } | 870 | av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data, changed); |
| 874 | if (s->apply_dovi || changed_csp) { | 871 | |
| 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 | } | ||
| 878 | if (s->apply_filmgrain) | 872 | if (s->apply_filmgrain) |
| 879 | av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS); | 873 | av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS); |
| 880 | 874 | ||