Skip to content

Instantly share code, notes, and snippets.

@zenoalbisser
Last active December 22, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenoalbisser/6550188 to your computer and use it in GitHub Desktop.
Save zenoalbisser/6550188 to your computer and use it in GitHub Desktop.
commit 6058ce044452c0c5fbedbad565773c3a1b35d462
Author: Zeno Albisser <zeno.albisser@digia.com>
Date: Thu Sep 12 22:36:42 2013 +0200
debug that one
diff --git a/common.c b/common.c
index dec4589..56f9a53 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,36 @@ 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];
+ // Fetch
+ in = _mm_loadu_si128(((__m128i*)&block[i*8])); // Convert the type by changing pointer
- if (tmp < 0) { tmp = 0; }
- else if (tmp > 255) { tmp = 255; }
+ 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
- out_data[i*w+j+x] = tmp;
- }
+ // Compute
+ in = _mm_adds_epi16(in, pred);
+
+ // Pack and clamp
+ in = _mm_packus_epi16 (in, _mm_setzero_si128());
+
+ // Save
+ _mm_storel_epi64((__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