1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * Multiple scan-order macroblock decoding functions. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /* |
|
22 * Includes |
|
23 */ |
|
24 #include "h263dConfig.h" |
|
25 #include "decmbs.h" |
|
26 #include "viddemux.h" |
|
27 /* MVE */ |
|
28 #include "MPEG4Transcoder.h" |
|
29 |
|
30 |
|
31 /* |
|
32 * Global functions |
|
33 */ |
|
34 |
|
35 /* {{-output"dmbsGetAndDecodeIMBsInScanOrder.txt"}} */ |
|
36 /* |
|
37 * dmbsGetAndDecodeIMBsInScanOrder |
|
38 * |
|
39 * Parameters: |
|
40 * numMBsToDecode the number of macroblocks to decode |
|
41 * inParam input parameters |
|
42 * inOutParam input/output parameters, these parameters |
|
43 * may be modified in the function |
|
44 * quant array for storing quantization parameters |
|
45 * |
|
46 * Function: |
|
47 * This function gets and decodes a requested number of INTRA frame |
|
48 * macroblocks in scan order. |
|
49 * |
|
50 * Returns: |
|
51 * >= 0 the function was successful |
|
52 * < 0 an error occured |
|
53 * |
|
54 */ |
|
55 |
|
56 int dmbsGetAndDecodeIMBsInScanOrder( |
|
57 const dmbIFrameMBInParam_t *inParam, |
|
58 dmbIFrameMBInOutParam_t *inOutParam, |
|
59 int *quant, CMPEG4Transcoder *hTranscoder) |
|
60 /* {{-output"dmbsGetAndDecodeIMBsInScanOrder.txt"}} */ |
|
61 { |
|
62 int currMBNum; |
|
63 int yWidth = inParam->pictParam->lumMemWidth; |
|
64 int uvWidth = yWidth / 2; |
|
65 int ret = 0; |
|
66 dmbIFrameMBInParam_t dmbi; |
|
67 |
|
68 memcpy(&dmbi, inParam, sizeof(dmbIFrameMBInParam_t)); |
|
69 |
|
70 for (currMBNum = 0; currMBNum < inParam->numMBsInSegment; currMBNum++) { |
|
71 |
|
72 hTranscoder->BeginOneMB(currMBNum + inParam->numMBsInSegment * inParam->yPosInMBs); |
|
73 |
|
74 ret = dmbGetAndDecodeIFrameMB(&dmbi, inOutParam, 0, hTranscoder); |
|
75 if ( ret < 0) |
|
76 return DMBS_ERR; |
|
77 else if ( ret == DMB_BIT_ERR ) { |
|
78 break; |
|
79 } |
|
80 |
|
81 /* Store quantizer and increment array index */ |
|
82 *quant = inOutParam->quant; |
|
83 quant++; |
|
84 |
|
85 if ( inOutParam->yMBInFrame != NULL ) |
|
86 { |
|
87 inOutParam->yMBInFrame += 16; |
|
88 inOutParam->uBlockInFrame += 8; |
|
89 inOutParam->vBlockInFrame += 8; |
|
90 } |
|
91 dmbi.xPosInMBs++; |
|
92 |
|
93 if (dmbi.xPosInMBs == inParam->pictParam->numMBsInMBLine) { |
|
94 if ( inOutParam->yMBInFrame != NULL ) |
|
95 { |
|
96 inOutParam->yMBInFrame += 15 * yWidth; |
|
97 inOutParam->uBlockInFrame += 7 * uvWidth; |
|
98 inOutParam->vBlockInFrame += 7 * uvWidth; |
|
99 } |
|
100 dmbi.xPosInMBs = 0; |
|
101 dmbi.yPosInMBs++; |
|
102 } |
|
103 } |
|
104 |
|
105 hTranscoder->H263OneGOBSliceEnded(dmbi.yPosInMBs * inParam->numMBsInSegment); |
|
106 |
|
107 return DMBS_OK; |
|
108 } |
|
109 |
|
110 |
|
111 /* {{-output"dmbsGetAndDecodePMBsInScanOrder.txt"}} */ |
|
112 /* |
|
113 * dmbsGetAndDecodePMBsInScanOrder |
|
114 * |
|
115 * Parameters: |
|
116 * numMBsToDecode the number of macroblocks to decode |
|
117 * inParam input parameters |
|
118 * inOutParam input/output parameters, these parameters |
|
119 * may be modified in the function |
|
120 * quant array for storing quantization parameters |
|
121 * |
|
122 * Function: |
|
123 * This function gets and decodes a requested number of INTER frame |
|
124 * macroblocks in scan order. |
|
125 * |
|
126 * Returns: |
|
127 * >= 0 the function was successful |
|
128 * < 0 an error occured |
|
129 * |
|
130 */ |
|
131 |
|
132 int dmbsGetAndDecodePMBsInScanOrder( |
|
133 const dmbPFrameMBInParam_t *inParam, |
|
134 dmbPFrameMBInOutParam_t *inOutParam, |
|
135 int *quant, CMPEG4Transcoder *hTranscoder) |
|
136 /* {{-output"dmbsGetAndDecodePMBsInScanOrder.txt"}} */ |
|
137 { |
|
138 int currMBNum; |
|
139 int yWidth = inParam->pictParam->lumMemWidth; |
|
140 int uvWidth = yWidth / 2; |
|
141 int ret = 0; |
|
142 dmbPFrameMBInParam_t dmbi; |
|
143 |
|
144 memcpy(&dmbi, inParam, sizeof(dmbPFrameMBInParam_t)); |
|
145 |
|
146 for (currMBNum = 0; currMBNum < inParam->numMBsInSegment; currMBNum++) { |
|
147 |
|
148 hTranscoder->BeginOneMB(currMBNum + inParam->numMBsInSegment * inParam->yPosInMBs); |
|
149 |
|
150 ret = dmbGetAndDecodePFrameMB(&dmbi, inOutParam, 0, hTranscoder); |
|
151 if (ret < 0) |
|
152 return DMBS_ERR; |
|
153 else if ( ret == DMB_BIT_ERR ) { |
|
154 break; |
|
155 } |
|
156 |
|
157 /* Store quantizer and increment array index */ |
|
158 *quant = inOutParam->quant; |
|
159 quant++; |
|
160 |
|
161 if ( inOutParam->yMBInFrame != NULL ) |
|
162 { |
|
163 inOutParam->yMBInFrame += 16; |
|
164 inOutParam->uBlockInFrame += 8; |
|
165 inOutParam->vBlockInFrame += 8; |
|
166 } |
|
167 dmbi.xPosInMBs++; |
|
168 |
|
169 if (dmbi.xPosInMBs == inParam->pictParam->numMBsInMBLine) { |
|
170 if ( inOutParam->yMBInFrame != NULL ) |
|
171 { |
|
172 inOutParam->yMBInFrame += 15 * yWidth; |
|
173 inOutParam->uBlockInFrame += 7 * uvWidth; |
|
174 inOutParam->vBlockInFrame += 7 * uvWidth; |
|
175 } |
|
176 dmbi.xPosInMBs = 0; |
|
177 dmbi.yPosInMBs++; |
|
178 } |
|
179 } |
|
180 |
|
181 hTranscoder->H263OneGOBSliceEnded(dmbi.yPosInMBs * inParam->numMBsInSegment); |
|
182 |
|
183 return DMBS_OK; |
|
184 |
|
185 } |
|
186 // End of File |
|