MCPcopy Create free account
hub / github.com/FFMS/ffms2 / FormatConversionToPixelFormat

Function FormatConversionToPixelFormat

src/vapoursynth/vapoursource4.cpp:72–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static 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
103static void FormatConversionToVS(VSVideoFormat &f, int id, VSCore *core, const VSAPI *vsapi) {
104 const AVPixFmtDescriptor &desc = *av_pix_fmt_desc_get((AVPixelFormat)id);

Callers 1

InitOutputFormatMethod · 0.85

Calls 5

GetNumPixFmtsFunction · 0.85
IsRealNativeEndianPlanarFunction · 0.85
HasAlphaFunction · 0.85
GetColorFamilyFunction · 0.85
GetSampleTypeFunction · 0.85

Tested by

no test coverage detected