Skip to content

Commit

Permalink
add support avs+'s new colorspaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
chikuzen committed Aug 17, 2016
1 parent fc1abfb commit 628dab8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
7 changes: 4 additions & 3 deletions readme.md
Expand Up @@ -2,7 +2,7 @@
This plugin is a rewrite of DctFilter for avisynth.

### Version:
0.4.0
0.5.0

### Requirement:
- Windows Vista sp2 or later
Expand All @@ -17,7 +17,7 @@ DCTFilter8(clip, float, float, float, float, float, float, float, float,
```
Execute 8x8 DCT to image.

clip: planar 8bit/16bit/float formats are supported.
clip: All planar formats(8/10/12/14/16bit and float, YUV/RGB with/without alpha) are supported.

float: All of which must be specified as in the range (0.0 <= x <= 1.0).
These correspond to scaling factors for the 8 rows and columns of the 8x8 DCT blocks.
Expand All @@ -30,9 +30,10 @@ Execute 8x8 DCT to image.
These correspond to scaling factors for the 4 rows and columns of the 4x4 DCT blocks.
The leftmost parameter corresponds to the top row, left column.

chroma: 0 = copy from source
chroma: 0 = copy from source (on RGB, B and R planes are copied).
1 = process (default)
2 = do not process nor copy, output will be trash.
note: alpha will be copied anytime.

opt: Specify which CPU optimization are used.
0 = use c++ routine.
Expand Down
28 changes: 26 additions & 2 deletions src/DCTFilter.cpp
Expand Up @@ -95,6 +95,21 @@ static void set_factors(
}


static int get_bitdepth(int pixel_type)
{
int bits = pixel_type & VideoInfo::CS_Sample_Bits_Mask;
switch (bits) {
case VideoInfo::CS_Sample_Bits_8: return 8;
case VideoInfo::CS_Sample_Bits_10: return 10;
case VideoInfo::CS_Sample_Bits_12: return 12;
case VideoInfo::CS_Sample_Bits_14: return 14;
case VideoInfo::CS_Sample_Bits_16: return 16;
case VideoInfo::CS_Sample_Bits_32: return 32;
}
return 0;
}


enum {
MODE_8X8,
MODE_4X4,
Expand All @@ -115,6 +130,7 @@ class DCTFilter : public GenericVideoFilter {
int componentSize;
int bitsPerComponent;
int mode;
bool hasAlpha;

fdct_idct_func_t mainProc8x8;
fdct_idct_func_t mainProc4x4;
Expand Down Expand Up @@ -158,14 +174,16 @@ DCTFilter::DCTFilter(PClip c, double* f8, double* f4, int dcount8, int dcount4,
planes[0] = PLANAR_Y;
planes[1] = PLANAR_U;
planes[2] = PLANAR_V;
hasAlpha = vi.IsYUVA();
} else {
planes[0] = PLANAR_G;
planes[1] = PLANAR_B;
planes[2] = PLANAR_R;
hasAlpha = vi.IsPlanarRGBA();
}

componentSize = vi.BytesFromPixels(1);
bitsPerComponent = componentSize * 8;
bitsPerComponent = get_bitdepth(vi.pixel_type);

if (chroma == 1) {
int w = vi.width >> vi.GetPlaneWidthSubsampling(planes[1]);
Expand Down Expand Up @@ -285,6 +303,12 @@ PVideoFrame __stdcall DCTFilter::GetFrame(int n, ise_t* env)
src->GetReadPtr(planes[2]), spitch, rowsize, height);
}

if (hasAlpha) {
env->BitBlt(dst->GetWritePtr(PLANAR_A), dst->GetPitch(PLANAR_A),
src->GetReadPtr(PLANAR_A), src->GetPitch(PLANAR_A),
dst->GetRowSize(PLANAR_A), dst->GetHeight(PLANAR_A));
}

if (isPlus) {
static_cast<ise2_t*>(env)->Free(buff);
}
Expand Down Expand Up @@ -387,7 +411,7 @@ static AVSValue __cdecl create_4d(AVSValue args, void*, ise_t* env)
}


static const AVS_Linkage* AVS_linkage = nullptr;
const AVS_Linkage* AVS_linkage = nullptr;


extern "C" __declspec(dllexport) const char* __stdcall
Expand Down
Binary file modified src/DCTFilter.rc
Binary file not shown.

0 comments on commit 628dab8

Please sign in to comment.