trans_tools.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*Daala video codec
  2. Copyright (c) 2013 Daala project contributors. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. - Redistributions of source code must retain the above copyright notice, this
  6. list of conditions and the following disclaimer.
  7. - Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
  11. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  13. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  14. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  16. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  17. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  18. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  19. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
  20. #if !defined(_tools_tran_tools_H)
  21. # define _tools_tran_tools_H (0)
  22. #include <stdio.h>
  23. #include "../src/internal.h"
  24. #include "vidinput.h"
  25. #define B_SZ_LOG (2)
  26. #define B_SZ (1<<B_SZ_LOG)
  27. #define NE_DISABLE_FILTER (0)
  28. #define NE_DISABLE_TRANSFORM (0)
  29. typedef struct image_ctx image_ctx;
  30. struct image_ctx{
  31. const char *name;
  32. int nxblocks;
  33. int nyblocks;
  34. };
  35. void image_ctx_init(image_ctx *_this,const char *_name,int _nxblocks,
  36. int _nyblocks);
  37. typedef struct trans_data trans_data;
  38. struct trans_data{
  39. int sz;
  40. int n;
  41. double *mean;
  42. double *cov;
  43. double *work;
  44. };
  45. void trans_data_init(trans_data *_this,int _sz);
  46. void trans_data_clear(trans_data *_this);
  47. void trans_data_add(trans_data *_this,const unsigned char *_data);
  48. void trans_data_combine(trans_data *_a,const trans_data *_b);
  49. void trans_data_correct(trans_data *_this);
  50. void trans_data_normalize(trans_data *_this);
  51. void trans_data_collapse(trans_data *_this,int _n,double *_r);
  52. void trans_data_expand(trans_data *_this,int _n,const double *_r);
  53. void trans_data_print(trans_data *_this,FILE *_fp);
  54. void covariance_collapse(const double *_cov,int _sz,int _n,double *_r,
  55. double *_work);
  56. void covariance_expand(double *_cov,int _sz,int _n,const double *_r);
  57. typedef struct trans_ctx trans_ctx;
  58. struct trans_ctx{
  59. image_ctx img;
  60. trans_data td;
  61. };
  62. typedef struct param_data param_data;
  63. struct param_data{
  64. int p[B_SZ/2-1];
  65. int q[B_SZ/2-1];
  66. int s[B_SZ/2];
  67. double grgt[B_SZ*B_SZ];
  68. double hi[2*B_SZ*B_SZ];
  69. double cg;
  70. double sba;
  71. double w;
  72. double bo;
  73. };
  74. void auto_regressive_collapsed(double *_out,int _sz,int _n,double _r);
  75. void analysis(double *_out,int _out_stride,const double *_in,int _in_stride,
  76. int _n,const int *_f);
  77. void synthesis(double *_out,int _out_stride,const double *_in,int _in_stride,
  78. int _n,const int *_f);
  79. double coding_gain_1d(const double _r[2*B_SZ*2*B_SZ],const int *_f);
  80. double coding_gain_1d_collapsed(const double _r[2*B_SZ],const int *_f);
  81. double coding_gain_2d(const double _r[2*B_SZ*2*B_SZ*2*B_SZ*2*B_SZ],const int *_f);
  82. double coding_gain_2d_collapsed(const double _r[2*B_SZ*2*B_SZ],const int *_f);
  83. extern const double *SUBSET1_1D[OD_NBSIZES];
  84. extern const double *SUBSET3_1D[OD_NBSIZES];
  85. extern const double *SUBSET1_2D[OD_NBSIZES];
  86. extern const double *SUBSET3_2D[OD_NBSIZES];
  87. #endif