ffmpeg解码后的视频帧怎样显示出来
1个回答
展开全部
贴你一段代码,希望有用
[mw_shl_code=cpp,true]
static Surface* getNativeSurface(JNIEnv* env, jobject jsurface) {
jclass clazz = env->FindClass("android/view/Surface");
if(clazz == NULL){
return NULL;
}
jfieldID field_surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");//env->GetFieldID(clazz, "mSurface", "I");
if(field_surface == NULL) {
return NULL;
}
return (Surface *) env->GetIntField(jsurface, field_surface);
}
static int initBitmap(SkBitmap *bitmap, int format, int width, int height, bool allocPixels) {
switch (format) {
case PIXEL_FORMAT_RGBA_8888:
bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
break;
case PIXEL_FORMAT_RGBA_4444:
bitmap->setConfig(SkBitmap::kARGB_4444_Config, width, height);
break;
case PIXEL_FORMAT_RGB_565:
bitmap->setConfig(SkBitmap::kRGB_565_Config, width, height);
break;
case PIXEL_FORMAT_A_8:
bitmap->setConfig(SkBitmap::kA8_Config, width, height);
break;
default:
bitmap->setConfig(SkBitmap::kNo_Config, width, height);
break;
}
if(allocPixels) {
bitmap->setIsOpaque(true);
//-- alloc array of pixels
if(!bitmap->allocPixels()) {
return -1;
}
}
return 0;
}
int AndroidSurface_register(JNIEnv* env, jobject jsurface) {
__android_log_print(ANDROID_LOG_INFO, TAG, "registering video surface");
sSurface = getNativeSurface(env, jsurface);
if(sSurface == NULL) {
return ANDROID_SURFACE_RESULT_JNI_EXCEPTION;
}
__android_log_print(ANDROID_LOG_INFO, TAG, "registered");
return ANDROID_SURFACE_RESULT_SUCCESS
[mw_shl_code=cpp,true]
static Surface* getNativeSurface(JNIEnv* env, jobject jsurface) {
jclass clazz = env->FindClass("android/view/Surface");
if(clazz == NULL){
return NULL;
}
jfieldID field_surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");//env->GetFieldID(clazz, "mSurface", "I");
if(field_surface == NULL) {
return NULL;
}
return (Surface *) env->GetIntField(jsurface, field_surface);
}
static int initBitmap(SkBitmap *bitmap, int format, int width, int height, bool allocPixels) {
switch (format) {
case PIXEL_FORMAT_RGBA_8888:
bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
break;
case PIXEL_FORMAT_RGBA_4444:
bitmap->setConfig(SkBitmap::kARGB_4444_Config, width, height);
break;
case PIXEL_FORMAT_RGB_565:
bitmap->setConfig(SkBitmap::kRGB_565_Config, width, height);
break;
case PIXEL_FORMAT_A_8:
bitmap->setConfig(SkBitmap::kA8_Config, width, height);
break;
default:
bitmap->setConfig(SkBitmap::kNo_Config, width, height);
break;
}
if(allocPixels) {
bitmap->setIsOpaque(true);
//-- alloc array of pixels
if(!bitmap->allocPixels()) {
return -1;
}
}
return 0;
}
int AndroidSurface_register(JNIEnv* env, jobject jsurface) {
__android_log_print(ANDROID_LOG_INFO, TAG, "registering video surface");
sSurface = getNativeSurface(env, jsurface);
if(sSurface == NULL) {
return ANDROID_SURFACE_RESULT_JNI_EXCEPTION;
}
__android_log_print(ANDROID_LOG_INFO, TAG, "registered");
return ANDROID_SURFACE_RESULT_SUCCESS
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询