issue 1957: Added support for reading embedded content (textures) in ASCII FBX. In ASCII FBX embedded content is encoded in Base64 and is surrounded by double quotation marks. The decoding functions are based on those used in the glTF importer.
This commit is contained in:
@@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/ByteSwapper.h>
|
||||
|
||||
#include <algorithm> // std::transform
|
||||
#include "FBXUtil.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace FBX {
|
||||
@@ -307,7 +308,22 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
||||
const Token& token = GetRequiredToken(*Content, 0);
|
||||
const char* data = token.begin();
|
||||
if (!token.IsBinary()) {
|
||||
DOMWarning("video content is not binary data, ignoring", &element);
|
||||
if (*data != '"') {
|
||||
DOMError("embedded content is not surrounded by quotation marks", &element);
|
||||
}
|
||||
else {
|
||||
const char* encodedData = data + 1;
|
||||
size_t encodedDataLen = static_cast<size_t>(token.end() - token.begin());
|
||||
// search for last quotation mark
|
||||
while (encodedDataLen > 1 && encodedData[encodedDataLen] != '"')
|
||||
encodedDataLen--;
|
||||
if (encodedDataLen % 4 != 0) {
|
||||
DOMError("embedded content is invalid, needs to be in base64", &element);
|
||||
}
|
||||
else {
|
||||
contentLength = Util::DecodeBase64(encodedData, encodedDataLen, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (static_cast<size_t>(token.end() - data) < 5) {
|
||||
DOMError("binary data array is too short, need five (5) bytes for type signature and element count", &element);
|
||||
|
||||
Reference in New Issue
Block a user