16fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org/*
26fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
36fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *
46fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *  Use of this source code is governed by a BSD-style license
56fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *  that can be found in the LICENSE file in the root of the source
66fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *  tree. An additional intellectual property rights grant can be found
76fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *  in the file PATENTS.  All contributing project authors may
86fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *  be found in the AUTHORS file in the root of the source tree.
96fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org */
106fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
11ecee051929d6ced19cf324688774acccc9ad4a0ajohannkoenig@chromium.org#include "./vpx_config.h"
1210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org#include "vp9/common/vp9_common.h"
136fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include "vp9/common/vp9_loopfilter.h"
146fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include "vp9/common/vp9_onyxc_int.h"
156fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
161958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.orgstatic INLINE int8_t signed_char_clamp(int t) {
1710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  return (int8_t)clamp(t, -128, 127);
186fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
196fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
2010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org// should we apply any filter at all: 11111111 yes, 00000000 no
211958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.orgstatic INLINE int8_t filter_mask(uint8_t limit, uint8_t blimit,
221958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org                                 uint8_t p3, uint8_t p2,
231958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org                                 uint8_t p1, uint8_t p0,
241958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org                                 uint8_t q0, uint8_t q1,
251958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org                                 uint8_t q2, uint8_t q3) {
26d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org  int8_t mask = 0;
276fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(p3 - p2) > limit) * -1;
286fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(p2 - p1) > limit) * -1;
296fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(p1 - p0) > limit) * -1;
306fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(q1 - q0) > limit) * -1;
316fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(q2 - q1) > limit) * -1;
326fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(q3 - q2) > limit) * -1;
336fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2  > blimit) * -1;
3410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  return ~mask;
356fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
366fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
3747265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.orgstatic INLINE int8_t flat_mask4(uint8_t thresh,
3847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t p3, uint8_t p2,
3947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t p1, uint8_t p0,
4047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t q0, uint8_t q1,
4147265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t q2, uint8_t q3) {
4247265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  int8_t mask = 0;
4347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(p1 - p0) > thresh) * -1;
4447265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(q1 - q0) > thresh) * -1;
4547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(p2 - p0) > thresh) * -1;
4647265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(q2 - q0) > thresh) * -1;
4747265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(p3 - p0) > thresh) * -1;
4847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(q3 - q0) > thresh) * -1;
4947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  return ~mask;
5047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org}
5147265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org
5247265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.orgstatic INLINE int8_t flat_mask5(uint8_t thresh,
5347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t p4, uint8_t p3,
5447265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t p2, uint8_t p1,
5547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t p0, uint8_t q0,
5647265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t q1, uint8_t q2,
5747265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                uint8_t q3, uint8_t q4) {
5847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  int8_t mask = ~flat_mask4(thresh, p3, p2, p1, p0, q0, q1, q2, q3);
5947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(p4 - p0) > thresh) * -1;
6047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  mask |= (abs(q4 - q0) > thresh) * -1;
6147265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  return ~mask;
6247265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org}
6347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org
6410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org// is there high edge variance internal edge: 11111111 yes, 00000000 no
6547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.orgstatic INLINE int8_t hev_mask(uint8_t thresh, uint8_t p1, uint8_t p0,
6647265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                              uint8_t q0, uint8_t q1) {
67d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org  int8_t hev = 0;
686fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  hev  |= (abs(p1 - p0) > thresh) * -1;
696fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  hev  |= (abs(q1 - q0) > thresh) * -1;
706fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  return hev;
716fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
726fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
73dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.orgstatic INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1,
7447265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                           uint8_t *op0, uint8_t *oq0, uint8_t *oq1) {
751958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  int8_t filter1, filter2;
766fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
771958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  const int8_t ps1 = (int8_t) *op1 ^ 0x80;
781958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  const int8_t ps0 = (int8_t) *op0 ^ 0x80;
791958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  const int8_t qs0 = (int8_t) *oq0 ^ 0x80;
801958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  const int8_t qs1 = (int8_t) *oq1 ^ 0x80;
81dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org  const uint8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1);
826fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
831958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  // add outer taps if we have high edge variance
841958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  int8_t filter = signed_char_clamp(ps1 - qs1) & hev;
856fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
861958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  // inner taps
871958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  filter = signed_char_clamp(filter + 3 * (qs0 - ps0)) & mask;
886fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
891958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  // save bottom 3 bits so that we round one side +4 and the other +3
901958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  // if it equals 4 we'll set to adjust by -1 to account for the fact
911958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  // we'd round 3 the other way
921958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  filter1 = signed_char_clamp(filter + 4) >> 3;
931958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  filter2 = signed_char_clamp(filter + 3) >> 3;
941958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org
951958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  *oq0 = signed_char_clamp(qs0 - filter1) ^ 0x80;
961958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  *op0 = signed_char_clamp(ps0 + filter2) ^ 0x80;
971958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org
981958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  // outer tap adjustments
9947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev;
1006fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
1011958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  *oq1 = signed_char_clamp(qs1 - filter) ^ 0x80;
1021958a6b43506c5fdf713554177fdd12c3b255c54johannkoenig@chromium.org  *op1 = signed_char_clamp(ps1 + filter) ^ 0x80;
1036fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
1046fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
1058b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_horizontal_4_c(uint8_t *s, int p /* pitch */,
1068b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                            const uint8_t *blimit, const uint8_t *limit,
1078b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                            const uint8_t *thresh, int count) {
10810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  int i;
10910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
11010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // loop filter designed to work using chars so that we can make maximum use
11110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // of 8 bit simd instructions.
11210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  for (i = 0; i < 8 * count; ++i) {
11310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
11410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = s[0 * p],  q1 = s[1 * p],  q2 = s[2 * p],  q3 = s[3 * p];
11510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const int8_t mask = filter_mask(*limit, *blimit,
11610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                                    p3, p2, p1, p0, q0, q1, q2, q3);
117dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter4(mask, *thresh, s - 2 * p, s - 1 * p, s, s + 1 * p);
1186fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    ++s;
11910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  }
1206fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
1216fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
1228b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_horizontal_4_dual_c(uint8_t *s, int p, const uint8_t *blimit0,
1238b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                 const uint8_t *limit0, const uint8_t *thresh0,
1248b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                 const uint8_t *blimit1, const uint8_t *limit1,
1258b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                 const uint8_t *thresh1) {
1268b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_horizontal_4_c(s, p, blimit0, limit0, thresh0, 1);
1278b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_horizontal_4_c(s + 8, p, blimit1, limit1, thresh1, 1);
128d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org}
129d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org
1308b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_vertical_4_c(uint8_t *s, int pitch, const uint8_t *blimit,
1318b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                          const uint8_t *limit, const uint8_t *thresh,
1328b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                          int count) {
13310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  int i;
13410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
13510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // loop filter designed to work using chars so that we can make maximum use
13610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // of 8 bit simd instructions.
13710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  for (i = 0; i < 8 * count; ++i) {
13810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
13910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = s[0],  q1 = s[1],  q2 = s[2],  q3 = s[3];
14010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const int8_t mask = filter_mask(*limit, *blimit,
14110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                                    p3, p2, p1, p0, q0, q1, q2, q3);
142dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter4(mask, *thresh, s - 2, s - 1, s, s + 1);
14310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    s += pitch;
14410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  }
1456fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
14610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
1478b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_vertical_4_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0,
1488b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                               const uint8_t *limit0, const uint8_t *thresh0,
1498b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                               const uint8_t *blimit1, const uint8_t *limit1,
1508b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                               const uint8_t *thresh1) {
1518b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_vertical_4_c(s, pitch, blimit0, limit0, thresh0, 1);
1528b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_vertical_4_c(s + 8 * pitch, pitch, blimit1, limit1,
153d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org                                  thresh1, 1);
154d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org}
155d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org
156dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.orgstatic INLINE void filter8(int8_t mask, uint8_t thresh, uint8_t flat,
15747265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                           uint8_t *op3, uint8_t *op2,
15847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                           uint8_t *op1, uint8_t *op0,
15947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                           uint8_t *oq0, uint8_t *oq1,
16047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                           uint8_t *oq2, uint8_t *oq3) {
1616fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  if (flat && mask) {
16210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
16310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3;
16410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
16547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    // 7-tap filter [1, 1, 1, 2, 1, 1, 1]
16647265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    *op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0, 3);
16747265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    *op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1, 3);
16847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    *op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2, 3);
16947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    *oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3, 3);
17047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    *oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3, 3);
17147265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    *oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3, 3);
1726fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  } else {
173dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter4(mask, thresh, op1,  op0, oq0, oq1);
1746fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  }
1756fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
176d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org
1778b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_horizontal_8_c(uint8_t *s, int p, const uint8_t *blimit,
1788b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                            const uint8_t *limit, const uint8_t *thresh,
1798b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                            int count) {
18010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  int i;
18110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
18210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // loop filter designed to work using chars so that we can make maximum use
18310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // of 8 bit simd instructions.
18410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  for (i = 0; i < 8 * count; ++i) {
18510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
18610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
18710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
18810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const int8_t mask = filter_mask(*limit, *blimit,
18910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                                    p3, p2, p1, p0, q0, q1, q2, q3);
19047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
191dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter8(mask, *thresh, flat, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p,
192dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org                                 s,         s + 1 * p, s + 2 * p, s + 3 * p);
1936fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    ++s;
19410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  }
1956fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
196d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org
1978b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_horizontal_8_dual_c(uint8_t *s, int p, const uint8_t *blimit0,
1988b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                 const uint8_t *limit0, const uint8_t *thresh0,
1998b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                 const uint8_t *blimit1, const uint8_t *limit1,
2008b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                 const uint8_t *thresh1) {
2018b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_horizontal_8_c(s, p, blimit0, limit0, thresh0, 1);
2028b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_horizontal_8_c(s + 8, p, blimit1, limit1, thresh1, 1);
203d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org}
204d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org
2058b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit,
2068b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                          const uint8_t *limit, const uint8_t *thresh,
2078b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                          int count) {
20810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  int i;
20910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
21010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  for (i = 0; i < 8 * count; ++i) {
21110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
21210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
21310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const int8_t mask = filter_mask(*limit, *blimit,
21410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                                    p3, p2, p1, p0, q0, q1, q2, q3);
21547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
216dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter8(mask, *thresh, flat, s - 4, s - 3, s - 2, s - 1,
217dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org                                 s,     s + 1, s + 2, s + 3);
21810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    s += pitch;
21910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  }
2206fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
221d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org
2228b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0,
2238b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                               const uint8_t *limit0, const uint8_t *thresh0,
2248b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                               const uint8_t *blimit1, const uint8_t *limit1,
2258b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                               const uint8_t *thresh1) {
2268b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_vertical_8_c(s, pitch, blimit0, limit0, thresh0, 1);
2278b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org  vp9_lpf_vertical_8_c(s + 8 * pitch, pitch, blimit1, limit1,
228d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org                                    thresh1, 1);
229d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org}
230d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org
231dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.orgstatic INLINE void filter16(int8_t mask, uint8_t thresh,
23247265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t flat, uint8_t flat2,
23347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *op7, uint8_t *op6,
23447265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *op5, uint8_t *op4,
23547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *op3, uint8_t *op2,
23647265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *op1, uint8_t *op0,
23747265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *oq0, uint8_t *oq1,
23847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *oq2, uint8_t *oq3,
23947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *oq4, uint8_t *oq5,
24047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                            uint8_t *oq6, uint8_t *oq7) {
241d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org  if (flat2 && flat && mask) {
24210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p7 = *op7, p6 = *op6, p5 = *op5, p4 = *op4,
24310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                  p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
24410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
24510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3,
24610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                  q4 = *oq4, q5 = *oq5, q6 = *oq6, q7 = *oq7;
24710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
24847265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    // 15-tap filter [1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]
24910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op6 = ROUND_POWER_OF_TWO(p7 * 7 + p6 * 2 + p5 + p4 + p3 + p2 + p1 + p0 +
25010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0, 4);
25110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op5 = ROUND_POWER_OF_TWO(p7 * 6 + p6 + p5 * 2 + p4 + p3 + p2 + p1 + p0 +
25210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1, 4);
25310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op4 = ROUND_POWER_OF_TWO(p7 * 5 + p6 + p5 + p4 * 2 + p3 + p2 + p1 + p0 +
25410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2, 4);
25510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op3 = ROUND_POWER_OF_TWO(p7 * 4 + p6 + p5 + p4 + p3 * 2 + p2 + p1 + p0 +
25610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3, 4);
25710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op2 = ROUND_POWER_OF_TWO(p7 * 3 + p6 + p5 + p4 + p3 + p2 * 2 + p1 + p0 +
25810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 + q4, 4);
25910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op1 = ROUND_POWER_OF_TWO(p7 * 2 + p6 + p5 + p4 + p3 + p2 + p1 * 2 + p0 +
26010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 + q4 + q5, 4);
26110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *op0 = ROUND_POWER_OF_TWO(p7 + p6 + p5 + p4 + p3 + p2 + p1 + p0 * 2 +
26210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 + q4 + q5 + q6, 4);
26310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq0 = ROUND_POWER_OF_TWO(p6 + p5 + p4 + p3 + p2 + p1 + p0 +
26410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 * 2 + q1 + q2 + q3 + q4 + q5 + q6 + q7, 4);
26510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq1 = ROUND_POWER_OF_TWO(p5 + p4 + p3 + p2 + p1 + p0 +
26610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 * 2 + q2 + q3 + q4 + q5 + q6 + q7 * 2, 4);
26710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq2 = ROUND_POWER_OF_TWO(p4 + p3 + p2 + p1 + p0 +
26810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 * 2 + q3 + q4 + q5 + q6 + q7 * 3, 4);
26910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq3 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + p0 +
27010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 * 2 + q4 + q5 + q6 + q7 * 4, 4);
27110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq4 = ROUND_POWER_OF_TWO(p2 + p1 + p0 +
27210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 + q4 * 2 + q5 + q6 + q7 * 5, 4);
27310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq5 = ROUND_POWER_OF_TWO(p1 + p0 +
27410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 + q4 + q5 * 2 + q6 + q7 * 6, 4);
27510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    *oq6 = ROUND_POWER_OF_TWO(p0 +
27610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                              q0 + q1 + q2 + q3 + q4 + q5 + q6 * 2 + q7 * 7, 4);
277d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org  } else {
278dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3);
279d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org  }
280d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org}
281d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org
2828b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_horizontal_16_c(uint8_t *s, int p, const uint8_t *blimit,
2838b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                             const uint8_t *limit, const uint8_t *thresh,
2848b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                             int count) {
28510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  int i;
28610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
28710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // loop filter designed to work using chars so that we can make maximum use
28810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  // of 8 bit simd instructions.
28947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org  for (i = 0; i < 8 * count; ++i) {
29010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
29110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
29210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const int8_t mask = filter_mask(*limit, *blimit,
29310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                                    p3, p2, p1, p0, q0, q1, q2, q3);
29447265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
29547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    const int8_t flat2 = flat_mask5(1,
29610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                             s[-8 * p], s[-7 * p], s[-6 * p], s[-5 * p], p0,
29710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                             q0, s[4 * p], s[5 * p], s[6 * p], s[7 * p]);
298d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org
299dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter16(mask, *thresh, flat, flat2,
30047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org             s - 8 * p, s - 7 * p, s - 6 * p, s - 5 * p,
30147265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org             s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p,
30247265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org             s,         s + 1 * p, s + 2 * p, s + 3 * p,
30347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org             s + 4 * p, s + 5 * p, s + 6 * p, s + 7 * p);
304d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org    ++s;
30510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  }
306d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org}
30710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
308d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.orgstatic void mb_lpf_vertical_edge_w(uint8_t *s, int p,
309d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org                                   const uint8_t *blimit,
310d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org                                   const uint8_t *limit,
311d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org                                   const uint8_t *thresh,
312d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org                                   int count) {
31310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  int i;
31410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org
315d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  for (i = 0; i < count; ++i) {
31610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
31710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const uint8_t q0 = s[0], q1 = s[1],  q2 = s[2], q3 = s[3];
31810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org    const int8_t mask = filter_mask(*limit, *blimit,
31910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org                                    p3, p2, p1, p0, q0, q1, q2, q3);
32047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
32147265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org    const int8_t flat2 = flat_mask5(1, s[-8], s[-7], s[-6], s[-5], p0,
32247265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org                                    q0, s[4], s[5], s[6], s[7]);
32347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org
324dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org    filter16(mask, *thresh, flat, flat2,
32547265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org             s - 8, s - 7, s - 6, s - 5, s - 4, s - 3, s - 2, s - 1,
32647265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org             s,     s + 1, s + 2, s + 3, s + 4, s + 5, s + 6, s + 7);
327d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org    s += p;
32810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org  }
329d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org}
330d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org
3318b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_vertical_16_c(uint8_t *s, int p, const uint8_t *blimit,
3328b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                           const uint8_t *limit, const uint8_t *thresh) {
333d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 8);
334d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org}
335d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org
3368b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.orgvoid vp9_lpf_vertical_16_dual_c(uint8_t *s, int p, const uint8_t *blimit,
3378b26fe55f3e4daa2311dbd2d95e8ac2b4e080685johannkoenig@chromium.org                                const uint8_t *limit, const uint8_t *thresh) {
338d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 16);
339d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org}
340