Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 2015 Parag Salasakar (parag.salasakar@imgtec.com)
  3.  *
  4.  * This file is part of FFmpeg.
  5.  *
  6.  * FFmpeg is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2.1 of the License, or (at your option) any later version.
  10.  *
  11.  * FFmpeg is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with FFmpeg; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19.  */
  20.  
  21. #include "libavutil/mips/generic_macros_msa.h"
  22. #include "blockdsp_mips.h"
  23.  
  24. static void copy_8bit_value_width8_msa(uint8_t *src, uint8_t val,
  25.                                        int32_t src_stride, int32_t height)
  26. {
  27.     int32_t cnt;
  28.     uint64_t dst0;
  29.     v16u8 val0;
  30.  
  31.     val0 = (v16u8) __msa_fill_b(val);
  32.     dst0 = __msa_copy_u_d((v2i64) val0, 0);
  33.  
  34.     for (cnt = (height >> 2); cnt--;) {
  35.         SD4(dst0, dst0, dst0, dst0, src, src_stride);
  36.         src += (4 * src_stride);
  37.     }
  38. }
  39.  
  40. static void copy_8bit_value_width16_msa(uint8_t *src, uint8_t val,
  41.                                         int32_t src_stride, int32_t height)
  42. {
  43.     int32_t cnt;
  44.     v16u8 val0;
  45.  
  46.     val0 = (v16u8) __msa_fill_b(val);
  47.  
  48.     for (cnt = (height >> 3); cnt--;) {
  49.         ST_UB8(val0, val0, val0, val0, val0, val0, val0, val0, src, src_stride);
  50.         src += (8 * src_stride);
  51.     }
  52. }
  53.  
  54. static void memset_zero_16width_msa(uint8_t *src, int32_t stride,
  55.                                     int32_t height)
  56. {
  57.     int8_t cnt;
  58.     v16u8 zero = { 0 };
  59.  
  60.     for (cnt = (height / 2); cnt--;) {
  61.         ST_UB(zero, src);
  62.         src += stride;
  63.         ST_UB(zero, src);
  64.         src += stride;
  65.     }
  66. }
  67.  
  68. void ff_fill_block16_msa(uint8_t *src, uint8_t val, int stride, int height)
  69. {
  70.     copy_8bit_value_width16_msa(src, val, stride, height);
  71. }
  72.  
  73. void ff_fill_block8_msa(uint8_t *src, uint8_t val, int stride, int height)
  74. {
  75.     copy_8bit_value_width8_msa(src, val, stride, height);
  76. }
  77.  
  78. void ff_clear_block_msa(int16_t *block)
  79. {
  80.     memset_zero_16width_msa((uint8_t *) block, 16, 8);
  81. }
  82.  
  83. void ff_clear_blocks_msa(int16_t *block)
  84. {
  85.     memset_zero_16width_msa((uint8_t *) block, 16, 8 * 6);
  86. }
  87.