Skip to content

Commit 11a39de

Browse files
PinterfPinterf
authored andcommitted
ConvertFromStacked: Y10,12,14 (was: Y16 only). ConvertFrom/ToDoubleWidth: RGB24/32<>RGB48/64
1 parent 984428a commit 11a39de

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

plugins/ConvertStacked/ConvertStacked.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class ConvertFromStacked : public GenericVideoFilter
182182
PVideoFrame dst = env->NewVideoFrame(vi);
183183

184184
const int planes[] = { PLANAR_Y, PLANAR_U, PLANAR_V };
185-
const int plane_count = vi.IsColorSpace(VideoInfo::CS_Y16) ? 1 : 3;
185+
const int plane_count = vi.IsY() ? 1 : 3;
186186
for (int p = 0; p < plane_count; ++p) {
187187
const int plane = planes[p];
188188
const uint8_t* msb = src->GetReadPtr(plane);
@@ -251,8 +251,10 @@ class ConvertFromDoubleWidth : public GenericVideoFilter
251251

252252
ConvertFromDoubleWidth(PClip src, int bits, IScriptEnvironment* env) : GenericVideoFilter(src)
253253
{
254-
if (vi.RowSize(PLANAR_U) % 2)
254+
if (!vi.IsRGB() && vi.RowSize(PLANAR_U) % 2)
255255
env->ThrowError("ConvertFromDoubleWidth: Input clip's chroma width must be even.");
256+
if ((vi.IsRGB24() || vi.IsRGB32()) && bits != 16)
257+
env->ThrowError("ConvertFromDoubleWidth: only bits=16 allowed for RGB24 or RGB32 input");
256258

257259
if (bits == 10 && vi.IsYV12())
258260
vi.pixel_type = VideoInfo::CS_YUV420P10;
@@ -286,7 +288,11 @@ class ConvertFromDoubleWidth : public GenericVideoFilter
286288
vi.pixel_type = VideoInfo::CS_YUV444P16;
287289
else if (bits == 16 && vi.IsY8())
288290
vi.pixel_type = VideoInfo::CS_Y16;
289-
else env->ThrowError("ConvertFromDoubleWidth: Input double width clip must be YV12, YV16, YV24 or Y8");
291+
else if (bits == 16 && vi.IsRGB24())
292+
vi.pixel_type = VideoInfo::CS_BGR48;
293+
else if (bits == 16 && vi.IsRGB32())
294+
vi.pixel_type = VideoInfo::CS_BGR64;
295+
else env->ThrowError("ConvertFromDoubleWidth: Input double width clip must be YV12, YV16, YV24, Y8, RGB24 or RGB32");
290296

291297
vi.width /= 2;
292298
}
@@ -322,7 +328,9 @@ class ConvertToDoubleWidth : public GenericVideoFilter
322328
else if (vi.IsColorSpace(VideoInfo::CS_YUV422P16)) vi.pixel_type = VideoInfo::CS_YV16;
323329
else if (vi.IsColorSpace(VideoInfo::CS_YUV444P16)) vi.pixel_type = VideoInfo::CS_YV24;
324330
else if (vi.IsColorSpace(VideoInfo::CS_Y16)) vi.pixel_type = VideoInfo::CS_Y8;
325-
else env->ThrowError("ConvertToDoubleWidth: Input clip must be 16bit format");
331+
else if (vi.IsColorSpace(VideoInfo::CS_BGR48)) vi.pixel_type = VideoInfo::CS_BGR24;
332+
else if (vi.IsColorSpace(VideoInfo::CS_BGR64)) vi.pixel_type = VideoInfo::CS_BGR32;
333+
else env->ThrowError("ConvertToDoubleWidth: Input clip must be 16bit YUV format, RGB48 or RGB64");
326334

327335
vi.width *= 2;
328336
}

0 commit comments

Comments
 (0)