Merge "vp8_decrypt_test.c: Silence MSVC data loss warning."

This commit is contained in:
Tom Finegan 2014-03-04 14:31:16 -08:00 committed by Gerrit Code Review
commit 7281c0b908
2 changed files with 7 additions and 7 deletions

View File

@ -35,14 +35,14 @@ const uint8_t secret_key[16] = {
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0
}; };
void encrypt_buffer(uint8_t *buffer, int size) { void encrypt_buffer(uint8_t *buffer, size_t size) {
for (int i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
buffer[i] ^= secret_key[i & 15]; buffer[i] ^= secret_key[i & 15];
} }
} }
void test_decrypt_cb(void *decrypt_state, const uint8_t *input, void test_decrypt_cb(void *decrypt_state, const uint8_t *input,
uint8_t *output, int count) { uint8_t *output, int count) {
const size_t offset = input - reinterpret_cast<uint8_t*>(decrypt_state); const size_t offset = input - reinterpret_cast<uint8_t*>(decrypt_state);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
output[i] = input[i] ^ secret_key[(offset + i) & 15]; output[i] = input[i] ^ secret_key[(offset + i) & 15];

View File

@ -26,9 +26,9 @@ const uint8_t test_key[16] = {
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0
}; };
void encrypt_buffer(const uint8_t *src, uint8_t *dst, void encrypt_buffer(const uint8_t *src, uint8_t *dst, size_t size,
int size, int offset = 0) { ptrdiff_t offset) {
for (int i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
dst[i] = src[i] ^ test_key[(offset + i) & 15]; dst[i] = src[i] ^ test_key[(offset + i) & 15];
} }
} }
@ -61,7 +61,7 @@ TEST(TestDecrypt, DecryptWorks) {
#if CONFIG_DECRYPT #if CONFIG_DECRYPT
std::vector<uint8_t> encrypted(video.frame_size()); std::vector<uint8_t> encrypted(video.frame_size());
encrypt_buffer(video.cxdata(), &encrypted[0], video.frame_size()); encrypt_buffer(video.cxdata(), &encrypted[0], video.frame_size(), 0);
vp8_decrypt_init di = { test_decrypt_cb, &encrypted[0] }; vp8_decrypt_init di = { test_decrypt_cb, &encrypted[0] };
decoder.Control(VP8D_SET_DECRYPTOR, &di); decoder.Control(VP8D_SET_DECRYPTOR, &di);
#endif // CONFIG_DECRYPT #endif // CONFIG_DECRYPT