[FFmpeg-devel] [PATCH] avfilter/vf_scale: Do not set YUV color range for RGB formats
wm4
nfxjfg at googlemail.com
Tue Mar 27 18:04:35 EEST 2018
On Tue, 27 Mar 2018 12:14:55 +0200
Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Mon, Mar 26, 2018 at 10:56:47PM +0100, Mark Thompson wrote:
> > On 26/03/18 22:44, Michael Niedermayer wrote:
> > > On Mon, Mar 26, 2018 at 08:34:06AM +0200, Paul B Mahol wrote:
> > >> On 3/26/18, Michael Niedermayer <michael at niedermayer.cc> wrote:
> > >>> On Wed, Mar 21, 2018 at 09:18:21AM +0100, Paul B Mahol wrote:
> > >>>> On 3/20/18, Michael Niedermayer <michael at niedermayer.cc> wrote:
> > >>>>> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > >>>>> ---
> > >>>>> libavfilter/vf_scale.c | 7 ++++++-
> > >>>>> 1 file changed, 6 insertions(+), 1 deletion(-)
> > >>>>>
> > >>>>> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> > >>>>> index 9f45032e85..2f6fa4791d 100644
> > >>>>> --- a/libavfilter/vf_scale.c
> > >>>>> +++ b/libavfilter/vf_scale.c
> > >>>>> @@ -407,6 +407,7 @@ static int filter_frame(AVFilterLink *link, AVFrame
> > >>>>> *in)
> > >>>>> AVFilterLink *outlink = link->dst->outputs[0];
> > >>>>> AVFrame *out;
> > >>>>> const AVPixFmtDescriptor *desc =
> > >>>>> av_pix_fmt_desc_get(link->format);
> > >>>>> + const AVPixFmtDescriptor *out_desc =
> > >>>>> av_pix_fmt_desc_get(outlink->format);
> > >>>>> char buf[32];
> > >>>>> int in_range;
> > >>>>>
> > >>>>> @@ -497,7 +498,11 @@ static int filter_frame(AVFilterLink *link,
> > >>>>> AVFrame
> > >>>>> *in)
> > >>>>> table, out_full,
> > >>>>> brightness, contrast,
> > >>>>> saturation);
> > >>>>>
> > >>>>> - out->color_range = out_full ? AVCOL_RANGE_JPEG :
> > >>>>> AVCOL_RANGE_MPEG;
> > >>>>> + // color_range describes YUV, it is undefined for RGB
> > >>>>> + if ((out_desc->flags & AV_PIX_FMT_FLAG_RGB) &&
> > >>>>> out_desc->nb_components != 1) {
> > >>>>> + out->color_range = AVCOL_RANGE_UNSPECIFIED;
> > >>>>> + } else
> > >>>>> + out->color_range = out_full ? AVCOL_RANGE_JPEG :
> > >>>>> AVCOL_RANGE_MPEG;
> > >>>>> }
> > >>>>>
> > >>>>> av_reduce(&out->sample_aspect_ratio.num,
> > >>>>> &out->sample_aspect_ratio.den,
> > >>>>> --
> > >>>>> 2.16.2
> > >>>>>
> > >>>>
> > >>>> This is not optimal, as full color_range should remain full when not
> > >>>> changed.
> > >>>
> > >>> there is no range for rgb formats. The range is specific to YUV based
> > >>> formats.
> > >>> Thats, if iam guessing correctly what you meant. You did not really say
> > >>> which case you meant here. So maybe there is an issue and i misunderstand
> > >>> what you refer to
> > >>
> > >> Maybe not for swscale here but does exist otherwise.
> > >
> > > It has no meaning for RGB. There is no limited range RGB
> > > also, the API defines it only for YUV. So if it had meaning for RGB its not defined
> > > what meaning that would be. The ranges for luma and chroma differ so its not
> > > natural or obvious how to extend it to RGB.
> > > Iam also not aware of any specification that defines limited range RGB
> > See HDMI, HD-SDI, CEA-861, pretty much anything related to sending RGB over wires in a non-PC context.
> >
> > (No comment on whether it is useful to include it, but dismissing limited range RGB as not a thing is probably not a good idea. I would kindof expect things like DeckLink to be using limited-range RGB everywhere, but I'm not familiar with the details there.)
>
> Is this used just over wires or also in software ?
Yes, it can happen that you "need" to output limited RGB for consumer
burning trash fire hardware.
> aka should we update our enum to also cover this and
> If yes then we also probably should add support for this
> to swscale
I tried to use it once and considered it a libswscale bug and reported
it, but was overruled or something.
More information about the ffmpeg-devel
mailing list