SDL2 编译报错error: undefined reference to 'openslES_ResumeDevices' 求解决思路

android studio编译SDL2生成.so文件时,报错如下:

Build command failed.
Error while executing process /Users/ing/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/Android.mk NDK_APPLICATION_MK=/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/Application.mk APP_ABI=x86_64 NDK_ALL_ABIS=x86_64 NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/build/intermediates/ndkBuild/debug/lib /Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/libSDL2.so}
[x86_64] Compile        : SDL2 <= SDL.c
[x86_64] Compile        : SDL2 <= SDL_assert.c
[x86_64] Compile        : SDL2 <= SDL_dataqueue.c
[x86_64] Compile        : SDL2 <= SDL_error.c
[x86_64] Compile        : SDL2 <= SDL_hints.c
[x86_64] Compile        : SDL2 <= SDL_log.c
[x86_64] Compile        : SDL2 <= SDL_audio.c
[x86_64] Compile        : SDL2 <= SDL_audiocvt.c
[x86_64] Compile        : SDL2 <= SDL_audiodev.c
[x86_64] Compile        : SDL2 <= SDL_audiotypecvt.c
[x86_64] Compile        : SDL2 <= SDL_mixer.c
[x86_64] Compile        : SDL2 <= SDL_wave.c
[x86_64] Compile        : SDL2 <= SDL_androidaudio.c
[x86_64] Compile        : SDL2 <= SDL_dummyaudio.c
[x86_64] Compile        : SDL2 <= SDL_atomic.c
[x86_64] Compile        : SDL2 <= SDL_spinlock.c
[x86_64] Compile        : SDL2 <= SDL_android.c
[x86_64] Compile        : SDL2 <= SDL_cpuinfo.c
[x86_64] Compile        : SDL2 <= SDL_dynapi.c
[x86_64] Compile        : SDL2 <= SDL_clipboardevents.c
[x86_64] Compile        : SDL2 <= SDL_displayevents.c
[x86_64] Compile        : SDL2 <= SDL_dropevents.c
[x86_64] Compile        : SDL2 <= SDL_events.c
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:285:59: warning: format specifies type 'long long' but the argument has type 'SDL_TouchID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); break;
                                       ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:282:50: note: expanded from macro 'PRINT_FINGER_EVENT'
                (uint) event->tfinger.timestamp, event->tfinger.touchId, \
                                                 ^~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:285:59: warning: format specifies type 'long long' but the argument has type 'SDL_FingerID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); break;
                                       ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:283:17: note: expanded from macro 'PRINT_FINGER_EVENT'
                event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:286:57: warning: format specifies type 'long long' but the argument has type 'SDL_TouchID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_FINGERUP) PRINT_FINGER_EVENT(event); break;
                                     ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:282:50: note: expanded from macro 'PRINT_FINGER_EVENT'
                (uint) event->tfinger.timestamp, event->tfinger.touchId, \
                                                 ^~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:286:57: warning: format specifies type 'long long' but the argument has type 'SDL_FingerID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_FINGERUP) PRINT_FINGER_EVENT(event); break;
                                     ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:283:17: note: expanded from macro 'PRINT_FINGER_EVENT'
                event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:287:61: warning: format specifies type 'long long' but the argument has type 'SDL_TouchID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_FINGERMOTION) PRINT_FINGER_EVENT(event); break;
                                         ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:282:50: note: expanded from macro 'PRINT_FINGER_EVENT'
                (uint) event->tfinger.timestamp, event->tfinger.touchId, \
                                                 ^~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:287:61: warning: format specifies type 'long long' but the argument has type 'SDL_FingerID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_FINGERMOTION) PRINT_FINGER_EVENT(event); break;
                                         ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:283:17: note: expanded from macro 'PRINT_FINGER_EVENT'
                event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:295:62: warning: format specifies type 'long long' but the argument has type 'SDL_TouchID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); break;
                                          ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:292:51: note: expanded from macro 'PRINT_DOLLAR_EVENT'
                (uint) event->dgesture.timestamp, event->dgesture.touchId, \
                                                  ^~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:295:62: warning: format specifies type 'long long' but the argument has type 'SDL_GestureID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); break;
                                          ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:293:17: note: expanded from macro 'PRINT_DOLLAR_EVENT'
                event->dgesture.gestureId, (uint) event->dgesture.numFingers, \
                ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:296:61: warning: format specifies type 'long long' but the argument has type 'SDL_TouchID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_DOLLARRECORD) PRINT_DOLLAR_EVENT(event); break;
                                         ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:292:51: note: expanded from macro 'PRINT_DOLLAR_EVENT'
                (uint) event->dgesture.timestamp, event->dgesture.touchId, \
                                                  ^~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:296:61: warning: format specifies type 'long long' but the argument has type 'SDL_GestureID' (aka 'long') [-Wformat]
        SDL_EVENT_CASE(SDL_DOLLARRECORD) PRINT_DOLLAR_EVENT(event); break;
                                         ~~~~~~~~~~~~~~~~~~~^~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:293:17: note: expanded from macro 'PRINT_DOLLAR_EVENT'
                event->dgesture.gestureId, (uint) event->dgesture.numFingers, \
                ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/events/SDL_events.c:301:51: warning: format specifies type 'long long' but the argument has type 'SDL_TouchID' (aka 'long') [-Wformat]
                (uint) event->mgesture.timestamp, event->mgesture.touchId,
                                                  ^~~~~~~~~~~~~~~~~~~~~~~
11 warnings generated.
[x86_64] Compile        : SDL2 <= SDL_gesture.c
[x86_64] Compile        : SDL2 <= SDL_keyboard.c
[x86_64] Compile        : SDL2 <= SDL_mouse.c
[x86_64] Compile        : SDL2 <= SDL_quit.c
[x86_64] Compile        : SDL2 <= SDL_touch.c
[x86_64] Compile        : SDL2 <= SDL_windowevents.c
[x86_64] Compile        : SDL2 <= SDL_rwops.c
[x86_64] Compile        : SDL2 <= SDL_haptic.c
[x86_64] Compile        : SDL2 <= SDL_syshaptic.c
[x86_64] Compile        : SDL2 <= SDL_gamecontroller.c
[x86_64] Compile        : SDL2 <= SDL_joystick.c
[x86_64] Compile        : SDL2 <= SDL_sysjoystick.c
[x86_64] Compile        : SDL2 <= SDL_hidapi_ps4.c
[x86_64] Compile        : SDL2 <= SDL_hidapi_switch.c
[x86_64] Compile        : SDL2 <= SDL_hidapi_xbox360.c
[x86_64] Compile        : SDL2 <= SDL_hidapi_xboxone.c
[x86_64] Compile        : SDL2 <= SDL_hidapijoystick.c
[x86_64] Compile        : SDL2 <= SDL_sysloadso.c
[x86_64] Compile        : SDL2 <= SDL_power.c
[x86_64] Compile        : SDL2 <= SDL_syspower.c
[x86_64] Compile        : SDL2 <= SDL_sysfilesystem.c
[x86_64] Compile        : SDL2 <= SDL_sensor.c
[x86_64] Compile        : SDL2 <= SDL_androidsensor.c
[x86_64] Compile        : SDL2 <= SDL_d3dmath.c
[x86_64] Compile        : SDL2 <= SDL_render.c
[x86_64] Compile        : SDL2 <= SDL_yuv_sw.c
[x86_64] Compile        : SDL2 <= SDL_render_d3d.c
[x86_64] Compile        : SDL2 <= SDL_shaders_d3d.c
[x86_64] Compile        : SDL2 <= SDL_render_d3d11.c
[x86_64] Compile        : SDL2 <= SDL_shaders_d3d11.c
[x86_64] Compile        : SDL2 <= SDL_render_gl.c
[x86_64] Compile        : SDL2 <= SDL_shaders_gl.c
[x86_64] Compile        : SDL2 <= SDL_render_gles.c
[x86_64] Compile        : SDL2 <= SDL_render_gles2.c
In file included from /Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/render/opengles2/SDL_render_gles2.c:273:
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/render/opengles2/SDL_gles2funcs.h:58:1: warning: incompatible pointer types assigning to 'void (*)(GLuint, GLsizei, const GLchar **, const GLint *)' (aka 'void (*)(unsigned int, int, const char **, const int *)') from 'void (GLuint, GLsizei, const GLchar *const *, const GLint *)' (aka 'void (unsigned int, int, const char *const *, const int *)') [-Wincompatible-pointer-types]
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *))
^              ~~~~~~~~~~~~~~
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/render/opengles2/SDL_render_gles2.c:262:45: note: expanded from macro 'SDL_PROC'
#define SDL_PROC(ret,func,params) data->func=func;
                                            ^~~~~
1 warning generated.
[x86_64] Compile        : SDL2 <= SDL_shaders_gles2.c
[x86_64] Compile        : SDL2 <= SDL_render_psp.c
[x86_64] Compile        : SDL2 <= SDL_blendfillrect.c
[x86_64] Compile        : SDL2 <= SDL_blendline.c
[x86_64] Compile        : SDL2 <= SDL_blendpoint.c
[x86_64] Compile        : SDL2 <= SDL_drawline.c
[x86_64] Compile        : SDL2 <= SDL_drawpoint.c
[x86_64] Compile        : SDL2 <= SDL_render_sw.c
[x86_64] Compile        : SDL2 <= SDL_rotate.c
[x86_64] Compile        : SDL2 <= SDL_getenv.c
[x86_64] Compile        : SDL2 <= SDL_iconv.c
[x86_64] Compile        : SDL2 <= SDL_malloc.c
[x86_64] Compile        : SDL2 <= SDL_qsort.c
[x86_64] Compile        : SDL2 <= SDL_stdlib.c
[x86_64] Compile        : SDL2 <= SDL_string.c
[x86_64] Compile        : SDL2 <= SDL_thread.c
[x86_64] Compile        : SDL2 <= SDL_syscond.c
[x86_64] Compile        : SDL2 <= SDL_sysmutex.c
[x86_64] Compile        : SDL2 <= SDL_syssem.c
[x86_64] Compile        : SDL2 <= SDL_systhread.c
[x86_64] Compile        : SDL2 <= SDL_systls.c
[x86_64] Compile        : SDL2 <= SDL_timer.c
[x86_64] Compile        : SDL2 <= SDL_systimer.c
[x86_64] Compile        : SDL2 <= SDL_RLEaccel.c
[x86_64] Compile        : SDL2 <= SDL_blit.c
[x86_64] Compile        : SDL2 <= SDL_blit_0.c
[x86_64] Compile        : SDL2 <= SDL_blit_1.c
[x86_64] Compile        : SDL2 <= SDL_blit_A.c
[x86_64] Compile        : SDL2 <= SDL_blit_N.c
[x86_64] Compile        : SDL2 <= SDL_blit_auto.c
[x86_64] Compile        : SDL2 <= SDL_blit_copy.c
[x86_64] Compile        : SDL2 <= SDL_blit_slow.c
[x86_64] Compile        : SDL2 <= SDL_bmp.c
[x86_64] Compile        : SDL2 <= SDL_clipboard.c
[x86_64] Compile        : SDL2 <= SDL_egl.c
[x86_64] Compile        : SDL2 <= SDL_fillrect.c
[x86_64] Compile        : SDL2 <= SDL_pixels.c
[x86_64] Compile        : SDL2 <= SDL_rect.c
[x86_64] Compile        : SDL2 <= SDL_shape.c
[x86_64] Compile        : SDL2 <= SDL_stretch.c
[x86_64] Compile        : SDL2 <= SDL_surface.c
[x86_64] Compile        : SDL2 <= SDL_video.c
[x86_64] Compile        : SDL2 <= SDL_vulkan_utils.c
[x86_64] Compile        : SDL2 <= SDL_yuv.c
[x86_64] Compile        : SDL2 <= SDL_androidclipboard.c
[x86_64] Compile        : SDL2 <= SDL_androidevents.c
[x86_64] Compile        : SDL2 <= SDL_androidgl.c
[x86_64] Compile        : SDL2 <= SDL_androidkeyboard.c
[x86_64] Compile        : SDL2 <= SDL_androidmessagebox.c
[x86_64] Compile        : SDL2 <= SDL_androidmouse.c
[x86_64] Compile        : SDL2 <= SDL_androidtouch.c
[x86_64] Compile        : SDL2 <= SDL_androidvideo.c
[x86_64] Compile        : SDL2 <= SDL_androidvulkan.c
[x86_64] Compile        : SDL2 <= SDL_androidwindow.c
[x86_64] Compile        : SDL2 <= yuv_rgb.c
[x86_64] Compile        : SDL2 <= SDL_test_assert.c
[x86_64] Compile        : SDL2 <= SDL_test_common.c
[x86_64] Compile        : SDL2 <= SDL_test_compare.c
[x86_64] Compile        : SDL2 <= SDL_test_crc32.c
[x86_64] Compile        : SDL2 <= SDL_test_font.c
[x86_64] Compile        : SDL2 <= SDL_test_fuzzer.c
[x86_64] Compile        : SDL2 <= SDL_test_harness.c
[x86_64] Compile        : SDL2 <= SDL_test_imageBlit.c
[x86_64] Compile        : SDL2 <= SDL_test_imageBlitBlend.c
[x86_64] Compile        : SDL2 <= SDL_test_imageFace.c
[x86_64] Compile        : SDL2 <= SDL_test_imagePrimitives.c
[x86_64] Compile        : SDL2 <= SDL_test_imagePrimitivesBlend.c
[x86_64] Compile        : SDL2 <= SDL_test_log.c
[x86_64] Compile        : SDL2 <= SDL_test_md5.c
[x86_64] Compile        : SDL2 <= SDL_test_memory.c
[x86_64] Compile        : SDL2 <= SDL_test_random.c
[x86_64] Compile++      : hidapi <= hid.cpp
[x86_64] Prebuilt       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-libc++/libs/x86_64/
[x86_64] SharedLibrary  : libhidapi.so
[x86_64] SharedLibrary  : libSDL2.so
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/objs-debug/SDL2/src/audio/SDL_audio.o:SDL_audio.c:bootstrap: error: undefined reference to 'openslES_bootstrap'
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/video/android/SDL_androidevents.c:105: error: undefined reference to 'openslES_PauseDevices'
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/video/android/SDL_androidevents.c:112: error: undefined reference to 'openslES_ResumeDevices'
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/video/android/SDL_androidevents.c:156: error: undefined reference to 'openslES_PauseDevices'
/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/src/main/jni/SDL/src/video/android/SDL_androidevents.c:167: error: undefined reference to 'openslES_ResumeDevices'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/ing/github/ffmp/SDL2-2.0.10/android-project/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/libSDL2.so] Error 1



感觉是调用opengl 的相关库时报错,未引用。请教有遇到过此类问题的或者有解决思路的,请不吝赐教。。

2个回答

你的函数只定义了,没有具体实现过程!
解决方法:
查看库文件是否齐全
检查动态、静态库连接是否有问题
如果都没有问题,联系你库的开发者(一般有网站),应该回有解决方法

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
海思平台编译SDL问题?
![图片说明](https://img-ask.csdn.net/upload/202001/16/1579163209_685367.png) root@avst-linux-server:/home/font/SDL-1.2.15# ./configure CC=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gcc --host=aarch64-himix100-linux --prefix=/home/font/test/SDL --enable-shared=no --enable-static=yes configure: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used. checking build system type... x86_64-unknown-linux-gnu checking host system type... Invalid configuration `aarch64-himix100-linux': machine `aarch64-himix100' not recognized configure: error: /bin/sh ./build-scripts/config.sub aarch64-himix100-linux failed root@avst-linux-server:/home/yushuo/font/SDL-1.2.15# 该如何解决呢?
编译pjsip android版时SDL报错
为了支持x264解码,使用支持x264的ffmpeg和SDL2.0编译pjsip的android版。编译好了SDL2,在pjsip的根目录下使用./configure-android 能够找到SDL2.0.但是编译的时候总是会报错。如图所视:![图片说明](https://img-ask.csdn.net/upload/201508/26/1440557385_978482.png) 如果不编译android版,只编译linux版是不会出问题的。
请问SDL2.0是怎么编译到ios平台的呢,我按照README-ios.txt编译但是编译过不了
uilding with iOS SDK v6.1 for iOS >= 3.0 checking build system type... i386-apple-darwin12.4.0 checking host system type... armv6-apple-darwin checking how to print strings... printf checking for armv6-apple-darwin-gcc... /Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 checking whether the C compiler works... no configure: error: in `/Users/PS/SDL2-2.0.0/build/armv6': configure: error: C compiler cannot create executables See `config.log' for more details 请问有遇到这样的问题没?我的系统 OS X 10.8.4,XCode4.6.3 SDK6.1
FFmpeg:avcodec_find_encoder_by_name("libx264")返回空,是怎么回事呢?
FFmpeg编译时的参数:./configure --enable-shared --enable-static --enable-pic --enable-gpl --enable-avresample --enable-sdl --enable-libx264 cmd中使用ffmpeg -encoders ![图片说明](https://img-ask.csdn.net/upload/201912/15/1576374486_153947.jpg) 新线索: 在win7、vs2015中此函数不为空,在win10、vs2017中为空; 在win10、vs2017中的debug模式下,此函数返回空,release模式下不为空;
knn猫狗识别算法中样本为0报错
错误如下: ValueError: With n_samples=0, test_size=0.25 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters. 代码如下: # import the necessary packages from sklearn.neighbors import KNeighborsClassifier from sklearn.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split from sklearn.metrics import classification_report from pyimagesearch.preprocessing import SimplePreprocessor from pyimagesearch.datasets import SimpleDatasetLoader from imutils import paths import argparse # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-d", "--datasets", type=str, default="‪H:\\111\\try1\\pyimagesearch\\datasets\\animals\\", help="path to input dataset") ap.add_argument("-k", "--neighbors", type=int, default=1, help="# of nearest neighbors for classification") ap.add_argument("-j", "--jobs", type=int, default=-1, help="# of jobs for k-NN distance (-1 uses all available cores)") args = vars(ap.parse_args()) # grab the list of images that we’ll be describing print("[INFO] loading images...") imagePaths = list(paths.list_images(args["datasets"])) # initialize the image preprocessor, load the dataset from disk, # and reshape the data matrix sp = SimplePreprocessor.SimplePreprocessor(32, 32) sdl = SimpleDatasetLoader.SimpleDatasetLoader(preprocessors=[sp]) (data, labels) = sdl.load(imagePaths, verbose=500) data = data.reshape((data.shape[0], 3072)) # show some information on memory consumption of the images print("[INFO] features matrix: {:.1f}MB".format( data.nbytes / (1024 * 1000.0))) # encode the labels as integers le = LabelEncoder() labels = le.fit_transform(labels) # partition the data into training and testing splits using 75% of # the data for training and the remaining 25% for testing (trainX, testX, trainY, testY) = train_test_split(data, labels, test_size=0.25, random_state=42) # train and evaluate a k-NN classifier on the raw pixel intensities print("[INFO] evaluating k-NN classifier...") model = KNeighborsClassifier(n_neighbors=args["neighbors"], n_jobs=args["jobs"]) model.fit(trainX, trainY) print(classification_report(testY, model.predict(testX), target_names=le.classes_)) ``` ```
在交叉编译SDL2-2.0.9时找不到相关头文件,但是明明在/usr/include/下面有?
编译是在utuntu-14.04.5-32上 目标是在编译SDL2的库放到arm板子上 我执行的步骤是: ———————— **1:**./configure --prefix=/home/makoto/yizhi/SDL/SDL2-2.0.9/temp/ --host=arm-linux **2**: make —————————— 然后就报错: ![图片说明](https://img-ask.csdn.net/upload/201903/19/1553000776_138754.png) 但是这个文件就在/usr/include 下面。。。 我接触linux不是很久,这个问题然我烦恼了好几天
Android 手持PDA 如何让扫描到的数据,跟随光标,输入到任意EditText
最近在研究Android 手持PDA的扫描系统 从厂家获得到了demo的源代码, 按照厂家的源代码修改完之后。发现扫描到的内容只能输入到固定的文本框内 如果一个界面内有有两个文本框,就只能输入到第一个文本框内。 请问如何能根据光标的位置,输入到不同的文本框内 布局文件 ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="50dp" android:text="Scan Test" android:id="@+id/tv_title" android:textSize="40dp"/> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:layout_below="@+id/tv_title" android:id="@+id/et1"/> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:layout_below="@+id/et1" android:id="@+id/et2"/> <Button android:id="@+id/btnOpen" android:layout_below="@+id/et2" android:text="Scan" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </RelativeLayout> ``` JAVA文件 ``` import android.Manifest; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.text.Selection; import android.text.Spannable; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.qs.service.ScanService; import com.zebra.sdl.SDLguiActivity; import java.util.ArrayList; import java.util.List; import java.util.Map; public class MainActivity extends AppCompatActivity { private ScanBroadcastReceiver scanBroadcastReceiver; Button btnOpen, btnEdit; public static EditText et_code1; List<Map<String, String>> listData = new ArrayList<Map<String, String>>(); String str2,str1,str; String TAG="数据"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et_code1 = (EditText) findViewById(R.id.et1); et_code1.setText(""); btnOpen = (Button) findViewById(R.id.btnOpen); btnOpen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { //斑马头软解码方式 if(Build.MODEL.contains("mipi")){ SDLguiActivity.doDecode(); }else{ //普通硬解码 ScanService.openScan(); } } }); //斑马头软解码方式 if(Build.MODEL.contains("mipi")){ //软解码为摄像头形式,需要加上权限 if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, 1000); } else { //说明已经获取到摄像头权限了 想干嘛干嘛 Intent newIntent = new Intent(MainActivity.this, SDLguiActivity.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startService(newIntent); } }else{ Intent newIntent = new Intent(MainActivity.this, ScanService.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startService(newIntent); } scanBroadcastReceiver = new ScanBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.qs.scancode"); this.registerReceiver(scanBroadcastReceiver, intentFilter); } @Override protected void onResume() { System.out.println("onResume" + "open"); Log.v("onResume", "open"); super.onResume(); } @Override protected void onDestroy() { this.unregisterReceiver(scanBroadcastReceiver); super.onDestroy(); } class ScanBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub //text1为扫描信息 String text1 = intent.getExtras().getString("code"); String str = et_code1.getText().toString().trim()+"\n"; et_code1.setText(str + text1); Editable text = et_code1.getText(); Spannable spanText = text; Selection.setSelection(spanText, text.length()); } } } ``` 求大神指点,本人是初学者,麻烦详细一点。
VS2015 编译预处理问题
VS C+++编译预处理问题 微软 编译器 编译平台:vs2015 update3,代码如下: #ifdef _WIN64 inline uint16_t zBSF(unsigned long * Index,uint64_t x) { return _BitScanForward64(Index,x); //编译报错行 } #endif 在编译目标平台选项设为x64的时候没有问题,但是设为x86的时候,报错,错误信息如下: Error C3861 '_BitScanForward64': identifier not found 我已经做了#ifdef _WIN64预处理了,指示预编译在x86下不要处理这段代码了啊,怎么感觉好像编译器不予理睬一般。这种预处理,我在其他地方用的很多,没有出现过什么问题。这个_BitScanForward64按微软说法是编译器内嵌函数,但是这又如何?指明了不要处理,为啥还处理,跪求求大神指点 不好意思,囊中空空,没有C币悬赏了啊 编译命令行所有选项: /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl /Fd"Debug\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\CPPTEST.pch" 链接命令行所有选项: /OUT:"D:\VS\CPPTEST\Debug\CPPTEST.exe" /MANIFEST /NXCOMPAT /PDB:"D:\VS\CPPTEST\Debug\CPPTEST.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"D:\VS\CPPTEST\Debug\CPPTEST.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\CPPTEST.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
pydub无法打开wav文件
打算使用pydub批量处理录音文件格式,但是光是执行到打开录音文件就会报错。 代码: from pydub import AudioSegment sound = AudioSegment.from_file('D:\\wavdownload\\1b449bd73b866e73c997401c19462353.wav', format='wav') 报错: Traceback (most recent call last): File "D:/PycharmProjects/chaxunyemian/wavtomp.py", line 5, in <module> sound = AudioSegment.from_file('D:\\wavdownload\\1b449bd73b866e73c997401c19462353.wav', format='wav') File "D:\Anaconda3\envs\baidujiami\lib\site-packages\pydub\audio_segment.py", line 704, in from_file p.returncode, p_err)) **pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1** Output from ffmpeg/avlib: ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 9.1.1 (GCC) 20190807 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Guessed Channel Layout for Input Stream #0.0 : mono Input #0, wav, from 'D:\wavdownload\1b449bd73b866e73c997401c19462353.wav': Duration: 00:01:17.70, bitrate: 64 kb/s Stream #0:0: Audio: pcm_alaw ([6][0][0][0] / 0x0006), 8000 Hz, mono, s16, 64 kb/s Stream mapping: Stream #0:0 -> #0:0 (pcm_alaw (native) -> pcm_s8 (native)) Press [q] to stop, [?] for help [wav @ 000000000042b9c0] **pcm_s8 codec not supported in WAVE format Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented Error initializing output stream 0:0 -- Conversion failed!** 是不是wav文件的编码有问题?我该如何解决 在cmd尝试用命令来转换格式是可以的: ffmpeg -i 1b449bd73b866e73c997401c19462353.wav d:\wavdownload\1b449bd73b866e73c997401c19462353.mp3 执行这条语句拿到了MP3文件。
SDL2 更改窗口大小,视频卡主
在使用SDL2.0时,使用了SDL API函数SDL_SetWindowSize函数后,视频播放就会卡主,若是使用SDL_SetWindowPosition只是移动位置是不会有问题的? ShowData(const unsigned char *pY,const unsigned char *pU,const unsigned char *pV,int width) { if( pTexture == NULL || pRender == NULL ) return; SDL_UpdateYUVTexture(pTexture,&sdlRT,pY,width,pU,width/2, pV,width/2); SDL_RenderClear( pRender ); SDL_RenderCopy( pRender, pTexture, &sdlRT, &dstRT ); SDL_RenderPresent( pRender ); }
ubuntu core上 SDL多声卡找不到,只能找到一个
用ls /dev/snd 显示本地声卡数量 root@FriendlyARM:~/bin# ls /dev/snd by-id by-path controlC0 controlC1 controlC2 pcmC0D0p pcmC1D0c pcmC1D0p pcmC2D0c pcmC2D0p timer 显示有3个声卡。 用SDL测试程序如下: #include "SDL2/SDL.h" #include <stdio.h> void main(void) { SDL_AudioDeviceID dev; int i,count=0; if(SDL_Init(SDL_INIT_AUDIO)) { printf("can't init sdl exit!\n"); exit(1); } count = SDL_GetNumAudioDevices(0); for(i=0;i<count;i++) { printf("Audio device %d: %s\n",i,SDL_GetAudioDeviceName(i,0)); } SDL_Quit(); } 编译 root@FriendlyARM:~/bin# gcc -o testsdl testsdl.c `sdl2-config --cflags --libs` 运行 root@FriendlyARM:~/bin# ./testsdl Audio device 0: System audio output device 这里显示,只找到了一个声卡,剩下的两个声卡找不到。 请问高手,这是什么情况?
linux SDL2安装后不能使用
我在虚拟机centos7下安装了SDL2,编译了test中的testdraw2.c 编译都是正确的,结果运行时出现了如提示“Couldn't initialize video driver: No available video device”不能正常运行,希望大神解决一下
eclipse下用sdl2加载图片
最近老师让用sdl2实现时钟,我在ubuntu下用eclipse写代码,编译得时候没有问题, 就是运行得时候什么都没有,对sdl不了解,想问问是怎么回事。 #include "SDL2/SDL.h" int main( int argc, char* args[] ) { SDL_Window* Window = NULL; SDL_Surface* hello = NULL; SDL_Init( SDL_INIT_EVERYTHING ); Window = SDL_CreateWindow("SDL_Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 240, 400, SDL_WINDOW_SHOWN); //Load image hello = SDL_GetWindowSurface(Window); hello = SDL_LoadBMP( "/home/×××××/lesson01/hello.bmp" ); SDL_FreeSurface(hello); SDL_DestroyWindow(Window); SDL_Quit(); return 0; }
ubuntu下sdl2出现no available video device错误
一个使用sdl库的c++小游戏,在SDL_CreateWindow时使用GetError()发现了"no available video device"错误。 怀疑是以前使用别人编译好的版本有问题,就卸载掉重新下载源码编译了下,还是错误。 查了很多资料没能解决,故来此处求问各位,多谢!
sdl2学习使用问题,求教程
正在学习sdl2,网上找不到什么资料,学得一团糟,求大神指条明路
vs2012下的SDL2怎么载入png文件?下载的SDL_image的包如何导入
# vs2012使用SDL2的sdl_image的包怎么配置? 求详细解答0.0
在xcode上配置sdl2的一点问题求指点
在官网下载了sdl2的文件,添加到framework里之后,在build phases里的linkbinary with libraries里想添加找不到 如图所示: ![图片说明](https://img-ask.csdn.net/upload/201708/08/1502176932_794778.png) ![图片说明](https://img-ask.csdn.net/upload/201708/08/1502176951_813272.png) 然后自己在原来下载的sdl2文件里把它添加进去了,但是添加之后 #include <SDL2/SDL.h> 显示这个文件not found 求教是什么原因呢? ![图片说明](https://img-ask.csdn.net/upload/201708/08/1502177045_136224.png)
SDL SDL_CreateWimdowFrom 线程问题
各位大侠,有谁对SDL2比较熟悉的啊,为什么我在自己创建的线程中使用SDL_CreateWimdowFrom会卡死?在主线程中调用该函数没问题,但在主线程中创建窗口,然后在其他线程绘制视频帧的时候如果改变窗口的位置或大小,有可能导致程序挂掉
关于SDL音频播放没声音的问题~
开始光播放视频正常,但加上音频线程后,不但没有声音,而且连视频也卡在了一帧上,求教,谢谢~ # videoplay.cpp #include "videoplay.h" videoplay::videoplay(){ pFormatContext = avformat_alloc_context(); pFrame = avcodec_alloc_frame(); pFrameRGB = avcodec_alloc_frame(); pktQueue = new packetQueue(); pktQueueAudio = new packetQueue(); } void videoplay::reset(){ av_free(pFormatContext); pFormatContext = avformat_alloc_context(); av_free(pFrame); pFrame = avcodec_alloc_frame(); av_free(pFrameRGB); pFrameRGB = avcodec_alloc_frame(); delete pktQueue; packetQueue_init(); } //打开视频文件,获取解码器 int videoplay::open_file(){ av_register_all(); if( avformat_open_input(&pFormatContext, path.c_str(), NULL, NULL )!=0 ) return -1; if( av_find_stream_info(pFormatContext)<0 ) return -1; av_dump_format(pFormatContext, 0, path.c_str(), 0); videoStream = -1; audioStream = -1; for( unsigned int i=0;i<pFormatContext->nb_streams;i++ ){ if( pFormatContext->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO ){ videoStream = i; } else if( pFormatContext->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO ){ audioStream = i; } } if( videoStream==-1 ) return -1; if( audioStream==-1 ) return -1; // video pCodecContext = pFormatContext->streams[videoStream]->codec; pCodec = avcodec_find_decoder(pCodecContext->codec_id); // audio aCodecContext = pFormatContext->streams[audioStream]->codec; aCodec = avcodec_find_decoder(aCodecContext->codec_id); if( pCodec==NULL || aCodec==NULL ) return -1; // video if( avcodec_open2( pCodecContext, pCodec, NULL )<0 ) return -1; ud *userdata = (ud*) malloc(sizeof(ud)); userdata->aCodecContext = aCodecContext; userdata->vp = this; // audio wanted_spec = (SDL_AudioSpec*) av_mallocz(sizeof(SDL_AudioSpec)); wanted_spec->freq = aCodecContext->sample_rate; wanted_spec->format = AUDIO_S16SYS; wanted_spec->channels = aCodecContext->channels; wanted_spec->silence = 0; wanted_spec->samples = SDL_AUDIO_BUFFER_SIZE; wanted_spec->callback = audio_callback; wanted_spec->userdata = userdata; if( SDL_OpenAudio(wanted_spec, NULL)<0 ) return -1; av_free(pCodec); av_free(aCodec); } //获取包,加入队列 int videoplay::getPackets(){ int numBytes; packetQueue_init(); pFrame = avcodec_alloc_frame(); pFrameRGB = avcodec_alloc_frame(); if( pFrame==NULL || pFrameRGB==NULL ) return -1; numBytes = avpicture_get_size( PIX_FMT_RGB24, pCodecContext->width, pCodecContext->height ); buffer = (uint8_t*)av_malloc(numBytes*sizeof(uint8_t)); avpicture_fill( (AVPicture*)pFrameRGB, buffer, PIX_FMT_RGB24, pCodecContext->width, pCodecContext->height ); AVPacket packet; while( av_read_frame(pFormatContext, &packet)>=0 ){ if( packet.stream_index==videoStream ) packetQueue_put( pktQueue, &packet ); if( packet.stream_index==audioStream ) packetQueue_put( pktQueueAudio, &packet ); } av_free(pCodecContext); } void videoplay::packetQueue_init(){ pktQueue = (packetQueue*)malloc(sizeof(packetQueue)); memset( pktQueue, 0, sizeof(packetQueue) ); pktQueue->mutex = SDL_CreateMutex(); pktQueue->cond = SDL_CreateCond(); pktQueueAudio = (packetQueue*)malloc(sizeof(packetQueue)); memset( pktQueueAudio, 0, sizeof(packetQueue) ); pktQueueAudio->mutex = SDL_CreateMutex(); pktQueueAudio->cond = SDL_CreateCond(); } bool videoplay::packetQueue_get(packetQueue *pktQueue, AVPacket *packet){ int ret = 0; //quit=0; AVPacketList *pkt1; SDL_LockMutex(pktQueue->mutex); if(pktQueue->nb_packets<=VIDEO_BUFFER_MIN_SIZE){ SDL_CondSignal(pktQueue->cond); } while(1) { pkt1=pktQueue->first; if(pkt1) { pktQueue->first=pkt1->next; if(!pktQueue->first)pktQueue->last=NULL; pktQueue->nb_packets--; *packet = pkt1->pkt; av_free(pkt1); ret=1; break; } else { SDL_CondWait(pktQueue->cond,pktQueue->mutex); } } SDL_UnlockMutex(pktQueue->mutex); return ret; } //往队列加包 void videoplay::packetQueue_put(packetQueue *pktQueue, AVPacket *packet){ AVPacketList *pkt1=(AVPacketList*)av_malloc(sizeof(AVPacketList)); pkt1->pkt=*packet; pkt1->next=NULL; SDL_LockMutex( pktQueue->mutex); if( pktQueue->nb_packets>=VIDEO_BUFFER_MAX_SIZE ){ SDL_CondWait( pktQueue->cond, pktQueue->mutex ); } if(!pktQueue->last) pktQueue->first=pkt1; else pktQueue->last->next=pkt1; pktQueue->last=pkt1; pktQueue->nb_packets++; if( pktQueue->nb_packets>=VIDEO_BUFFER_MIN_SIZE ){ SDL_CondSignal(pktQueue->cond); } SDL_CondSignal(pktQueue->cond); SDL_UnlockMutex(pktQueue->mutex); return ; } QImage* videoplay::play(QImage &image){ AVPacket *packet = new AVPacket(); struct SwsContext *pSwsCtx; int frameFinished; while( packetQueue_get( pktQueue, packet) ){ avcodec_decode_video2( pCodecContext, pFrame, &frameFinished, packet ); if( frameFinished ){ pSwsCtx = sws_getContext( pCodecContext->width, pCodecContext->height,pCodecContext->pix_fmt, pCodecContext->width, pCodecContext->height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL ); sws_scale (pSwsCtx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecContext->height, pFrameRGB->data, pFrameRGB->linesize); bmp->pixels[0] = pFrameRGB->data[0]; bmp->pixels[1] = pFrameRGB->data[2]; bmp->pixels[2] = pFrameRGB->data[1]; bmp->pitches[0] = pFrameRGB->linesize[0]; bmp->pitches[1] = pFrameRGB->linesize[2]; bmp->pitches[2] = pFrameRGB->linesize[1]; SDL_UnlockYUVOverlay(bmp); rect.x=0; rect.y=0; rect.w=pCodecContext->width; rect.h=pCodecContext->height; SDL_DisplayYUVOverlay(bmp,&rect); */ memcpy( buffer,pFrameRGB,sizeof(AVFrame) ); QImage tmpImage( (uchar*)buffer, pCodecContext->width, pCodecContext->height, QImage::Format_RGB888 ); image = tmpImage.copy(); SDL_Delay(40); int i = 0; return &image; } } return NULL; } int videoplay::audio_decode_frame( videoplay *vp, AVCodecContext *aCodecContext, Uint8 *audio_buf, int buf_size ){ static AVPacket pkt; static Uint8 *audio_pkt_data = NULL; static int audio_pkt_size = 0; int len_1, data_size; while(1){ while(audio_pkt_size>0){ data_size = buf_size; len_1 = avcodec_decode_audio3( aCodecContext, (int16_t*)audio_buf, &data_size, &pkt); if( len_1<0 ){ audio_pkt_size = 0; break; } audio_pkt_data = audio_pkt_data + len_1; audio_pkt_size = audio_pkt_size - len_1; if( data_size<=0 ) continue; return data_size; } if(pkt.data) av_free_packet(&pkt); if( vp->packetQueue_get(vp->pktQueueAudio, &pkt)==0 ) return -1; audio_pkt_data = pkt.data; audio_pkt_size = pkt.size; } } void videoplay::audio_callback( void*userdata, Uint8 *stream, int len ){ ud *udata = (ud*)userdata; AVCodecContext *aCodecContext = udata->aCodecContext; videoplay *vp = udata->vp; int len_1, audio_size; static Uint8 audio_buf[AVCODEC_MAX_AUDIO_FRAME_SIZE*3/2]; static unsigned int audio_buf_size = 0; static unsigned int audio_buf_index = 0; while( len>0 ){ if( audio_buf_index>=audio_buf_size ){ audio_size = audio_decode_frame( vp, aCodecContext, audio_buf, sizeof(audio_buf) ); if( audio_size<0 ){ audio_buf_size = 1024; memset( audio_buf, 0 , audio_buf_size ); } else audio_buf_size = audio_size; audio_buf_index = 0; } } len_1 = audio_buf_size - audio_buf_index; if( len_1>len ) len_1 = len; // memcpy( stream, (Uint8*)audio_buf+audio_buf_index, len_1 ); SDL_MixAudio(stream,(Uint8*)audio_buf+audio_buf_index, len_1, SDL_MIX_MAXVOLUME ); len = len - len_1; stream = stream + len_1; audio_buf_index = audio_buf_index + len_1; } # mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include <Windows.h> #include "videoplay.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect( this, SIGNAL(readOneFrame(QPixmap)), this, SLOT(setPic(QPixmap)) ); } MainWindow::~MainWindow() { delete ui; } int threadFunc( void *arg){ videoplay *vp = (videoplay*)arg; vp->getPackets(); return 1; } int MainWindow::threadFunc_1( void *arg){ MainWindow *mainWindow = (MainWindow*)arg; QImage *image = new QImage(); while( mainWindow->vp.play(*image) ){ QPixmap pixmap = QPixmap::fromImage(image->scaled(mainWindow->ui->label->size(), Qt::KeepAspectRatio)); emit mainWindow->readOneFrame(pixmap); Sleep(1); mainWindow->state = 1; } delete image; return 1; } int threadFunc_2( void *arg){ while(1) SDL_PauseAudio(5); return 1; } void MainWindow::closeEvent(QCloseEvent *event){ SDL_KillThread(decodeTid); SDL_KillThread(videoTid); SDL_KillThread(audioTid); } void MainWindow::on_pushButton_clicked() //打开,获取到视频文件路径 path { vp.reset(); QFileDialog* fileDialog = new QFileDialog(this); QString path = fileDialog->getOpenFileName(this, "打开", ".", "Video Files(*.mp4 *.avi,*rmvb);;all(*)", 0, 0); decodeTid=NULL; videoTid=NULL; if( path.length()!=0 ){ if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) ) return ; ui->label->setText( path ); vp.setPath(path.toStdString()); vp.open_file(); decodeTid = SDL_CreateThread(threadFunc,&vp); videoTid = SDL_CreateThread(threadFunc_1,this); SDL_PauseAudio(0); audioTid = SDL_CreateThread(threadFunc_2,NULL); } } void MainWindow::on_pushButton_2_clicked() //快退 { } void MainWindow::on_pushButton_3_clicked() //播放/停止 { if( state==1 ){ //点击后暂停 ui->pushButton_3->setText(tr("暂停")); state = 0; } else{ ui->pushButton_3->setText(tr("播放")); //点击后播放 state = 1; } } void MainWindow::on_pushButton_4_clicked() //快进 { } void MainWindow::setPic(QPixmap pixmap){ ui->label->setPixmap(pixmap); ui->label->repaint(); }
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方...
吐血推荐珍藏的Visual Studio Code插件
作为一名Java工程师,由于工作需要,最近一个月一直在写NodeJS,这种经历可以说是一部辛酸史了。好在有神器Visual Studio Code陪伴,让我的这段经历没有更加困难。眼看这段经历要告一段落了,今天就来给大家分享一下我常用的一些VSC的插件。 VSC的插件安装方法很简单,只需要点击左侧最下方的插件栏选项,然后就可以搜索你想要的插件了。 下面我们进入正题 Material Theme ...
如何防止抄袭PCB电路板
目录 1、抄板是什么 2、抄板是否属于侵权 3、如何防止抄板 1、抄板是什么 抄板也叫克隆或仿制,是对设计出来的PCB板进行反向技术研究;目前全新的定义:从狭义上来说,抄板仅指对电子产品电路板PCB文件的提取还原和利用文件进行电路板克隆的过程;从广义上来说,抄板不仅包括对电路板文件提取、电路板克隆、电路板仿制等技术过程,而且包括对电路板文件进行修改(即改板)、对电子产品外形模具进行三维...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Python 植物大战僵尸代码实现(2):植物卡片选择和种植
这篇文章要介绍的是: - 上方植物卡片栏的实现。 - 点击植物卡片,鼠标切换为植物图片。 - 鼠标移动时,判断当前在哪个方格中,并显示半透明的植物作为提示。
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问