OpenCores
URL https://opencores.org/ocsvn/mpeg2fpga/mpeg2fpga/trunk

Subversion Repositories mpeg2fpga

[/] [mpeg2fpga/] [trunk/] [tools/] [mpeg2dec/] [idctref.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kdv
#ifdef HAVE_MMX
2
#include <string.h>
3
 
4
void Initialize_Reference_IDCT() { /* nothing */ }
5
 
6
/* perform intel mmx IDCT matrix multiply for 8x8 coefficient block */
7
 
8
void Reference_IDCT(block, i)
9
short *block;
10
int i;  /* is intra */
11
{
12
   if (0)
13
        block[0] += 8;   /* add 0.5 to [0][0] for I-frames */
14
   IDCT_mmx(block);
15
}
16
 
17
#else
18
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
19
 
20
/*
21
 * Disclaimer of Warranty
22
 *
23
 * These software programs are available to the user without any license fee or
24
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
25
 * any and all warranties, whether express, implied, or statuary, including any
26
 * implied warranties or merchantability or of fitness for a particular
27
 * purpose.  In no event shall the copyright-holder be liable for any
28
 * incidental, punitive, or consequential damages of any kind whatsoever
29
 * arising from the use of these programs.
30
 *
31
 * This disclaimer of warranty extends to the user of these programs and user's
32
 * customers, employees, agents, transferees, successors, and assigns.
33
 *
34
 * The MPEG Software Simulation Group does not represent or warrant that the
35
 * programs furnished hereunder are free of infringement of any third-party
36
 * patents.
37
 *
38
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
39
 * are subject to royalty fees to patent holders.  Many of these patents are
40
 * general enough such that they are unavoidable regardless of implementation
41
 * design.
42
 *
43
 */
44
 
45
/*  Perform IEEE 1180 reference (64-bit floating point, separable 8x1
46
 *  direct matrix multiply) Inverse Discrete Cosine Transform
47
*/
48
 
49
 
50
/* Here we use math.h to generate constants.  Compiler results may
51
   vary a little */
52
 
53
#include <math.h>
54
 
55
#include "config.h"
56
 
57
#ifndef PI
58
# ifdef M_PI
59
#  define PI M_PI
60
# else
61
#  define PI 3.14159265358979323846
62
# endif
63
#endif
64
 
65
/* global declarations */
66
void Initialize_Fast_IDCTref _ANSI_ARGS_((void));
67
void Reference_IDCT _ANSI_ARGS_((short *block));
68
 
69
/* private data */
70
 
71
/* cosine transform matrix for 8x1 IDCT */
72
static double c[8][8];
73
 
74
/* initialize DCT coefficient matrix */
75
 
76
void Initialize_Reference_IDCT()
77
{
78
  int freq, time;
79
  double scale;
80
 
81
  for (freq=0; freq < 8; freq++)
82
  {
83
    scale = (freq == 0) ? sqrt(0.125) : 0.5;
84
    for (time=0; time<8; time++)
85
      c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
86
  }
87
}
88
 
89
/* perform IDCT matrix multiply for 8x8 coefficient block */
90
 
91
void Reference_IDCT(block)
92
short *block;
93
{
94
  int i, j, k, v;
95
  double partial_product;
96
  double tmp[64];
97
 
98
  for (i=0; i<8; i++)
99
    for (j=0; j<8; j++)
100
    {
101
      partial_product = 0.0;
102
 
103
      for (k=0; k<8; k++)
104
        partial_product+= c[k][j]*block[8*i+k];
105
 
106
      tmp[8*i+j] = partial_product;
107
    }
108
 
109
  /* Transpose operation is integrated into address mapping by switching
110
     loop order of i and j */
111
 
112
  for (j=0; j<8; j++)
113
    for (i=0; i<8; i++)
114
    {
115
      partial_product = 0.0;
116
 
117
      for (k=0; k<8; k++)
118
        partial_product+= c[k][i]*tmp[8*k+j];
119
 
120
      v = (int) floor(partial_product+0.5);
121
      block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);
122
    }
123
}
124
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.