├── .gitignore ├── app ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── cpp │ ├── drawer │ │ ├── base_drawer.cpp │ │ ├── base_drawer.h │ │ ├── triangle_drawer.cpp │ │ └── triangle_drawer.h │ ├── egl │ │ ├── egl_core.cpp │ │ ├── egl_core.h │ │ ├── egl_surface.cpp │ │ ├── egl_surface.h │ │ ├── gl_render.cpp │ │ └── gl_render.h │ ├── filter │ │ ├── adjust │ │ │ ├── brightness_filter.cpp │ │ │ ├── brightness_filter.h │ │ │ ├── color_invert_filter.cpp │ │ │ ├── color_invert_filter.h │ │ │ ├── contrast_image_filter.cpp │ │ │ ├── contrast_image_filter.h │ │ │ ├── exposure_filter.cpp │ │ │ ├── exposure_filter.h │ │ │ ├── hue_filter.cpp │ │ │ ├── hue_filter.h │ │ │ ├── saturation_filter.cpp │ │ │ ├── saturation_filter.h │ │ │ ├── sharpen_filter.cpp │ │ │ └── sharpen_filter.h │ │ └── base │ │ │ ├── image_filter.cpp │ │ │ └── image_filter.h │ ├── opengl_demo.cpp │ ├── render │ │ ├── image_render.cpp │ │ └── image_render.h │ └── utils │ │ ├── logger.h │ │ ├── opengl_utils.h │ │ └── stb_image.h │ ├── java │ └── com │ │ └── poney │ │ ├── blogdemo │ │ ├── MainActivity.java │ │ ├── base │ │ │ └── camera │ │ │ │ ├── Camera1Loader.kt │ │ │ │ ├── Camera2Loader.kt │ │ │ │ ├── CameraLoader.kt │ │ │ │ ├── CameraPreview.java │ │ │ │ ├── ImageExt.kt │ │ │ │ └── ViewExt.kt │ │ ├── demo1 │ │ │ ├── DemoActivity.java │ │ │ ├── EGLDemoActivity.java │ │ │ ├── drawer │ │ │ │ ├── BitmapDrawer.kt │ │ │ │ ├── IDrawer.kt │ │ │ │ └── TriangleDrawer.kt │ │ │ └── filter │ │ │ │ └── base │ │ │ │ └── GPUImageFilterType.java │ │ ├── demo2 │ │ │ ├── H264AACFFMpegActivity.kt │ │ │ ├── H264AACMediaCodecActivity.kt │ │ │ ├── H264AsyncMediaCodecActivity.kt │ │ │ └── Mp4MediaCodecActivity.kt │ │ ├── ffplaydemo │ │ │ ├── FFAVPlayerActivity.java │ │ │ └── FFPlayActivity.java │ │ └── mediacodecdemo │ │ │ ├── lib │ │ │ ├── AudioDecoder.java │ │ │ ├── AudioExtractor.java │ │ │ ├── BaseDecoder.java │ │ │ ├── DecodeState.java │ │ │ ├── DecodeType.java │ │ │ ├── IDecoder.java │ │ │ ├── IExtractor.java │ │ │ ├── IStateListener.java │ │ │ ├── MMExtractor.java │ │ │ ├── VideoDecoder.java │ │ │ └── VideoExtractor.java │ │ │ └── play │ │ │ ├── MediaCodecAVActivity.java │ │ │ ├── MediaCodecAVSyncActivity.java │ │ │ └── advance │ │ │ ├── CodecState.java │ │ │ ├── MediaCodecPlayer.java │ │ │ ├── MediaTimeProvider.java │ │ │ ├── NonBlockingAudioTrack.java │ │ │ └── VideoFrameReleaseTimeHelper.java │ │ └── utils │ │ └── AutoFitSurfaceView.kt │ └── res │ ├── color │ ├── selector_image_back.xml │ ├── selector_image_edit.xml │ └── selector_image_edit_yellow.xml │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable-xxhdpi │ ├── edit_bg_adjust_contrast.png │ ├── edit_bg_adjust_contrast_press.png │ ├── edit_bg_adjust_exposure.png │ ├── edit_bg_adjust_exposure_press.png │ ├── edit_bg_adjust_hdr.png │ ├── edit_bg_adjust_hdr_press.png │ ├── edit_bg_adjust_saturation.png │ ├── edit_bg_adjust_saturation_press.png │ ├── edit_bg_adjust_sharpness.png │ ├── edit_bg_adjust_sharpness_press.png │ ├── edit_bg_adjust_vibrance.png │ ├── edit_bg_adjust_vibrance_press.png │ ├── edit_color_hue.png │ └── edit_color_hue_press.png │ ├── drawable │ ├── ic_default.xml │ ├── ic_default_select.xml │ ├── ic_launcher_background.xml │ ├── ic_switch_camera.xml │ ├── selector_image_edit_adjust_bright.xml │ ├── selector_image_edit_adjust_contrast.xml │ ├── selector_image_edit_adjust_default.xml │ ├── selector_image_edit_adjust_exposure.xml │ ├── selector_image_edit_adjust_hue.xml │ ├── selector_image_edit_adjust_saturation.xml │ ├── selector_image_edit_adjust_sharpness.xml │ └── selector_image_edit_adjust_vibrance.xml │ ├── layout │ ├── activity_codec_h_a.xml │ ├── activity_codec_mp4.xml │ ├── activity_demo.xml │ ├── activity_egl_demo.xml │ ├── activity_f_f_a_v_player.xml │ ├── activity_ff_play.xml │ ├── activity_ffmpeg_h_a.xml │ ├── activity_main.xml │ └── activity_media_codec_a_v.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_round.png │ └── icon_default.jpg │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_round.png │ ├── ic_qxx.png │ └── wall.jpg │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── buildv21.gradle ├── common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── poney │ │ └── ffmpeg │ │ ├── base │ │ ├── AbsBaseActivity.java │ │ └── BaseApplication.java │ │ ├── core │ │ └── AppCore.java │ │ ├── task │ │ └── AssertReleaseTask.java │ │ └── utils │ │ ├── ResReadUtils.java │ │ ├── ShaderUtils.java │ │ └── TextureUtils.java │ └── res │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libyuv-single ├── .gitignore ├── build.gradle ├── libs │ └── armeabi-v7a │ │ └── libyuv.so ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ └── include │ │ │ ├── libyuv.h │ │ │ └── libyuv │ │ │ ├── basic_types.h │ │ │ ├── compare.h │ │ │ ├── compare_row.h │ │ │ ├── convert.h │ │ │ ├── convert_argb.h │ │ │ ├── convert_from.h │ │ │ ├── convert_from_argb.h │ │ │ ├── cpu_id.h │ │ │ ├── macros_msa.h │ │ │ ├── mjpeg_decoder.h │ │ │ ├── planar_functions.h │ │ │ ├── rotate.h │ │ │ ├── rotate_argb.h │ │ │ ├── rotate_row.h │ │ │ ├── row.h │ │ │ ├── scale.h │ │ │ ├── scale_argb.h │ │ │ ├── scale_row.h │ │ │ ├── version.h │ │ │ └── video_common.h │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── poney │ └── libyuv │ └── single │ └── ExampleUnitTest.java ├── media ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── cpp │ ├── encode │ │ ├── encode_jpeg.cpp │ │ ├── encode_jpeg.h │ │ ├── encode_mp4.cpp │ │ ├── encode_mp4.h │ │ ├── encode_video.cpp │ │ ├── encode_video.h │ │ ├── logger.h │ │ ├── native_code.cpp │ │ └── native_code.h │ ├── ffmpeg │ │ ├── ffplay_demo.cpp │ │ └── include │ │ │ ├── libavcodec │ │ │ ├── ac3_parser.h │ │ │ ├── adts_parser.h │ │ │ ├── avcodec.h │ │ │ ├── avdct.h │ │ │ ├── avfft.h │ │ │ ├── d3d11va.h │ │ │ ├── dirac.h │ │ │ ├── dv_profile.h │ │ │ ├── dxva2.h │ │ │ ├── jni.h │ │ │ ├── mediacodec.h │ │ │ ├── qsv.h │ │ │ ├── vaapi.h │ │ │ ├── vdpau.h │ │ │ ├── version.h │ │ │ ├── videotoolbox.h │ │ │ ├── vorbis_parser.h │ │ │ └── xvmc.h │ │ │ ├── libavdevice │ │ │ ├── avdevice.h │ │ │ └── version.h │ │ │ ├── libavfilter │ │ │ ├── avfilter.h │ │ │ ├── buffersink.h │ │ │ ├── buffersrc.h │ │ │ └── version.h │ │ │ ├── libavformat │ │ │ ├── avformat.h │ │ │ ├── avio.h │ │ │ └── version.h │ │ │ ├── libavutil │ │ │ ├── adler32.h │ │ │ ├── aes.h │ │ │ ├── aes_ctr.h │ │ │ ├── attributes.h │ │ │ ├── audio_fifo.h │ │ │ ├── avassert.h │ │ │ ├── avconfig.h │ │ │ ├── avstring.h │ │ │ ├── avutil.h │ │ │ ├── base64.h │ │ │ ├── blowfish.h │ │ │ ├── bprint.h │ │ │ ├── bswap.h │ │ │ ├── buffer.h │ │ │ ├── camellia.h │ │ │ ├── cast5.h │ │ │ ├── channel_layout.h │ │ │ ├── common.h │ │ │ ├── cpu.h │ │ │ ├── crc.h │ │ │ ├── des.h │ │ │ ├── dict.h │ │ │ ├── display.h │ │ │ ├── downmix_info.h │ │ │ ├── encryption_info.h │ │ │ ├── error.h │ │ │ ├── eval.h │ │ │ ├── ffversion.h │ │ │ ├── fifo.h │ │ │ ├── file.h │ │ │ ├── frame.h │ │ │ ├── hash.h │ │ │ ├── hdr_dynamic_metadata.h │ │ │ ├── hmac.h │ │ │ ├── hwcontext.h │ │ │ ├── hwcontext_cuda.h │ │ │ ├── hwcontext_d3d11va.h │ │ │ ├── hwcontext_drm.h │ │ │ ├── hwcontext_dxva2.h │ │ │ ├── hwcontext_mediacodec.h │ │ │ ├── hwcontext_qsv.h │ │ │ ├── hwcontext_vaapi.h │ │ │ ├── hwcontext_vdpau.h │ │ │ ├── hwcontext_videotoolbox.h │ │ │ ├── imgutils.h │ │ │ ├── intfloat.h │ │ │ ├── intreadwrite.h │ │ │ ├── lfg.h │ │ │ ├── log.h │ │ │ ├── lzo.h │ │ │ ├── macros.h │ │ │ ├── mastering_display_metadata.h │ │ │ ├── mathematics.h │ │ │ ├── md5.h │ │ │ ├── mem.h │ │ │ ├── motion_vector.h │ │ │ ├── murmur3.h │ │ │ ├── opt.h │ │ │ ├── parseutils.h │ │ │ ├── pixdesc.h │ │ │ ├── pixelutils.h │ │ │ ├── pixfmt.h │ │ │ ├── random_seed.h │ │ │ ├── rational.h │ │ │ ├── rc4.h │ │ │ ├── replaygain.h │ │ │ ├── ripemd.h │ │ │ ├── samplefmt.h │ │ │ ├── sha.h │ │ │ ├── sha512.h │ │ │ ├── spherical.h │ │ │ ├── stereo3d.h │ │ │ ├── tea.h │ │ │ ├── threadmessage.h │ │ │ ├── time.h │ │ │ ├── timecode.h │ │ │ ├── timestamp.h │ │ │ ├── tree.h │ │ │ ├── twofish.h │ │ │ ├── tx.h │ │ │ ├── version.h │ │ │ └── xtea.h │ │ │ ├── libpostproc │ │ │ ├── postprocess.h │ │ │ └── version.h │ │ │ ├── libswresample │ │ │ ├── swresample.h │ │ │ └── version.h │ │ │ └── libswscale │ │ │ ├── swscale.h │ │ │ └── version.h │ ├── sdl2 │ │ └── include │ │ │ ├── SDL.h │ │ │ ├── SDL_assert.h │ │ │ ├── SDL_atomic.h │ │ │ ├── SDL_audio.h │ │ │ ├── SDL_bits.h │ │ │ ├── SDL_blendmode.h │ │ │ ├── SDL_clipboard.h │ │ │ ├── SDL_config.h │ │ │ ├── SDL_config.h.cmake │ │ │ ├── SDL_config.h.in │ │ │ ├── SDL_config_android.h │ │ │ ├── SDL_config_iphoneos.h │ │ │ ├── SDL_config_macosx.h │ │ │ ├── SDL_config_minimal.h │ │ │ ├── SDL_config_pandora.h │ │ │ ├── SDL_config_psp.h │ │ │ ├── SDL_config_windows.h │ │ │ ├── SDL_config_winrt.h │ │ │ ├── SDL_config_wiz.h │ │ │ ├── SDL_copying.h │ │ │ ├── SDL_cpuinfo.h │ │ │ ├── SDL_egl.h │ │ │ ├── SDL_endian.h │ │ │ ├── SDL_error.h │ │ │ ├── SDL_events.h │ │ │ ├── SDL_filesystem.h │ │ │ ├── SDL_gamecontroller.h │ │ │ ├── SDL_gesture.h │ │ │ ├── SDL_haptic.h │ │ │ ├── SDL_hints.h │ │ │ ├── SDL_joystick.h │ │ │ ├── SDL_keyboard.h │ │ │ ├── SDL_keycode.h │ │ │ ├── SDL_loadso.h │ │ │ ├── SDL_log.h │ │ │ ├── SDL_main.h │ │ │ ├── SDL_messagebox.h │ │ │ ├── SDL_mouse.h │ │ │ ├── SDL_mutex.h │ │ │ ├── SDL_name.h │ │ │ ├── SDL_opengl.h │ │ │ ├── SDL_opengl_glext.h │ │ │ ├── SDL_opengles.h │ │ │ ├── SDL_opengles2.h │ │ │ ├── SDL_opengles2_gl2.h │ │ │ ├── SDL_opengles2_gl2ext.h │ │ │ ├── SDL_opengles2_gl2platform.h │ │ │ ├── SDL_opengles2_khrplatform.h │ │ │ ├── SDL_pixels.h │ │ │ ├── SDL_platform.h │ │ │ ├── SDL_power.h │ │ │ ├── SDL_quit.h │ │ │ ├── SDL_rect.h │ │ │ ├── SDL_render.h │ │ │ ├── SDL_revision.h │ │ │ ├── SDL_rwops.h │ │ │ ├── SDL_scancode.h │ │ │ ├── SDL_shape.h │ │ │ ├── SDL_stdinc.h │ │ │ ├── SDL_surface.h │ │ │ ├── SDL_system.h │ │ │ ├── SDL_syswm.h │ │ │ ├── SDL_test.h │ │ │ ├── SDL_test_assert.h │ │ │ ├── SDL_test_common.h │ │ │ ├── SDL_test_compare.h │ │ │ ├── SDL_test_crc32.h │ │ │ ├── SDL_test_font.h │ │ │ ├── SDL_test_fuzzer.h │ │ │ ├── SDL_test_harness.h │ │ │ ├── SDL_test_images.h │ │ │ ├── SDL_test_log.h │ │ │ ├── SDL_test_md5.h │ │ │ ├── SDL_test_memory.h │ │ │ ├── SDL_test_random.h │ │ │ ├── SDL_thread.h │ │ │ ├── SDL_timer.h │ │ │ ├── SDL_touch.h │ │ │ ├── SDL_types.h │ │ │ ├── SDL_version.h │ │ │ ├── SDL_video.h │ │ │ ├── SDL_vulkan.h │ │ │ ├── begin_code.h │ │ │ └── close_code.h │ └── utils │ │ ├── const.h │ │ ├── logger.h │ │ └── timer.c │ ├── java │ └── com │ │ └── poney │ │ └── ffmpeg │ │ ├── audio │ │ └── AudioRecordLoader.java │ │ ├── encoder │ │ ├── AACMediaCodecEncoder.java │ │ ├── EncoderCallback.java │ │ ├── H264FFMPEGEncoder.java │ │ ├── H264MediaCodecAsyncEncoder.java │ │ ├── H264MediaCodecEncoder.java │ │ ├── MediaEncoder.java │ │ └── Mp4MediaCodecRecord.java │ │ └── play │ │ ├── FFUtils.java │ │ └── FFVideoView.java │ ├── jniLibs │ └── armeabi-v7a │ │ ├── libavcodec.so │ │ ├── libavdevice.so │ │ ├── libavfilter.so │ │ ├── libavformat.so │ │ ├── libavutil.so │ │ ├── libpostproc.so │ │ ├── libswresample.so │ │ └── libswscale.so │ └── res │ └── values │ └── strings.xml ├── pdf └── opengles20-reference-card.pdf ├── sdl2-hello ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── libs │ └── armeabi-v7a │ │ └── libSDL2.so ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── input.bmp │ ├── cpp │ ├── include │ │ ├── SDL.h │ │ ├── SDL_assert.h │ │ ├── SDL_atomic.h │ │ ├── SDL_audio.h │ │ ├── SDL_bits.h │ │ ├── SDL_blendmode.h │ │ ├── SDL_clipboard.h │ │ ├── SDL_config.h │ │ ├── SDL_config.h.cmake │ │ ├── SDL_config.h.in │ │ ├── SDL_config_android.h │ │ ├── SDL_config_iphoneos.h │ │ ├── SDL_config_macosx.h │ │ ├── SDL_config_minimal.h │ │ ├── SDL_config_pandora.h │ │ ├── SDL_config_psp.h │ │ ├── SDL_config_windows.h │ │ ├── SDL_config_winrt.h │ │ ├── SDL_config_wiz.h │ │ ├── SDL_copying.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_egl.h │ │ ├── SDL_endian.h │ │ ├── SDL_error.h │ │ ├── SDL_events.h │ │ ├── SDL_filesystem.h │ │ ├── SDL_gamecontroller.h │ │ ├── SDL_gesture.h │ │ ├── SDL_haptic.h │ │ ├── SDL_hints.h │ │ ├── SDL_joystick.h │ │ ├── SDL_keyboard.h │ │ ├── SDL_keycode.h │ │ ├── SDL_loadso.h │ │ ├── SDL_log.h │ │ ├── SDL_main.h │ │ ├── SDL_messagebox.h │ │ ├── SDL_mouse.h │ │ ├── SDL_mutex.h │ │ ├── SDL_name.h │ │ ├── SDL_opengl.h │ │ ├── SDL_opengl_glext.h │ │ ├── SDL_opengles.h │ │ ├── SDL_opengles2.h │ │ ├── SDL_opengles2_gl2.h │ │ ├── SDL_opengles2_gl2ext.h │ │ ├── SDL_opengles2_gl2platform.h │ │ ├── SDL_opengles2_khrplatform.h │ │ ├── SDL_pixels.h │ │ ├── SDL_platform.h │ │ ├── SDL_power.h │ │ ├── SDL_quit.h │ │ ├── SDL_rect.h │ │ ├── SDL_render.h │ │ ├── SDL_revision.h │ │ ├── SDL_rwops.h │ │ ├── SDL_scancode.h │ │ ├── SDL_shape.h │ │ ├── SDL_stdinc.h │ │ ├── SDL_surface.h │ │ ├── SDL_system.h │ │ ├── SDL_syswm.h │ │ ├── SDL_test.h │ │ ├── SDL_test_assert.h │ │ ├── SDL_test_common.h │ │ ├── SDL_test_compare.h │ │ ├── SDL_test_crc32.h │ │ ├── SDL_test_font.h │ │ ├── SDL_test_fuzzer.h │ │ ├── SDL_test_harness.h │ │ ├── SDL_test_images.h │ │ ├── SDL_test_log.h │ │ ├── SDL_test_md5.h │ │ ├── SDL_test_memory.h │ │ ├── SDL_test_random.h │ │ ├── SDL_thread.h │ │ ├── SDL_timer.h │ │ ├── SDL_touch.h │ │ ├── SDL_types.h │ │ ├── SDL_version.h │ │ ├── SDL_video.h │ │ ├── SDL_vulkan.h │ │ ├── begin_code.h │ │ └── close_code.h │ └── sdl2_hello.c │ ├── java │ ├── com │ │ └── poney │ │ │ └── sdl2 │ │ │ └── hello │ │ │ └── SDLHelloActivity.java │ └── org │ │ └── libsdl │ │ └── app │ │ ├── SDL.java │ │ ├── SDLActivity.java │ │ ├── SDLAudioManager.java │ │ └── SDLControllerManager.java │ └── res │ ├── layout │ └── activity_sdl_hello.xml │ └── values │ └── strings.xml ├── settings.gradle └── source ├── cuc_ieschool.mp4 └── mvtest.mp4 /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | android { 5 | compileSdkVersion 29 6 | buildToolsVersion "30.0.2" 7 | 8 | defaultConfig { 9 | applicationId "com.poney.blogdemo" 10 | minSdkVersion 21 11 | targetSdkVersion 29 12 | versionCode 1 13 | versionName "1.0" 14 | externalNativeBuild { 15 | cmake { 16 | cppFlags "" 17 | } 18 | ndk { 19 | abiFilters "armeabi-v7a" 20 | } 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | externalNativeBuild { 31 | cmake { 32 | path "CMakeLists.txt" 33 | version "3.10.2" 34 | } 35 | } 36 | 37 | 38 | compileOptions { 39 | sourceCompatibility JavaVersion.VERSION_1_8 40 | targetCompatibility JavaVersion.VERSION_1_8 41 | } 42 | } 43 | 44 | dependencies { 45 | implementation fileTree(dir: "libs", include: ["*.jar"]) 46 | implementation 'androidx.appcompat:appcompat:1.2.0' 47 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 48 | implementation dependenciesConfig.butterknife 49 | implementation dependenciesConfig.rxpermissions 50 | implementation dependenciesConfig.rxjava 51 | implementation dependenciesConfig.rxandroid 52 | 53 | 54 | annotationProcessor dependenciesConfig.butterknifeannotation 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 56 | implementation project(path: ':media') 57 | 58 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/cpp/drawer/base_drawer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/16. 3 | // 4 | 5 | #include "base_drawer.h" 6 | #include "../utils/logger.h" 7 | #include 8 | 9 | BaseDrawer::BaseDrawer() { 10 | 11 | } 12 | 13 | BaseDrawer::~BaseDrawer() { 14 | 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/drawer/base_drawer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/12. 3 | // 4 | 5 | #ifndef BLOGDEMO_BASE_DRAWER_H 6 | #define BLOGDEMO_BASE_DRAWER_H 7 | 8 | #include 9 | #include "../utils/opengl_utils.h" 10 | 11 | class BaseDrawer { 12 | protected: 13 | const char *TAG = "BaseDrawer"; 14 | GLuint m_program_id = 0; 15 | 16 | //顶点坐标接收者 17 | GLint m_vertex_pos_handler = -1; 18 | 19 | //纹理坐标接收者 20 | GLint m_texture_pos_handler = -1; 21 | 22 | //纹理接收者 23 | GLint m_texture_handler = -1; 24 | 25 | 26 | public: 27 | 28 | BaseDrawer(); 29 | 30 | ~BaseDrawer(); 31 | 32 | virtual void OnInit() = 0; 33 | 34 | virtual void Release() = 0; 35 | 36 | virtual void DoDraw(int textureId, void *vertexPos, void *texturePos) = 0; 37 | 38 | virtual const GLchar *GetVertexShader() = 0; 39 | 40 | virtual const GLchar *GetFragmentShader() = 0; 41 | 42 | }; 43 | 44 | 45 | #endif //BLOGDEMO_BASE_DRAWER_H 46 | -------------------------------------------------------------------------------- /app/src/main/cpp/drawer/triangle_drawer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/12. 3 | // 4 | 5 | #include "triangle_drawer.h" 6 | #include "../utils/logger.h" 7 | 8 | TriangleDrawer::TriangleDrawer() { 9 | 10 | } 11 | 12 | TriangleDrawer::~TriangleDrawer() { 13 | 14 | } 15 | 16 | void TriangleDrawer::OnInit() { 17 | //创建程序 18 | m_program_id = OpenGLUtils::CreateProgram(GetVertexShader(), GetFragmentShader()); 19 | m_vertex_pos_handler = glGetAttribLocation(m_program_id, "aPosition"); 20 | } 21 | 22 | 23 | void TriangleDrawer::Release() { 24 | glDisableVertexAttribArray(m_vertex_pos_handler); 25 | glBindTexture(GL_TEXTURE_2D, 0); 26 | glDeleteProgram(m_program_id); 27 | } 28 | 29 | void TriangleDrawer::DoDraw(int textureId, void *vertexPos, void *texturePos) { 30 | //启用顶点的句柄 31 | glEnableVertexAttribArray(m_vertex_pos_handler); 32 | glVertexAttribPointer(m_vertex_pos_handler, 3, GL_FLOAT, GL_FALSE, 0, m_vertex_coors); 33 | //开始绘制 34 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); 35 | 36 | } 37 | 38 | const char *TriangleDrawer::GetVertexShader() { 39 | return "attribute vec4 aPosition; \n" 40 | "void main() \n" 41 | "{ \n" 42 | " gl_Position = aPosition; \n" 43 | "} \n";; 44 | } 45 | 46 | const char *TriangleDrawer::GetFragmentShader() { 47 | return "precision mediump float; \n" 48 | "void main() \n" 49 | "{ \n" 50 | " gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 ); \n" 51 | "} \n"; 52 | } -------------------------------------------------------------------------------- /app/src/main/cpp/drawer/triangle_drawer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/12. 3 | // 4 | 5 | #ifndef BLOGDEMO_TRIANGLE_DRAWER_H 6 | #define BLOGDEMO_TRIANGLE_DRAWER_H 7 | 8 | 9 | #include "base_drawer.h" 10 | #include 11 | 12 | class TriangleDrawer : public BaseDrawer { 13 | private: 14 | const char *TAG = "TriangleDrawer"; 15 | 16 | const GLfloat m_vertex_coors[9] = { 17 | -0.5f, -0.5f, 0.0f,//左下 18 | 0.5f, -0.5f, 0.0f,//右下 19 | 0.0f, 0.5f, 0.0f//上 20 | }; 21 | 22 | 23 | public: 24 | TriangleDrawer(); 25 | 26 | ~TriangleDrawer(); 27 | 28 | 29 | void Release() override; 30 | 31 | void DoDraw(int textureId, void *vertexPos, void *texturePos) override; 32 | 33 | void OnInit() override; 34 | 35 | const GLchar *GetVertexShader() override; 36 | 37 | const GLchar *GetFragmentShader() override; 38 | }; 39 | 40 | 41 | #endif //BLOGDEMO_TRIANGLE_DRAWER_H 42 | -------------------------------------------------------------------------------- /app/src/main/cpp/egl/egl_core.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/9/16. 3 | // 4 | 5 | #ifndef WHEAT_EGL_CORE_H 6 | #define WHEAT_EGL_CORE_H 7 | 8 | extern "C" { 9 | #include 10 | #include 11 | }; 12 | 13 | class EglCore { 14 | private: 15 | const char *TAG = "EglCore"; 16 | //EGL显示窗口 17 | EGLDisplay m_egl_dsp = EGL_NO_DISPLAY; 18 | //EGL上下文 19 | EGLContext m_egl_context = EGL_NO_CONTEXT; 20 | //EGL配置 21 | EGLConfig m_egl_config; 22 | 23 | EGLConfig GetEGLConfig(); 24 | 25 | public: 26 | EglCore(); 27 | 28 | ~EglCore(); 29 | 30 | bool Init(EGLContext share_ctx); 31 | 32 | //根据比例窗口创建显示表面 33 | EGLSurface CreateWindSurface(ANativeWindow *window); 34 | 35 | EGLSurface CreateOffScreenSurface(int width, int height); 36 | 37 | //将OpenGL上下文与当前线程绑定 38 | void MakeCurrent(EGLSurface egl_surface); 39 | 40 | //将缓存数据交换至前台显示 41 | void SwapBuffer(EGLSurface egl_surface); 42 | 43 | //释放显示 44 | void DestroySurface(EGLSurface egl_surface); 45 | 46 | //释放EGL 47 | void Release(); 48 | }; 49 | 50 | 51 | #endif //WHEAT_EGL_CORE_H 52 | -------------------------------------------------------------------------------- /app/src/main/cpp/egl/egl_surface.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/9/16. 3 | // 4 | 5 | #include "egl_surface.h" 6 | #include "../utils/logger.h" 7 | 8 | EglSurface::EglSurface() { 9 | m_core = new EglCore(); 10 | } 11 | 12 | EglSurface::~EglSurface() { 13 | delete m_core; 14 | } 15 | 16 | bool EglSurface::Init() { 17 | return m_core->Init(NULL); 18 | } 19 | /** 20 | * 21 | * @param native_window 传入上一步创建的ANativeWindow 22 | * @param width 23 | * @param height 24 | */ 25 | void EglSurface::CreateEglSurface(ANativeWindow *native_window, int width, int height) { 26 | if (native_window != NULL) { 27 | this->m_native_window = native_window; 28 | m_surface = m_core->CreateWindSurface(m_native_window); 29 | } else { 30 | m_surface = m_core->CreateOffScreenSurface(width, height); 31 | } 32 | if (m_surface == NULL) { 33 | LOGE(TAG, "EGL create window surface fail") 34 | Release(); 35 | } 36 | MakeCurrent(); 37 | } 38 | 39 | void EglSurface::MakeCurrent() { 40 | m_core->MakeCurrent(m_surface); 41 | } 42 | 43 | void EglSurface::SwapBuffers() { 44 | m_core->SwapBuffer(m_surface); 45 | } 46 | 47 | void EglSurface::DestroyEglSurface() { 48 | if (m_surface != NULL) { 49 | if (m_core != NULL) { 50 | m_core->DestroySurface(m_surface); 51 | } 52 | m_surface = NULL; 53 | } 54 | } 55 | 56 | void EglSurface::Release() { 57 | DestroyEglSurface(); 58 | if (m_core != NULL) { 59 | m_core->Release(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/cpp/egl/egl_surface.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/9/16. 3 | // 4 | #include 5 | #include "egl_core.h" 6 | 7 | #ifndef WHEAT_EGL_SURFACE_H 8 | #define WHEAT_EGL_SURFACE_H 9 | 10 | 11 | class EglSurface { 12 | private: 13 | const char *TAG = "EglSurface"; 14 | 15 | ANativeWindow *m_native_window = NULL; 16 | 17 | EglCore *m_core; 18 | 19 | EGLSurface m_surface; 20 | public: 21 | EglSurface(); 22 | ~EglSurface(); 23 | 24 | bool Init(); 25 | void CreateEglSurface(ANativeWindow *native_window, int width, int height); 26 | void MakeCurrent(); 27 | void SwapBuffers(); 28 | void DestroyEglSurface(); 29 | void Release(); 30 | }; 31 | 32 | 33 | #endif //WHEAT_EGL_SURFACE_H 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/egl/gl_render.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/9/16. 3 | // 4 | 5 | #ifndef WHEAT_OPENGL_RENDER_H 6 | #define WHEAT_OPENGL_RENDER_H 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "egl_surface.h" 15 | #include "../render/image_render.h" 16 | 17 | class GLRender { 18 | private: 19 | 20 | const char *TAG = "GLRender"; 21 | 22 | //OpenGL渲染状态 23 | enum STATE { 24 | NO_SURFACE, //没有有效的surface 25 | FRESH_SURFACE, //持有一个为初始化的新的surface 26 | RENDERING, //初始化完毕,可以开始渲染 27 | SURFACE_DESTROY, //surface销毁 28 | STOP //停止绘制 29 | }; 30 | 31 | JNIEnv *m_env = NULL; 32 | 33 | //线程依附的jvm环境 34 | JavaVM *m_jvm_for_thread = NULL; 35 | 36 | //Surface引用,必须要使用引用,否则无法在线程中操作 37 | jobject m_surface_ref = NULL; 38 | 39 | //本地屏幕 40 | ANativeWindow *m_native_window = NULL; 41 | 42 | //EGL显示表面 43 | EglSurface *m_egl_surface = NULL; 44 | 45 | int m_window_width = 0; 46 | int m_window_height = 0; 47 | // 绘制代理器 48 | ImageRender *pImageRender = NULL; 49 | 50 | STATE m_state = NO_SURFACE; 51 | 52 | // 初始化相关的方法 53 | void InitRenderThread(); 54 | 55 | bool InitEGL(); 56 | 57 | void InitDspWindow(JNIEnv *env); 58 | 59 | // 创建/销毁 Surface 60 | void CreateSurface(); 61 | 62 | 63 | void DestroySurface(); 64 | 65 | // 渲染方法 66 | void Render(); 67 | 68 | void ReleaseSurface(); 69 | 70 | void ReleaseWindow(); 71 | 72 | // 渲染线程回调方法 73 | static void sRenderThread(std::shared_ptr that); 74 | 75 | public: 76 | GLRender(JNIEnv *env); 77 | 78 | ~GLRender(); 79 | 80 | void SetSurface(jobject surface); 81 | 82 | void SetOffScreenSize(int width, int height); 83 | 84 | void Stop(); 85 | 86 | void SetBitmapRender(ImageRender *bitmapRender); 87 | 88 | 89 | // 释放资源相关方法 90 | void ReleaseRender(); 91 | 92 | ImageRender *GetImageRender(); 93 | }; 94 | 95 | 96 | #endif //WHEAT_OPENGL_RENDER_H 97 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/brightness_filter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/29. 3 | // 4 | 5 | #include "brightness_filter.h" 6 | 7 | void BrightnessFilter::OnInit() { 8 | ImageFilter::OnInit(); 9 | m_brightnessLocation = glGetUniformLocation(m_program_id, "brightness"); 10 | setValue(m_brightness); 11 | } 12 | 13 | const GLchar *BrightnessFilter::GetFragmentShader() { 14 | return "" 15 | "varying highp vec2 textureCoordinate;\n" 16 | " \n" 17 | " uniform sampler2D inputImageTexture;\n" 18 | " uniform lowp float brightness;\n" 19 | " \n" 20 | " void main()\n" 21 | " {\n" 22 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" 23 | " \n" 24 | " gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);\n" 25 | " }"; 26 | 27 | } 28 | 29 | void BrightnessFilter::setValue(float value) { 30 | m_brightness = value; 31 | setFloat(m_brightnessLocation, m_brightness); 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/brightness_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/29. 3 | // 4 | 5 | #ifndef BLOGDEMO_BRIGHTNESS_FILTER_H 6 | #define BLOGDEMO_BRIGHTNESS_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class BrightnessFilter : public ImageFilter { 12 | private: 13 | int m_brightnessLocation; 14 | float m_brightness = 0.0f; 15 | public: 16 | virtual void OnInit(); 17 | 18 | virtual const GLchar *GetFragmentShader(); 19 | 20 | void setValue(float value); 21 | }; 22 | 23 | 24 | #endif //BLOGDEMO_BRIGHTNESS_FILTER_H 25 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/color_invert_filter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #include "color_invert_filter.h" 6 | 7 | 8 | const GLchar *ColorInvertImageFilter::GetVertexShader() { 9 | return ImageFilter::GetVertexShader(); 10 | } 11 | 12 | const GLchar *ColorInvertImageFilter::GetFragmentShader() { 13 | return "" 14 | "varying highp vec2 textureCoordinate;\n" 15 | "\n" 16 | "uniform sampler2D inputImageTexture;\n" 17 | "\n" 18 | "void main()\n" 19 | "{\n" 20 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" 21 | " \n" 22 | " gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);\n" 23 | "}";; 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/color_invert_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #ifndef BLOGDEMO_COLOR_INVERT_FILTER_H 6 | #define BLOGDEMO_COLOR_INVERT_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class ColorInvertImageFilter : public ImageFilter { 12 | public: 13 | 14 | virtual const GLchar *GetVertexShader(); 15 | 16 | virtual const GLchar *GetFragmentShader(); 17 | }; 18 | 19 | 20 | #endif //BLOGDEMO_COLOR_INVERT_FILTER_H 21 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/contrast_image_filter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #include "contrast_image_filter.h" 6 | 7 | 8 | void ContrastImageFilter::OnInit() { 9 | ImageFilter::OnInit(); 10 | m_contrastLocation = glGetUniformLocation(m_program_id, "m_contrast"); 11 | setValue(m_contrast); 12 | } 13 | 14 | const GLchar *ContrastImageFilter::GetFragmentShader() { 15 | return "" 16 | "varying highp vec2 textureCoordinate;\n" 17 | " \n" 18 | " uniform sampler2D inputImageTexture;\n" 19 | " uniform lowp float m_contrast;\n" 20 | " \n" 21 | " void main()\n" 22 | " {\n" 23 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" 24 | " \n" 25 | " gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * m_contrast + vec3(0.5)), textureColor.w);\n" 26 | " }"; 27 | 28 | } 29 | 30 | void ContrastImageFilter::setValue(float contrast) { 31 | m_contrast = contrast; 32 | setFloat(m_contrastLocation, contrast); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/contrast_image_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #ifndef BLOGDEMO_CONTRAST_IMAGE_FILTER_H 6 | #define BLOGDEMO_CONTRAST_IMAGE_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class ContrastImageFilter : public ImageFilter { 12 | private: 13 | int m_contrastLocation; 14 | float m_contrast = 1.2f; 15 | public: 16 | 17 | virtual void OnInit(); 18 | 19 | virtual const GLchar *GetFragmentShader(); 20 | 21 | void setValue(float contrast); 22 | }; 23 | 24 | 25 | #endif //BLOGDEMO_CONTRAST_IMAGE_FILTER_H 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/exposure_filter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #include "exposure_filter.h" 6 | 7 | void ExposureFilter::OnInit() { 8 | ImageFilter::OnInit(); 9 | m_exposureLocation = glGetUniformLocation(m_program_id, "exposure"); 10 | setValue(m_exposure); 11 | } 12 | 13 | const GLchar *ExposureFilter::GetFragmentShader() { 14 | return "" 15 | " varying highp vec2 textureCoordinate;\n" 16 | " \n" 17 | " uniform sampler2D inputImageTexture;\n" 18 | " uniform highp float exposure;\n" 19 | " \n" 20 | " void main()\n" 21 | " {\n" 22 | " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" 23 | " \n" 24 | " gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);\n" 25 | " } "; 26 | } 27 | 28 | void ExposureFilter::setValue(float exposure) { 29 | m_exposure = exposure; 30 | setFloat(m_exposureLocation, m_exposure); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/exposure_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #ifndef BLOGDEMO_EXPOSURE_FILTER_H 6 | #define BLOGDEMO_EXPOSURE_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class ExposureFilter : public ImageFilter { 12 | private: 13 | int m_exposureLocation; 14 | float m_exposure = 1.0f; 15 | 16 | public: 17 | 18 | virtual void OnInit(); 19 | 20 | virtual const GLchar *GetFragmentShader(); 21 | 22 | void setValue(float exposure); 23 | }; 24 | 25 | 26 | #endif //BLOGDEMO_EXPOSURE_FILTER_H 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/hue_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/30. 3 | // 4 | 5 | #ifndef BLOGDEMO_HUE_FILTER_H 6 | #define BLOGDEMO_HUE_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class HueFilter : public ImageFilter { 12 | private: 13 | int m_hue_location; 14 | float m_hue = 90.0f; 15 | 16 | public: 17 | 18 | virtual void OnInit(); 19 | 20 | virtual const GLchar *GetFragmentShader(); 21 | 22 | void setValue(float hue); 23 | }; 24 | 25 | 26 | #endif //BLOGDEMO_HUE_FILTER_H 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/saturation_filter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/29. 3 | // 4 | 5 | #include "saturation_filter.h" 6 | 7 | void SaturationFilter::OnInit() { 8 | ImageFilter::OnInit(); 9 | m_saturationLocation = glGetUniformLocation(m_program_id, "saturation"); 10 | setValue(m_saturation); 11 | } 12 | 13 | const GLchar *SaturationFilter::GetFragmentShader() { 14 | return "" 15 | " varying highp vec2 textureCoordinate;\n" 16 | " \n" 17 | " uniform sampler2D inputImageTexture;\n" 18 | " uniform lowp float saturation;\n" 19 | " \n" 20 | " // Values from \"Graphics Shaders: Theory and Practice\" by Bailey and Cunningham\n" 21 | " const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n" 22 | " \n" 23 | " void main()\n" 24 | " {\n" 25 | " lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" 26 | " lowp float luminance = dot(textureColor.rgb, luminanceWeighting);\n" 27 | " lowp vec3 greyScaleColor = vec3(luminance);\n" 28 | " \n" 29 | " gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);\n" 30 | " \n" 31 | " }";; 32 | } 33 | 34 | void SaturationFilter::setValue(float saturation) { 35 | m_saturation = saturation; 36 | setFloat(m_saturationLocation, m_saturation); 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/saturation_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/29. 3 | // 4 | 5 | #ifndef BLOGDEMO_SATURATION_FILTER_H 6 | #define BLOGDEMO_SATURATION_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class SaturationFilter : public ImageFilter { 12 | private: 13 | int m_saturationLocation; 14 | float m_saturation = 1.0f; 15 | 16 | public: 17 | virtual void OnInit(); 18 | 19 | virtual const GLchar *GetFragmentShader(); 20 | 21 | void setValue(float saturation); 22 | }; 23 | 24 | 25 | #endif //BLOGDEMO_SATURATION_FILTER_H 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/adjust/sharpen_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/11/3. 3 | // 4 | 5 | #ifndef BLOGDEMO_SHARPEN_FILTER_H 6 | #define BLOGDEMO_SHARPEN_FILTER_H 7 | 8 | 9 | #include "../base/image_filter.h" 10 | 11 | class SharpenFilter : public ImageFilter { 12 | private: 13 | int m_sharpnessLocation; 14 | float m_sharpness = 0.0f; 15 | int imageWidthFactorLocation; 16 | int imageHeightFactorLocation; 17 | 18 | public: 19 | virtual void OnInit(); 20 | 21 | virtual const GLchar *GetFragmentShader(); 22 | 23 | void setValue(float saturation); 24 | 25 | virtual const GLchar *GetVertexShader(); 26 | 27 | virtual void onOutputSizeChanged(int width, int height); 28 | 29 | 30 | }; 31 | 32 | 33 | #endif //BLOGDEMO_SHARPEN_FILTER_H 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/base/image_filter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #include "image_filter.h" 6 | 7 | void ImageFilter::setFloat(int location, float floatValue) { 8 | glUniform1f(location, floatValue); 9 | } 10 | 11 | void ImageFilter::OnInit() { 12 | if (!isInitialized) { 13 | m_program_id = OpenGLUtils::CreateProgram(GetVertexShader(), GetFragmentShader()); 14 | m_vertex_pos_handler = glGetAttribLocation(m_program_id, "position"); 15 | m_texture_pos_handler = glGetAttribLocation(m_program_id, "inputTextureCoordinate"); 16 | m_texture_handler = glGetUniformLocation(m_program_id, "inputImageTexture"); 17 | isInitialized = true; 18 | } 19 | 20 | } 21 | 22 | void ImageFilter::Release() { 23 | isInitialized = false; 24 | glDeleteProgram(m_program_id); 25 | } 26 | 27 | void ImageFilter::DoDraw(int textureId, void *vertexPos, void *texturePos) { 28 | //启用顶点的句柄 29 | glEnableVertexAttribArray(m_vertex_pos_handler); 30 | glEnableVertexAttribArray(m_texture_pos_handler); 31 | //设置着色器参数 32 | // glUniformMatrix4fv(m_vertex_matrix_handler, 1, false, m_matrix, 0); 33 | glVertexAttribPointer(m_vertex_pos_handler, 3, GL_FLOAT, GL_FALSE, 0, vertexPos); 34 | glVertexAttribPointer(m_texture_pos_handler, 2, GL_FLOAT, GL_FALSE, 0, texturePos); 35 | //开始绘制 36 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 37 | } 38 | 39 | const GLchar *ImageFilter::GetVertexShader() { 40 | return 41 | "attribute vec4 position;\n" 42 | "attribute vec4 inputTextureCoordinate;\n" 43 | " \n" 44 | "varying vec2 textureCoordinate;\n" 45 | " \n" 46 | "void main()\n" 47 | "{\n" 48 | " gl_Position = position;\n" 49 | " textureCoordinate = inputTextureCoordinate.xy;\n" 50 | "}"; 51 | } 52 | 53 | const GLchar *ImageFilter::GetFragmentShader() { 54 | 55 | return "precision mediump float;\n" 56 | "varying highp vec2 textureCoordinate;\n" 57 | " \n" 58 | "uniform sampler2D inputImageTexture;\n" 59 | " \n" 60 | "void main()\n" 61 | "{\n" 62 | " gl_FragColor = texture2D(inputImageTexture, textureCoordinate);\n" 63 | "}"; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/cpp/filter/base/image_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/28. 3 | // 4 | 5 | #ifndef BLOGDEMO_IMAGE_FILTER_H 6 | #define BLOGDEMO_IMAGE_FILTER_H 7 | 8 | 9 | #include "../../drawer/base_drawer.h" 10 | 11 | class ImageFilter : public BaseDrawer { 12 | private : 13 | bool isInitialized; 14 | protected: 15 | void setFloat(int location, float floatValue); 16 | 17 | public: 18 | virtual void OnInit(); 19 | 20 | virtual void Release(); 21 | 22 | virtual void DoDraw(int textureId, void *vertexPos, void *texturePos); 23 | 24 | virtual const GLchar *GetVertexShader(); 25 | 26 | virtual const GLchar *GetFragmentShader(); 27 | }; 28 | 29 | 30 | #endif //BLOGDEMO_IMAGE_FILTER_H 31 | -------------------------------------------------------------------------------- /app/src/main/cpp/render/image_render.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by poney.ma on 2020/10/16. 3 | // 4 | 5 | #ifndef BLOGDEMO_IMAGE_RENDER_H 6 | #define BLOGDEMO_IMAGE_RENDER_H 7 | 8 | 9 | #include "../drawer/base_drawer.h" 10 | #include "../filter/base/image_filter.h" 11 | 12 | class ImageRender { 13 | private: 14 | const char *TAG = "ImageRender"; 15 | int m_origin_width = 0; 16 | 17 | int m_origin_height = 0; 18 | 19 | 20 | int m_output_width = 0; 21 | 22 | int m_output_height = 0; 23 | 24 | 25 | //顶点坐标 26 | GLfloat m_vertex_coors[12] = { 27 | -1.0f, -1.0f, 0.0f,//左下 28 | 1.0f, -1.0f, 0.0f,//右下 29 | -1.0f, 1.0f, 0.0f,//左上 30 | 1.0f, 1.0f, 0.0f//右上 31 | }; 32 | 33 | //纹理坐标 34 | GLfloat m_texture_coors[8] = { 35 | 0.0f, 1.0f, 36 | 1.0f, 1.0f, 37 | 0.0f, 0.0f, 38 | 1.0f, 0.0f 39 | }; 40 | 41 | // 自定义用户数据,可用于存放画面数据 42 | void *cst_data = NULL; 43 | 44 | ImageFilter *m_filter; 45 | 46 | 47 | GLuint m_texture_id = 0; 48 | 49 | public: 50 | ImageRender(int origin_width, int origin_height, void *p); 51 | 52 | ~ImageRender(); 53 | 54 | 55 | void AdjustImageScale(); 56 | 57 | void OnOutputSizeChanged(int outputWidth, int outputHeight); 58 | 59 | float addDistance(const GLfloat d, float horizontal); 60 | 61 | void ResetTextureCoors(); 62 | 63 | void DoDraw(); 64 | 65 | void Release(); 66 | 67 | ImageFilter *getFilter() const; 68 | 69 | void setFilter(ImageFilter *mFilter); 70 | 71 | bool isReadyToDraw(); 72 | 73 | bool texture_loaded; 74 | }; 75 | 76 | 77 | #endif //BLOGDEMO_IMAGE_RENDER_H 78 | -------------------------------------------------------------------------------- /app/src/main/cpp/utils/logger.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by cxp on 2019-07-31. 3 | // 4 | 5 | #ifndef LEARNVIDEO_LOGGER_H 6 | #define LEARNVIDEO_LOGGER_H 7 | 8 | #include 9 | 10 | #define LOG 11 | 12 | #ifdef LOG 13 | #define LOGD(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_DEBUG,TAG,FORMAT,##__VA_ARGS__); 14 | #define LOGI(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_INFO,TAG,FORMAT,##__VA_ARGS__); 15 | #define LOGW(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_WARN,TAG,FORMAT,##__VA_ARGS__); 16 | #define LOGE(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_ERROR,TAG,FORMAT,##__VA_ARGS__); 17 | 18 | #define LOG_INFO(TAG, SPEC, FMT, ...) LOGI(TAG, "[%s] " FMT, SPEC, ##__VA_ARGS__) 19 | #define LOG_ERROR(TAG, SPEC, FMT, ...) LOGE(TAG, "[%s] " FMT, SPEC, ##__VA_ARGS__) 20 | #else 21 | #define LOGD(TAG, FORMAT,...); 22 | #define LOGI(TAG, FORMAT,...); 23 | #define LOGW(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_WARN,TAG,FORMAT,##__VA_ARGS__); 24 | #define LOGE(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_ERROR,TAG,FORMAT,##__VA_ARGS__); 25 | #endif 26 | 27 | #endif //LEARNVIDEO_LOGGER_H 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/base/camera/CameraLoader.kt: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.base.camera 2 | 3 | import android.view.SurfaceHolder 4 | 5 | 6 | abstract class CameraLoader { 7 | 8 | protected var onPreviewFrame: ((data: ByteArray, width: Int, height: Int) -> Unit)? = null 9 | 10 | abstract fun onResume(width: Int, height: Int) 11 | 12 | abstract fun setPreview(holder: SurfaceHolder) 13 | 14 | abstract fun onPause() 15 | 16 | abstract fun switchCamera() 17 | 18 | abstract fun getCameraOrientation(): Int 19 | 20 | abstract fun hasMultipleCamera(): Boolean 21 | 22 | fun setOnPreviewFrameListener(onPreviewFrame: (data: ByteArray, width: Int, height: Int) -> Unit) { 23 | this.onPreviewFrame = onPreviewFrame 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/base/camera/CameraPreview.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.base.camera; 2 | 3 | import android.content.Context; 4 | import android.view.SurfaceHolder; 5 | import android.view.SurfaceView; 6 | 7 | /** 8 | * camera预览视图 9 | */ 10 | public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback { 11 | private SurfaceHolder mHolder; 12 | 13 | public CameraPreview(Context context) { 14 | super(context); 15 | mHolder = getHolder(); 16 | mHolder.addCallback(this); 17 | mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 18 | } 19 | 20 | @Override 21 | public void surfaceCreated(SurfaceHolder holder) { 22 | } 23 | 24 | 25 | @Override 26 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { 27 | 28 | } 29 | 30 | @Override 31 | public void surfaceDestroyed(SurfaceHolder holder) { 32 | } 33 | 34 | 35 | } -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/base/camera/ImageExt.kt: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.base.camera 2 | 3 | import android.graphics.ImageFormat 4 | import android.media.Image 5 | import android.os.Build 6 | import androidx.annotation.RequiresApi 7 | 8 | @RequiresApi(Build.VERSION_CODES.LOLLIPOP) 9 | fun Image.generateNV21Data(): ByteArray { 10 | val crop = cropRect 11 | val format = format 12 | val width = crop.width() 13 | val height = crop.height() 14 | val planes = planes 15 | val data = ByteArray(width * height * ImageFormat.getBitsPerPixel(format) / 8) 16 | val rowData = ByteArray(planes[0].rowStride) 17 | var channelOffset = 0 18 | var outputStride = 1 19 | for (i in planes.indices) { 20 | when (i) { 21 | 0 -> { 22 | channelOffset = 0 23 | outputStride = 1 24 | } 25 | 1 -> { 26 | channelOffset = width * height + 1 27 | outputStride = 2 28 | } 29 | 2 -> { 30 | channelOffset = width * height 31 | outputStride = 2 32 | } 33 | } 34 | val buffer = planes[i].buffer 35 | val rowStride = planes[i].rowStride 36 | val pixelStride = planes[i].pixelStride 37 | val shift = if (i == 0) 0 else 1 38 | val w = width shr shift 39 | val h = height shr shift 40 | buffer.position(rowStride * (crop.top shr shift) + pixelStride * (crop.left shr shift)) 41 | for (row in 0 until h) { 42 | val length: Int 43 | if (pixelStride == 1 && outputStride == 1) { 44 | length = w 45 | buffer.get(data, channelOffset, length) 46 | channelOffset += length 47 | } else { 48 | length = (w - 1) * pixelStride + 1 49 | buffer.get(rowData, 0, length) 50 | for (col in 0 until w) { 51 | data[channelOffset] = rowData[col * pixelStride] 52 | channelOffset += outputStride 53 | } 54 | } 55 | if (row < h - 1) { 56 | buffer.position(buffer.position() + rowStride - length) 57 | } 58 | } 59 | } 60 | return data 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/base/camera/ViewExt.kt: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.base.camera 2 | 3 | import android.view.View 4 | import androidx.core.view.ViewCompat 5 | 6 | inline fun View.doOnLayout(crossinline action: (view: View) -> Unit) { 7 | if (ViewCompat.isLaidOut(this) && !isLayoutRequested) { 8 | action(this) 9 | } else { 10 | doOnNextLayout { action(it) } 11 | } 12 | } 13 | 14 | inline fun View.doOnNextLayout(crossinline action: (view: View) -> Unit) { 15 | addOnLayoutChangeListener(object : View.OnLayoutChangeListener { 16 | override fun onLayoutChange( 17 | view: View, 18 | left: Int, 19 | top: Int, 20 | right: Int, 21 | bottom: Int, 22 | oldLeft: Int, 23 | oldTop: Int, 24 | oldRight: Int, 25 | oldBottom: Int 26 | ) { 27 | view.removeOnLayoutChangeListener(this) 28 | action(view) 29 | } 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/demo1/drawer/IDrawer.kt: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.demo1.drawer 2 | 3 | interface IDrawer { 4 | fun draw() 5 | fun release() 6 | } -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/demo1/filter/base/GPUImageFilterType.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.demo1.filter.base; 2 | 3 | /** 4 | * Created by why8222 on 2016/2/25. 5 | */ 6 | public enum GPUImageFilterType { 7 | NONE, 8 | //image adjust 9 | INVERT, 10 | CONTRAST, 11 | BRIGHTNESS, 12 | EXPOSURE, 13 | HUE, 14 | SATURATION, 15 | SHARPEN 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/ffplaydemo/FFAVPlayerActivity.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.ffplaydemo; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | 7 | import com.poney.blogdemo.R; 8 | 9 | /** 10 | * FFMpeg音视频同步播放 11 | */ 12 | public class FFAVPlayerActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_f_f_a_v_player); 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/ffplaydemo/FFPlayActivity.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.ffplaydemo; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | import android.os.Environment; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | import com.poney.blogdemo.R; 11 | import com.poney.ffmpeg.play.FFUtils; 12 | import com.poney.ffmpeg.play.FFVideoView; 13 | 14 | /** 15 | * FFMpeg 仅视频播放 16 | */ 17 | public class FFPlayActivity extends AppCompatActivity { 18 | private TextView mTextView; 19 | private FFVideoView mVideoView; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_ff_play); 25 | 26 | mTextView = findViewById(R.id.sample_text); 27 | mVideoView = findViewById(R.id.videoView); 28 | } 29 | 30 | public void onButtonClick(View view) { 31 | int id = view.getId(); 32 | 33 | switch (id) { 34 | case R.id.button_protocol: 35 | setInfoText(FFUtils.urlProtocolInfo()); 36 | break; 37 | case R.id.button_codec: 38 | setInfoText(FFUtils.avCodecInfo()); 39 | break; 40 | case R.id.button_filter: 41 | setInfoText(FFUtils.avFilterInfo()); 42 | break; 43 | case R.id.button_format: 44 | setInfoText(FFUtils.avFormatInfo()); 45 | break; 46 | case R.id.button_play: 47 | String videoPath = Environment.getExternalStorageDirectory() + "/killer.mp4"; 48 | 49 | mVideoView.playVideo(videoPath); 50 | break; 51 | } 52 | } 53 | 54 | private void setInfoText(String content) { 55 | if (mTextView != null) { 56 | mTextView.setText(content); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/AudioExtractor.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | import android.media.MediaFormat; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | /** 8 | * @author poney.ma 9 | * @project BlogDemo 10 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 11 | * @date 2021/1/5 12 | */ 13 | public class AudioExtractor implements IExtractor { 14 | private MMExtractor mmExtractor; 15 | 16 | public AudioExtractor(String path) { 17 | this.mmExtractor = new MMExtractor(path); 18 | } 19 | 20 | 21 | @Override 22 | public MediaFormat getFormat() { 23 | return mmExtractor.getAudioFormat(); 24 | } 25 | 26 | @Override 27 | public int readBuffer(ByteBuffer byteBuffer) { 28 | return mmExtractor.readBuffer(byteBuffer); 29 | } 30 | 31 | @Override 32 | public long getCurrentTimeStamp() { 33 | return mmExtractor.getCurSampleTime(); 34 | } 35 | 36 | @Override 37 | public long seek(long pos) { 38 | return mmExtractor.seek(pos); 39 | } 40 | 41 | @Override 42 | public void setStartPos(long pos) { 43 | mmExtractor.setStartPos(pos); 44 | } 45 | 46 | @Override 47 | public void stop() { 48 | mmExtractor.stop(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/DecodeState.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | /** 4 | * @author poney.ma 5 | * @project BlogDemo 6 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 7 | * @date 2021/1/4 8 | */ 9 | public enum DecodeState { 10 | /**开始状态*/ 11 | START, 12 | /**解码中*/ 13 | DECODING, 14 | /**解码暂停*/ 15 | PAUSE, 16 | /**正在快进*/ 17 | SEEKING, 18 | /**解码完成*/ 19 | FINISH, 20 | /**解码器释放*/ 21 | STOP 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/DecodeType.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | /** 4 | * @author poney.ma 5 | * @project BlogDemo 6 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 7 | * @date 2021/1/4 8 | */ 9 | public enum DecodeType { 10 | /** 11 | * 未知 12 | */ 13 | UNKNOWN, 14 | /** 15 | * 音频 16 | */ 17 | AUDIO, 18 | /** 19 | * 视频 20 | */ 21 | VIDEO 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/IDecoder.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | /** 4 | * @author poney.ma 5 | * @project BlogDemo 6 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 7 | * @date 2021/1/4 8 | */ 9 | public interface IDecoder extends Runnable { 10 | //继续解码 11 | void resume(); 12 | 13 | //暂停解码 14 | void pause(); 15 | 16 | //停止解码 17 | void stop(); 18 | 19 | //是否正在解码 20 | boolean isDecoding(); 21 | 22 | //是否正在快进 23 | boolean isSeeking(); 24 | 25 | //是否停止解码 26 | boolean isStop(); 27 | 28 | void setStateListener(IStateListener stateListener); 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/IExtractor.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | import android.media.MediaFormat; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | /** 8 | * @author poney.ma 9 | * @project BlogDemo 10 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 11 | * @date 2021/1/4 12 | */ 13 | public interface IExtractor { 14 | //获取音视频格式参数 15 | MediaFormat getFormat(); 16 | 17 | //读取音视频数据 18 | int readBuffer(ByteBuffer byteBuffer); 19 | 20 | //获取当前帧时间 21 | long getCurrentTimeStamp(); 22 | 23 | //Seek到指定位置,并返回实际帧的时间戳 24 | long seek(long pos); 25 | 26 | void setStartPos(long pos); 27 | 28 | //停止读取数据 29 | void stop(); 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/IStateListener.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | /** 4 | * @author poney.ma 5 | * @project BlogDemo 6 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 7 | * @date 2021/1/4 8 | */ 9 | public interface IStateListener { 10 | void decoderPrepare(BaseDecoder baseDecoder); 11 | void decoderReady(BaseDecoder baseDecoder); 12 | void decoderRunning(BaseDecoder baseDecoder); 13 | void decoderPause(BaseDecoder baseDecoder); 14 | void decoderFinish(BaseDecoder baseDecoder); 15 | void decoderDestroy(BaseDecoder baseDecoder); 16 | void decoderError(BaseDecoder baseDecoder, String reason); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/lib/VideoExtractor.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.lib; 2 | 3 | import android.media.MediaFormat; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | /** 8 | * @author poney.ma 9 | * @project BlogDemo 10 | * @package_name com.poney.blogdemo.mediacodecdemo.lib 11 | * @date 2021/1/5 12 | */ 13 | public class VideoExtractor implements IExtractor { 14 | private MMExtractor mmExtractor; 15 | 16 | public VideoExtractor(String path) { 17 | this.mmExtractor = new MMExtractor(path); 18 | } 19 | 20 | 21 | @Override 22 | public MediaFormat getFormat() { 23 | return mmExtractor.getVideoFormat(); 24 | } 25 | 26 | @Override 27 | public int readBuffer(ByteBuffer byteBuffer) { 28 | return mmExtractor.readBuffer(byteBuffer); 29 | } 30 | 31 | @Override 32 | public long getCurrentTimeStamp() { 33 | return mmExtractor.getCurSampleTime(); 34 | } 35 | 36 | @Override 37 | public long seek(long pos) { 38 | return mmExtractor.seek(pos); 39 | } 40 | 41 | @Override 42 | public void setStartPos(long pos) { 43 | mmExtractor.setStartPos(pos); 44 | } 45 | 46 | @Override 47 | public void stop() { 48 | mmExtractor.stop(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/poney/blogdemo/mediacodecdemo/play/advance/MediaTimeProvider.java: -------------------------------------------------------------------------------- 1 | package com.poney.blogdemo.mediacodecdemo.play.advance; 2 | 3 | /* 4 | * Interface used by CodecState to retrieve Media timing info from parent Player 5 | */ 6 | public interface MediaTimeProvider { 7 | public long getNowUs(); 8 | public long getRealTimeUsForMediaTime(long mediaTimeUs); 9 | public long getVsyncDurationNs(); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/res/color/selector_image_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/color/selector_image_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/color/selector_image_edit_yellow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_contrast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_contrast.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_contrast_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_contrast_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_exposure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_exposure.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_exposure_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_exposure_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_hdr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_hdr.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_hdr_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_hdr_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_saturation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_saturation.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_saturation_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_saturation_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_sharpness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_sharpness.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_sharpness_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_sharpness_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_vibrance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_vibrance.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_bg_adjust_vibrance_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_bg_adjust_vibrance_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_color_hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_color_hue.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/edit_color_hue_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoveWFan/BlogDemo/798df321acb14f7e7aa991f2bafca45164b489ae/app/src/main/res/drawable-xxhdpi/edit_color_hue_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_default.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_default_select.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_switch_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_bright.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_contrast.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_exposure.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_hue.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_saturation.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_sharpness.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_edit_adjust_vibrance.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_codec_h_a.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 21 | 22 |