stats_tools.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_stats_tools_H)
  21. # define _tools_stats_tools_H (1)
  22. #include "od_defs.h"
  23. #include "od_covmat.h"
  24. #include "image.h"
  25. #include "../src/intra.h"
  26. typedef struct mode_data mode_data;
  27. struct mode_data{
  28. int n;
  29. double satd_avg[B_SZ_MAX*B_SZ_MAX];
  30. double mean;
  31. double var;
  32. od_covmat ref;
  33. od_covmat res;
  34. };
  35. void mode_data_init(mode_data *_md,int _b_sz);
  36. void mode_data_clear(mode_data *_md);
  37. void mode_data_add_input(mode_data *_md,const unsigned char *_data,int _stride,
  38. int _b_sz);
  39. void mode_data_add_block(mode_data *_md,const od_coeff *_block,int _stride,
  40. int _ref);
  41. void mode_data_correct(mode_data *_md,int _b_sz);
  42. void mode_data_print(mode_data *_md,const char *_label,double *_scale,
  43. int _b_sz);
  44. void mode_data_combine(mode_data *_a,const mode_data *_b);
  45. void mode_data_params(mode_data *_this,double _b[B_SZ*B_SZ],double *_scale);
  46. typedef struct intra_stats intra_stats;
  47. struct intra_stats{
  48. int b_sz_log;
  49. mode_data fr;
  50. mode_data md[OD_INTRA_NMODES];
  51. };
  52. void intra_stats_init(intra_stats *_this,int _b_sz_log);
  53. void intra_stats_clear(intra_stats *_this);
  54. void intra_stats_reset(intra_stats *_this);
  55. void intra_stats_update(intra_stats *_this,const unsigned char *_data,
  56. int _stride,int _mode,const od_coeff *_ref,int _ref_stride,
  57. const double *_res,int _res_stride);
  58. void intra_stats_correct(intra_stats *_this);
  59. void intra_stats_print(intra_stats *_this,const char *_label,double *_scale);
  60. void intra_stats_combine(intra_stats *_this,const intra_stats *_that);
  61. /* Is there a good way to have a static initializer in C? */
  62. extern double VP8_SCALE[OD_NBSIZES][B_SZ_MAX];
  63. extern double OD_SCALE[OD_NBSIZES][B_SZ_MAX];
  64. void vp8_scale_init(double *_vp8_scale,int _b_sz_log);
  65. void od_scale_init(double *_od_scale,int _b_sz_log);
  66. int vp8_select_mode(const unsigned char *_data,int _stride,double *_weight);
  67. int od_select_mode_satd(const od_coeff *_block,double *_weight,int _b_sz_log);
  68. int od_select_mode_bits(const od_coeff *_block,double *_weight,
  69. double _b[OD_INTRA_NMODES][B_SZ*B_SZ]);
  70. int ne_apply_to_blocks(void *_ctx,int _ctx_sz,int _plmask,int _padding,
  71. plane_start_func _start,int _nfuncs,const block_func *_funcs,
  72. plane_finish_func _finish,int _argc,const char *_argv[]);
  73. #endif