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.

83 lines
2.5KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <stdint.h>
  19. #include "config.h"
  20. #include "libavutil/attributes.h"
  21. #include "utvideodsp.h"
  22. static void restore_rgb_planes_c(uint8_t *src_r,
  23. uint8_t *src_g,
  24. uint8_t *src_b,
  25. ptrdiff_t linesize_r,
  26. ptrdiff_t linesize_g,
  27. ptrdiff_t linesize_b,
  28. int width, int height)
  29. {
  30. uint8_t r, g, b;
  31. int i, j;
  32. for (j = 0; j < height; j++) {
  33. for (i = 0; i < width; i++) {
  34. r = src_r[i];
  35. g = src_g[i];
  36. b = src_b[i];
  37. src_r[i] = r + g - 0x80;
  38. src_b[i] = b + g - 0x80;
  39. }
  40. src_r += linesize_r;
  41. src_g += linesize_g;
  42. src_b += linesize_b;
  43. }
  44. }
  45. static void restore_rgb_planes10_c(uint16_t *src_r,
  46. uint16_t *src_g,
  47. uint16_t *src_b,
  48. ptrdiff_t linesize_r,
  49. ptrdiff_t linesize_g,
  50. ptrdiff_t linesize_b,
  51. int width, int height)
  52. {
  53. int r, g, b;
  54. int i, j;
  55. for (j = 0; j < height; j++) {
  56. for (i = 0; i < width; i++) {
  57. r = src_r[i];
  58. g = src_g[i];
  59. b = src_b[i];
  60. src_r[i] = (r + g - 0x200) & 0x3FF;
  61. src_b[i] = (b + g - 0x200) & 0x3FF;
  62. }
  63. src_r += linesize_r;
  64. src_g += linesize_g;
  65. src_b += linesize_b;
  66. }
  67. }
  68. av_cold void ff_utvideodsp_init(UTVideoDSPContext *c)
  69. {
  70. c->restore_rgb_planes = restore_rgb_planes_c;
  71. c->restore_rgb_planes10 = restore_rgb_planes10_c;
  72. if (ARCH_X86)
  73. ff_utvideodsp_init_x86(c);
  74. }