You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

345 lines
15KB

  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 Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; 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. /**
  63. * one-dimensional inverse 8-point Haar transform on rows for Indeo 4
  64. *
  65. * @param[in] in pointer to the vector of transform coefficients
  66. * @param[out] out pointer to the output buffer (frame)
  67. * @param[in] pitch pitch to move to the next y line
  68. * @param[in] flags pointer to the array of column flags:
  69. * != 0 - non_empty column, 0 - empty one
  70. * (this array must be filled by caller)
  71. */
  72. void ff_ivi_row_haar8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  73. const uint8_t *flags);
  74. /**
  75. * one-dimensional inverse 8-point Haar transform on columns for Indeo 4
  76. *
  77. * @param[in] in pointer to the vector of transform coefficients
  78. * @param[out] out pointer to the output buffer (frame)
  79. * @param[in] pitch pitch to move to the next y line
  80. * @param[in] flags pointer to the array of column flags:
  81. * != 0 - non_empty column, 0 - empty one
  82. * (this array must be filled by caller)
  83. */
  84. void ff_ivi_col_haar8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  85. const uint8_t *flags);
  86. /**
  87. * two-dimensional inverse Haar 4x4 transform for Indeo 4
  88. *
  89. * @param[in] in pointer to the vector of transform coefficients
  90. * @param[out] out pointer to the output buffer (frame)
  91. * @param[in] pitch pitch to move to the next y line
  92. * @param[in] flags pointer to the array of column flags:
  93. * != 0 - non_empty column, 0 - empty one
  94. * (this array must be filled by caller)
  95. */
  96. void ff_ivi_inverse_haar_4x4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  97. const uint8_t *flags);
  98. /**
  99. * one-dimensional inverse 4-point Haar transform on rows for Indeo 4
  100. *
  101. * @param[in] in pointer to the vector of transform coefficients
  102. * @param[out] out pointer to the output buffer (frame)
  103. * @param[in] pitch pitch to move to the next y line
  104. * @param[in] flags pointer to the array of column flags:
  105. * != 0 - non_empty column, 0 - empty one
  106. * (this array must be filled by caller)
  107. */
  108. void ff_ivi_row_haar4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  109. const uint8_t *flags);
  110. /**
  111. * one-dimensional inverse 4-point Haar transform on columns for Indeo 4
  112. *
  113. * @param[in] in pointer to the vector of transform coefficients
  114. * @param[out] out pointer to the output buffer (frame)
  115. * @param[in] pitch pitch to move to the next y line
  116. * @param[in] flags pointer to the array of column flags:
  117. * != 0 - non_empty column, 0 - empty one
  118. * (this array must be filled by caller)
  119. */
  120. void ff_ivi_col_haar4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  121. const uint8_t *flags);
  122. /**
  123. * DC-only two-dimensional inverse Haar transform for Indeo 4.
  124. * Performing the inverse transform in this case is equivalent to
  125. * spreading DC_coeff >> 3 over the whole block.
  126. *
  127. * @param[in] in pointer to the dc coefficient
  128. * @param[out] out pointer to the output buffer (frame)
  129. * @param[in] pitch pitch to move to the next y line
  130. * @param[in] blk_size transform block size
  131. */
  132. void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  133. int blk_size);
  134. /**
  135. * two-dimensional inverse slant 8x8 transform
  136. *
  137. * @param[in] in pointer to the vector of transform coefficients
  138. * @param[out] out pointer to the output buffer (frame)
  139. * @param[in] pitch pitch to move to the next y line
  140. * @param[in] flags pointer to the array of column flags:
  141. * != 0 - non_empty column, 0 - empty one
  142. * (this array must be filled by caller)
  143. */
  144. void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  145. const uint8_t *flags);
  146. /**
  147. * two-dimensional inverse slant 4x4 transform
  148. *
  149. * @param[in] in pointer to the vector of transform coefficients
  150. * @param[out] out pointer to the output buffer (frame)
  151. * @param[in] pitch pitch to move to the next y line
  152. * @param[in] flags pointer to the array of column flags:
  153. * != 0 - non_empty column, 0 - empty one
  154. * (this array must be filled by caller)
  155. */
  156. void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  157. const uint8_t *flags);
  158. /**
  159. * DC-only two-dimensional inverse slant transform.
  160. * Performing the inverse slant transform in this case is equivalent to
  161. * spreading (DC_coeff + 1)/2 over the whole block.
  162. * It works much faster than performing the slant transform on a vector of zeroes.
  163. *
  164. * @param[in] in pointer to the dc coefficient
  165. * @param[out] out pointer to the output buffer (frame)
  166. * @param[in] pitch pitch to move to the next y line
  167. * @param[in] blk_size transform block size
  168. */
  169. void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  170. /**
  171. * inverse 1D row slant transform
  172. *
  173. * @param[in] in pointer to the vector of transform coefficients
  174. * @param[out] out pointer to the output buffer (frame)
  175. * @param[in] pitch pitch to move to the next y line
  176. * @param[in] flags pointer to the array of column flags (unused here)
  177. */
  178. void ff_ivi_row_slant8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  179. const uint8_t *flags);
  180. /**
  181. * inverse 1D column slant transform
  182. *
  183. * @param[in] in pointer to the vector of transform coefficients
  184. * @param[out] out pointer to the output buffer (frame)
  185. * @param[in] pitch pitch to move to the next y line
  186. * @param[in] flags pointer to the array of column flags:
  187. * != 0 - non_empty column, 0 - empty one
  188. * (this array must be filled by caller)
  189. */
  190. void ff_ivi_col_slant8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  191. const uint8_t *flags);
  192. /**
  193. * inverse 1D row slant transform
  194. *
  195. * @param[in] in pointer to the vector of transform coefficients
  196. * @param[out] out pointer to the output buffer (frame)
  197. * @param[in] pitch pitch to move to the next y line
  198. * @param[in] flags pointer to the array of column flags (unused here)
  199. */
  200. void ff_ivi_row_slant4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  201. const uint8_t *flags);
  202. /**
  203. * inverse 1D column slant transform
  204. *
  205. * @param[in] in pointer to the vector of transform coefficients
  206. * @param[out] out pointer to the output buffer (frame)
  207. * @param[in] pitch pitch to move to the next y line
  208. * @param[in] flags pointer to the array of column flags:
  209. * != 0 - non_empty column, 0 - empty one
  210. * (this array must be filled by caller)
  211. */
  212. void ff_ivi_col_slant4(const int32_t *in, int16_t *out, ptrdiff_t pitch,
  213. const uint8_t *flags);
  214. /**
  215. * DC-only inverse row slant transform
  216. */
  217. void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  218. /**
  219. * DC-only inverse column slant transform
  220. */
  221. void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  222. /**
  223. * Copy the pixels into the frame buffer.
  224. */
  225. void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch, const uint8_t *flags);
  226. /**
  227. * Copy the DC coefficient into the first pixel of the block and
  228. * zero all others.
  229. */
  230. void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch, int blk_size);
  231. /**
  232. * 8x8 block motion compensation with adding delta
  233. *
  234. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  235. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  236. * @param[in] pitch pitch for moving to the next y line
  237. * @param[in] mc_type interpolation type
  238. */
  239. void ff_ivi_mc_8x8_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  240. /**
  241. * 4x4 block motion compensation with adding delta
  242. *
  243. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  244. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  245. * @param[in] pitch pitch for moving to the next y line
  246. * @param[in] mc_type interpolation type
  247. */
  248. void ff_ivi_mc_4x4_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  249. /**
  250. * motion compensation without adding delta
  251. *
  252. * @param[in,out] buf pointer to the block in the current frame receiving the result
  253. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  254. * @param[in] pitch pitch for moving to the next y line
  255. * @param[in] mc_type interpolation type
  256. */
  257. void ff_ivi_mc_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  258. /**
  259. * 4x4 block motion compensation without adding delta
  260. *
  261. * @param[in,out] buf pointer to the block in the current frame receiving the result
  262. * @param[in] ref_buf pointer to the corresponding block in the reference frame
  263. * @param[in] pitch pitch for moving to the next y line
  264. * @param[in] mc_type interpolation type
  265. */
  266. void ff_ivi_mc_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, ptrdiff_t pitch, int mc_type);
  267. /**
  268. * 8x8 block motion compensation with adding delta
  269. *
  270. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  271. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  272. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  273. * @param[in] pitch pitch for moving to the next y line
  274. * @param[in] mc_type interpolation type for backward reference
  275. * @param[in] mc_type2 interpolation type for forward reference
  276. */
  277. 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);
  278. /**
  279. * 4x4 block motion compensation with adding delta
  280. *
  281. * @param[in,out] buf pointer to the block in the current frame buffer containing delta
  282. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  283. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  284. * @param[in] pitch pitch for moving to the next y line
  285. * @param[in] mc_type interpolation type for backward reference
  286. * @param[in] mc_type2 interpolation type for forward reference
  287. */
  288. 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);
  289. /**
  290. * motion compensation without adding delta for B-frames
  291. *
  292. * @param[in,out] buf pointer to the block in the current frame receiving the result
  293. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  294. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  295. * @param[in] pitch pitch for moving to the next y line
  296. * @param[in] mc_type interpolation type for backward reference
  297. * @param[in] mc_type2 interpolation type for forward reference
  298. */
  299. 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);
  300. /**
  301. * 4x4 block motion compensation without adding delta for B-frames
  302. *
  303. * @param[in,out] buf pointer to the block in the current frame receiving the result
  304. * @param[in] ref_buf pointer to the corresponding block in the backward reference frame
  305. * @param[in] ref_buf2 pointer to the corresponding block in the forward reference frame
  306. * @param[in] pitch pitch for moving to the next y line
  307. * @param[in] mc_type interpolation type for backward reference
  308. * @param[in] mc_type2 interpolation type for forward reference
  309. */
  310. 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);
  311. #endif /* AVCODEC_IVI_DSP_H */