Normalize deprecated JPEG-range YUVJ formats before creating swscale contexts. swscale expects non-YUVJ formats plus explicit color-range metadata.
| 76 | // Normalize deprecated JPEG-range YUVJ formats before creating swscale contexts. |
| 77 | // swscale expects non-YUVJ formats plus explicit color-range metadata. |
| 78 | static AVPixelFormat NormalizeDeprecatedPixFmt(AVPixelFormat pix_fmt, bool& is_full_range) { |
| 79 | switch (pix_fmt) { |
| 80 | case AV_PIX_FMT_YUVJ420P: |
| 81 | is_full_range = true; |
| 82 | return AV_PIX_FMT_YUV420P; |
| 83 | case AV_PIX_FMT_YUVJ422P: |
| 84 | is_full_range = true; |
| 85 | return AV_PIX_FMT_YUV422P; |
| 86 | case AV_PIX_FMT_YUVJ444P: |
| 87 | is_full_range = true; |
| 88 | return AV_PIX_FMT_YUV444P; |
| 89 | case AV_PIX_FMT_YUVJ440P: |
| 90 | is_full_range = true; |
| 91 | return AV_PIX_FMT_YUV440P; |
| 92 | #ifdef AV_PIX_FMT_YUVJ411P |
| 93 | case AV_PIX_FMT_YUVJ411P: |
| 94 | is_full_range = true; |
| 95 | return AV_PIX_FMT_YUV411P; |
| 96 | #endif |
| 97 | default: |
| 98 | return pix_fmt; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | FFmpegReader::FFmpegReader(const std::string &path, bool inspect_reader) |
| 103 | : FFmpegReader(path, DurationStrategy::VideoPreferred, inspect_reader) {} |