Advertisement
Guest User

Untitled

a guest
May 28th, 2015
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. /* Inc., 51 Franklin Street, Fifth Floor
  2. * Boston MA 02110-1301, USA.
  3. * modified by CHEF-KOCH 10.04.2015
  4. */
  5.  
  6. --- qcom.h
  7. +++ qcom.h
  8. @@ -1,3 +1,14 @@
  9. -#include <vlc_picture.h>
  10. +#ifndef _QCOM_H_
  11. +#define _QCOM_H_
  12.  
  13. -void qcom_convert(const uint8_t *src, picture_t *pic);
  14. +#ifdef __cplusplus
  15. +extern "C" {
  16. +#endif
  17. +
  18. +void qcom_convert(const uint8_t *src, uint8_t* dst, size_t w, size_t h);
  19. +
  20. +#ifdef __cplusplus
  21. +}
  22. +#endif
  23. +
  24. +#endif
  25. --- qcom.c
  26. +++ qcom.c
  27. @@ -20,18 +20,10 @@
  28.  
  29. -#ifdef HAVE_CONFIG_H
  30. -# include "config.h"
  31. -#endif
  32. -
  33. -#include <vlc_picture.h>
  34. -
  35. -#include <string.h>
  36. #include <stdint.h>
  37. -
  38. +#include <string.h>
  39. #include "qcom.h"
  40.  
  41. -
  42. /*
  43. * The format is called QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka.
  44. * First wtf: why call it YUV420? It is NV12 (interleaved U&V).
  45. @@ -42,8 +34,7 @@
  46. #define TILE_SIZE (TILE_WIDTH * TILE_HEIGHT)
  47.  
  48. /* get frame tile coordinate. XXX: nothing to be understood here, don't try. */
  49. -static size_t tile_pos(size_t x, size_t y, size_t w, size_t h)
  50. -{
  51. +static size_t tile_pos(size_t x, size_t y, size_t w, size_t h) {
  52. size_t flim = x + (y & ~1) * w;
  53.  
  54. if (y & 1) {
  55. @@ -55,11 +46,10 @@
  56. return flim;
  57. }
  58.  
  59. -void qcom_convert(const uint8_t *src, picture_t *pic)
  60. -{
  61. - size_t width = pic->format.i_width;
  62. - size_t pitch = pic->p[0].i_pitch;
  63. - size_t height = pic->format.i_height;
  64. +void qcom_convert(const uint8_t *src, uint8_t* dst, size_t w, size_t h) {
  65. + size_t width = w; //pic->format.i_width;
  66. + size_t pitch = w; //pic->p[0].i_pitch;
  67. + size_t height = h; //pic->format.i_height;
  68.  
  69. const size_t tile_w = (width - 1) / TILE_WIDTH + 1;
  70. const size_t tile_w_align = (tile_w + 1) & ~1;
  71. @@ -70,21 +60,23 @@
  72. size_t luma_size = tile_w_align * tile_h_luma * TILE_SIZE;
  73.  
  74. #define TILE_GROUP_SIZE (4 * TILE_SIZE)
  75. - if((luma_size % TILE_GROUP_SIZE) != 0)
  76. + if ((luma_size % TILE_GROUP_SIZE) != 0)
  77. luma_size = (((luma_size - 1) / TILE_GROUP_SIZE) + 1) * TILE_GROUP_SIZE;
  78.  
  79. - for(size_t y = 0; y < tile_h_luma; y++) {
  80. + for (size_t y = 0; y < tile_h_luma; y++) {
  81. size_t row_width = width;
  82. - for(size_t x = 0; x < tile_w; x++) {
  83. + for (size_t x = 0; x < tile_w; x++) {
  84. /* luma source pointer for this tile */
  85. - const uint8_t *src_luma = src
  86. - + tile_pos(x, y,tile_w_align, tile_h_luma) * TILE_SIZE;
  87. + const uint8_t *src_luma = src
  88. + + tile_pos(x, y, tile_w_align, tile_h_luma) * TILE_SIZE;
  89.  
  90. /* chroma source pointer for this tile */
  91. const uint8_t *src_chroma = src + luma_size
  92. - + tile_pos(x, y/2, tile_w_align, tile_h_chroma) * TILE_SIZE;
  93. + + tile_pos(x, y / 2, tile_w_align, tile_h_chroma)
  94. + * TILE_SIZE;
  95. +
  96. if (y & 1)
  97. - src_chroma += TILE_SIZE/2;
  98. + src_chroma += TILE_SIZE / 2;
  99.  
  100. /* account for right columns */
  101. size_t tile_width = row_width;
  102. @@ -101,19 +93,21 @@
  103.  
  104. /* dest chroma memory index for this tile */
  105. /* XXX: remove divisions */
  106. - size_t chroma_idx = (luma_idx / pitch) * pitch/2 + (luma_idx % pitch);
  107. + size_t chroma_idx = (luma_idx / pitch) * pitch / 2
  108. + + (luma_idx % pitch) + w*h;
  109.  
  110. tile_height /= 2; // we copy 2 luma lines at once
  111. while (tile_height--) {
  112. - memcpy(&pic->p[0].p_pixels[luma_idx], src_luma, tile_width);
  113. +
  114. + memcpy(&dst[luma_idx], src_luma, tile_width);
  115. src_luma += TILE_WIDTH;
  116. luma_idx += pitch;
  117.  
  118. - memcpy(&pic->p[0].p_pixels[luma_idx], src_luma, tile_width);
  119. + memcpy(&dst[luma_idx], src_luma, tile_width);
  120. src_luma += TILE_WIDTH;
  121. luma_idx += pitch;
  122.  
  123. - memcpy(&pic->p[1].p_pixels[chroma_idx], src_chroma, tile_width);
  124. + memcpy(&dst[chroma_idx], src_chroma, tile_width);
  125. src_chroma += TILE_WIDTH;
  126. chroma_idx += pitch;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement