TRACE_WRAPPER PP_Resource trace_ppb_graphics3d_create(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]) { trace_info("[PPB] {full} %s intance=%d, share_context=%d, attrib_list={TODO}\n", __func__+6, instance, share_context); return ppb_graphics3d_create(instance, share_context, attrib_list); }
PP_Resource ppb_video_decoder_create(PP_Instance instance, PP_Resource context, PP_VideoDecoder_Profile profile) { if (!config.enable_hwdec) { trace_info_f(" hardware-accelerated decoding was disabled in config file\n"); return 0; } if (!display.va_available) { trace_info_f(" no hw acceleration available\n"); return 0; } if (!display.glXBindTexImageEXT) { trace_info_f(" no glXBindTexImageEXT available\n"); return 0; } switch (profile) { case PP_VIDEODECODER_H264PROFILE_BASELINE: case PP_VIDEODECODER_H264PROFILE_MAIN: case PP_VIDEODECODER_H264PROFILE_EXTENDED: case PP_VIDEODECODER_H264PROFILE_HIGH: // pass, there is an implementation below break; case PP_VIDEODECODER_H264PROFILE_NONE: case PP_VIDEODECODER_H264PROFILE_HIGH10PROFILE: case PP_VIDEODECODER_H264PROFILE_HIGH422PROFILE: case PP_VIDEODECODER_H264PROFILE_HIGH444PREDICTIVEPROFILE: case PP_VIDEODECODER_H264PROFILE_SCALABLEBASELINE: case PP_VIDEODECODER_H264PROFILE_SCALABLEHIGH: case PP_VIDEODECODER_H264PROFILE_STEREOHIGH: case PP_VIDEODECODER_H264PROFILE_MULTIVIEWHIGH: case PP_VIDEODECODER_VP8PROFILE_ANY: case PP_VIDEODECODER_PROFILE_UNKNOWN: default: trace_error("%s, profile %d is not supported\n", __func__, profile); return 0; } const struct PPP_VideoDecoder_Dev_0_11 *ppp_video_decoder_dev = NULL; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } ppp_video_decoder_dev = ppp_get_interface(PPP_VIDEODECODER_DEV_INTERFACE); if (!ppp_video_decoder_dev) { trace_error("%s, no viable %s\n", __func__, PPP_VIDEODECODER_DEV_INTERFACE); return 0; } if (pp_resource_get_type(context) != PP_RESOURCE_GRAPHICS3D) { trace_error("%s, bad resource\n", __func__); return 0; } PP_Resource video_decoder = pp_resource_allocate(PP_RESOURCE_VIDEO_DECODER, pp_i); struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER); if (!vd) { trace_error("%s, resource allocation failed\n", __func__); return 0; } vd->orig_graphics3d = pp_resource_ref(context); vd->ppp_video_decoder_dev = ppp_video_decoder_dev; // create auxiliary GL context int32_t attribs[] = { PP_GRAPHICS3DATTRIB_WIDTH, 32, // dimensions can be arbitrary PP_GRAPHICS3DATTRIB_HEIGHT, 32, PP_GRAPHICS3DATTRIB_RED_SIZE, 8, PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8, PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8, PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 16, GLX_Y_INVERTED_EXT, True, GLX_BIND_TO_TEXTURE_RGBA_EXT, True, PP_GRAPHICS3DATTRIB_NONE, }; vd->graphics3d = ppb_graphics3d_create(vd->instance->id, vd->orig_graphics3d, attribs); if (!vd->graphics3d) { trace_error("%s, can't create graphics3d context\n", __func__); goto err_1; } vd->codec_id = AV_CODEC_ID_H264; // TODO: other codecs vd->avcodec = avcodec_find_decoder(vd->codec_id); if (!vd->avcodec) { trace_error("%s, can't create codec\n", __func__); goto err_1; } vd->avparser = av_parser_init(vd->codec_id); if (!vd->avparser) { trace_error("%s, can't create parser\n", __func__); goto err_1; } vd->avctx = avcodec_alloc_context3(vd->avcodec); if (!vd->avctx) { trace_error("%s, can't create codec context\n", __func__); goto err_1; } if (vd->avcodec->capabilities & CODEC_CAP_TRUNCATED) { trace_info("%s, codec have CODEC_CAP_TRUNCATED\n", __func__); vd->avctx->flags |= CODEC_FLAG_TRUNCATED; } vd->avctx->opaque = vd; vd->avctx->thread_count = 1; vd->avctx->get_format = get_format; #if AVCTX_HAVE_REFCOUNTED_BUFFERS vd->avctx->get_buffer2 = get_buffer2; vd->avctx->refcounted_frames = 1; #else vd->avctx->get_buffer = get_buffer; vd->avctx->release_buffer = release_buffer; #endif if (avcodec_open2(vd->avctx, vd->avcodec, NULL) < 0) { trace_error("%s, can't open codec\n", __func__); goto err_1; } vd->avframe = av_frame_alloc(); if (!vd->avframe) { trace_error("%s, can't alloc frame\n", __func__); goto err_1; } pp_resource_release(video_decoder); return video_decoder; err_1: ppb_video_decoder_destroy_priv(vd); pp_resource_release(video_decoder); pp_resource_expunge(video_decoder); return 0; }