Develop and Download Open Source Software

Browse Subversion Repository

Contents of /encode.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (show annotations) (download) (as text)
Mon Oct 11 13:26:23 2010 UTC (13 years, 7 months ago) by berupon
File MIME type: text/x-chdr
File size: 2888 byte(s)
GUIで、圧縮設定を調整して結果を確認出来るアプリケーションの作成開始。
1 #pragma once
2
3 #include "IntraPrediction.h"
4
5 void copy(int in[8][8], int out[8][8])
6 {
7 for (size_t i=0; i<8; ++i)
8 for (size_t j=0; j<8; ++j)
9 out[i][j] = in[i][j];
10 }
11
12 size_t sumOfAbsolutes(const int values[8][8])
13 {
14 size_t ret = 0;
15 for (size_t i=0; i<8; ++i)
16 for (size_t j=0; j<8; ++j)
17 ret += std::abs(values[i][j]);
18 return ret;
19 }
20
21 // quantize blocks...
22 template <typename T>
23 void encode(
24 Quantizer& quantizer,
25 size_t hBlocks, size_t vBlocks,
26 const T* in, int inLineOffsetBytes,
27 int* out, int outLineOffsetBytes
28 )
29 {
30 int values[8][8];
31 int tmps[8][8];
32 int tmps2[8][8];
33
34 IntraPrediction::Predictor8 predictor;
35 int cols[17];
36 int rows[17];
37 int predictionScores[9];
38
39 const T* src = in;
40 int* dest = out;
41
42 // top
43 {
44 const T* srcLine = src;
45 int* destLine = dest;
46
47 // top left
48 gather(srcLine, inLineOffsetBytes, values);
49 dct_8x8(values, tmps);
50 quantizer.quantize(values);
51 scatter(destLine, outLineOffsetBytes, values);
52 srcLine += 8; destLine += 8;
53 // top remain
54 for (size_t x=1; x<hBlocks; ++x) {
55 #if 0
56 decodeRightMostColumn(quantizer, rows+1, values, tmps);
57 // predictor.rows[0] = predictor.rows[1] =
58 int sum = 0;
59 for (size_t i=1; i<9; ++i) {
60 sum += rows[i];
61 }
62 std::copy(rows+1, rows+9, predictor.rows+1);
63 predictor.average = sum / 8;
64 gather(srcLine, inLineOffsetBytes, values);
65 predictor.horizontal(values, tmps);
66 //sum = sumOfAbsolutes(tmps);
67 //predictor.horizontalUp(values, tmps);
68 //sum = sumOfAbsolutes(tmps);
69 //predictor.dc(values, tmps);
70 //sum = sumOfAbsolutes(tmps);
71 dct_8x8(tmps, tmps2);
72 quantizer.quantize(tmps);
73 scatter(destLine, outLineOffsetBytes, tmps);
74 #else
75 gather(srcLine, inLineOffsetBytes, values);
76 dct_8x8(values, tmps);
77 quantizer.quantize(values);
78 scatter(destLine, outLineOffsetBytes, values);
79 #endif
80 srcLine += 8; destLine += 8;
81 }
82 OffsetPtr(src, inLineOffsetBytes*8);
83 OffsetPtr(dest, outLineOffsetBytes*8);
84 }
85
86 for (size_t y=1; y<vBlocks; ++y) {
87
88 const T* srcLine = src;
89 int* destLine = dest;
90
91 // left
92 gather(srcLine, inLineOffsetBytes, values);
93 dct_8x8(values, tmps);
94 quantizer.quantize(values);
95 scatter(destLine, outLineOffsetBytes, values);
96 srcLine += 8; destLine += 8;
97 // between
98 for (size_t x=1; x<hBlocks-1; ++x) {
99 gather(srcLine, inLineOffsetBytes, values);
100 dct_8x8(values, tmps);
101 quantizer.quantize(values);
102 //values[0][0] = 100;
103 scatter(destLine, outLineOffsetBytes, values);
104 srcLine += 8; destLine += 8;
105 }
106 // right
107 gather(srcLine, inLineOffsetBytes, values);
108 dct_8x8(values, tmps);
109 quantizer.quantize(values);
110 scatter(destLine, outLineOffsetBytes, values);
111 srcLine += 8; destLine += 8;
112
113 OffsetPtr(src, inLineOffsetBytes*8);
114 OffsetPtr(dest, outLineOffsetBytes*8);
115 }
116 }
117

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26