RagePhoto(A): add jpegSign() function
- RagePhotoC: add ragephoto_getphotosign() ragephoto_getphotosignf() ragephotodata_getphotosign() and ragephotodata_getphotosignf() functions
This commit is contained in:
parent
564a8c92b5
commit
cac7fd221f
4 changed files with 110 additions and 0 deletions
|
@ -120,6 +120,20 @@ inline void uInt32ToCharLE(uint32_t x, char *y)
|
||||||
y[2] = x >> 16;
|
y[2] = x >> 16;
|
||||||
y[3] = x >> 24;
|
y[3] = x >> 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline uint32_t joaatFromInitial(const char *data, size_t size, uint32_t init_val)
|
||||||
|
{
|
||||||
|
uint32_t val = init_val;
|
||||||
|
for (size_t i = 0; i != size; i++) {
|
||||||
|
val += data[i];
|
||||||
|
val += (val << 10);
|
||||||
|
val ^= (val >> 6);
|
||||||
|
}
|
||||||
|
val += (val << 3);
|
||||||
|
val ^= (val >> 11);
|
||||||
|
val += (val << 15);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
/* END OF STATIC LIBRARY FUNCTIONS */
|
/* END OF STATIC LIBRARY FUNCTIONS */
|
||||||
|
|
||||||
/* BEGIN OF RAGEPHOTO CLASS */
|
/* BEGIN OF RAGEPHOTO CLASS */
|
||||||
|
@ -526,6 +540,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
|
||||||
std::cout << "jsonBuffer: " << rp_data->jsonBuffer << std::endl;
|
std::cout << "jsonBuffer: " << rp_data->jsonBuffer << std::endl;
|
||||||
std::cout << "jsonOffset: " << rp_data->jsonOffset << std::endl;
|
std::cout << "jsonOffset: " << rp_data->jsonOffset << std::endl;
|
||||||
std::cout << "json: " << rp_data->json << std::endl;
|
std::cout << "json: " << rp_data->json << std::endl;
|
||||||
|
std::cout << "sign: " << jpegSign(rp_data) << std::endl;
|
||||||
std::cout << "titlBuffer: " << rp_data->titlBuffer << std::endl;
|
std::cout << "titlBuffer: " << rp_data->titlBuffer << std::endl;
|
||||||
std::cout << "titlOffset: " << rp_data->titlOffset << std::endl;
|
std::cout << "titlOffset: " << rp_data->titlOffset << std::endl;
|
||||||
std::cout << "title: " << rp_data->title << std::endl;
|
std::cout << "title: " << rp_data->title << std::endl;
|
||||||
|
@ -617,6 +632,29 @@ const char* RagePhoto::jpegData() const
|
||||||
return m_data->jpeg;
|
return m_data->jpeg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t RagePhoto::jpegSign(uint32_t photoFormat, RagePhotoData *rp_data)
|
||||||
|
{
|
||||||
|
if (photoFormat == PhotoFormat::GTA5)
|
||||||
|
return (0x100000000000000ULL | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, SignInitials::SIGTA5));
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t RagePhoto::jpegSign(RagePhotoData *rp_data)
|
||||||
|
{
|
||||||
|
return jpegSign(rp_data->photoFormat, rp_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t RagePhoto::jpegSign(uint32_t photoFormat) const
|
||||||
|
{
|
||||||
|
return jpegSign(photoFormat, m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t RagePhoto::jpegSign() const
|
||||||
|
{
|
||||||
|
return jpegSign(m_data->photoFormat, m_data);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t RagePhoto::jpegSize() const
|
uint32_t RagePhoto::jpegSize() const
|
||||||
{
|
{
|
||||||
if (m_data->jpeg)
|
if (m_data->jpeg)
|
||||||
|
@ -1273,6 +1311,28 @@ const char* ragephoto_getphotoheader(ragephoto_t instance)
|
||||||
return ragePhoto->header();
|
return ragePhoto->header();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t ragephoto_getphotosign(ragephoto_t instance)
|
||||||
|
{
|
||||||
|
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
|
||||||
|
return ragePhoto->jpegSign();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat)
|
||||||
|
{
|
||||||
|
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
|
||||||
|
return ragePhoto->jpegSign(photoFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data)
|
||||||
|
{
|
||||||
|
return RagePhoto::jpegSign(rp_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoFormat)
|
||||||
|
{
|
||||||
|
return RagePhoto::jpegSign(photoFormat, rp_data);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ragephoto_getphotosize(ragephoto_t instance)
|
uint32_t ragephoto_getphotosize(ragephoto_t instance)
|
||||||
{
|
{
|
||||||
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
|
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
|
||||||
|
|
|
@ -92,6 +92,10 @@ public:
|
||||||
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
||||||
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
||||||
};
|
};
|
||||||
|
/** Sign Initials */
|
||||||
|
enum SignInitials : uint32_t {
|
||||||
|
SIGTA5 = 0xE47AB81CUL, /**< GTA V Sign Initial */
|
||||||
|
};
|
||||||
RagePhoto();
|
RagePhoto();
|
||||||
~RagePhoto();
|
~RagePhoto();
|
||||||
void addParser(RagePhotoFormatParser *rp_parser); /**< Add a custom defined RagePhotoFormatParser. */
|
void addParser(RagePhotoFormatParser *rp_parser); /**< Add a custom defined RagePhotoFormatParser. */
|
||||||
|
@ -119,6 +123,10 @@ public:
|
||||||
const std::string_view jpeg_view() const; /**< Returns the Photo JPEG data. */
|
const std::string_view jpeg_view() const; /**< Returns the Photo JPEG data. */
|
||||||
#endif
|
#endif
|
||||||
const char* jpegData() const; /**< Returns the Photo JPEG data. */
|
const char* jpegData() const; /**< Returns the Photo JPEG data. */
|
||||||
|
static uint64_t jpegSign(uint32_t photoFormat, RagePhotoData *rp_data); /**< Returns the Photo JPEG sign. */
|
||||||
|
static uint64_t jpegSign(RagePhotoData *rp_data); /**< Returns the Photo JPEG sign. */
|
||||||
|
uint64_t jpegSign(uint32_t photoFormat) const; /**< Returns the Photo JPEG sign. */
|
||||||
|
uint64_t jpegSign() const; /**< Returns the Photo JPEG sign. */
|
||||||
uint32_t jpegSize() const; /**< Returns the Photo JPEG data size. */
|
uint32_t jpegSize() const; /**< Returns the Photo JPEG data size. */
|
||||||
const char* description() const; /**< Returns the Photo description. */
|
const char* description() const; /**< Returns the Photo description. */
|
||||||
const char* json() const; /**< Returns the Photo JSON data. */
|
const char* json() const; /**< Returns the Photo JSON data. */
|
||||||
|
|
|
@ -92,6 +92,10 @@ public:
|
||||||
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
||||||
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
||||||
};
|
};
|
||||||
|
/** Sign Initials */
|
||||||
|
enum SignInitials : uint32_t {
|
||||||
|
SIGTA5 = 0xE47AB81CUL, /**< GTA V Sign Initial */
|
||||||
|
};
|
||||||
RagePhotoA() {
|
RagePhotoA() {
|
||||||
instance = ragephoto_open();
|
instance = ragephoto_open();
|
||||||
}
|
}
|
||||||
|
@ -167,6 +171,22 @@ public:
|
||||||
const char* jpegData() const {
|
const char* jpegData() const {
|
||||||
return ragephoto_getphotojpeg(instance);
|
return ragephoto_getphotojpeg(instance);
|
||||||
}
|
}
|
||||||
|
/**< Returns the Photo JPEG sign. */
|
||||||
|
static uint64_t jpegSign(uint32_t photoFormat, RagePhotoData *rp_data) {
|
||||||
|
return ragephotodata_getphotosignf(rp_data, photoFormat);
|
||||||
|
}
|
||||||
|
/**< Returns the Photo JPEG sign. */
|
||||||
|
static uint64_t jpegSign(RagePhotoData *rp_data) {
|
||||||
|
return ragephotodata_getphotosign(rp_data);
|
||||||
|
}
|
||||||
|
/**< Returns the Photo JPEG sign. */
|
||||||
|
uint64_t jpegSign(uint32_t photoFormat) const {
|
||||||
|
return ragephoto_getphotosignf(instance, photoFormat);
|
||||||
|
}
|
||||||
|
/**< Returns the Photo JPEG sign. */
|
||||||
|
uint64_t jpegSign() const {
|
||||||
|
return ragephoto_getphotosign(instance);
|
||||||
|
}
|
||||||
/** Returns the Photo JPEG data size. */
|
/** Returns the Photo JPEG data size. */
|
||||||
uint32_t jpegSize() const {
|
uint32_t jpegSize() const {
|
||||||
return ragephoto_getphotosize(instance);
|
return ragephoto_getphotosize(instance);
|
||||||
|
|
|
@ -123,6 +123,28 @@ LIBRAGEPHOTO_C_BINDING const char* ragephoto_getphotojson(ragephoto_t instance);
|
||||||
*/
|
*/
|
||||||
LIBRAGEPHOTO_C_BINDING const char* ragephoto_getphotoheader(ragephoto_t instance);
|
LIBRAGEPHOTO_C_BINDING const char* ragephoto_getphotoheader(ragephoto_t instance);
|
||||||
|
|
||||||
|
/** Returns the Photo JPEG sign.
|
||||||
|
* \param instance \p ragephoto_t instance
|
||||||
|
*/
|
||||||
|
LIBRAGEPHOTO_C_BINDING uint64_t ragephoto_getphotosign(ragephoto_t instance);
|
||||||
|
|
||||||
|
/** Returns the Photo JPEG sign.
|
||||||
|
* \param instance \p ragephoto_t instance
|
||||||
|
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||||
|
*/
|
||||||
|
LIBRAGEPHOTO_C_BINDING uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat);
|
||||||
|
|
||||||
|
/** Returns the Photo JPEG sign.
|
||||||
|
* \param rp_data RagePhotoData object
|
||||||
|
*/
|
||||||
|
LIBRAGEPHOTO_C_BINDING uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data);
|
||||||
|
|
||||||
|
/** Returns the Photo JPEG sign.
|
||||||
|
* \param rp_data RagePhotoData object
|
||||||
|
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||||
|
*/
|
||||||
|
LIBRAGEPHOTO_C_BINDING uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoFormat);
|
||||||
|
|
||||||
/** Returns the Photo JPEG data size.
|
/** Returns the Photo JPEG data size.
|
||||||
* \param instance \p ragephoto_t instance
|
* \param instance \p ragephoto_t instance
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue