mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Fixed checksum on bitdepth > 8 cases
Conflicts: src/nal.c src/nal.h src/strategies/generic/nal-generic.c src/strategies/strategies-nal.c src/strategies/strategies-nal.h
This commit is contained in:
parent
57ab46f110
commit
414ebe6101
|
@ -713,7 +713,7 @@ static void add_checksum(encoder_state_t * const state)
|
|||
|
||||
nal_write(stream, NAL_SUFFIT_SEI_NUT, 0, 0);
|
||||
|
||||
image_checksum(frame->rec, checksum);
|
||||
image_checksum(state->encoder_control->bitdepth,frame->rec, checksum);
|
||||
|
||||
WRITE_U(stream, 132, 8, "sei_type");
|
||||
WRITE_U(stream, 13, 8, "size");
|
||||
|
|
|
@ -72,11 +72,11 @@ void nal_write(bitstream_t * const bitstream, const uint8_t nal_type,
|
|||
\param checksum_out Result of the calculation.
|
||||
\returns Void
|
||||
*/
|
||||
void image_checksum(const kvz_picture *im, unsigned char checksum_out[][SEI_HASH_MAX_LENGTH])
|
||||
void image_checksum(const kvz_picture *im, unsigned char checksum_out[][SEI_HASH_MAX_LENGTH], const uint8_t bitdepth)
|
||||
{
|
||||
array_checksum(im->y, im->height, im->width, im->width, checksum_out[0]);
|
||||
array_checksum(im->y, im->height, im->width, im->width, checksum_out[0], bitdepth);
|
||||
|
||||
/* The number of chroma pixels is half that of luma. */
|
||||
array_checksum(im->u, im->height >> 1, im->width >> 1, im->width >> 1, checksum_out[1]);
|
||||
array_checksum(im->v, im->height >> 1, im->width >> 1, im->width >> 1, checksum_out[2]);
|
||||
array_checksum(im->u, im->height >> 1, im->width >> 1, im->width >> 1, checksum_out[1], bitdepth);
|
||||
array_checksum(im->v, im->height >> 1, im->width >> 1, im->width >> 1, checksum_out[2], bitdepth);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ enum {
|
|||
void nal_write(bitstream_t * const bitstream, const uint8_t nal_type,
|
||||
const uint8_t temporal_id, const int long_start_code);
|
||||
void image_checksum(const kvz_picture *im,
|
||||
unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]);
|
||||
unsigned char checksum_out[][SEI_HASH_MAX_LENGTH], const uint8_t bitdepth);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
static void array_checksum_generic(const kvz_pixel* data,
|
||||
const int height, const int width,
|
||||
const int stride,
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH]) {
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth) {
|
||||
int x, y;
|
||||
int checksum = 0;
|
||||
|
||||
|
@ -42,6 +42,9 @@ static void array_checksum_generic(const kvz_pixel* data,
|
|||
for (x = 0; x < width; ++x) {
|
||||
const uint8_t mask = (uint8_t)((x & 0xff) ^ (y & 0xff) ^ (x >> 8) ^ (y >> 8));
|
||||
checksum += (data[(y * stride) + x] & 0xff) ^ mask;
|
||||
if(bitdepth > 8) {
|
||||
checksum += ((data[(y * stride) + x]>>8) & 0xff) ^ mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,13 +58,18 @@ static void array_checksum_generic(const kvz_pixel* data,
|
|||
static void array_checksum_generic4(const kvz_pixel* data,
|
||||
const int height, const int width,
|
||||
const int stride,
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH]) {
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth) {
|
||||
uint32_t checksum = 0;
|
||||
int y, x, xp;
|
||||
|
||||
static uint8_t ckmap_initialized = 0;
|
||||
static uint32_t ckmap[64*256];
|
||||
|
||||
|
||||
//TODO: add 10-bit support
|
||||
if(bitdepth != 8) {
|
||||
array_checksum_generic(data, height, width, stride,checksum_out, bitdepth);
|
||||
return;
|
||||
}
|
||||
if (!ckmap_initialized) {
|
||||
uint8_t * const ckmap_uint8 = (uint8_t*)&ckmap;
|
||||
int x, y;
|
||||
|
@ -98,13 +106,18 @@ static void array_checksum_generic4(const kvz_pixel* data,
|
|||
static void array_checksum_generic8(const kvz_pixel* data,
|
||||
const int height, const int width,
|
||||
const int stride,
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH]) {
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth) {
|
||||
uint32_t checksum = 0;
|
||||
int y, x, xp;
|
||||
|
||||
static uint8_t ckmap_initialized = 0;
|
||||
static uint64_t ckmap[32*256];
|
||||
|
||||
//TODO: add 10-bit support
|
||||
if(bitdepth != 8) {
|
||||
array_checksum_generic(data, height, width, stride,checksum_out, bitdepth);
|
||||
return;
|
||||
}
|
||||
if (!ckmap_initialized) {
|
||||
uint8_t * const ckmap_uint8 = (uint8_t*)&ckmap;
|
||||
int x, y;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
void (*array_checksum)(const kvz_pixel* data,
|
||||
const int height, const int width,
|
||||
const int stride,
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH]);
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth);
|
||||
|
||||
|
||||
int strategy_register_nal(void* opaque) {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
typedef void (*array_checksum_func)(const kvz_pixel* data,
|
||||
const int height, const int width,
|
||||
const int stride,
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH]);
|
||||
unsigned char checksum_out[SEI_HASH_MAX_LENGTH], const uint8_t bitdepth);
|
||||
extern array_checksum_func array_checksum;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue