15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  Use of this source code is governed by a BSD-style license
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  that can be found in the LICENSE file in the root of the source
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  tree. An additional intellectual property rights grant can be found
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  in the file PATENTS.  All contributing project authors may
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *  be found in the AUTHORS file in the root of the source tree.
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "vpx_config.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "vp8_rtcd.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "vpx_mem/vpx_mem.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void vp8_dequant_idct_add_c(short *input, short *dq,
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            unsigned char *dest, int stride);
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void vp8_dc_only_idct_add_c(short input_dc, unsigned char * pred,
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int pred_stride, unsigned char *dst_ptr,
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int dst_stride);
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void vp8_dequant_idct_add_y_block_c
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            (short *q, short *dq,
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             unsigned char *dst, int stride, char *eobs)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
25d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    int i, j;
26d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (i = 0; i < 4; i++)
28d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    {
29d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)        for (j = 0; j < 4; j++)
30d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)        {
31d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)            if (*eobs++ > 1)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                vp8_dequant_idct_add_c (q, dq, dst, stride);
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            else
34d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)            {
35d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                vp8_dc_only_idct_add_c (q[0]*dq[0], dst, stride, dst, stride);
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                vpx_memset(q, 0, 2 * sizeof(q[0]));
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            }
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            q   += 16;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            dst += 4;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        dst += 4*stride - 16;
44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    }
45d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}
46d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
47d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)void vp8_dequant_idct_add_uv_block_c
48eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch            (short *q, short *dq,
49eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch             unsigned char *dstu, unsigned char *dstv, int stride, char *eobs)
50eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch{
51eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    int i, j;
52d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
53eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    for (i = 0; i < 2; i++)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    {
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        for (j = 0; j < 2; j++)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            if (*eobs++ > 1)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                vp8_dequant_idct_add_c (q, dq, dstu, stride);
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            else
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            {
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                vp8_dc_only_idct_add_c (q[0]*dq[0], dstu, stride, dstu, stride);
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                vpx_memset(q, 0, 2 * sizeof(q[0]));
63d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)            }
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            q    += 16;
66d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)            dstu += 4;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
68eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
69d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)        dstu += 4*stride - 8;
70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    }
71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
72d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    for (i = 0; i < 2; i++)
73eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    {
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        for (j = 0; j < 2; j++)
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        {
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            if (*eobs++ > 1)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                vp8_dequant_idct_add_c (q, dq, dstv, stride);
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            else
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            {
80                vp8_dc_only_idct_add_c (q[0]*dq[0], dstv, stride, dstv, stride);
81                vpx_memset(q, 0, 2 * sizeof(q[0]));
82            }
83
84            q    += 16;
85            dstv += 4;
86        }
87
88        dstv += 4*stride - 8;
89    }
90}
91