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.

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