Must be called last as it rewinds the file.
| 2175 | |
| 2176 | // Must be called last as it rewinds the file. |
| 2177 | bool |
| 2178 | ktxValidator::validateTranscode(validationContext& ctx) |
| 2179 | { |
| 2180 | uint32_t* bdb = ctx.pActualDfd + 1; // Basic descriptor block. |
| 2181 | uint32_t model = KHR_DFDVAL(bdb, MODEL); |
| 2182 | if (model != KHR_DF_MODEL_UASTC && model != KHR_DF_MODEL_ETC1S) { |
| 2183 | // Nothin to do. Not transcodable. |
| 2184 | return true; |
| 2185 | } |
| 2186 | |
| 2187 | bool retval; |
| 2188 | istream& is = *ctx.inp; |
| 2189 | is.seekg(0); |
| 2190 | streambuf* _streambuf = (is.rdbuf()); |
| 2191 | StreambufStream<streambuf*> ktx2Stream(_streambuf, ios::in); |
| 2192 | KtxTexture<ktxTexture2> texture2; |
| 2193 | ktx_error_code_e result = ktxTexture2_CreateFromStream(ktx2Stream.stream(), |
| 2194 | KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, |
| 2195 | texture2.pHandle()); |
| 2196 | if (result != KTX_SUCCESS) { |
| 2197 | addIssue(logger::eError, FileError.CreateFailure, |
| 2198 | ktxErrorString(result)); |
| 2199 | retval = false; |
| 2200 | } |
| 2201 | |
| 2202 | if (model == KHR_DF_MODEL_ETC1S) |
| 2203 | result = ktxTexture2_TranscodeBasis(texture2.handle(), |
| 2204 | KTX_TTF_ETC2_RGBA, 0); |
| 2205 | else |
| 2206 | result = ktxTexture2_TranscodeBasis(texture2.handle(), |
| 2207 | KTX_TTF_ASTC_4x4_RGBA, 0); |
| 2208 | if (result != KTX_SUCCESS) { |
| 2209 | addIssue(logger::eError, Transcode.Failure, ktxErrorString(result)); |
| 2210 | retval = false; |
| 2211 | } else { |
| 2212 | retval = true; |
| 2213 | } |
| 2214 | return retval; |
| 2215 | } |
| 2216 |
nothing calls this directly
no test coverage detected