Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VK_Video #1245

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ RUN apt-get update && apt-get install -y \
libglu1-mesa-dev \
xorg-dev \
adb \
ninja-build \
software-properties-common

RUN pip3 --no-cache-dir install \
Expand Down
2 changes: 1 addition & 1 deletion assets
Submodule assets updated 42 files
+4 −7 README.md
+ Videos/Holochip640x480.mp4
+0 −8 scenes/Buggy/README.md
+0 −15,818 scenes/Buggy/glTF-Embedded/Buggy.gltf
+ scenes/Buggy/screenshot/screenshot.png
+0 −29 scenes/morpheus_team/LICENSE.txt
+0 −616 scenes/morpheus_team/lego_ball_phone/mlp.json
+0 −140 scenes/morpheus_team/lego_ball_phone/shape0.gltf
+0 −6 scenes/morpheus_team/lego_ball_phone/shape0.mtl
+0 −3 scenes/morpheus_team/lego_ball_phone/shape0.obj
+ scenes/morpheus_team/lego_ball_phone/shape0.pngfeat0.png
+ scenes/morpheus_team/lego_ball_phone/shape0.pngfeat1.png
+0 −616 scenes/morpheus_team/lego_boba_fett_phone/mlp.json
+0 −140 scenes/morpheus_team/lego_boba_fett_phone/shape0.gltf
+0 −6 scenes/morpheus_team/lego_boba_fett_phone/shape0.mtl
+0 −3 scenes/morpheus_team/lego_boba_fett_phone/shape0.obj
+ scenes/morpheus_team/lego_boba_fett_phone/shape0.pngfeat0.png
+ scenes/morpheus_team/lego_boba_fett_phone/shape0.pngfeat1.png
+0 −616 scenes/morpheus_team/lego_monster_truck_phone/mlp.json
+0 −140 scenes/morpheus_team/lego_monster_truck_phone/shape0.gltf
+0 −6 scenes/morpheus_team/lego_monster_truck_phone/shape0.mtl
+0 −3 scenes/morpheus_team/lego_monster_truck_phone/shape0.obj
+ scenes/morpheus_team/lego_monster_truck_phone/shape0.pngfeat0.png
+ scenes/morpheus_team/lego_monster_truck_phone/shape0.pngfeat1.png
+0 −616 scenes/morpheus_team/lego_tractor_phone/mlp.json
+0 −140 scenes/morpheus_team/lego_tractor_phone/shape0.gltf
+0 −6 scenes/morpheus_team/lego_tractor_phone/shape0.mtl
+0 −3 scenes/morpheus_team/lego_tractor_phone/shape0.obj
+ scenes/morpheus_team/lego_tractor_phone/shape0.pngfeat0.png
+ scenes/morpheus_team/lego_tractor_phone/shape0.pngfeat1.png
+0 −11 scenes/pica_pica_robot/license.txt
+ scenes/pica_pica_robot/scene.bin
+0 −1,801 scenes/pica_pica_robot/scene.gltf
+0 −15 scenes/primitives/LICENSE.md
+0 −7 scenes/primitives/README.md
+0 −611 scenes/primitives/primitives.gltf
+0 −2,667 scenes/subpass_scene_opaque.gltf
+0 −665 scenes/subpass_scene_transparent.gltf
+0 −15 scenes/terrain/LICENSE.md
+0 −5 scenes/terrain/README.md
+0 −121 scenes/terrain/terrain.gltf
+ textures/transparent_glass_rgba.ktx
199 changes: 199 additions & 0 deletions samples/extensions/video/CMake/FindFFmpeg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#[==[
Provides the following variables:

* `FFMPEG_INCLUDE_DIRS`: Include directories necessary to use FFMPEG.
* `FFMPEG_LIBRARIES`: Libraries necessary to use FFMPEG. Note that this only
includes libraries for the components requested.
* `FFMPEG_VERSION`: The version of FFMPEG found.

The following components are supported:

* `avcodec`
* `avdevice`
* `avfilter`
* `avformat`
* `avresample`
* `avutil`
* `swresample`
* `swscale`

For each component, the following are provided:

* `FFMPEG_<component>_FOUND`: Libraries for the component.
* `FFMPEG_<component>_INCLUDE_DIRS`: Include directories for
the component.
* `FFMPEG_<component>_LIBRARIES`: Libraries for the component.
* `FFMPEG::<component>`: A target to use with `target_link_libraries`.

Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS`
are guaranteed to set these variables or provide targets.
#]==]

function (_ffmpeg_find component headername)
find_path("FFMPEG_${component}_INCLUDE_DIR"
NAMES
"lib${component}/${headername}"
PATHS
"${FFMPEG_ROOT}/include"
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
PATH_SUFFIXES
ffmpeg
DOC "FFMPEG's ${component} include directory")
mark_as_advanced("FFMPEG_${component}_INCLUDE_DIR")

# On Windows, static FFMPEG is sometimes built as `lib<name>.a`.
if (WIN32)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib")
list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
endif ()

find_library("FFMPEG_${component}_LIBRARY"
NAMES
"${component}"
PATHS
"${FFMPEG_ROOT}/lib"
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
"${FFMPEG_ROOT}/bin"
DOC "FFMPEG's ${component} library")
mark_as_advanced("FFMPEG_${component}_LIBRARY")

if (FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR)
set(_deps_found TRUE)
set(_deps_link)
foreach (_ffmpeg_dep IN LISTS ARGN)
if (TARGET "FFMPEG::${_ffmpeg_dep}")
list(APPEND _deps_link "FFMPEG::${_ffmpeg_dep}")
else ()
set(_deps_found FALSE)
endif ()
endforeach ()
if (_deps_found)
if (NOT TARGET "FFMPEG::${component}")
add_library("FFMPEG::${component}" UNKNOWN IMPORTED)
set_target_properties("FFMPEG::${component}" PROPERTIES
IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}")
endif ()
set("FFMPEG_${component}_FOUND" 1
PARENT_SCOPE)

set(version_header_path "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h")
if (EXISTS "${version_header_path}")
string(TOUPPER "${component}" component_upper)
file(STRINGS "${version_header_path}" version
REGEX "#define *LIB${component_upper}_VERSION_(MAJOR|MINOR|MICRO) ")
string(REGEX REPLACE ".*_MAJOR *\([0-9]*\).*" "\\1" major "${version}")
string(REGEX REPLACE ".*_MINOR *\([0-9]*\).*" "\\1" minor "${version}")
string(REGEX REPLACE ".*_MICRO *\([0-9]*\).*" "\\1" micro "${version}")
if (NOT major STREQUAL "" AND
NOT minor STREQUAL "" AND
NOT micro STREQUAL "")
set("FFMPEG_${component}_VERSION" "${major}.${minor}.${micro}"
PARENT_SCOPE)
endif ()
endif ()
else ()
set("FFMPEG_${component}_FOUND" 0
PARENT_SCOPE)
set(what)
if (NOT FFMPEG_${component}_LIBRARY)
set(what "library")
endif ()
if (NOT FFMPEG_${component}_INCLUDE_DIR)
if (what)
string(APPEND what " or headers")
else ()
set(what "headers")
endif ()
endif ()
set("FFMPEG_${component}_NOT_FOUND_MESSAGE"
"Could not find the ${what} for ${component}."
PARENT_SCOPE)
endif ()
endif ()
endfunction ()

_ffmpeg_find(avutil avutil.h)
_ffmpeg_find(avresample avresample.h
avutil)
_ffmpeg_find(swresample swresample.h
avutil)
_ffmpeg_find(swscale swscale.h
avutil)
_ffmpeg_find(avcodec avcodec.h
avutil)
_ffmpeg_find(avformat avformat.h
avcodec avutil)
_ffmpeg_find(avfilter avfilter.h
avutil)
_ffmpeg_find(avdevice avdevice.h
avformat avutil)

if (TARGET FFMPEG::avutil)
set(_ffmpeg_version_header_path "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h")
if (EXISTS "${_ffmpeg_version_header_path}")
file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version
REGEX "FFMPEG_VERSION")
string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_ffmpeg_version}")
unset(_ffmpeg_version)
else ()
set(FFMPEG_VERSION FFMPEG_VERSION-NOTFOUND)
endif ()
unset(_ffmpeg_version_header_path)
endif ()

set(FFMPEG_INCLUDE_DIRS)
set(FFMPEG_LIBRARIES)
set(_ffmpeg_required_vars)
foreach (_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS)
if (TARGET "FFMPEG::${_ffmpeg_component}")
set(FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS
"${FFMPEG_${_ffmpeg_component}_INCLUDE_DIR}")
set(FFMPEG_${_ffmpeg_component}_LIBRARIES
"${FFMPEG_${_ffmpeg_component}_LIBRARY}")
list(APPEND FFMPEG_INCLUDE_DIRS
"${FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS}")
list(APPEND FFMPEG_LIBRARIES
"${FFMPEG_${_ffmpeg_component}_LIBRARIES}")
if (FFMEG_FIND_REQUIRED_${_ffmpeg_component})
list(APPEND _ffmpeg_required_vars
"FFMPEG_${_ffmpeg_required_vars}_INCLUDE_DIRS"
"FFMPEG_${_ffmpeg_required_vars}_LIBRARIES")
endif ()
endif ()
endforeach ()
unset(_ffmpeg_component)

if (FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFMPEG
REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES ${_ffmpeg_required_vars}
VERSION_VAR FFMPEG_VERSION
HANDLE_COMPONENTS)
unset(_ffmpeg_required_vars)

if(${FFMPEG_avcodec_FOUND})
message(STATUS "FFMPEG found at: ${FFMPEG_LIBRARIES}")
endif ()
41 changes: 41 additions & 0 deletions samples/extensions/video/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2023, Holochip Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/CMake")

find_package(FFmpeg COMPONENTS avcodec avformat)

# FFMPEG is required for THIS sample, but isn't needed for any other.
# FFMPEG can be a fairly large commitment to install on developer's machines, so test for it and only enable this
# if FFMPEG is setup.
# NB: Vulkan Video isn't supported on any mobile device, so no care is given to figure out if we're building on a mobile device and are linking against the host FFMPEG.
if(${FFMPEG_avdevice_FOUND})
get_filename_component(FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_LIST_DIR} PATH)
get_filename_component(CATEGORY_NAME ${PARENT_DIR} NAME)

add_subdirectory(VkCodecUtils)

add_sample(
ID ${FOLDER_NAME}
CATEGORY ${CATEGORY_NAME}
AUTHOR "Holochip"
NAME "video"
DESCRIPTION "Sample description"
LIBS VkCodecUtils
)
endif()
Loading
Loading