This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 26th, 2012  |  syntax: None  |  size: 2.33 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --- /dev/null   2012-07-26 21:04:11.000000000 +0200
  2. +++ Makefile    2012-07-26 19:23:48.000000000 +0200
  3. @@ -0,0 +1,8 @@
  4. +all: crash
  5. +
  6. +crash: crash.cpp
  7. +#      g++ -O3 -m32 crash.cpp -o crash  -I/Users/memphis/src/xbmc-memphiz/lib/ffmpeg/ -L/Users/memphis/src/xbmc-memphiz/lib/ffmpeg/libswscale -lswscale -L/Users/memphis/src/xbmc-memphiz/lib/ffmpeg/libavutil -lavutil
  8. +       g++ -O3 -m32 crash.cpp -o crash  -I/Users/memphis/src/xbmc-memphiz/lib/ffmpeg/ -L../ffmpeg2/libswscale -lswscale -L../ffmpeg2/libavutil -lavutil
  9. +
  10. +clean:
  11. +       rm crash
  12. \ No newline at end of file
  13. --- /dev/null   2012-07-26 21:04:11.000000000 +0200
  14. +++ crash.cpp   2012-07-26 21:59:28.000000000 +0200
  15. @@ -0,0 +1,52 @@
  16. +#include <stddef.h>
  17. +
  18. +extern "C" {
  19. +#include <libswscale/swscale.h>
  20. +#include <libswscale/swscale_internal.h>
  21. +#include <libavutil/avutil.h>
  22. +}
  23. +#include <stdio.h>
  24. +#include <stdlib.h>
  25. +#include <stdint.h>
  26. +
  27. +bool ScaleImage(uint8_t *in_pixels, unsigned int in_width, unsigned int in_height, unsigned int in_pitch,
  28. +                          uint8_t *out_pixels, unsigned int out_width, unsigned int out_height, unsigned int out_pitch)
  29. +{
  30. +  int cpuFlags = SWS_CPU_CAPS_MMX | SWS_CPU_CAPS_MMX2;
  31. +
  32. +  struct SwsContext *context = sws_getContext(in_width, in_height, PIX_FMT_BGRA,
  33. +                                                         out_width, out_height, PIX_FMT_BGRA,
  34. +                                                         SWS_FAST_BILINEAR | cpuFlags, NULL, NULL, NULL);
  35. +
  36. +  uint8_t *src[] = { in_pixels, 0, 0, 0 };
  37. +  int     srcStride[] = { in_pitch, 0, 0, 0 };
  38. +  uint8_t *dst[] = { out_pixels , 0, 0, 0 };
  39. +  int     dstStride[] = { out_pitch, 0, 0, 0 };
  40. +
  41. +  fprintf(stderr,"chrSrcW: %i\n", context->chrSrcW);
  42. +
  43. +  if (context)
  44. +  {
  45. +    sws_scale(context, src, srcStride, 0, in_height, dst, dstStride);
  46. +    sws_freeContext(context);
  47. +    return false;
  48. +  }
  49. +  return true;
  50. +}
  51. +
  52. +int main(char **argc, int argv)
  53. +{
  54. +  int inwidth = 753;
  55. +  int inheight = 1024;
  56. +  unsigned char *inbuff = new unsigned char[inwidth * inheight * 4];
  57. +  int outwidth = 529;
  58. +  int outheight = 720;
  59. +  uint32_t *outbuff = new uint32_t[outwidth * outheight];
  60. +
  61. +  ScaleImage((uint8_t *)inbuff, inwidth, inheight, inwidth * 4,
  62. +            (uint8_t *)outbuff, outwidth, outheight, outwidth * 4);
  63. +
  64. +  delete [] inbuff;
  65. +  delete [] outbuff;
  66. +  return 0;
  67. +}
clone this paste RAW Paste Data