static int vdec_h264_get_param(unsigned long h_vdec, enum vdec_get_param_type type, void *out) { struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec; switch (type) { case GET_PARAM_DISP_FRAME_BUFFER: vdec_h264_get_fb(inst, &inst->vsi->list_disp, true, out); break; case GET_PARAM_FREE_FRAME_BUFFER: vdec_h264_get_fb(inst, &inst->vsi->list_free, false, out); break; case GET_PARAM_PIC_INFO: get_pic_info(inst, out); break; case GET_PARAM_DPB_SIZE: get_dpb_size(inst, out); break; case GET_PARAM_CROP_INFO: get_crop_info(inst, out); break; default: mtk_vcodec_err(inst, "invalid get parameter type=%d", type); return -EINVAL; } return 0; }
JNIEXPORT jobject JNICALL Java_com_amlogic_graphics_PictureKit_loadPictureNative (JNIEnv* env, jclass thiz, jstring filename, jobject dec_obj) { aml_dec_para_t dec_info = {0}; aml_image_info_t image_info = {0}; const char* str=env->GetStringUTFChars(filename,NULL); jobject obj; dec_info.fn=(char*)str; dec_info.iwidth = env->GetIntField(dec_obj, gdecoderInfo_imageWidthID); dec_info.iheight = env->GetIntField(dec_obj, gdecoderInfo_imageHeightID); dec_info.width = env->GetIntField(dec_obj, gdecoderInfo_widthToDecoderID); dec_info.height = env->GetIntField(dec_obj, gdecoderInfo_HeightToDecoderID); dec_info.mode = env->GetIntField(dec_obj, gdecoderInfo_decodeModeID); dec_info.thumbpref = env->GetIntField(dec_obj,gdecoderInfo_thumbPreferID); dec_info.pic_type= env->GetIntField(dec_obj, gdecoderInfo_pictureTypeID); dec_info.colormode = COLOR_S32_ABGR; if(get_pic_info(&dec_info)==FH_ERROR_OK) { env->SetIntField(dec_obj, gdecoderInfo_imageWidthID,dec_info.iwidth); env->SetIntField(dec_obj, gdecoderInfo_imageHeightID,dec_info.iheight); env->SetIntField(dec_obj, gdecoderInfo_widthToDecoderID,0); env->SetIntField(dec_obj, gdecoderInfo_HeightToDecoderID,0); env->SetIntField(dec_obj, gdecoderInfo_colorModeID,0); env->SetIntField(dec_obj, gdecoderInfo_pictureTypeID,dec_info.pic_type); if(load_pic(&dec_info,&image_info)!=FH_ERROR_OK) { obj=NULL; } else { obj = env->AllocObject(gImageInfo_class); if(obj) { env->SetIntField(obj, gdecoderInfo_originImageWidthID,dec_info.iwidth); env->SetIntField(obj, gdecoderInfo_originImageHeightID,dec_info.iheight); env->SetIntField(obj, gdecoderInfo_outImageWidthID,image_info.width); env->SetIntField(obj, gdecoderInfo_outImageHeightID,image_info.height); if (hasException(env)) { obj = NULL; } } } } env->ReleaseStringUTFChars(filename,str); return obj; }
JNIEXPORT jobject JNICALL Java_com_amlogic_graphics_PictureKit_loadPicture2BmNative (JNIEnv* env , jclass thiz, jstring filename, jobject dec_obj) { aml_dec_para_t dec_info; aml_image_info_t image_info; const char* str=env->GetStringUTFChars(filename,NULL); memset(&dec_info,0,sizeof(aml_dec_para_t)); memset(&image_info,0,sizeof(aml_image_info_t)); jobject obj=NULL; dec_info.fn=(char*)str; dec_info.iwidth = env->GetIntField(dec_obj, gdecoderInfo_imageWidthID); dec_info.iheight = env->GetIntField(dec_obj, gdecoderInfo_imageHeightID); dec_info.width = env->GetIntField(dec_obj, gdecoderInfo_widthToDecoderID); dec_info.height = env->GetIntField(dec_obj, gdecoderInfo_HeightToDecoderID); if(dec_info.width<=0) dec_info.width=1280; if(dec_info.height<=0) dec_info.height=720; dec_info.mode = env->GetIntField(dec_obj, gdecoderInfo_decodeModeID); dec_info.thumbpref = env->GetIntField(dec_obj,gdecoderInfo_thumbPreferID); dec_info.pic_type= env->GetIntField(dec_obj, gdecoderInfo_pictureTypeID); dec_info.colormode = COLOR_S32_ABGR; dec_info.image_3d_mode_pref = env->GetIntField(dec_obj, gdecoderInfo_3DPrefID); dec_info.image_3d_lr_offset = env->GetIntField(dec_obj, gdecoderInfo_3DParam1ID); dec_info.image_3d_preserv = env->GetIntField(dec_obj, gdecoderInfo_3DParam2ID); /*ALOGD("%d===%d==%d=======\n",dec_info.image_3d_mode_pref, dec_info.image_3d_info.l_or_r_first, dec_info.image_3d_info.image_offset);*/ if(get_pic_info(&dec_info)==FH_ERROR_OK) { env->SetIntField(dec_obj, gdecoderInfo_imageWidthID,dec_info.iwidth); env->SetIntField(dec_obj, gdecoderInfo_imageHeightID,dec_info.iheight); env->SetIntField(dec_obj, gdecoderInfo_widthToDecoderID,0); env->SetIntField(dec_obj, gdecoderInfo_HeightToDecoderID,0); env->SetIntField(dec_obj, gdecoderInfo_colorModeID,0); env->SetIntField(dec_obj, gdecoderInfo_pictureTypeID,dec_info.pic_type); if(load_pic(&dec_info,&image_info)!=FH_ERROR_OK) obj=NULL; else if(image_info.width<=0||image_info.height<=0) obj=NULL; else obj = create_java_bitmap(env,image_info.data,image_info.width,image_info.height,32); if(image_info.data) free(image_info.data); } env->ReleaseStringUTFChars(filename,str); return obj; }
JNIEXPORT jobject JNICALL Java_com_amlogic_graphics_PictureKit_getPictureInfoNative (JNIEnv* env, jclass thiz, jstring filename) { const char* str=env->GetStringUTFChars(filename,NULL); aml_dec_para_t dec_info; jobject obj; dec_info.fn=(char*)str; if(get_pic_info(&dec_info)==FH_ERROR_OK) { obj = env->AllocObject(gdecoderInfo_class); if(obj) { env->SetIntField(obj, gdecoderInfo_imageWidthID,dec_info.iwidth); env->SetIntField(obj, gdecoderInfo_imageHeightID,dec_info.iheight); env->SetIntField(obj, gdecoderInfo_widthToDecoderID,0); env->SetIntField(obj, gdecoderInfo_HeightToDecoderID,0); env->SetIntField(obj, gdecoderInfo_colorModeID,0); env->SetIntField(obj, gdecoderInfo_pictureTypeID,dec_info.pic_type); if (hasException(env)) { obj = NULL; } } } env->ReleaseStringUTFChars(filename,str); return obj; }
static int vdec_h264_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs, struct vdec_fb *fb, bool *res_chg) { struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec; struct vdec_vpu_inst *vpu = &inst->vpu; int nal_start_idx = 0; int err = 0; unsigned int nal_start; unsigned int nal_type; unsigned char *buf; unsigned int buf_sz; unsigned int data[2]; uint64_t vdec_fb_va = (u64)(uintptr_t)fb; uint64_t y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0; uint64_t c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0; mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p", ++inst->num_nalu, y_fb_dma, c_fb_dma, fb); /* bs NULL means flush decoder */ if (bs == NULL) return vpu_dec_reset(vpu); buf = (unsigned char *)bs->va; buf_sz = bs->size; nal_start_idx = find_start_code(buf, buf_sz); if (nal_start_idx < 0) goto err_free_fb_out; nal_start = buf[nal_start_idx]; nal_type = NAL_TYPE(buf[nal_start_idx]); mtk_vcodec_debug(inst, "\n + NALU[%d] type %d +\n", inst->num_nalu, nal_type); if (nal_type == NAL_H264_PPS) { buf_sz -= nal_start_idx; if (buf_sz > HDR_PARSING_BUF_SZ) { err = -EILSEQ; goto err_free_fb_out; } memcpy(inst->vsi->hdr_buf, buf + nal_start_idx, buf_sz); } inst->vsi->dec.bs_dma = (uint64_t)bs->dma_addr; inst->vsi->dec.y_fb_dma = y_fb_dma; inst->vsi->dec.c_fb_dma = c_fb_dma; inst->vsi->dec.vdec_fb_va = vdec_fb_va; data[0] = buf_sz; data[1] = nal_start; err = vpu_dec_start(vpu, data, 2); if (err) goto err_free_fb_out; *res_chg = inst->vsi->dec.resolution_changed; if (*res_chg) { struct vdec_pic_info pic; mtk_vcodec_debug(inst, "- resolution changed -"); get_pic_info(inst, &pic); if (inst->vsi->dec.realloc_mv_buf) { err = alloc_mv_buf(inst, &pic); if (err) goto err_free_fb_out; } } if (nal_type == NAL_NON_IDR_SLICE || nal_type == NAL_IDR_SLICE) { /* wait decoder done interrupt */ err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED, WAIT_INTR_TIMEOUT_MS); if (err) goto err_free_fb_out; vpu_dec_end(vpu); } mtk_vcodec_debug(inst, "\n - NALU[%d] type=%d -\n", inst->num_nalu, nal_type); return 0; err_free_fb_out: put_fb_to_free(inst, fb); mtk_vcodec_err(inst, "\n - NALU[%d] err=%d -\n", inst->num_nalu, err); return err; }
int main(int argc, char *argv[]) { cam cam_object, *cam; Display *display; Screen *screen_num; gchar *poopoo = NULL; gchar *pixfilename = "camorama/camorama.png"; gchar *filename; //= "/usr/opt/garnome/share/camorama/camorama.glade"; int x = -1, y = -1; gboolean buggery = FALSE; GtkWidget *button; GConfClient *gc; const struct poptOption popt_options[] = { {"version", 'V', POPT_ARG_NONE, &ver, 0, N_("show version and exit"), NULL}, {"device", 'd', POPT_ARG_STRING, &poopoo, 0, N_("v4l device to use"), NULL}, {"debug", 'D', POPT_ARG_NONE, &buggery, 0, N_("enable debugging code"), NULL}, {"width", 'x', POPT_ARG_INT, &x, 0, N_("capture width"), NULL}, {"height", 'y', POPT_ARG_INT, &y, 0, N_("capture height"), NULL}, {"max", 'M', POPT_ARG_NONE, &max, 0, N_("maximum capture size"), NULL}, {"min", 'm', POPT_ARG_NONE, &min, 0, N_("minimum capture size"), NULL}, {"half", 'H', POPT_ARG_NONE, &half, 0, N_("middle capture size"), NULL}, {"read", 'R', POPT_ARG_NONE, &use_read, 0, N_("use read() rather than mmap()"), NULL}, POPT_TABLEEND }; cam = &cam_object; /* set some default values */ cam->frame_number = 0; cam->pic = NULL; cam->pixmap = NULL; cam->size = PICHALF; cam->video_dev = NULL; cam->read = FALSE; bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); /* gnome_program_init - initialize everything (gconf, threads, etc) */ gnome_program_init (PACKAGE_NAME, PACKAGE_VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR, GNOME_PARAM_POPT_TABLE, popt_options, GNOME_PARAM_HUMAN_READABLE_NAME, _("camorama"), NULL); /* gtk is initialized now */ camorama_stock_init(); camorama_filters_init(); cam->debug = buggery; cam->x = x; cam->y = y; glade_gnome_init (); glade_set_custom_handler (camorama_glade_handler, cam); if (ver) { fprintf (stderr, _("\n\nCamorama version %s\n\n"), VERSION); exit (0); } if (max) { cam->size = PICMAX; } if (min) { cam->size = PICMIN; } if (half) { cam->size = PICHALF; } if (use_read) { printf ("gah!\n"); cam->read = TRUE; } gc = gconf_client_get_default (); cam->gc = gc; gconf_client_add_dir (cam->gc, PATH, GCONF_CLIENT_PRELOAD_NONE, NULL); gconf_client_notify_add (cam->gc, KEY1, (void *) gconf_notify_func, cam->pixdir, NULL, NULL); gconf_client_notify_add (cam->gc, KEY5, (void *) gconf_notify_func, cam->rhost, NULL, NULL); gconf_client_notify_add (cam->gc, KEY2, (void *) gconf_notify_func, cam->capturefile, NULL, NULL); gconf_client_notify_add (cam->gc, KEY3, (void *) gconf_notify_func_int, GINT_TO_POINTER (cam->savetype), NULL, NULL); gconf_client_notify_add (cam->gc, KEY4, (void *) gconf_notify_func_bool, &cam->timestamp, NULL, NULL); if (!poopoo) { gchar const* gconf_device = gconf_client_get_string(cam->gc, KEY_DEVICE, NULL); if(gconf_device) { cam->video_dev = g_strdup(gconf_device); } else { cam->video_dev = g_strdup ("/dev/video0"); } } else { cam->video_dev = g_strdup (poopoo); } cam->pixdir = g_strdup (gconf_client_get_string (cam->gc, KEY1, NULL)); cam->capturefile = g_strdup (gconf_client_get_string (cam->gc, KEY2, NULL)); cam->rhost = g_strdup (gconf_client_get_string (cam->gc, KEY5, NULL)); cam->rlogin = g_strdup (gconf_client_get_string (cam->gc, KEY6, NULL)); cam->rpw = g_strdup (gconf_client_get_string (cam->gc, KEY7, NULL)); cam->rpixdir = g_strdup (gconf_client_get_string (cam->gc, KEY8, NULL)); cam->rcapturefile = g_strdup (gconf_client_get_string (cam->gc, KEY9, NULL)); cam->savetype = gconf_client_get_int (cam->gc, KEY3, NULL); cam->rsavetype = gconf_client_get_int (cam->gc, KEY10, NULL); cam->ts_string = g_strdup (gconf_client_get_string (cam->gc, KEY16, NULL)); cam->date_format = "%Y-%m-%d %H:%M:%S"; cam->timestamp = gconf_client_get_bool (cam->gc, KEY4, NULL); cam->rtimestamp = gconf_client_get_bool (cam->gc, KEY11, NULL); cam->cap = gconf_client_get_bool (cam->gc, KEY12, NULL); cam->rcap = gconf_client_get_bool (cam->gc, KEY13, NULL); cam->timefn = gconf_client_get_bool (cam->gc, KEY14, NULL); cam->rtimefn = gconf_client_get_bool (cam->gc, KEY15, NULL); cam->usestring = gconf_client_get_bool (cam->gc, KEY18, NULL); cam->usedate = gconf_client_get_bool (cam->gc, KEY19, NULL); cam->acap = gconf_client_get_bool (cam->gc, KEY20, NULL); cam->timeout_interval = gconf_client_get_int (cam->gc, KEY21, NULL); cam->show_adjustments = gconf_client_get_bool (cam->gc, KEY22, NULL); cam->show_effects = gconf_client_get_bool (cam->gc, KEY23, NULL); /* get desktop depth */ display = (Display *) gdk_x11_get_default_xdisplay (); screen_num = xlib_rgb_get_screen (); gdk_pixbuf_xlib_init (display, 0); cam->desk_depth = xlib_rgb_get_depth (); cam->dev = open (cam->video_dev, O_RDWR); camera_cap (cam); get_win_info (cam); /* query/set window attributes */ cam->vid_win.x = 0; cam->vid_win.y = 0; cam->vid_win.width = cam->x; cam->vid_win.height = cam->y; cam->vid_win.chromakey = 0; cam->vid_win.flags = 0; set_win_info (cam); get_win_info (cam); /* get picture attributes */ get_pic_info (cam); // set_pic_info(cam); /* set_pic_info(cam); */ cam->contrast = cam->vid_pic.contrast; cam->brightness = cam->vid_pic.brightness; cam->colour = cam->vid_pic.colour; cam->hue = cam->vid_pic.hue; cam->wb = cam->vid_pic.whiteness; cam->depth = cam->vid_pic.depth / 8; cam->pic_buf = malloc (cam->x * cam->y * cam->depth); cam->tmp = malloc (cam->vid_cap.maxwidth * cam->vid_cap.maxheight * cam->depth); //cam->tmp = NULL; /* set the buffer size */ if (cam->read == FALSE) { set_buffer (cam); } //cam->read = FALSE; /* initialize cam and create the window */ if (cam->read == FALSE) { pt2Function = timeout_func; init_cam (NULL, cam); } else { printf ("using read()\n"); cam->pic = realloc (cam->pic, (cam->vid_cap.maxwidth * cam->vid_cap.maxheight * 3)); pt2Function = read_timeout_func; } cam->pixmap = gdk_pixmap_new (NULL, cam->x, cam->y, cam->desk_depth); filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_DATADIR, "camorama/camorama.glade", TRUE, NULL); if (filename == NULL) { error_dialog (_ ("Couldn't find the main interface file (camorama.glade).")); exit (1); } //pixfilename = gnome_program_locate_file(NULL, GNOME_FILE_DOMAIN_APP_DATADIR, "pixmaps/camorama.png", TRUE, NULL); //printf("pixfile = %s\n",pixfilename); //pixfilename); //printf("pixfile = %s\n",pixfilename); cam->xml = glade_xml_new (filename, NULL, NULL); /*eggtray */ /*tray_icon = egg_tray_icon_new ("Our other cool tray icon"); * button = gtk_button_new_with_label ("This is a another\ncool tray icon"); * g_signal_connect (button, "clicked", * G_CALLBACK (second_button_pressed), tray_icon); * * gtk_container_add (GTK_CONTAINER (tray_icon), button); * gtk_widget_show_all (GTK_WIDGET (tray_icon)); */ load_interface (cam); cam->idle_id = gtk_idle_add ((GSourceFunc) pt2Function, (gpointer) cam); gtk_timeout_add (2000, (GSourceFunc) fps, cam->status); gtk_main (); return 0; }