//************************************* uint8_t vidHardPDRemoval::configure (AVDMGenericVideoStream * in) { int v,w; _param->show=GUI_YesNo(QT_TR_NOOP("Metrics"),QT_TR_NOOP("Do you want to print metrics on screen ?" )); v=_param->threshold; w=_param->noise; if(DIA_GetIntegerValue(&v, 2, 99,"Treshold","Treshold value (smaller = harder to match)")) { if(DIA_GetIntegerValue(&w, 2, 99,"Noise","Noise threshold")) { _param->threshold=v; _param->noise=w; _lastRemoved=0xFFFF; return 1; } } return 0; }
/** * Handles Click event for "Clear List" button. * * @param w The widget. * @return True, always. */ bool GUI_Widget_HOF_ClearList_Click(Widget *w) { /* "Are you sure you want to clear the high scores?" */ if (GUI_YesNo(0x148)) { HallOfFameStruct *data = w->data; memset(data, 0, 128); if (File_Exists("SAVEFAME.DAT")) File_Delete("SAVEFAME.DAT"); GUI_HallOfFame_DrawData(data, true); g_doQuitHOF = true; } GUI_Widget_MakeNormal(w, false); return true; }
/** * Handles Click event for "Clear List" button. * * @param w The widget. * @return True, always. */ bool GUI_Widget_HOF_ClearList_Click(Widget *w) { /* "Are you sure you want to clear the high scores?" */ if (GUI_YesNo(STR_ARE_YOU_SURE_YOU_WANT_TO_CLEAR_THE_HIGH_SCORES)) { HallOfFameStruct *data = w->data; memset(data, 0, 128); if (File_Exists_Personal("SAVEFAME.DAT")) File_Delete_Personal("SAVEFAME.DAT"); GUI_HallOfFame_DrawData(data, true); g_doQuitHOF = true; } GUI_Widget_MakeNormal(w, false); return true; }
uint8_t oplug_mp4(const char *name, ADM_OUT_FORMAT type) { AVDMGenericVideoStream *_incoming=NULL; AVDMGenericAudioStream *audio=NULL; uint8_t audioBuffer[48000]; uint8_t *videoBuffer=NULL; uint32_t alen;//,flags; uint32_t size; uint8_t ret=0; uint32_t sample_got=0,sample; uint32_t extraDataSize=0; uint8_t *extraData=NULL; lavMuxer *muxer=NULL; aviInfo info; uint32_t width,height; DIA_encoding *encoding_gui=NULL; Encoder *_encode=NULL; char *TwoPassLogFile=NULL; uint32_t total=0; uint32_t videoExtraDataSize=0; uint8_t *videoExtraData=NULL; uint8_t *dummy,err; WAVHeader *audioinfo=NULL; int prefill=0; uint32_t displayFrame=0; ADMBitstream bitstream; uint32_t frameWrite=0; ADM_MUXER_TYPE muxerType=MUXER_MP4; uint8_t dualPass=0; uint8_t r=0; uint32_t skipping=1; if(type==ADM_PSP) muxerType=MUXER_PSP; else muxerType=MUXER_MP4; // Setup video if(videoProcessMode()) { _incoming = getLastVideoFilter (frameStart,frameEnd-frameStart); }else { _incoming = getFirstVideoFilter (frameStart,frameEnd-frameStart); } videoBuffer=new uint8_t[_incoming->getInfo()->width*_incoming->getInfo()->height*3]; // Set global header encoding, needed for H264 _encode = getVideoEncoder (_incoming->getInfo()->width, _incoming->getInfo()->height,1); total= _incoming->getInfo()->nb_frames; encoding_gui=new DIA_encoding(_incoming->getInfo()->fps1000); if (!_encode) { GUI_Error_HIG (_("Cannot initialize the video stream"), NULL); goto stopit; } // init compressor encoding_gui->setContainer("MP4"); encoding_gui->setAudioCodec("None"); if(!videoProcessMode()) encoding_gui->setCodec("Copy"); else encoding_gui->setCodec(_encode->getDisplayName()); TwoPassLogFile=new char[strlen(name)+6]; strcpy(TwoPassLogFile,name); strcat(TwoPassLogFile,".stat"); _encode->setLogFile(TwoPassLogFile,total); if (!_encode->configure (_incoming)) { GUI_Error_HIG (_("Filter init failed"), NULL); goto stopit; }; dualPass=_encode->isDualPass(); if(dualPass) { if(!prepareDualPass(videoBuffer,TwoPassLogFile,encoding_gui,_encode,total)) goto stopit; }else { encoding_gui->setPhasis ("Encoding"); } info.width=_incoming->getInfo()->width; info.height=_incoming->getInfo()->height; info.nb_frames=_incoming->getInfo()->nb_frames; info.fps1000=_incoming->getInfo()->fps1000; info.fcc=*(uint32_t *)_encode->getCodecName(); //FIXME _encode->hasExtraHeaderData( &videoExtraDataSize,&dummy); if(videoExtraDataSize) { printf("We have extradata for video in copy mode (%d)\n",videoExtraDataSize); videoExtraData=new uint8_t[videoExtraDataSize]; memcpy(videoExtraData,dummy,videoExtraDataSize); } // _________________Setup video (cont) _______________ // ___________ Read 1st frame _________________ ADM_assert(_encode); bitstream.data=videoBuffer; preFilling: bitstream.cleanup(0); if(!(err=_encode->encode ( prefill, &bitstream)))//&len, videoBuffer, &flags,&displayFrame)) { printf("MP4:First frame error\n"); GUI_Error_HIG (_("Error while encoding"), NULL); goto stopit; } if(!bitstream.len) { prefill++; goto preFilling; } if(!bitstream.flags & AVI_KEY_FRAME) { GUI_Error_HIG (_("KeyFrame error"),_( "The beginning frame is not a key frame.\nPlease move the A marker.")); goto stopit; } //len=bitstream.len; // If needed get VOL header if(isMpeg4Compatible(info.fcc) && !videoExtraDataSize && bitstream.len) { // And put them as extradata for esds atom uint32_t voslen=0; if(extractVolHeader(videoBuffer,bitstream.len,&voslen)) { if(voslen) { videoExtraDataSize=voslen; videoExtraData=new uint8_t[videoExtraDataSize]; memcpy(videoExtraData,videoBuffer,videoExtraDataSize); } } else printf("Oops should be settings data for esds\n"); } // ____________Setup audio__________________ if(currentaudiostream) { audio=mpt_getAudioStream(); if(!audio) { GUI_Error_HIG (_("Cannot initialize the audio stream"), NULL); goto stopit; } } if(audio) { audioinfo=audio->getInfo(); audio->extraData(&extraDataSize,&extraData); if(audioProcessMode()) encoding_gui->setAudioCodec(getStrFromAudioCodec(audio->getInfo()->encoding)); else encoding_gui->setAudioCodec("Copy"); }else { encoding_gui->setAudioCodec("None"); } // ____________Setup Muxer _____________________ muxer= new lavMuxer; if(!muxer->open( name, 2000000, // Muxrate MUXER_MP4, &info,videoExtraDataSize,videoExtraData, audioinfo,extraDataSize,extraData)) goto stopit; //_____________ Loop _____________________ encoding_gui->setContainer("MP4"); if(audio) encoding_gui->setAudioCodec(getStrFromAudioCodec(audio->getInfo()->encoding)); if(!videoProcessMode()) encoding_gui->setCodec("Copy"); else encoding_gui->setCodec(_encode->getDisplayName()); // if(bitstream.len) { muxer->writeVideoPacket( &bitstream); frameWrite++; } for(int frame=1;frame<total;frame++) { while(muxer->needAudio()) { if(!audio->getPacket(audioBuffer,&alen,&sample)) break; if(alen) { muxer->writeAudioPacket(alen,audioBuffer,sample_got); encoding_gui->feedAudioFrame(alen); sample_got+=sample; } } ADM_assert(_encode); bitstream.cleanup(frameWrite); if(!prefill || frame+prefill<total) { r=_encode->encode ( prefill+frame, &bitstream); } else { r=_encode->encode ( total-1, &bitstream); } if(!r) { printf("MP4:Frame %u error\n",frame); GUI_Error_HIG (_("Error while encoding"), NULL); goto stopit; } if(!bitstream.len && skipping) { printf("Frame skipped (xvid ?)\n"); continue; } skipping=0; // printf("Prefill %u FrameWrite :%u Frame %u PtsFrame :%u\n",prefill,frameWrite,frame,bitstream.ptsFrame); frameWrite++; muxer->writeVideoPacket( &bitstream); encoding_gui->setFrame(frame,total); encoding_gui->feedFrame(bitstream.len); if(!encoding_gui->isAlive()) { if(GUI_YesNo(_("Stop Request"), _("Do you want to abort encoding ?"))) goto stopit; } } ret=1; stopit: if(muxer) muxer->close(); if(encoding_gui) delete encoding_gui; if(TwoPassLogFile) delete [] TwoPassLogFile; if(videoBuffer) delete [] videoBuffer; if(muxer) delete muxer; if(_encode) delete _encode; if(videoExtraData) delete [] videoExtraData; // Cleanup deleteAudioFilter (audio); return ret; }
/** * Handles Click event for "Options" button. * * @param w The widget. * @return False, always. */ bool GUI_Widget_Options_Click(Widget *w) { WindowDesc *desc = &g_optionsWindowDesc; uint16 cursor = g_cursorSpriteID; bool loop; g_cursorSpriteID = 0; Sprites_SetMouseSprite(0, 0, g_sprites[0]); Sprites_UnloadTiles(); memmove(g_palette_998A, g_paletteActive, 256 * 3); Driver_Voice_Play(NULL, 0xFF); Timer_SetTimer(TIMER_GAME, false); GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22); ShadeScreen(); GUI_Window_BackupScreen(desc); GUI_Window_Create(desc); for (loop = true; loop; sleepIdle()) { Widget *w2 = g_widgetLinkedListTail; uint16 key = GUI_Widget_HandleEvents(w2); if ((key & 0x8000) != 0) { w = GUI_Widget_Get_ByIndex(w2, key); GUI_Window_RestoreScreen(desc); switch ((key & 0x7FFF) - 0x1E) { case 0: if (GUI_Widget_SaveLoad_Click(false)) loop = false; break; case 1: if (GUI_Widget_SaveLoad_Click(true)) loop = false; break; case 2: GUI_Widget_GameControls_Click(w); break; case 3: /* "Are you sure you wish to restart?" */ if (!GUI_YesNo(0x76)) break; loop = false; g_gameMode = GM_RESTART; break; case 4: /* "Are you sure you wish to pick a new house?" */ if (!GUI_YesNo(0x77)) break; loop = false; Driver_Music_FadeOut(); g_gameMode = GM_PICKHOUSE; break; case 5: loop = false; break; case 6: /* "Are you sure you want to quit playing?" */ loop = !GUI_YesNo(0x65); g_running = loop; Sound_Output_Feedback(0xFFFE); while (Driver_Voice_IsPlaying()) sleepIdle(); break; default: break; } if (g_running && loop) { GUI_Window_BackupScreen(desc); GUI_Window_Create(desc); } } GUI_PaletteAnimate(); } g_textDisplayNeedsUpdate = true; Sprites_LoadTiles(); GUI_DrawInterfaceAndRadar(SCREEN_0); UnshadeScreen(); GUI_Widget_MakeSelected(w, false); Timer_SetTimer(TIMER_GAME, true); GameOptions_Save(); Structure_Recount(); Unit_Recount(); g_cursorSpriteID = cursor; Sprites_SetMouseSprite(0, 0, g_sprites[cursor]); return false; }