ivi_dsp.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /*
  2. * DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
  3. *
  4. * Copyright (c) 2009-2011 Maxim Poliakovski
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * DSP functions (inverse transforms, motion compensations, wavelet recomposition)
  25. * for Indeo Video Interactive codecs.
  26. */
  27. #ifndef AVCODEC_IVI_DSP_H
  28. #define AVCODEC_IVI_DSP_H
  29. #include <stddef.h>
  30. #include <stdint.h>
  31. #include "ivi.h"
  32. /**
  33. * 5/3 wavelet recomposition filter for Indeo5
  34. *
  35. * @param[in] plane pointer to the descriptor of the plane being processed
  36. * @param[out] dst pointer to the destination buffer
  37. * @param[in] dst_pitch pitch of the destination buffer
  38. */
  39. void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
  40. const ptrdiff_t dst_pitch);
  41. /**
  42. * Haar wavelet recomposition filter for Indeo 4
  43. *
  44. * @param[in] plane pointer to the descriptor of the plane being processed
  45. * @param[out] dst pointer to the destination buffer
  46. * @param[in] dst_pitch pitch of the destination buffer
  47. */
  48. void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
  49. const ptrdiff_t dst_pitch);
  50. /**
  51. * two-dimensional inverse Haar 8x8 transform for Indeo 4
  52. *
  53. * @param[in] in pointer to the vector of transform coefficients
  54. * @param[out] out pointer to the output buffer (frame)
  55. * @param[in] pitch pitch to move to the next y line
  56. * @param[in] flags pointer to the array of column flags:
  57. * != 0 - non_empty column, 0 - empty one
  58. * (this array must be filled by caller)
  59. */
  60. void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  61. const uint8_t *flags);
  62. void ff_ivi_inverse_haar_8x1(const int32_t *in, int16_t *out, uint32_t pitch,
  63. const uint8_t *flags);
  64. void ff_ivi_inverse_haar_1x8(const int32_t *in, int16_t *out, uint32_t pitch,
  65. const uint8_t *flags);
  66. /**
  67. * one-dimensional inverse 8-point Haar transform on rows for Indeo 4
  68. *
  69. * @param[in] in pointer to the vector of transform coefficients
  70. * @param[out] out pointer to the output buffer (frame)
  71. * @param[in] pitch pitch to move to the next y line
  72. * @param[in] flags pointer to the array of column flags:
  73. * != 0 - non_empty column, 0 - empty one
  74. * (this array must be filled by caller)
  75. */
  76. void ff_ivi_row_haar8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  77. const uint8_t *flags);
  78. /**
  79. * one-dimensional inverse 8-point Haar transform on columns for Indeo 4
  80. *
  81. * @param[in] in pointer to the vector of transform coefficients
  82. * @param[out] out pointer to the output buffer (frame)
  83. * @param[in] pitch pitch to move to the next y line
  84. * @param[in] flags pointer to the array of column flags:
  85. * != 0 - non_empty column, 0 - empty one
  86. * (this array must be filled by caller)
  87. */
  88. void ff_ivi_col_haar8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  89. const uint8_t *flags);
  90. /**
  91. * two-dimensional inverse Haar 4x4 transform for Indeo 4
  92. *
  93. * @param[in] in pointer to the vector of transform coefficients
  94. * @param[out] out pointer to the output buffer (frame)
  95. * @param[in] pitch pitch to move to the next y line
  96. * @param[in] flags pointer to the array of column flags:
  97. * != 0 - non_empty column, 0 - empty one
  98. * (this array must be filled by caller)
  99. */
  100. void ff_ivi_inverse_haar_4x4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  101. const uint8_t *flags);
  102. /**
  103. * one-dimensional inverse 4-point Haar transform on rows for Indeo 4
  104. *
  105. * @param[in] in pointer to the vector of transform coefficients
  106. * @param[out] out pointer to the output buffer (frame)
  107. * @param[in] pitch pitch to move to the next y line
  108. * @param[in] flags pointer to the array of column flags:
  109. * != 0 - non_empty column, 0 - empty one
  110. * (this array must be filled by caller)
  111. */
  112. void ff_ivi_row_haar4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  113. const uint8_t *flags);
  114. /**
  115. * one-dimensional inverse 4-point Haar transform on columns for Indeo 4
  116. *
  117. * @param[in] in pointer to the vector of transform coefficients
  118. * @param[out] out pointer to the output buffer (frame)
  119. * @param[in] pitch pitch to move to the next y line
  120. * @param[in] flags pointer to the array of column flags:
  121. * != 0 - non_empty column, 0 - empty one
  122. * (this array must be filled by caller)
  123. */
  124. void ff_ivi_col_haar4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  125. const uint8_t *flags);
  126. /**
  127. * DC-only two-dimensional inverse Haar transform for Indeo 4.
  128. * Performing the inverse transform in this case is equivalent to
  129. * spreading DC_coeff >> 3 over the whole block.
  130. *
  131. * @param[in] in pointer to the dc coefficient
  132. * @param[out] out pointer to the output buffer (frame)
  133. * @param[in] pitch pitch to move to the next y line
  134. * @param[in] blk_size transform block size
  135. */
  136. void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  137. int blk_size);
  138. /**
  139. * two-dimensional inverse slant 8x8 transform
  140. *
  141. * @param[in] in pointer to the vector of transform coefficients
  142. * @param[out] out pointer to the output buffer (frame)
  143. * @param[in] pitch pitch to move to the next y line
  144. * @param[in] flags pointer to the array of column flags:
  145. * != 0 - non_empty column, 0 - empty one
  146. * (this array must be filled by caller)
  147. */
  148. void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  149. const uint8_t *flags);
  150. /**
  151. * two-dimensional inverse slant 4x4 transform
  152. *
  153. * @param[in] in pointer to the vector of transform coefficients
  154. * @param[out] out pointer to the output buffer (frame)
  155. * @param[in] pitch pitch to move to the next y line
  156. * @param[in] flags pointer to the array of column flags:
  157. * != 0 - non_empty column, 0 - empty one
  158. * (this array must be filled by caller)
  159. */
  160. void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  161. const uint8_t *flags);
  162. /**
  163. * DC-only two-dimensional inverse slant transform.
  164. * Performing the inverse slant transform in this case is equivalent to
  165. * spreading (DC_coeff + 1)/2 over the whole block.
  166. * It works much faster than performing the slant transform on a vector of zeroes.
  167. *
  168. * @param[in] in pointer to the dc coefficient
  169. * @param[out] out pointer to the output buffer (frame)
  170. * @param[in] pitch pitch to move to the next y line
  171. * @param[in] blk_size transform block size
  172. */
  173. void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  174. /**
  175. * inverse 1D row slant transform
  176. *
  177. * @param[in] in pointer to the vector of transform coefficients
  178. * @param[out] out pointer to the output buffer (frame)
  179. * @param[in] pitch pitch to move to the next y line
  180. * @param[in] flags pointer to the array of column flags (unused here)
  181. */
  182. void ff_ivi_row_slant8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  183. const uint8_t *flags);
  184. /**
  185. * inverse 1D column slant transform
  186. *
  187. * @param[in] in pointer to the vector of transform coefficients
  188. * @param[out] out pointer to the output buffer (frame)
  189. * @param[in] pitch pitch to move to the next y line
  190. * @param[in] flags pointer to the array of column flags:
  191. * != 0 - non_empty column, 0 - empty one
  192. * (this array must be filled by caller)
  193. */
  194. void ff_ivi_col_slant8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  195. const uint8_t *flags);
  196. /**
  197. * inverse 1D row slant transform
  198. *
  199. * @param[in] in pointer to the vector of transform coefficients
  200. * @param[out] out pointer to the output buffer (frame)
  201. * @param[in] pitch pitch to move to the next y line
  202. * @param[in] flags pointer to the array of column flags (unused here)
  203. */
  204. void ff_ivi_row_slant4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  205. const uint8_t *flags);
  206. /**
  207. * inverse 1D column slant transform
  208. *
  209. * @param[in] in pointer to the vector of transform coefficients
  210. * @param[out] out pointer to the output buffer (frame)
  211. * @param[in] pitch pitch to move to the next y line
  212. * @param[in] flags pointer to the array of column flags:
  213. * != 0 - non_empty column, 0 - empty one
  214. * (this array must be filled by caller)
  215. */
  216. void ff_ivi_col_slant4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  217. const uint8_t *flags);
  218. /**
  219. * DC-only inverse row slant transform
  220. */
  221. void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  222. /**
  223. * DC-only inverse column slant transform
  224. */
  225. void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  226. /**
  227. * Copy the pixels into the frame buffer.
  228. */
  229. void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch, const uint8_t *flags);
  230. /**
  231. * Copy the DC coefficient into the first pixel of the block and
  232. * zero all others.
  233. */
  234. void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  235. /**
  236. * 8x8 block motion compensation with adding delta
  237. *
  238. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  239. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  240. * @param[in] pitch pitch for moving to the next y line
  241. * @param[in] mc_type interpolation type
  242. */
  243. void ff_ivi_mc_8x8_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  244. /**
  245. * 4x4 block motion compensation with adding delta
  246. *
  247. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  248. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  249. * @param[in] pitch pitch for moving to the next y line
  250. * @param[in] mc_type interpolation type
  251. */
  252. void ff_ivi_mc_4x4_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  253. /**
  254. * motion compensation without adding delta
  255. *
  256. * @param[in,out] buf pointer to the block in the current frame receiving the result
  257. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  258. * @param[in] pitch pitch for moving to the next y line
  259. * @param[in] mc_type interpolation type
  260. */
  261. void ff_ivi_mc_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  262. /**
  263. * 4x4 block motion compensation without adding delta
  264. *
  265. * @param[in,out] buf pointer to the block in the current frame receiving the result
  266. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  267. * @param[in] pitch pitch for moving to the next y line
  268. * @param[in] mc_type interpolation type
  269. */
  270. void ff_ivi_mc_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  271. /**
  272. * 8x8 block motion compensation with adding delta
  273. *
  274. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  275. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  276. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  277. * @param[in] pitch pitch for moving to the next y line
  278. * @param[in] mc_type interpolation type for backward reference
  279. * @param[in] mc_type2 interpolation type for forward reference
  280. */
  281. void ff_ivi_mc_avg_8x8_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, ptrdiff_t pitch, int mc_type, int mc_type2);
  282. /**
  283. * 4x4 block motion compensation with adding delta
  284. *
  285. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  286. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  287. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  288. * @param[in] pitch pitch for moving to the next y line
  289. * @param[in] mc_type interpolation type for backward reference
  290. * @param[in] mc_type2 interpolation type for forward reference
  291. */
  292. void ff_ivi_mc_avg_4x4_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, ptrdiff_t pitch, int mc_type, int mc_type2);
  293. /**
  294. * motion compensation without adding delta for B-frames
  295. *
  296. * @param[in,out] buf pointer to the block in the current frame receiving the result
  297. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  298. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  299. * @param[in] pitch pitch for moving to the next y line
  300. * @param[in] mc_type interpolation type for backward reference
  301. * @param[in] mc_type2 interpolation type for forward reference
  302. */
  303. void ff_ivi_mc_avg_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, ptrdiff_t pitch, int mc_type, int mc_type2);
  304. /**
  305. * 4x4 block motion compensation without adding delta for B-frames
  306. *
  307. * @param[in,out] buf pointer to the block in the current frame receiving the result
  308. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  309. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  310. * @param[in] pitch pitch for moving to the next y line
  311. * @param[in] mc_type interpolation type for backward reference
  312. * @param[in] mc_type2 interpolation type for forward reference
  313. */
  314. void ff_ivi_mc_avg_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, ptrdiff_t pitch, int mc_type, int mc_type2);
  315. #endif /* AVCODEC_IVI_DSP_H */