Skip to content

Commit

Permalink
Throw error on too small dimensions vs. taps
Browse files Browse the repository at this point in the history
Signed-off-by: jpsdr <jpsdr.psx@free.fr>
  • Loading branch information
jpsdr committed Feb 21, 2021
1 parent b97aa9b commit 7550a28
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 30 deletions.
Binary file removed Documentation.zip
Binary file not shown.
25 changes: 12 additions & 13 deletions ResampleMT - Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ GaussResizeMT
SincResizeMT
SinPowResizeMT (same parameters than Gauss, default param 2.5)
SincLin2ResizeMT (same parameters than Sinc, default param 15)

UserDefined2ResampleMT (Same parameters as BicubicResize)
Control values are b and c as floats in range -50..250.
Default values are b=121, c=19. b and c parameters are 2 and 3 members of impulse response of filter defined at +-2 samples
range. Middle (first) member = 1.0, i.e. 235 in 8bit video limited range encoding. To view how it contol sharpness and ringing
and 'near peaking' better use web-scripting application at Documentation/sig_rest_en_sym.html. b and c paramters equal
to 6 and 7 samples started from 1st from the left. Samples values input and processing or 3 and 4 are interconneted internally to
represent actual filter procesing. Curve at the graph represent resulted symmetrical impulse responce.
Mouse cursor and dragging for sliders may be used to set samples values.
Examples:
b=126 c=22 - medium soft, almost no ringing.
b=102 c=2 - sharper, small local peaking.
b=68 c=-30 - more sharper, stronger local peaking.
b=82 c=20 - sharp but lots of far ringing. Not for using.
Control values are b and c as floats in range -50..250.
Default values are b=121, c=19. b and c parameters are 2 and 3 members of impulse response of filter defined at +-2 samples
range. Middle (first) member = 1.0, i.e. 235 in 8bit video limited range encoding. To view how it contol sharpness and ringing
and 'near peaking' better use web-scripting application at Documentation/sig_rest_en_sym.html. b and c paramters equal
to 6 and 7 samples started from 1st from the left. Samples values input and processing or 3 and 4 are interconneted internally to
represent actual filter procesing. Curve at the graph represent resulted symmetrical impulse responce.
Mouse cursor and dragging for sliders may be used to set samples values.
Examples:
b=126 c=22 - medium soft, almost no ringing.
b=102 c=2 - sharper, small local peaking.
b=68 c=-30 - more sharper, stronger local peaking.
b=82 c=20 - sharp but lots of far ringing. Not for using.


Parameters are exactly the same than the orignal resampling functions, and in the same order, so they are totaly
Expand Down
51 changes: 40 additions & 11 deletions ResampleMT/resample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,14 @@ FilteredResizeH::FilteredResizeH( PClip _child, double subrange_left, double sub
resampling_program_luma = func->GetResamplingProgram(vi.width, subrange_left, subrange_width, target_width, bits_per_pixel, env);
SizeH=dst_width;
}
resampler_h_luma = GetResampler(true,resampling_program_luma,env);

if (vi.width<resampling_program_luma->filter_size)
{
FreeData();
if (threads>1) poolInterface->DeAllocateAllThreads(true);
env->ThrowError("ResizeHMT: Source width (%d) is too small for this resizing method, must be minimum of %d",vi.width,resampling_program_luma->filter_size);
}

if (desample && ((SizeH>vi.width) || (SizeH==-1)))
{
Expand All @@ -2611,8 +2619,6 @@ FilteredResizeH::FilteredResizeH( PClip _child, double subrange_left, double sub
else env->ThrowError("ResizeHMT: Matrix can't be reversed!");
}

threads_number=CreateMTData(threads_number,src_width,vi.height,SizeH,vi.height,shift_w,shift_h);

if (vi.IsPlanar() && !grey && !isRGBPfamily)
{
const int div = 1 << shift_w;
Expand Down Expand Up @@ -2646,12 +2652,19 @@ FilteredResizeH::FilteredResizeH( PClip _child, double subrange_left, double sub
bits_per_pixel,
env);
}
resampler_h_chroma = GetResampler(true,resampling_program_chroma,env);

const int w_UV=vi.width >> shift_w;

if (w_UV<resampling_program_chroma->filter_size)
{
FreeData();
if (threads>1) poolInterface->DeAllocateAllThreads(true);
env->ThrowError("ResizeHMT: Source chroma width (%d) is too small for this resizing method, must be minimum of %d",w_UV,resampling_program_chroma->filter_size);
}
}

// Plannar + SSSE3 = use new horizontal resizer routines
resampler_h_luma = GetResampler(true,resampling_program_luma,env);

if (vi.IsPlanar() && !grey && !isRGBPfamily) resampler_h_chroma = GetResampler(true,resampling_program_chroma,env);
threads_number=CreateMTData(threads_number,src_width,vi.height,SizeH,vi.height,shift_w,shift_h);

if (threads_number>1)
{
Expand Down Expand Up @@ -3356,6 +3369,16 @@ FilteredResizeV::FilteredResizeV( PClip _child, double subrange_top, double subr
SizeV=target_height;
}

resampler_luma_aligned = GetResampler(true,filter_storage_luma_aligned,resampling_program_luma);
resampler_luma_unaligned = GetResampler(false,filter_storage_luma_unaligned,resampling_program_luma);

if (vi.height<resampling_program_luma->filter_size)
{
FreeData();
if (threads>1) poolInterface->DeAllocateAllThreads(true);
env->ThrowError("ResizeVMT: Source height (%d) is too small for this resizing method, must be minimum of %d",vi.height,resampling_program_luma->filter_size);
}

if (desample && ((SizeV>vi.height) || (SizeV==-1)))
{
FreeData();
Expand All @@ -3364,8 +3387,6 @@ FilteredResizeV::FilteredResizeV( PClip _child, double subrange_top, double subr
else env->ThrowError("ResizeVMT: Matrix can't be reversed!");
}

threads_number=CreateMTData(threads_number,work_width,vi.height,work_width,SizeV,shift_w,shift_h);

src_pitch_table_luma = (int *)_aligned_malloc(sizeof(int) * vi.height, 64);
if (src_pitch_table_luma==NULL)
{
Expand All @@ -3374,9 +3395,6 @@ FilteredResizeV::FilteredResizeV( PClip _child, double subrange_top, double subr
env->ThrowError("ResizeVMT: Could not reserve memory in a resampler.");
}

resampler_luma_aligned = GetResampler(true,filter_storage_luma_aligned,resampling_program_luma);
resampler_luma_unaligned = GetResampler(false,filter_storage_luma_unaligned,resampling_program_luma);

if (vi.IsPlanar() && !grey && !isRGBPfamily)
{
const int div = 1 << shift_h;
Expand Down Expand Up @@ -3420,8 +3438,19 @@ FilteredResizeV::FilteredResizeV( PClip _child, double subrange_top, double subr
}
resampler_chroma_aligned = GetResampler(true,filter_storage_chroma_aligned,resampling_program_chroma);
resampler_chroma_unaligned = GetResampler(false,filter_storage_chroma_unaligned,resampling_program_chroma);

const int h_UV=vi.height >> shift_h;

if (h_UV<resampling_program_chroma->filter_size)
{
FreeData();
if (threads>1) poolInterface->DeAllocateAllThreads(true);
env->ThrowError("ResizeVMT: Source chroma height (%d) is too small for this resizing method, must be minimum of %d",h_UV,resampling_program_chroma->filter_size);
}
}

threads_number=CreateMTData(threads_number,work_width,vi.height,work_width,SizeV,shift_w,shift_h);

if (threads_number>1)
{
if (!poolInterface->GetUserId(UserId))
Expand Down
2 changes: 1 addition & 1 deletion ResampleMT/resample.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "./resample_functions.h"
#include "./ThreadPoolInterface.h"

#define RESAMPLE_MT_VERSION "ResampleMT 2.3.1 JPSDR"
#define RESAMPLE_MT_VERSION "ResampleMT 2.3.2 JPSDR"

// Resizer function pointer
typedef void (*ResamplerV)(BYTE* dst, const BYTE* src, int dst_pitch, int src_pitch, ResamplingProgram* program, int width, int bits_per_pixel, int MinY, int MaxY, const int* pitch_table, const void* storage,const uint8_t range,const bool mode_YUY2);
Expand Down
10 changes: 5 additions & 5 deletions ResampleMT/resample.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,3,1,0
PRODUCTVERSION 2,3,1,0
FILEVERSION 2,3,2,0
PRODUCTVERSION 2,3,2,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -41,11 +41,11 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "ResampleMT v2.3.1 for Avisynth 2.6.x"
VALUE "FileVersion", "2.3.1"
VALUE "FileDescription", "ResampleMT v2.3.2 for Avisynth 2.6.x"
VALUE "FileVersion", "2.3.2"
VALUE "LegalCopyright", "Copyright (C) 2016 JPSDR & Avs+ team"
VALUE "OriginalFilename", "ResampleMT.dll"
VALUE "ProductVersion", "2.3.1"
VALUE "ProductVersion", "2.3.2"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 7550a28

Please sign in to comment.