Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
  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. #ifndef AVCODEC_DIRAC_DWT_H
  22. #define AVCODEC_DIRAC_DWT_H
  23.  
  24. #include <stdint.h>
  25.  
  26. typedef int DWTELEM;
  27. typedef short IDWTELEM;
  28.  
  29. #define MAX_DWT_SUPPORT 8
  30. #define MAX_DECOMPOSITIONS 8
  31.  
  32. typedef struct DWTCompose {
  33.     IDWTELEM *b[MAX_DWT_SUPPORT];
  34.     int y;
  35. } DWTCompose;
  36.  
  37. struct DWTContext;
  38.  
  39. // Possible prototypes for vertical_compose functions
  40. typedef void (*vertical_compose_2tap)(IDWTELEM *b0, IDWTELEM *b1, int width);
  41. typedef void (*vertical_compose_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width);
  42. typedef void (*vertical_compose_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width);
  43. typedef void (*vertical_compose_9tap)(IDWTELEM *dst, IDWTELEM *b[8], int width);
  44.  
  45. typedef struct DWTContext {
  46.     IDWTELEM *buffer;
  47.     IDWTELEM *temp;
  48.     int width;
  49.     int height;
  50.     int stride;
  51.     int decomposition_count;
  52.     int support;
  53.  
  54.     void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride);
  55.     void (*vertical_compose_l0)(void);
  56.     void (*vertical_compose_h0)(void);
  57.     void (*vertical_compose_l1)(void);
  58.     void (*vertical_compose_h1)(void);
  59.     void (*vertical_compose)(void);     ///< one set of lowpass and highpass combined
  60.     void (*horizontal_compose)(IDWTELEM *b, IDWTELEM *tmp, int width);
  61.  
  62.     DWTCompose cs[MAX_DECOMPOSITIONS];
  63. } DWTContext;
  64.  
  65. enum dwt_type {
  66.     DWT_SNOW_DAUB9_7,
  67.     DWT_SNOW_LEGALL5_3,
  68.     DWT_DIRAC_DD9_7,
  69.     DWT_DIRAC_LEGALL5_3,
  70.     DWT_DIRAC_DD13_7,
  71.     DWT_DIRAC_HAAR0,
  72.     DWT_DIRAC_HAAR1,
  73.     DWT_DIRAC_FIDELITY,
  74.     DWT_DIRAC_DAUB9_7,
  75.     DWT_NUM_TYPES
  76. };
  77.  
  78. // -1 if an error occurred, e.g. the dwt_type isn't recognized
  79. int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height,
  80.                           int stride, enum dwt_type type, int decomposition_count,
  81.                           IDWTELEM *temp);
  82.  
  83. void ff_spatial_idwt_slice2(DWTContext *d, int y);
  84.  
  85. // shared stuff for simd optimiztions
  86. #define COMPOSE_53iL0(b0, b1, b2)\
  87.     (b1 - ((b0 + b2 + 2) >> 2))
  88.  
  89. #define COMPOSE_DIRAC53iH0(b0, b1, b2)\
  90.     (b1 + ((b0 + b2 + 1) >> 1))
  91.  
  92. #define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
  93.     (b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4))
  94.  
  95. #define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\
  96.     (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5))
  97.  
  98. #define COMPOSE_HAARiL0(b0, b1)\
  99.     (b0 - ((b1 + 1) >> 1))
  100.  
  101. #define COMPOSE_HAARiH0(b0, b1)\
  102.     (b0 + b1)
  103.  
  104. #define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
  105.     (b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8))
  106.  
  107. #define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\
  108.     (b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8))
  109.  
  110. #define COMPOSE_DAUB97iL1(b0, b1, b2)\
  111.     (b1 - ((1817*(b0 + b2) + 2048) >> 12))
  112.  
  113. #define COMPOSE_DAUB97iH1(b0, b1, b2)\
  114.     (b1 - (( 113*(b0 + b2) + 64) >> 7))
  115.  
  116. #define COMPOSE_DAUB97iL0(b0, b1, b2)\
  117.     (b1 + (( 217*(b0 + b2) + 2048) >> 12))
  118.  
  119. #define COMPOSE_DAUB97iH0(b0, b1, b2)\
  120.     (b1 + ((6497*(b0 + b2) + 2048) >> 12))
  121.  
  122.  
  123. #endif /* AVCODEC_DWT_H */
  124.