| 70 | } |
| 71 | |
| 72 | static int FormatConversionToPixelFormat(int id, bool alpha, VSCore *core, const VSAPI *vsapi) { |
| 73 | VSVideoFormat f; |
| 74 | vsapi->getVideoFormatByID(&f, id, core); |
| 75 | int npixfmt = GetNumPixFmts(); |
| 76 | // Look for a suitable format without alpha first to not waste memory |
| 77 | if (!alpha) { |
| 78 | for (int i = 0; i < npixfmt; i++) { |
| 79 | const AVPixFmtDescriptor &desc = *av_pix_fmt_desc_get((AVPixelFormat)i); |
| 80 | if (IsRealNativeEndianPlanar(desc) && !HasAlpha(desc) |
| 81 | && GetColorFamily(desc) == f.colorFamily |
| 82 | && desc.comp[0].depth == f.bitsPerSample |
| 83 | && desc.log2_chroma_w == f.subSamplingW |
| 84 | && desc.log2_chroma_h == f.subSamplingH |
| 85 | && GetSampleType(desc) == f.sampleType) |
| 86 | return i; |
| 87 | } |
| 88 | } |
| 89 | // Try all remaining formats |
| 90 | for (int i = 0; i < npixfmt; i++) { |
| 91 | const AVPixFmtDescriptor &desc = *av_pix_fmt_desc_get((AVPixelFormat)i); |
| 92 | if (IsRealNativeEndianPlanar(desc) && HasAlpha(desc) |
| 93 | && GetColorFamily(desc) == f.colorFamily |
| 94 | && desc.comp[0].depth == f.bitsPerSample |
| 95 | && desc.log2_chroma_w == f.subSamplingW |
| 96 | && desc.log2_chroma_h == f.subSamplingH |
| 97 | && GetSampleType(desc) == f.sampleType) |
| 98 | return i; |
| 99 | } |
| 100 | return AV_PIX_FMT_NONE; |
| 101 | } |
| 102 | |
| 103 | static void FormatConversionToVS(VSVideoFormat &f, int id, VSCore *core, const VSAPI *vsapi) { |
| 104 | const AVPixFmtDescriptor &desc = *av_pix_fmt_desc_get((AVPixelFormat)id); |
no test coverage detected