OpenHEVC / openHEVC

HEVC decoder
http://openhevc.github.io/openHEVC/
531 stars 192 forks source link

Compiled openHEVC with win7+visual studio2013 succeed, but got an error when run it on Windows #42

Open fengxiujie opened 8 years ago

fengxiujie commented 8 years ago

Hi, there,

I succeeded to compile openHEVC on win7 with visual studio2013 ultimate + cmake, however I got an unexpected error when running the executable program "hevc_sdl2.exe". Could any of you please take a look? Thanks a lot! Here is detail:

Compile openHEVC on win7 with visual studio2013 ultimate + cmake:

  1. Download CMake from https://cmake.org/ and install it
  2. Download yasm from http://yasm.tortall.net/Download.html, install it and add it to "path" environment parameter.
  3. git clone git://github.com/OpenHEVC/openHEVC.git
  4. git checkout hevc_rext
  5. create a folder "build" in opehnHEVC
  6. Download SDL2 from https://www.libsdl.org/download-2.0.php and put it in openHEVC folder
  7. Download pthreadVC2.lib and pthreadVC2.dll and put it in openHEVC folder
  8. Use cmake to generate visual studio solution; Configure SDL2MAIN_LIBRARY to "SDL2main.lib", configure SDL2_INCLUDE_DIR to "SDL2/include", configure SDL2_LIBRARY to "SDL2.lib";configure and generate.
  9. open "openHEVC.sln" vith msvs2013. Build project "LibOpenHevcWrapper" and got some compiling errors.
  10. Fix compiling errors by: a) Add files "libavutil/fifo.c" and "libavcodec/frame_thread_encoder.c" from ffmpeg source code; b) uncomment "attribute((always_inline))"; c) Replace " //r0 = ((m128i)builtin_ia32_psrawi128 ((__v8hi)(r0), (1))); with "r0 = _mm_srai_epi16(r0, 1);"
  11. Compile and run

However, when I run the executable program with command line "hevc_sdl2.exe -i SlideShow_1280x72_60fps_1200kbps.265 -o test.yuv", I got an error "Run-Time Check Failure #2 - Stack around the variable 'left_array' was corrupted." I debuged it in msvc 2013, and found the call stack below when the issue occurred:

hevc_sdl2.exe!intra_pred_8(HEVCContext * s, int x0, int y0, int log2_size, int c_idx) 行 344 C hevc_sdl2.exe!intra_pred_3_8(HEVCContext * s, int x0, int y0, int c_idx) 行 353 C hevc_sdl2.exe!hls_transform_unit(HEVCContext * s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, int cbf_luma, int * cbf_cb, int * cbf_cr) 行 1219 C hevc_sdl2.exe!hls_transform_tree(HEVCContext * s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, const int * base_cbf_cb, const int * base_cbf_cr) 行 1529 C hevc_sdl2.exe!hls_coding_unit(HEVCContext * s, int x0, int y0, int log2_cb_size) 行 2444 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2538 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2512 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2523 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2507 C hevc_sdl2.exe!hls_decode_entry(AVCodecContext * avctxt, void * isFilterThread) 行 2646 C hevc_sdl2.exe!avcodec_default_execute(AVCodecContext * c, int (AVCodecContext , void ) * func, void * arg, int * ret, int count, int size) 行 1123 C hevc_sdl2.exe!hls_slice_data(HEVCContext * s, const unsigned char * nal, int length) 行 2972 C hevc_sdl2.exe!decode_nal_unit(HEVCContext * s, const unsigned char * nal, int length) 行 3325 C hevc_sdl2.exe!decode_nal_units(HEVCContext * s, const unsigned char * buf, int length) 行 3894 C hevc_sdl2.exe!hevc_decode_frame(AVCodecContext * avctx, void * data, int * got_output, AVPacket * avpkt) 行 4022 C hevc_sdl2.exe!avcodec_decode_video2(AVCodecContext * avctx, AVFrame * picture, int * got_picture_ptr, const AVPacket * avpkt) 行 2373 C hevc_sdl2.exe!libOpenHevcDecode(void * openHevcHandle, const unsigned char * buff, int au_len, __int64 pts) 行 131 C hevc_sdl2.exe!video_decodeexample(const char * filename) 行 223 C

I doubt this issue was caused by these two modification when I tried to fix the compiling issues:

  1. Uncomment "attribute((always_inline))"----do not know the consequence
  2. Replace " //r0 = ((m128i)builtin_ia32_psrawi128 ((__v8hi)(r0), (1))); with "r0 = _mm_srai_epi16(r0, 1);" ---- In the beginning, I just uncommented this line but I got the "Run-Time Check Failure #2 - Stack around the variable 'left_array' was corrupted." error, then I googled it and found the replacement, but I got the same failure.

I also pasted the shortcuts as below when error occurred. Please take a look, many thanks in advance!

image image

pcabarat commented 8 years ago

Hi.

The problem here seems to come from x86 SIMD optimizations. What happens if you don't : uncomment " attribute ((always_inline))"; and Replace " //r0 = ((m128i)builtin_ia32_psrawi128 ((__v8hi)(r0), (1))); with "r0 = _mm_srai_epi16(r0, 1);"? What are the compilation errors you get in stage 9?

----- Mail original ----- De: "fengxiujie" notifications@github.com À: "OpenHEVC/openHEVC" openHEVC@noreply.github.com Envoyé: Vendredi 6 Mai 2016 04:54:09 Objet: [OpenHEVC/openHEVC] Compiled openHEVC with win7+visual studio2013 succeed, but got an error when run it on Windows (#42)

Hi, there,

I succeeded to compile openHEVC on win7 with visual studio2013 ultimate + cmake, however I got an unexpected error when running the executable program "hevc_sdl2.exe". Could any of you please take a look? Thanks a lot! Here is detail: Compile openHEVC on win7 with visual studio2013 ultimate + cmake:

1. Download CMake from https://cmake.org/ and install it 
2. Download yasm from http://yasm.tortall.net/Download.html , install it and add it to "path" environment parameter. 
3. git clone git://github.com/OpenHEVC/openHEVC.git 
4. git checkout hevc_rext 
5. create a folder "build" in opehnHEVC 
6. Download SDL2 from https://www.libsdl.org/download-2.0.php and put it in openHEVC folder 
7. Download pthreadVC2.lib and pthreadVC2.dll and put it in openHEVC folder 
8. Use cmake to generate visual studio solution; Configure SDL2MAIN_LIBRARY to "SDL2main.lib", configure SDL2_INCLUDE_DIR to "SDL2/include", configure SDL2_LIBRARY to "SDL2.lib";configure and generate. 
9. open "openHEVC.sln" vith msvs2013. Build project "LibOpenHevcWrapper" and got some compiling errors. 
10. Fix compiling errors by: a) Add files "libavutil/fifo.c" and "libavcodec/frame_thread_encoder.c" from ffmpeg source code; b) uncomment " attribute ((always_inline))"; c) Replace " //r0 = ((__m128i)__builtin_ia32_psrawi128 ((__v8hi)(r0), (1))); with "r0 = _mm_srai_epi16(r0, 1);" 
11. Compile and run 

However, when I run the executable program with command line "hevc_sdl2.exe -i SlideShow_1280x72_60fps_1200kbps.265 -o test.yuv", I got an error "Run-Time Check Failure #2 - Stack around the variable 'left_array' was corrupted." I debuged it in msvc 2013, and found the call stack below when the issue occurred:

hevc_sdl2.exe!intra_pred_8(HEVCContext * s, int x0, int y0, int log2_size, int c_idx) 行 344 C hevc_sdl2.exe!intra_pred_3_8(HEVCContext * s, int x0, int y0, int c_idx) 行 353 C hevc_sdl2.exe!hls_transform_unit(HEVCContext * s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, int cbf_luma, int * cbf_cb, int * cbf_cr) 行 1219 C hevc_sdl2.exe!hls_transform_tree(HEVCContext * s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, const int * base_cbf_cb, const int * base_cbf_cr) 行 1529 C hevc_sdl2.exe!hls_coding_unit(HEVCContext * s, int x0, int y0, int log2_cb_size) 行 2444 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2538 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2512 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2523 C hevc_sdl2.exe!hls_coding_quadtree(HEVCContext * s, int x0, int y0, int log2_cb_size, int cb_depth) 行 2507 C hevc_sdl2.exe!hls_decode_entry(AVCodecContext * avctxt, void * isFilterThread) 行 2646 C hevc_sdl2.exe!avcodec_default_execute(AVCodecContext * c, int (AVCodecContext , void ) * func, void * arg, int * ret, int count, int size) 行 1123 C hevc_sdl2.exe!hls_slice_data(HEVCContext * s, const unsigned char * nal, int length) 行 2972 C hevc_sdl2.exe!decode_nal_unit(HEVCContext * s, const unsigned char * nal, int length) 行 3325 C hevc_sdl2.exe!decode_nal_units(HEVCContext * s, const unsigned char * buf, int length) 行 3894 C hevc_sdl2.exe!hevc_decode_frame(AVCodecContext * avctx, void * data, int * got_output, AVPacket * avpkt) 行 4022 C hevc_sdl2.exe!avcodec_decode_video2(AVCodecContext * avctx, AVFrame * picture, int * got_picture_ptr, const AVPacket * avpkt) 行 2373 C hevc_sdl2.exe!libOpenHevcDecode(void * openHevcHandle, const unsigned char * buff, int au_len, __int64 pts) 行 131 C hevc_sdl2.exe!video_decodeexample(const char * filename) 行 223 C

I doubt this issue was caused by these two modification when I tried to fix the compiling issues:

  1. Uncomment " attribute ((always_inline))"----do not know the consequence
  2. Replace " //r0 = ((m128i)builtin_ia32_psrawi128 ((__v8hi)(r0), (1))); with "r0 = _mm_srai_epi16(r0, 1);" ---- In the beginning, I just uncommented this line but I got the "Run-Time Check Failure #2 - Stack around the variable 'left_array' was corrupted." error, then I googled it and found the replacement, but I got the same failure.

Could any of you please help? Many thanks in advance!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

fengxiujie commented 8 years ago

Acctually, I got a lot of compiling errors and I fixed them one by one. I agree that the running issues may come from x86 SIMD optimizations. MSVC2013 could not recognize " attribute ((always_inline))" and " ((m128i)builtin_ia32_psrawi128 ((__v8hi)(r0), (1)))". It would raise warnings before compling. After compiling, I got syntax errors for " attribute ((always_inline))" , and undeclared identifier “v8hi” for " ((m128i)builtin_ia32_psrawi128 ((v8hi)(r0), (1)))". Do you know the exact meanings of these two statements? Thanks!