xref: /aosp_15_r20/external/libvpx/vpx_dsp/subtract.c (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1*fb1b10abSAndroid Build Coastguard Worker /*
2*fb1b10abSAndroid Build Coastguard Worker  *  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3*fb1b10abSAndroid Build Coastguard Worker  *
4*fb1b10abSAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*fb1b10abSAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*fb1b10abSAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*fb1b10abSAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*fb1b10abSAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*fb1b10abSAndroid Build Coastguard Worker  */
10*fb1b10abSAndroid Build Coastguard Worker 
11*fb1b10abSAndroid Build Coastguard Worker #include <stdlib.h>
12*fb1b10abSAndroid Build Coastguard Worker 
13*fb1b10abSAndroid Build Coastguard Worker #include "./vpx_config.h"
14*fb1b10abSAndroid Build Coastguard Worker #include "./vpx_dsp_rtcd.h"
15*fb1b10abSAndroid Build Coastguard Worker 
16*fb1b10abSAndroid Build Coastguard Worker #include "vpx/vpx_integer.h"
17*fb1b10abSAndroid Build Coastguard Worker #include "vpx_ports/mem.h"
18*fb1b10abSAndroid Build Coastguard Worker 
vpx_subtract_block_c(int rows,int cols,int16_t * diff_ptr,ptrdiff_t diff_stride,const uint8_t * src_ptr,ptrdiff_t src_stride,const uint8_t * pred_ptr,ptrdiff_t pred_stride)19*fb1b10abSAndroid Build Coastguard Worker void vpx_subtract_block_c(int rows, int cols, int16_t *diff_ptr,
20*fb1b10abSAndroid Build Coastguard Worker                           ptrdiff_t diff_stride, const uint8_t *src_ptr,
21*fb1b10abSAndroid Build Coastguard Worker                           ptrdiff_t src_stride, const uint8_t *pred_ptr,
22*fb1b10abSAndroid Build Coastguard Worker                           ptrdiff_t pred_stride) {
23*fb1b10abSAndroid Build Coastguard Worker   int r, c;
24*fb1b10abSAndroid Build Coastguard Worker 
25*fb1b10abSAndroid Build Coastguard Worker   for (r = 0; r < rows; r++) {
26*fb1b10abSAndroid Build Coastguard Worker     for (c = 0; c < cols; c++) diff_ptr[c] = src_ptr[c] - pred_ptr[c];
27*fb1b10abSAndroid Build Coastguard Worker 
28*fb1b10abSAndroid Build Coastguard Worker     diff_ptr += diff_stride;
29*fb1b10abSAndroid Build Coastguard Worker     pred_ptr += pred_stride;
30*fb1b10abSAndroid Build Coastguard Worker     src_ptr += src_stride;
31*fb1b10abSAndroid Build Coastguard Worker   }
32*fb1b10abSAndroid Build Coastguard Worker }
33*fb1b10abSAndroid Build Coastguard Worker 
34*fb1b10abSAndroid Build Coastguard Worker #if CONFIG_VP9_HIGHBITDEPTH
vpx_highbd_subtract_block_c(int rows,int cols,int16_t * diff_ptr,ptrdiff_t diff_stride,const uint8_t * src8_ptr,ptrdiff_t src_stride,const uint8_t * pred8_ptr,ptrdiff_t pred_stride,int bd)35*fb1b10abSAndroid Build Coastguard Worker void vpx_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr,
36*fb1b10abSAndroid Build Coastguard Worker                                  ptrdiff_t diff_stride, const uint8_t *src8_ptr,
37*fb1b10abSAndroid Build Coastguard Worker                                  ptrdiff_t src_stride, const uint8_t *pred8_ptr,
38*fb1b10abSAndroid Build Coastguard Worker                                  ptrdiff_t pred_stride, int bd) {
39*fb1b10abSAndroid Build Coastguard Worker   int r, c;
40*fb1b10abSAndroid Build Coastguard Worker   uint16_t *src = CONVERT_TO_SHORTPTR(src8_ptr);
41*fb1b10abSAndroid Build Coastguard Worker   uint16_t *pred = CONVERT_TO_SHORTPTR(pred8_ptr);
42*fb1b10abSAndroid Build Coastguard Worker   (void)bd;
43*fb1b10abSAndroid Build Coastguard Worker 
44*fb1b10abSAndroid Build Coastguard Worker   for (r = 0; r < rows; r++) {
45*fb1b10abSAndroid Build Coastguard Worker     for (c = 0; c < cols; c++) {
46*fb1b10abSAndroid Build Coastguard Worker       diff_ptr[c] = src[c] - pred[c];
47*fb1b10abSAndroid Build Coastguard Worker     }
48*fb1b10abSAndroid Build Coastguard Worker 
49*fb1b10abSAndroid Build Coastguard Worker     diff_ptr += diff_stride;
50*fb1b10abSAndroid Build Coastguard Worker     pred += pred_stride;
51*fb1b10abSAndroid Build Coastguard Worker     src += src_stride;
52*fb1b10abSAndroid Build Coastguard Worker   }
53*fb1b10abSAndroid Build Coastguard Worker }
54*fb1b10abSAndroid Build Coastguard Worker #endif  // CONFIG_VP9_HIGHBITDEPTH
55