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