Skip to content

Commit

Permalink
* Add presets for NVIDIA Video Codec SDK 11.0.10 (pull #1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
devjeonghwan committed Mar 25, 2021
1 parent f46fa02 commit eb6ca2c
Show file tree
Hide file tree
Showing 170 changed files with 16,451 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/nvcodec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: nvcodec
on:
push:
paths:
- nvcodec/**
pull_request:
paths:
- nvcodec/**
workflow_dispatch:
env:
CI_DEPLOY_NEED_CUDA: 1
CI_DEPLOY_MODULE: ${{ github.workflow }}
CI_DEPLOY_PLATFORM: ${{ github.job }}
CI_DEPLOY_SETTINGS: ${{ secrets.CI_DEPLOY_SETTINGS }}
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
STAGING_REPOSITORY: ${{ secrets.STAGING_REPOSITORY }}
jobs:
linux-x86_64:
runs-on: ubuntu-16.04
container: centos:6
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
windows-x86_64:
runs-on: windows-2019
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions
redeploy:
needs: [linux-x86_64, windows-x86_64]
runs-on: ubuntu-16.04
steps:
- uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add presets for NVIDIA Video Codec SDK 11.0.x ([pull #1020](https://github.com/bytedeco/javacpp-presets/pull/1020))
* Map `std::vector<cv::Range>` to `RangeVector` in `opencv_core.Mat` for convenience ([issue bytedeco/javacv#1607](https://github.com/bytedeco/javacv/issues/1607))
* Include `genericaliasobject.h`, `context.h`, `tracemalloc.h`, and `datetime.h` for CPython ([issue #1017](https://github.com/bytedeco/javacpp-presets/issues/1017))
* Add samples using LLVM modules to deal with bitcode and object files ([pull #1016](https://github.com/bytedeco/javacpp-presets/pull/1016))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ JavaCPP Presets
[![caffe](https://github.com/bytedeco/javacpp-presets/workflows/caffe/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Acaffe)
[![openpose](https://github.com/bytedeco/javacpp-presets/workflows/openpose/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aopenpose)
[![cuda](https://github.com/bytedeco/javacpp-presets/workflows/cuda/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Acuda)
[![nvcodec](https://github.com/bytedeco/javacpp-presets/workflows/nvcodec/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Anvcodec)
[![opencl](https://github.com/bytedeco/javacpp-presets/workflows/opencl/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aopencl)
[![mxnet](https://github.com/bytedeco/javacpp-presets/workflows/mxnet/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Amxnet)
[![tensorflow](https://github.com/bytedeco/javacpp-presets/workflows/tensorflow/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Atensorflow)
Expand Down Expand Up @@ -200,6 +201,7 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip
* CUDA 11.2.x https://developer.nvidia.com/cuda-downloads
* cuDNN 8.1.x https://developer.nvidia.com/cudnn
* NCCL 2.8.x https://developer.nvidia.com/nccl
* NVIDIA Video Codec SDK 11.0.x https://developer.nvidia.com/nvidia-video-codec-sdk
* OpenCL 3.0 https://github.com/KhronosGroup/OpenCL-ICD-Loader
* MXNet 1.8.0 https://github.com/apache/incubator-mxnet
* TensorFlow 1.15.x https://github.com/tensorflow/tensorflow
Expand Down
2 changes: 1 addition & 1 deletion cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function sedinplace {
}

if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe openpose cuda opencl mxnet tensorflow tensorrt ale onnx ngraph onnxruntime tvm liquidfun qt skia cpu_features systems)
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe openpose cuda nvcodec opencl mxnet tensorflow tensorrt ale onnx ngraph onnxruntime tvm liquidfun qt skia cpu_features systems)
fi

for PROJECT in ${PROJECTS[@]}; do
Expand Down
128 changes: 128 additions & 0 deletions nvcodec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
JavaCPP Presets for NVIDIA Video Codec SDK
==========================================

[![Gitter](https://badges.gitter.im/bytedeco/javacpp.svg)](https://gitter.im/bytedeco/javacpp) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/nvcodec/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/nvcodec) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.bytedeco/nvcodec.svg)](http://bytedeco.org/builds/)
<sup>Build status for all platforms:</sup> [![nvcodec](https://github.com/bytedeco/javacpp-presets/workflows/nvcodec/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Anvcodec) <sup>Commercial support:</sup> [![xscode](https://img.shields.io/badge/Available%20on-xs%3Acode-blue?style=?style=plastic&logo=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////////VXz1bAAAAAJ0Uk5T/wDltzBKAAAAlUlEQVR42uzXSwqAMAwE0Mn9L+3Ggtgkk35QwcnSJo9S+yGwM9DCooCbgn4YrJ4CIPUcQF7/XSBbx2TEz4sAZ2q1RAECBAiYBlCtvwN+KiYAlG7UDGj59MViT9hOwEqAhYCtAsUZvL6I6W8c2wcbd+LIWSCHSTeSAAECngN4xxIDSK9f4B9t377Wd7H5Nt7/Xz8eAgwAvesLRjYYPuUAAAAASUVORK5CYII=)](https://xscode.com/bytedeco/javacpp-presets)


License Agreements
------------------
By downloading these archives, you agree to the terms of the license agreements for NVIDIA software included in the archives.

### NVIDIA Video Codec SDK
To view the license for NVIDIA Video Codec SDK included in these archives, click [here](https://docs.nvidia.com/video-technologies/video-codec-sdk/license/)


Introduction
------------
This directory contains the JavaCPP Presets module for:

* NVIDIA Video Codec SDK 11.0.10 https://developer.nvidia.com/nvidia-video-codec-sdk

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.


Documentation
-------------
Java API documentation is available here:

* http://bytedeco.org/javacpp-presets/nvcodec/apidocs/


Sample Usage
------------
Here is a simple example ported to Java from C code based on `Samples/AppEncode/AppEncCuda` and `Samples/AppDecode/AppDec` included in `Video_Codec_SDK_11.0.10.zip` available at:

* https://developer.nvidia.com/nvidia-video-codec-sdk/download

We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `SampleEncodeDecode.java` source files below, simply execute on the command line:
```bash
$ mvn compile exec:java
```
You can find more encoder and decoder samples in the [`samples`](samples) subdirectory.

### The `pom.xml` build file
```xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.nvcodec</groupId>
<artifactId>sampleencodedecode</artifactId>
<version>1.5.6-SNAPSHOT</version>
<properties>
<exec.mainClass>SampleEncodeDecode</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>nvcodec-platform</artifactId>
<version>11.0.10-1.5.6-SNAPSHOT</version>
</dependency>

<!-- Additional dependencies to use bundled CUDA -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>cuda-platform-redist</artifactId>
<version>11.2-8.1-1.5.6-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>.</sourceDirectory>
</build>
</project>
```

### The `SampleEncodeDecode.java` source file
```java
import org.bytedeco.cuda.cudart.CUctx_st;
import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.nvcodec.nvcuvid.CUVIDDECODECAPS;

import static org.bytedeco.cuda.global.cudart.*;
import static org.bytedeco.nvcodec.global.nvcuvid.*;
import static org.bytedeco.nvcodec.global.nvencodeapi.*;

public class SampleEncodeDecode {
public static void checkEncodeApiCall(String functionName, int result) {
if (result != NV_ENC_SUCCESS) {
System.err.printf("ERROR: %s returned '%d' \r\n", functionName, result);
System.exit(-1);
}
}

public static void checkCudaApiCall(String functionName, int result) {
if (result != CUDA_SUCCESS) {
System.err.printf("ERROR: %s returned '%d' \r\n", functionName, result);
System.exit(-1);
}
}

public static void main(String[] args) {
int targetGpu = 0; // If you use NVIDIA GPU not '0', changing it.

CUctx_st cuContext = new CUctx_st();

checkCudaApiCall("cuInit", cuInit(0));
checkCudaApiCall("cuCtxCreate", cuCtxCreate(cuContext, 0, targetGpu));
// Check encoder max supported version
{
IntPointer version = new IntPointer(1);

checkEncodeApiCall("NvEncodeAPIGetMaxSupportedVersion", NvEncodeAPIGetMaxSupportedVersion(version));

System.out.printf("Encoder Max Supported Version\t : %d \r\n", version.get());
}

// Query decoder capability 'MPEG-1' codec
{
CUVIDDECODECAPS decodeCaps = new CUVIDDECODECAPS();
decodeCaps.eCodecType(cudaVideoCodec_HEVC);
decodeCaps.eChromaFormat(cudaVideoChromaFormat_420);
decodeCaps.nBitDepthMinus8(2); // 10 bit

checkCudaApiCall("cuvidGetDecoderCaps", cuvidGetDecoderCaps(decodeCaps));

System.out.printf("Decoder Capability MPEG-1 Codec\t : %s \r\n", (decodeCaps.bIsSupported() != 0));
}
}
}
```
28 changes: 28 additions & 0 deletions nvcodec/cppbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# This file is meant to be included by the parent cppbuild.sh script
if [[ -z "$PLATFORM" ]]; then
pushd ..
bash cppbuild.sh "$@" nvcodec
popd
exit
fi

case $PLATFORM in
linux-x86_64)
if [[ ! -d "/usr/local/videocodecsdk/" ]]; then
echo "Please install the Video Codec SDK in /usr/local/videocodecsdk/"
exit 1
fi
;;
windows-x86_64)
if [[ ! -d "C:/Program Files/NVIDIA GPU Computing Toolkit/VideoCodecSDK/" ]]; then
echo "Please install the Video Codec SDK in C:/Program Files/NVIDIA GPU Computing Toolkit/VideoCodecSDK/"
exit 1
fi
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
;;
esac

cd ../..
115 changes: 115 additions & 0 deletions nvcodec/platform/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-presets</artifactId>
<version>1.5.6-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<groupId>org.bytedeco</groupId>
<artifactId>nvcodec-platform</artifactId>
<version>11.0.10-${project.parent.version}</version>
<name>JavaCPP Presets Platform for NVIDIA Video Codec SDK</name>

<properties>
<javacpp.moduleId>nvcodec</javacpp.moduleId>
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>cuda-platform</artifactId>
<version>11.2-8.1-${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.windows-x86_64}</classifier>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<configuration>
<archive>
<manifestEntries>
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-windows-x86_64.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
<execution>
<id>empty-javadoc-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>javadoc</classifier>
</configuration>
</execution>
<execution>
<id>empty-sources-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>sources</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>none</phase>
</execution>
<execution>
<id>add-platform-module-info</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<modules>
<module>
<file>${project.build.directory}/${project.artifactId}.jar</file>
<moduleInfoSource>
module org.bytedeco.${javacpp.moduleId}.platform {
requires static org.bytedeco.${javacpp.moduleId}.linux.x86_64;
requires static org.bytedeco.${javacpp.moduleId}.windows.x86_64;
}
</moduleInfoSource>
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit eb6ca2c

Please sign in to comment.