if(!bitmap) break;
ADM_assert(last>=first);   if(!bitmap) continue; if(first==last) continue;
uint8_t ADM_ocr_engine( void){//     uint32_t nbSub=0;    FILE *out=NULL;    head.next=NULL;    ADMVideoVobSub *vobsub=NULL;    uint32_t startTime,endTime;    uint32_t w,h,oldw=0,oldh=0;    uint32_t oldbitmapw=0;    uint32_t oldbitmaph=0;    uint32_t first,last;    uint32_t seqNum;    char     text[1024];    lang_index=0;    nbGlyphs=0;    // Create UI && prepare callback        dialog=DIA_ocr();    gtk_register_dialog(dialog);#define ASSOCIATE(x,y)   gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(x),y)    ASSOCIATE(buttonStart,actionGo);    ASSOCIATE(buttonOk,   actionAccept);    ASSOCIATE(buttonskip,     actionSkip);    ASSOCIATE(buttonIgnore,   actionIgnore);        ASSOCIATE(buttonGlyphLoad,   actionLoadGlyph);    ASSOCIATE(buttonGlyphSave,   actionSaveGlyph);        ASSOCIATE(buttonVobsub,   actionLoadVob);    ASSOCIATE(buttonSrt,   actionSaveSub);       gtk_widget_show(dialog);//  disable        mainDisplay=WID(drawingareaBitmap);    smallDisplay=WID(drawingareaSmall);        CONNECT(drawingareaBitmap,expose_event,gui_draw);    CONNECT(drawingareaSmall,expose_event,gui_draw_small);    CONNECT(entry,activate,cb_accept);_again:        if(!setup()) goto endIt;    printf("Go go go\n");    // Everything ready go go go              redraw_x=redraw_y=0;    GTK_PURGE;//  Time to go    // Inactivate frame1=gliph    frame2=in/out  buttonStart    gtk_widget_set_sensitive(WID(buttonStart),0);    gtk_widget_set_sensitive(WID(frameGlyph),0);    gtk_widget_set_sensitive(WID(frameLoad),0);    gtk_widget_set_sensitive(WID(frameBitmap),1);    gtk_widget_set_sensitive(WID(buttonStart),0);    // Activate output   // gtk_widget_set_sensitive(WID(Current_Glyph),1);    //     char *fileout;   fileout=(char *)gtk_label_get_text(GTK_LABEL(WID(labelSrt)));   if(!fileout)    {        GUI_Alert("Ouptut file incorrect!");        goto _again;    }    out=fopen(fileout,"wb");    if(!out)    {        GUI_Alert("Ouptut file incorrect!");        goto _again;    }         vobsub=new ADMVideoVobSub(subparam.subname,subparam.index);    nbSub=vobsub->getNbImage();       if(!nbSub)    {        GUI_Alert("Problem loading sub!");        delete vobsub;        vobsub=NULL;        goto _again;     }    seqNum=1;   // Sub number in srt file    oldw=oldh=0;            for(uint32_t i=0;i<nbSub;i++)    {            first=last=0;            bitmap=vobsub->getBitmap(i,&startTime, &endTime,&first,&last);            // Update display            if(!bitmap) break;            // If the bitmap size changed or does not exist yet...            if(!workArea || oldbitmapw!=bitmap->_width || oldbitmaph!=bitmap->_height)            {              if(workArea)               {                delete [] workArea;                workArea=NULL;               }              workArea=new uint8_t[bitmap->_width*(bitmap->_height)];            }            oldbitmaph=bitmap->_height;            oldbitmapw=bitmap->_width;           //            w=bitmap->_width;           h=last-first+1;           redraw_x=w;           redraw_y=h;           //**           if(oldw!=w || oldh !=h)           {                                GTK_PURGE;           }           // Build           mergeBitmap(bitmap->_bitmap+first*w, workArea, bitmap->_alphaMask+first*w,  w,   h);           // Merge             GTK_PURGE;             gui_draw();             GTK_PURGE;              // OCR             if(!ocrBitmap(workArea,w,h)) goto endIt;             //             gtk_label_set_text(GTK_LABEL(WID(labelText)),decodedString);             fprintf(out,"%d\n",seqNum++);             uint16_t hh,mm,ss,ms;             ms2time(startTime, &hh, &mm, &ss, &ms);             fprintf(out,"%02d:%02d:%02d,%03d --> ",hh,mm,ss,ms);             ms2time(endTime, &hh, &mm, &ss, &ms);             fprintf(out,"%02d:%02d:%02d,%03d\n",hh,mm,ss,ms);             fprintf(out,"%s\n\n",decodedString);             //                          oldw=w;             oldh=h;             // Update infos             sprintf(text,"%03d/%03d",i+1,nbSub);             gtk_label_set_text(GTK_LABEL(WID(labelNbLines)),text);             sprintf(text,"%03d",nbGlyphs);             gtk_label_set_text(GTK_LABEL(WID(labelNbGlyphs)),text);    }endIt:    // Final round    gtk_widget_set_sensitive(WID(frameGlyph),1);    gtk_widget_set_sensitive(WID(frameLoad),0);    gtk_widget_set_sensitive(WID(buttonStart),0);      gtk_widget_set_sensitive(WID(frameBitmap),0);   // gtk_widget_set_sensitive(WID(Current_Glyph),0);         if(nbGlyphs && actionSaveGlyph==gtk_dialog_run(GTK_DIALOG(dialog)))        saveGlyph();    if(vobsub)        delete vobsub;    vobsub=NULL;    if(out)         fclose(out);    out=NULL;    gtk_unregister_dialog(dialog);    gtk_widget_destroy(dialog);    if(head.next)        destroyGlyphTree(&head);    head.next=NULL;    return 1;}