image_tools.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_image_tools_H)
  21. # define _tools_image_tools_H (0)
  22. #include <stdio.h>
  23. #include "od_defs.h"
  24. #include "image.h"
  25. #include "stats_tools.h"
  26. extern od_rgba16_pixel COLORS[OD_INTRA_NMODES];
  27. void image_draw_block(od_rgba16_image *_image,int _x,int _y,
  28. const unsigned char *_block,int _stride);
  29. int image_write_png(od_rgba16_image *_image,const char *_name);
  30. typedef struct image_files image_files;
  31. struct image_files{
  32. od_rgba16_image raw;
  33. od_rgba16_image map;
  34. od_rgba16_image pred;
  35. od_rgba16_image res;
  36. };
  37. void image_files_init(image_files *_this,int _nxblocks,int _nyblocks);
  38. void image_files_clear(image_files *_this);
  39. void image_files_write(image_files *_this,const char *_name,const char *_suf);
  40. typedef struct image_data image_data;
  41. struct image_data{
  42. const char *name;
  43. int nxblocks;
  44. int nyblocks;
  45. int b_sz_log;
  46. unsigned char *mask;
  47. unsigned char *mode;
  48. double *weight;
  49. od_coeff *pre;
  50. int pre_stride;
  51. od_coeff *fdct;
  52. int fdct_stride;
  53. #if TF_BLOCKS
  54. od_coeff *tf;
  55. #endif
  56. double *pred;
  57. int pred_stride;
  58. od_coeff *idct;
  59. int idct_stride;
  60. od_coeff *post;
  61. int post_stride;
  62. };
  63. void image_data_init(image_data *_this,const char *_name,int _b_sz_log,
  64. int _nxblocks,int _nyblocks);
  65. void image_data_clear(image_data *_this);
  66. void image_data_mask(image_data *_this,const unsigned char *_data,int _stride);
  67. void image_data_pre_block(image_data *_this,const unsigned char *_data,
  68. int _stride,int _bi,int _bj);
  69. void image_data_fdct_block(image_data *_this,int _bi,int _bj);
  70. #if TF_BLOCKS
  71. void image_data_tf_block(image_data *_this,int _bi,int _bj);
  72. #endif
  73. void image_data_print_block(image_data *_this,int _bi,int _bj,FILE *_fp);
  74. void image_data_load_block(image_data *_this,int _bi,int _bj,
  75. od_coeff _coeffs[5*B_SZ*B_SZ]);
  76. void image_data_pred_block(image_data *_this,int _bi,int _bj);
  77. void image_data_stats_block(image_data *_this,const unsigned char *_data,
  78. int _stride,int _bi,int _bj,intra_stats *_stats);
  79. void image_data_idct_block(image_data *_this,int _bi,int _bj);
  80. void image_data_post_block(image_data *_this,int _bi,int _bj);
  81. void image_data_files_block(image_data *_this,const unsigned char *_data,
  82. int _stride,int _bi,int _bj,image_files *_files);
  83. int image_data_save_map(image_data *_this);
  84. int image_data_load_map(image_data *_this);
  85. #endif