Git init
[external/libtheora.git] / lib / fragment.c
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-2009                *
9  * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
10  *                                                                  *
11  ********************************************************************
12
13   function:
14     last mod: $Id: fragment.c 16503 2009-08-22 18:14:02Z giles $
15
16  ********************************************************************/
17 #include <string.h>
18 #include "internal.h"
19
20 void oc_frag_copy(const oc_theora_state *_state,unsigned char *_dst,
21  const unsigned char *_src,int _ystride){
22   (*_state->opt_vtable.frag_copy)(_dst,_src,_ystride);
23 }
24
25 void oc_frag_copy_c(unsigned char *_dst,const unsigned char *_src,int _ystride){
26   int i;
27   for(i=8;i-->0;){
28     memcpy(_dst,_src,8*sizeof(*_dst));
29     _dst+=_ystride;
30     _src+=_ystride;
31   }
32 }
33
34 void oc_frag_recon_intra(const oc_theora_state *_state,unsigned char *_dst,
35  int _ystride,const ogg_int16_t _residue[64]){
36   _state->opt_vtable.frag_recon_intra(_dst,_ystride,_residue);
37 }
38
39 void oc_frag_recon_intra_c(unsigned char *_dst,int _ystride,
40  const ogg_int16_t _residue[64]){
41   int i;
42   for(i=0;i<8;i++){
43     int j;
44     for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+128);
45     _dst+=_ystride;
46   }
47 }
48
49 void oc_frag_recon_inter(const oc_theora_state *_state,unsigned char *_dst,
50  const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){
51   _state->opt_vtable.frag_recon_inter(_dst,_src,_ystride,_residue);
52 }
53
54 void oc_frag_recon_inter_c(unsigned char *_dst,
55  const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){
56   int i;
57   for(i=0;i<8;i++){
58     int j;
59     for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+_src[j]);
60     _dst+=_ystride;
61     _src+=_ystride;
62   }
63 }
64
65 void oc_frag_recon_inter2(const oc_theora_state *_state,unsigned char *_dst,
66  const unsigned char *_src1,const unsigned char *_src2,int _ystride,
67  const ogg_int16_t _residue[64]){
68   _state->opt_vtable.frag_recon_inter2(_dst,_src1,_src2,_ystride,_residue);
69 }
70
71 void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1,
72  const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]){
73   int i;
74   for(i=0;i<8;i++){
75     int j;
76     for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+(_src1[j]+_src2[j]>>1));
77     _dst+=_ystride;
78     _src1+=_ystride;
79     _src2+=_ystride;
80   }
81 }
82
83 void oc_restore_fpu(const oc_theora_state *_state){
84   _state->opt_vtable.restore_fpu();
85 }
86
87 void oc_restore_fpu_c(void){}