History

avfilter/vf_scale: tag output color space

When using vf_scale to force a specific output color space, also tag this on the AVFrame. (Mirroring existing logic for output range) Move the sanity fix for RGB after the new assignment, to avoid leaking bogus YUV colorspace metadata for RGB spaces.

Niklas Haas committed 3 years ago

Commit cf600461 parent 5d5bb771 file · +14 −12Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_scale.c+14−12
@@ -799,18 +799,6 @@ scale: · 798 unmodified lines
799799 out->width = outlink->w;
800800 out->height = outlink->h;
801801
802− // Sanity checks:
803− // 1. If the output is RGB, set the matrix coefficients to RGB.
804− // 2. If the output is not RGB and we've got the RGB/XYZ (identity)
805− // matrix configured, unset the matrix.
806− // In theory these should be in swscale itself as the AVFrame
807− // based API gets in, so that not every swscale API user has
808− // to go through duplicating such sanity checks.
809− if (av_pix_fmt_desc_get(out->format)->flags & AV_PIX_FMT_FLAG_RGB)
810− out->colorspace = AVCOL_SPC_RGB;
811− else if (out->colorspace == AVCOL_SPC_RGB)
812− out->colorspace = AVCOL_SPC_UNSPECIFIED;
813−
814802 if (scale->output_is_pal)
815803 avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
816804
@@ -857,8 +845,22 @@ scale: · 40 unmodified lines
857845 brightness, contrast, saturation);
858846
859847 out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
848+ if (scale->out_color_matrix != AVCOL_SPC_UNSPECIFIED)
849+ out->colorspace = scale->out_color_matrix;
860850 }
861851
852+ // Sanity checks:
853+ // 1. If the output is RGB, set the matrix coefficients to RGB.
854+ // 2. If the output is not RGB and we've got the RGB/XYZ (identity)
855+ // matrix configured, unset the matrix.
856+ // In theory these should be in swscale itself as the AVFrame
857+ // based API gets in, so that not every swscale API user has
858+ // to go through duplicating such sanity checks.
859+ if (av_pix_fmt_desc_get(out->format)->flags & AV_PIX_FMT_FLAG_RGB)
860+ out->colorspace = AVCOL_SPC_RGB;
861+ else if (out->colorspace == AVCOL_SPC_RGB)
862+ out->colorspace = AVCOL_SPC_UNSPECIFIED;
863+
862864 av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
863865 (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
864866 (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,

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