Add Russian translation provided by Валерий Крувялис <valkru@mail.ru>
[xiph-mirror.git] / theora-old / lib / reconstruct.c
blobca99e01809576147b8425269669c5a61ebd098d8
1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
13 function:
14 last mod: $Id$
16 ********************************************************************/
18 #include "codec_internal.h"
20 static void copy8x8__c (unsigned char *src,
21 unsigned char *dest,
22 unsigned int stride)
24 int j;
25 for ( j = 0; j < 8; j++ ){
26 ((ogg_uint32_t*)dest)[0] = ((ogg_uint32_t*)src)[0];
27 ((ogg_uint32_t*)dest)[1] = ((ogg_uint32_t*)src)[1];
28 src+=stride;
29 dest+=stride;
33 static void recon_intra8x8__c (unsigned char *ReconPtr, ogg_int16_t *ChangePtr,
34 ogg_uint32_t LineStep)
36 ogg_uint32_t i;
38 for (i = 8; i; i--){
39 /* Convert the data back to 8 bit unsigned */
40 /* Saturate the output to unsigend 8 bit values */
41 ReconPtr[0] = clamp255( ChangePtr[0] + 128 );
42 ReconPtr[1] = clamp255( ChangePtr[1] + 128 );
43 ReconPtr[2] = clamp255( ChangePtr[2] + 128 );
44 ReconPtr[3] = clamp255( ChangePtr[3] + 128 );
45 ReconPtr[4] = clamp255( ChangePtr[4] + 128 );
46 ReconPtr[5] = clamp255( ChangePtr[5] + 128 );
47 ReconPtr[6] = clamp255( ChangePtr[6] + 128 );
48 ReconPtr[7] = clamp255( ChangePtr[7] + 128 );
50 ReconPtr += LineStep;
51 ChangePtr += 8;
55 static void recon_inter8x8__c (unsigned char *ReconPtr, unsigned char *RefPtr,
56 ogg_int16_t *ChangePtr, ogg_uint32_t LineStep)
58 ogg_uint32_t i;
60 for (i = 8; i; i--){
61 ReconPtr[0] = clamp255(RefPtr[0] + ChangePtr[0]);
62 ReconPtr[1] = clamp255(RefPtr[1] + ChangePtr[1]);
63 ReconPtr[2] = clamp255(RefPtr[2] + ChangePtr[2]);
64 ReconPtr[3] = clamp255(RefPtr[3] + ChangePtr[3]);
65 ReconPtr[4] = clamp255(RefPtr[4] + ChangePtr[4]);
66 ReconPtr[5] = clamp255(RefPtr[5] + ChangePtr[5]);
67 ReconPtr[6] = clamp255(RefPtr[6] + ChangePtr[6]);
68 ReconPtr[7] = clamp255(RefPtr[7] + ChangePtr[7]);
70 ChangePtr += 8;
71 ReconPtr += LineStep;
72 RefPtr += LineStep;
76 static void recon_inter8x8_half__c (unsigned char *ReconPtr, unsigned char *RefPtr1,
77 unsigned char *RefPtr2, ogg_int16_t *ChangePtr,
78 ogg_uint32_t LineStep)
80 ogg_uint32_t i;
82 for (i = 8; i; i--){
83 ReconPtr[0] = clamp255((((int)RefPtr1[0] + (int)RefPtr2[0]) >> 1) + ChangePtr[0] );
84 ReconPtr[1] = clamp255((((int)RefPtr1[1] + (int)RefPtr2[1]) >> 1) + ChangePtr[1] );
85 ReconPtr[2] = clamp255((((int)RefPtr1[2] + (int)RefPtr2[2]) >> 1) + ChangePtr[2] );
86 ReconPtr[3] = clamp255((((int)RefPtr1[3] + (int)RefPtr2[3]) >> 1) + ChangePtr[3] );
87 ReconPtr[4] = clamp255((((int)RefPtr1[4] + (int)RefPtr2[4]) >> 1) + ChangePtr[4] );
88 ReconPtr[5] = clamp255((((int)RefPtr1[5] + (int)RefPtr2[5]) >> 1) + ChangePtr[5] );
89 ReconPtr[6] = clamp255((((int)RefPtr1[6] + (int)RefPtr2[6]) >> 1) + ChangePtr[6] );
90 ReconPtr[7] = clamp255((((int)RefPtr1[7] + (int)RefPtr2[7]) >> 1) + ChangePtr[7] );
92 ChangePtr += 8;
93 ReconPtr += LineStep;
94 RefPtr1 += LineStep;
95 RefPtr2 += LineStep;
99 void dsp_recon_init (DspFunctions *funcs, ogg_uint32_t cpu_flags)
101 funcs->copy8x8 = copy8x8__c;
102 funcs->recon_intra8x8 = recon_intra8x8__c;
103 funcs->recon_inter8x8 = recon_inter8x8__c;
104 funcs->recon_inter8x8_half = recon_inter8x8_half__c;
105 #if defined(USE_ASM)
106 if (cpu_flags & CPU_X86_MMX) {
107 dsp_mmx_recon_init(funcs);
109 #endif