Created
September 12, 2013 21:30
-
-
Save zenoalbisser/6544067 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit cc4411da548016a7bcd94678e63b89170b852012 | |
Author: Zeno Albisser <[email protected]> | |
Date: Thu Sep 12 22:36:42 2013 +0200 | |
debug that one | |
diff --git a/common.c b/common.c | |
index dec4589..7079c2b 100644 | |
--- a/common.c | |
+++ b/common.c | |
@@ -6,6 +6,7 @@ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
+#include <emmintrin.h> | |
#include "c63.h" | |
#include "tables.h" | |
@@ -14,29 +15,44 @@ void dequantize_idct_row(int16_t *in_data, uint8_t *prediction, int w, int h, | |
int y, uint8_t *out_data, uint8_t *quantization) | |
{ | |
int x; | |
- | |
int16_t block[8*8]; | |
+ __m128i in; | |
+ __m128i pred; | |
+ __m128i mask_min = _mm_set1_epi16(255); | |
+ __m128i mask_max = _mm_setzero_si128(); | |
/* Perform the dequantization and iDCT */ | |
for(x = 0; x < w; x += 8) | |
{ | |
- int i, j; | |
- | |
dequant_idct_block_8x8(in_data+(x*8), block, quantization); | |
- for (i = 0; i < 8; ++i) | |
+ int i; | |
+ for (i = 0; i < 8; i++) | |
{ | |
- for (j = 0; j < 8; ++j) | |
- { | |
- /* Add prediction block. Note: DCT is not precise - | |
- Clamp to legal values */ | |
- int16_t tmp = block[i*8+j] + (int16_t)prediction[i*w+j+x]; | |
- | |
- if (tmp < 0) { tmp = 0; } | |
- else if (tmp > 255) { tmp = 255; } | |
- | |
- out_data[i*w+j+x] = tmp; | |
- } | |
+ // Fetch | |
+ in = _mm_loadl_epi64(((__m128i*)&block[i*8])); // Convert the type by changing pointer | |
+ in = _mm_unpacklo_epi8(in, _mm_setzero_si128()); // and then get values | |
+ | |
+ | |
+ // in = _mm_loadu_si128((__m128i*)&block[i*8]); | |
+ pred = _mm_loadl_epi64(((__m128i*)&prediction[i*w+x])); // Convert the type by changing pointer | |
+ pred = _mm_unpacklo_epi8(pred, _mm_setzero_si128()); // and then get values | |
+ | |
+ // Compute | |
+ in = _mm_adds_epi16(in, pred); | |
+ | |
+ // Clamp | |
+ // in = _mm_max_epi16(in, mask_max); | |
+ // in = _mm_min_epi16(in, mask_min); | |
+ | |
+ // Save | |
+ in = _mm_packus_epi16 (in, _mm_setzero_si128()); | |
+ uint8_t* p = ∈ | |
+ fprintf(stderr, "%d %d %d %d %d %d %d %d ", p[15], p[14], p[13], p[12], p[11], p[10], p[9], p[8]); | |
+ fprintf(stderr, "%d %d %d %d %d %d %d %d\n", p[7], p[6], p[5], p[4], p[3], p[2], p[1], p[0]); | |
+ // Save | |
+ _mm_storel_epi64((__m128i*)(out_data+(i*w+x)), in); | |
+ // _mm_storeu_si128((__m128i*)&out_data[i*w+x], in); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment