1 Star 0 Fork 1

小飞not/ffmpeg_sample-H264_to_cv-Mat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
H264Decoder_jni.cpp 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
hiro 提交于 2017-06-30 09:39 . add jni support
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class H264Decoder */
#include "H264Decoder.h"
#ifndef _Included_H264Decoder
#define _Included_H264Decoder
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: H264Decoder
* Method: nativeH264init
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_H264Decoder_nativeH264init
(JNIEnv *env, jobject){
jlong result = (jlong)new H264Decoder();
return result;
}
/*
* Class: H264Decoder
* Method: nativeH264decode
* Signature: (J[BI)[B
*/
JNIEXPORT jbyteArray JNICALL Java_H264Decoder_nativeH264decode
(JNIEnv *env, jobject jobj, jlong thiz, jbyteArray frm, jint jlen){
H264Decoder * decoder = ((H264Decoder*)thiz);
int len = jlen;// jint is long in C++,
jbyte* bBuffer = env->GetByteArrayElements(frm,NULL);//remeber to get element
unsigned char * buf = (unsigned char *)bBuffer;
decoder->decode(buf,len);
cv::Mat result = decoder->getMat();
if(result.data!=nullptr){
int offset = sizeof(int)/sizeof(unsigned char);
offset*=2;
int matSize[2]= {result.rows,result.cols};
int size = result.total()*result.elemSize();
jbyteArray resultArray = env->NewByteArray(size+offset);
jbyte* array = env->GetByteArrayElements(resultArray,JNI_FALSE);
memcpy(array,matSize,sizeof(matSize));
memcpy(array+offset,result.data,size);
env->ReleaseByteArrayElements(resultArray,array,JNI_FALSE);
return resultArray;
}
else{
return nullptr;
}
}
#ifdef __cplusplus
}
#endif
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiaofeinot/ffmpeg_sample-H264_to_cv-Mat.git
git@gitee.com:xiaofeinot/ffmpeg_sample-H264_to_cv-Mat.git
xiaofeinot
ffmpeg_sample-H264_to_cv-Mat
ffmpeg_sample-H264_to_cv-Mat
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385