Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- /dev/null 2012-07-26 21:04:11.000000000 +0200
- +++ Makefile 2012-07-26 19:23:48.000000000 +0200
- @@ -0,0 +1,8 @@
- +all: crash
- +
- +crash: crash.cpp
- +# 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
- + g++ -O3 -m32 crash.cpp -o crash -I/Users/memphis/src/xbmc-memphiz/lib/ffmpeg/ -L../ffmpeg2/libswscale -lswscale -L../ffmpeg2/libavutil -lavutil
- +
- +clean:
- + rm crash
- \ No newline at end of file
- --- /dev/null 2012-07-26 21:04:11.000000000 +0200
- +++ crash.cpp 2012-07-26 21:59:28.000000000 +0200
- @@ -0,0 +1,52 @@
- +#include <stddef.h>
- +
- +extern "C" {
- +#include <libswscale/swscale.h>
- +#include <libswscale/swscale_internal.h>
- +#include <libavutil/avutil.h>
- +}
- +#include <stdio.h>
- +#include <stdlib.h>
- +#include <stdint.h>
- +
- +bool ScaleImage(uint8_t *in_pixels, unsigned int in_width, unsigned int in_height, unsigned int in_pitch,
- + uint8_t *out_pixels, unsigned int out_width, unsigned int out_height, unsigned int out_pitch)
- +{
- + int cpuFlags = SWS_CPU_CAPS_MMX | SWS_CPU_CAPS_MMX2;
- +
- + struct SwsContext *context = sws_getContext(in_width, in_height, PIX_FMT_BGRA,
- + out_width, out_height, PIX_FMT_BGRA,
- + SWS_FAST_BILINEAR | cpuFlags, NULL, NULL, NULL);
- +
- + uint8_t *src[] = { in_pixels, 0, 0, 0 };
- + int srcStride[] = { in_pitch, 0, 0, 0 };
- + uint8_t *dst[] = { out_pixels , 0, 0, 0 };
- + int dstStride[] = { out_pitch, 0, 0, 0 };
- +
- + fprintf(stderr,"chrSrcW: %i\n", context->chrSrcW);
- +
- + if (context)
- + {
- + sws_scale(context, src, srcStride, 0, in_height, dst, dstStride);
- + sws_freeContext(context);
- + return false;
- + }
- + return true;
- +}
- +
- +int main(char **argc, int argv)
- +{
- + int inwidth = 753;
- + int inheight = 1024;
- + unsigned char *inbuff = new unsigned char[inwidth * inheight * 4];
- + int outwidth = 529;
- + int outheight = 720;
- + uint32_t *outbuff = new uint32_t[outwidth * outheight];
- +
- + ScaleImage((uint8_t *)inbuff, inwidth, inheight, inwidth * 4,
- + (uint8_t *)outbuff, outwidth, outheight, outwidth * 4);
- +
- + delete [] inbuff;
- + delete [] outbuff;
- + return 0;
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement