Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: source/libvpx/vp9/decoder/vp9_dequantize.c

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_dequantize.h ('k') | source/libvpx/vp9/decoder/vp9_detokenize.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 11
12 #include "vp9_rtcd.h" 12 #include "vp9_rtcd.h"
13 #include "vp9/decoder/vp9_dequantize.h" 13 #include "vp9/decoder/vp9_dequantize.h"
14 #include "vpx_mem/vpx_mem.h" 14 #include "vpx_mem/vpx_mem.h"
15 #include "vp9/decoder/vp9_onyxd_int.h" 15 #include "vp9/decoder/vp9_onyxd_int.h"
16 #include "vp9/common/vp9_common.h"
16 static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch, 17 static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch,
17 uint8_t *dest, int stride, int width, int height) { 18 uint8_t *dest, int stride, int width, int height) {
18 int r, c; 19 int r, c;
19 20
20 for (r = 0; r < height; r++) { 21 for (r = 0; r < height; r++) {
21 for (c = 0; c < width; c++) { 22 for (c = 0; c < width; c++) {
22 int a = diff[c] + pred[c]; 23 dest[c] = clip_pixel(diff[c] + pred[c]);
23
24 if (a < 0)
25 a = 0;
26 else if (a > 255)
27 a = 255;
28
29 dest[c] = (uint8_t) a;
30 } 24 }
31 25
32 dest += stride; 26 dest += stride;
33 diff += width; 27 diff += width;
34 pred += pitch; 28 pred += pitch;
35 } 29 }
36 } 30 }
37 31
38 static void add_constant_residual(const int16_t diff, const uint8_t *pred, 32 static void add_constant_residual(const int16_t diff, const uint8_t *pred,
39 int pitch, uint8_t *dest, int stride, 33 int pitch, uint8_t *dest, int stride,
40 int width, int height) { 34 int width, int height) {
41 int r, c; 35 int r, c;
42 36
43 for (r = 0; r < height; r++) { 37 for (r = 0; r < height; r++) {
44 for (c = 0; c < width; c++) { 38 for (c = 0; c < width; c++) {
45 int a = diff + pred[c]; 39 dest[c] = clip_pixel(diff + pred[c]);
46
47 if (a < 0)
48 a = 0;
49 else if (a > 255)
50 a = 255;
51
52 dest[c] = (uint8_t) a;
53 } 40 }
54 41
55 dest += stride; 42 dest += stride;
56 pred += pitch; 43 pred += pitch;
57 } 44 }
58 } 45 }
59 46
60 void vp9_dequantize_b_c(BLOCKD *d) { 47 void vp9_dequantize_b_c(BLOCKD *d) {
61 48
62 int i; 49 int i;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 const int16_t *Q = d->qcoeff; 184 const int16_t *Q = d->qcoeff;
198 const int16_t *DQC = d->dequant; 185 const int16_t *DQC = d->dequant;
199 186
200 for (i = 0; i < 16; i++) { 187 for (i = 0; i < 16; i++) {
201 DQ[i] = (int16_t)((Q[i] * DQC[i])); 188 DQ[i] = (int16_t)((Q[i] * DQC[i]));
202 } 189 }
203 } 190 }
204 191
205 void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq, 192 void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
206 uint8_t *pred, uint8_t *dest, int pitch, 193 uint8_t *pred, uint8_t *dest, int pitch,
207 int stride, int dc, uint16_t eobs) { 194 int stride, int dc, int eob) {
208 int16_t output[64]; 195 int16_t output[64];
209 int16_t *diff_ptr = output; 196 int16_t *diff_ptr = output;
210 int i; 197 int i;
211 198
212 /* If dc is 1, then input[0] is the reconstructed value, do not need 199 /* If dc is 1, then input[0] is the reconstructed value, do not need
213 * dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1. 200 * dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.
214 */ 201 */
215 if (!dc) 202 if (!dc)
216 input[0] *= dq[0]; 203 input[0] *= dq[0];
217 204
218 /* The calculation can be simplified if there are not many non-zero dct 205 /* The calculation can be simplified if there are not many non-zero dct
219 * coefficients. Use eobs to decide what to do. 206 * coefficients. Use eobs to decide what to do.
220 * TODO(yunqingwang): "eobs = 1" case is also handled in vp9_short_idct8x8_c. 207 * TODO(yunqingwang): "eobs = 1" case is also handled in vp9_short_idct8x8_c.
221 * Combine that with code here. 208 * Combine that with code here.
222 */ 209 */
223 if (eobs == 0) { 210 if (eob == 0) {
224 /* All 0 DCT coefficient */ 211 /* All 0 DCT coefficient */
225 vp9_copy_mem8x8(pred, pitch, dest, stride); 212 vp9_copy_mem8x8(pred, pitch, dest, stride);
226 } else if (eobs == 1) { 213 } else if (eob == 1) {
227 /* DC only DCT coefficient. */ 214 /* DC only DCT coefficient. */
228 int16_t out; 215 int16_t out;
229 216
230 /* Note: the idct1 will need to be modified accordingly whenever 217 /* Note: the idct1 will need to be modified accordingly whenever
231 * vp9_short_idct8x8_c() is modified. */ 218 * vp9_short_idct8x8_c() is modified. */
232 out = (input[0] + 1 + (input[0] < 0)) >> 2; 219 out = (input[0] + 1 + (input[0] < 0)) >> 2;
233 out = out << 3; 220 out = out << 3;
234 out = (out + 32) >> 7; 221 out = (out + 32) >> 7;
235 222
236 input[0] = 0; 223 input[0] = 0;
237 224
238 add_constant_residual(out, pred, pitch, dest, stride, 8, 8); 225 add_constant_residual(out, pred, pitch, dest, stride, 8, 8);
239 } else if (eobs <= 10) { 226 } else if (eob <= 10) {
240 input[1] = input[1] * dq[1]; 227 input[1] = input[1] * dq[1];
241 input[2] = input[2] * dq[1]; 228 input[2] = input[2] * dq[1];
242 input[3] = input[3] * dq[1]; 229 input[3] = input[3] * dq[1];
243 input[8] = input[8] * dq[1]; 230 input[8] = input[8] * dq[1];
244 input[9] = input[9] * dq[1]; 231 input[9] = input[9] * dq[1];
245 input[10] = input[10] * dq[1]; 232 input[10] = input[10] * dq[1];
246 input[16] = input[16] * dq[1]; 233 input[16] = input[16] * dq[1];
247 input[17] = input[17] * dq[1]; 234 input[17] = input[17] * dq[1];
248 input[24] = input[24] * dq[1]; 235 input[24] = input[24] * dq[1];
249 236
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // vp9_short_idct16x16_c(input, output, 32); 281 // vp9_short_idct16x16_c(input, output, 32);
295 282
296 vpx_memset(input, 0, 512); 283 vpx_memset(input, 0, 512);
297 284
298 add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16); 285 add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
299 } 286 }
300 } 287 }
301 288
302 void vp9_dequant_idct_add_16x16_c(int16_t *input, const int16_t *dq, 289 void vp9_dequant_idct_add_16x16_c(int16_t *input, const int16_t *dq,
303 uint8_t *pred, uint8_t *dest, int pitch, 290 uint8_t *pred, uint8_t *dest, int pitch,
304 int stride, uint16_t eobs) { 291 int stride, int eob) {
305 int16_t output[256]; 292 int16_t output[256];
306 int16_t *diff_ptr = output; 293 int16_t *diff_ptr = output;
307 int i; 294 int i;
308 295
309 /* The calculation can be simplified if there are not many non-zero dct 296 /* The calculation can be simplified if there are not many non-zero dct
310 * coefficients. Use eobs to separate different cases. */ 297 * coefficients. Use eobs to separate different cases. */
311 if (eobs == 0) { 298 if (eob == 0) {
312 /* All 0 DCT coefficient */ 299 /* All 0 DCT coefficient */
313 vp9_copy_mem16x16(pred, pitch, dest, stride); 300 vp9_copy_mem16x16(pred, pitch, dest, stride);
314 } else if (eobs == 1) { 301 } else if (eob == 1) {
315 /* DC only DCT coefficient. */ 302 /* DC only DCT coefficient. */
316 int16_t out; 303 int16_t out;
317 304
318 /* Note: the idct1 will need to be modified accordingly whenever 305 /* Note: the idct1 will need to be modified accordingly whenever
319 * vp9_short_idct16x16_c() is modified. */ 306 * vp9_short_idct16x16_c() is modified. */
320 out = (input[0] * dq[0] + 2) >> 2; 307 out = (input[0] * dq[0] + 2) >> 2;
321 out = (out + 2) >> 2; 308 out = (out + 2) >> 2;
322 out = (out + 4) >> 3; 309 out = (out + 4) >> 3;
323 310
324 input[0] = 0; 311 input[0] = 0;
325 312
326 add_constant_residual(out, pred, pitch, dest, stride, 16, 16); 313 add_constant_residual(out, pred, pitch, dest, stride, 16, 16);
327 } else if (eobs <= 10) { 314 } else if (eob <= 10) {
328 input[0]= input[0] * dq[0]; 315 input[0]= input[0] * dq[0];
329 input[1] = input[1] * dq[1]; 316 input[1] = input[1] * dq[1];
330 input[2] = input[2] * dq[1]; 317 input[2] = input[2] * dq[1];
331 input[3] = input[3] * dq[1]; 318 input[3] = input[3] * dq[1];
332 input[16] = input[16] * dq[1]; 319 input[16] = input[16] * dq[1];
333 input[17] = input[17] * dq[1]; 320 input[17] = input[17] * dq[1];
334 input[18] = input[18] * dq[1]; 321 input[18] = input[18] * dq[1];
335 input[32] = input[32] * dq[1]; 322 input[32] = input[32] * dq[1];
336 input[33] = input[33] * dq[1]; 323 input[33] = input[33] * dq[1];
337 input[48] = input[48] * dq[1]; 324 input[48] = input[48] * dq[1];
(...skipping 15 matching lines...) Expand all
353 input[i] = input[i] * dq[1]; 340 input[i] = input[i] * dq[1];
354 341
355 // the idct halves ( >> 1) the pitch 342 // the idct halves ( >> 1) the pitch
356 vp9_short_idct16x16_c(input, output, 32); 343 vp9_short_idct16x16_c(input, output, 32);
357 344
358 vpx_memset(input, 0, 512); 345 vpx_memset(input, 0, 512);
359 346
360 add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16); 347 add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
361 } 348 }
362 } 349 }
350
351 void vp9_dequant_idct_add_32x32_c(int16_t *input, const int16_t *dq,
352 uint8_t *pred, uint8_t *dest, int pitch,
353 int stride, int eob) {
354 int16_t output[1024];
355 int i;
356
357 input[0]= input[0] * dq[0] / 2;
358 for (i = 1; i < 1024; i++)
359 input[i] = input[i] * dq[1] / 2;
360 vp9_short_idct32x32_c(input, output, 64);
361 vpx_memset(input, 0, 2048);
362
363 add_residual(output, pred, pitch, dest, stride, 32, 32);
364 }
365
366 void vp9_dequant_idct_add_uv_block_16x16_c(int16_t *q, const int16_t *dq,
367 uint8_t *dstu,
368 uint8_t *dstv,
369 int stride,
370 uint16_t *eobs) {
371 vp9_dequant_idct_add_16x16_c(q, dq, dstu, dstu, stride, stride, eobs[0]);
372 vp9_dequant_idct_add_16x16_c(q + 256, dq,
373 dstv, dstv, stride, stride, eobs[4]);
374 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_dequantize.h ('k') | source/libvpx/vp9/decoder/vp9_detokenize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698