Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color range should be specified in parameters #82

Open
hmaarrfk opened this issue Jan 4, 2023 · 1 comment
Open

Color range should be specified in parameters #82

hmaarrfk opened this issue Jan 4, 2023 · 1 comment

Comments

@hmaarrfk
Copy link
Contributor

hmaarrfk commented Jan 4, 2023

I've really been trying to better understand how ffmpeg is really treating our data.

I found that there is a difference between "tv" color range, and "pc" color range. Where the "tv" color range is compressed, and the "pc" color range is "full".

The code in FFMPEG:

static int convert_range(enum AVColorRange color_range)
{
    switch (color_range) {
    case AVCOL_RANGE_UNSPECIFIED:
    case AVCOL_RANGE_MPEG:
        return ZIMG_RANGE_LIMITED;
    case AVCOL_RANGE_JPEG:
        return ZIMG_RANGE_FULL;
    }
    return ZIMG_RANGE_LIMITED;
}

Thus if you leave the color range unspecified, it will be compressed, very likely not what you want in modern image processing.

I've been adding code to specify the color range as 2 in hopes to avoid color compression. I'm really not sure if it does the right thing since it seems that the color range of yuv isn't specified in the log of the implicit conversion that ffmpeg adds if your input and output colors do not match.

Some related discussion here:
https://www.facebook.com/permalink.php?story_fbid=2413101932257643&id=100006735798590

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Jan 4, 2023

Hmm, it seems that opencv's reader would throw a warning if the full range is specified.

I'm not too sure how to get around this, opencv doesn't expose a large chunk of the options that libav has.

The warning looks something like:

WARNING:libav.swscaler:deprecated pixel format used, make sure you did set range correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant