26
26
template <typename T>
27
27
using subsample_function_t = T (*)(cudaTextureObject_t tex, int xo, int yo,
28
28
int dst_width, int dst_height,
29
+ int src_left, int src_top,
29
30
int src_width, int src_height,
30
31
int bit_depth, float param);
31
32
@@ -64,11 +65,12 @@ static inline __device__ ushort conv_16to10(ushort in)
64
65
subsample_function_t <in_T_uv> subsample_func_uv> \
65
66
__device__ static inline void N (cudaTextureObject_t src_tex[4 ], T *dst[4 ], int xo, int yo, \
66
67
int dst_width, int dst_height, int dst_pitch, \
67
- int src_width, int src_height, float param)
68
+ int src_left, int src_top, int src_width, int src_height, float param)
68
69
69
70
#define SUB_F (m, plane ) \
70
71
subsample_func_##m(src_tex[plane], xo, yo, \
71
72
dst_width, dst_height, \
73
+ src_left, src_top, \
72
74
src_width, src_height, \
73
75
in_bit_depth, param)
74
76
@@ -1063,13 +1065,14 @@ template<typename T>
1063
1065
__device__ static inline T Subsample_Nearest (cudaTextureObject_t tex,
1064
1066
int xo, int yo,
1065
1067
int dst_width, int dst_height,
1068
+ int src_left, int src_top,
1066
1069
int src_width, int src_height,
1067
1070
int bit_depth, float param)
1068
1071
{
1069
1072
float hscale = (float )src_width / (float )dst_width;
1070
1073
float vscale = (float )src_height / (float )dst_height;
1071
- float xi = (xo + 0 .5f ) * hscale;
1072
- float yi = (yo + 0 .5f ) * vscale;
1074
+ float xi = (xo + 0 .5f ) * hscale + src_left ;
1075
+ float yi = (yo + 0 .5f ) * vscale + src_top ;
1073
1076
1074
1077
return tex2D <T>(tex, xi, yi);
1075
1078
}
@@ -1078,13 +1081,14 @@ template<typename T>
1078
1081
__device__ static inline T Subsample_Bilinear (cudaTextureObject_t tex,
1079
1082
int xo, int yo,
1080
1083
int dst_width, int dst_height,
1084
+ int src_left, int src_top,
1081
1085
int src_width, int src_height,
1082
1086
int bit_depth, float param)
1083
1087
{
1084
1088
float hscale = (float )src_width / (float )dst_width;
1085
1089
float vscale = (float )src_height / (float )dst_height;
1086
- float xi = (xo + 0 .5f ) * hscale;
1087
- float yi = (yo + 0 .5f ) * vscale;
1090
+ float xi = (xo + 0 .5f ) * hscale + src_left ;
1091
+ float yi = (yo + 0 .5f ) * vscale + src_top ;
1088
1092
// 3-tap filter weights are {wh,1.0,wh} and {wv,1.0,wv}
1089
1093
float wh = min (max (0 .5f * (hscale - 1 .0f ), 0 .0f ), 1 .0f );
1090
1094
float wv = min (max (0 .5f * (vscale - 1 .0f ), 0 .0f ), 1 .0f );
@@ -1109,13 +1113,14 @@ template<typename T, coeffs_function_t coeffs_function>
1109
1113
__device__ static inline T Subsample_Bicubic (cudaTextureObject_t tex,
1110
1114
int xo, int yo,
1111
1115
int dst_width, int dst_height,
1116
+ int src_left, int src_top,
1112
1117
int src_width, int src_height,
1113
1118
int bit_depth, float param)
1114
1119
{
1115
1120
float hscale = (float )src_width / (float )dst_width;
1116
1121
float vscale = (float )src_height / (float )dst_height;
1117
- float xi = (xo + 0 .5f ) * hscale - 0 .5f ;
1118
- float yi = (yo + 0 .5f ) * vscale - 0 .5f ;
1122
+ float xi = (xo + 0 .5f ) * hscale - 0 .5f + src_left ;
1123
+ float yi = (yo + 0 .5f ) * vscale - 0 .5f + src_top ;
1119
1124
float px = floor (xi);
1120
1125
float py = floor (yi);
1121
1126
float fx = xi - px;
@@ -1147,7 +1152,7 @@ __device__ static inline T Subsample_Bicubic(cudaTextureObject_t tex,
1147
1152
cudaTextureObject_t src_tex_2, cudaTextureObject_t src_tex_3, \
1148
1153
T *dst_0, T *dst_1, T *dst_2, T *dst_3, \
1149
1154
int dst_width, int dst_height, int dst_pitch, \
1150
- int src_width, int src_height, float param
1155
+ int src_left, int src_top, int src_width, int src_height, float param
1151
1156
1152
1157
#define SUBSAMPLE (Convert, T ) \
1153
1158
cudaTextureObject_t src_tex[4 ] = \
@@ -1159,6 +1164,7 @@ __device__ static inline T Subsample_Bicubic(cudaTextureObject_t tex,
1159
1164
Convert ( \
1160
1165
src_tex, dst, xo, yo, \
1161
1166
dst_width, dst_height, dst_pitch, \
1167
+ src_left, src_top, \
1162
1168
src_width, src_height, param);
1163
1169
1164
1170
extern " C" {
0 commit comments