bool retro_load_game(const struct retro_game_info *info) { if (failed_init) return false; overscan = false; environ_cb(RETRO_ENVIRONMENT_GET_OVERSCAN, &overscan); set_basename(info->path); game = MDFNI_LoadGame(MEDNAFEN_CORE_NAME_MODULE, info->path); if (!game) return false; MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24); memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat)); surf = new MDFN_Surface(NULL, FB_WIDTH, FB_HEIGHT, FB_WIDTH, pix_fmt); hookup_ports(true); check_variables(); return game; }
void retro_init() { MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24); surf = new MDFN_Surface(mednafen_buf, 384, 224, 384, pix_fmt); std::vector<MDFNGI*> ext; MDFNI_InitializeModules(ext); const char *dir = NULL; const char *saves = NULL; std::vector<MDFNSetting> settings; environ_cb(RETRO_ENVIRONMENT_GET_SAVES_DIRECTORY, &saves); if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { std::string save_path = saves; //dox http://mednafen.sourceforge.net/documentation/09x/vb.html MDFNSetting vb_parallax = { "vb.disable_parallax", MDFNSF_EMU_STATE, "Disable parallax for BG and OBJ rendering", NULL, MDFNST_BOOL, "1", NULL, NULL, NULL }; MDFNSetting vb_anaglyph_preset = { "vb.anaglyph.preset", MDFNSF_EMU_STATE, "Disable anaglyph preset", NULL, MDFNST_BOOL, "disabled", NULL, NULL, NULL }; MDFNSetting vb_anaglyph_lcolor = { "vb.anaglyph.lcolor", MDFNSF_EMU_STATE, "Anaglyph l color", NULL, MDFNST_BOOL, "0xFF0000", NULL, NULL, NULL }; //MDFNSetting vb_anaglyph_lcolor = { "vb.anaglyph.lcolor", MDFNSF_EMU_STATE, "Anaglyph l color", NULL, MDFNST_BOOL, "0xFFFFFF", NULL, NULL, NULL }; MDFNSetting vb_anaglyph_rcolor = { "vb.anaglyph.rcolor", MDFNSF_EMU_STATE, "Anaglyph r color", NULL, MDFNST_BOOL, "0x000000", NULL, NULL, NULL }; //MDFNSetting vb_allow_draw_skip = { "vb.allow_draw_skip", MDFNSF_EMU_STATE, "Allow draw skipping", NULL, MDFNST_BOOL, "1", NULL, NULL, NULL }; //MDFNSetting vb_instant_display_hack = { "vb.instant_display_hack", MDFNSF_EMU_STATE, "ADisplay latency reduction hack", NULL, MDFNST_BOOL, "1", NULL, NULL, NULL }; MDFNSetting filesys = { "filesys.path_sav", MDFNSF_NOFLAGS, "Memcards", NULL, MDFNST_STRING, save_path.c_str() }; settings.push_back(vb_parallax); settings.push_back(vb_anaglyph_preset); settings.push_back(vb_anaglyph_lcolor); settings.push_back(vb_anaglyph_rcolor); //settings.push_back(vb_allow_draw_skip); //settings.push_back(vb_instant_display_hack); settings.push_back(filesys); MDFNI_Initialize(dir, settings); } else { fprintf(stderr, "System directory is not defined. Cannot continue ...\n"); failed_init = true; } // Hints that we need a fairly powerful system to run this. unsigned level = 3; environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); }
void retro_init() { MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24); surf = new MDFN_Surface(mednafen_buf, 680, 480, 680, pix_fmt); std::vector<MDFNGI*> ext; MDFNI_InitializeModules(ext); const char *dir = NULL; std::vector<MDFNSetting> settings; if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { std::string eu_path = dir; eu_path += "/scph5502.bin"; std::string jp_path = dir; jp_path += "/scph5500.bin"; std::string na_path = dir; na_path += "/scph5501.bin"; MDFNSetting jp_setting = { "psx.bios_jp", MDFNSF_EMU_STATE, "SCPH-5500 BIOS", NULL, MDFNST_STRING, jp_path.c_str() }; MDFNSetting eu_setting = { "psx.bios_eu", MDFNSF_EMU_STATE, "SCPH-5502 BIOS", NULL, MDFNST_STRING, eu_path.c_str() }; MDFNSetting na_setting = { "psx.bios_na", MDFNSF_EMU_STATE, "SCPH-5501 BIOS", NULL, MDFNST_STRING, na_path.c_str() }; MDFNSetting filesys = { "filesys.path_sav", MDFNSF_NOFLAGS, "Memcards", NULL, MDFNST_STRING, "." }; settings.push_back(jp_setting); settings.push_back(eu_setting); settings.push_back(na_setting); settings.push_back(filesys); MDFNI_Initialize(dir, settings); } else { fprintf(stderr, "System directory is not defined. Cannot continue ...\n"); failed_init = true; } // Hints that we need a fairly powerful system to run this. unsigned level = 3; environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); }
void retro_init() { MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24); surf = new MDFN_Surface(mednafen_buf, 1365, 265, 1365, pix_fmt); std::vector<MDFNGI*> ext; MDFNI_InitializeModules(ext); const char *dir = NULL; const char *saves = NULL; std::vector<MDFNSetting> settings; environ_cb(RETRO_ENVIRONMENT_GET_SAVES_DIRECTORY, &saves); if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { std::string pce_path = dir; pce_path += "/syscard3.pce"; std::string save_path = saves; MDFNSetting pce_setting = { "pce.cdbios", MDFNSF_EMU_STATE, "PCE CD BIOS", NULL, MDFNST_STRING, pce_path.c_str() }; MDFNSetting filesys = { "filesys.path_sav", MDFNSF_NOFLAGS, "Memcards", NULL, MDFNST_STRING, save_path.c_str() }; settings.push_back(pce_setting); settings.push_back(filesys); MDFNI_Initialize(dir, settings); } else { fprintf(stderr, "System directory is not defined. Cannot continue ...\n"); failed_init = true; } // Hints that we need a fairly powerful system to run this. unsigned level = 3; environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); }
avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt(),img_convert_ctx(0) #else avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt() #endif { f=avcodec_alloc_frame(); } avframe::avframe(AVFrame *src, AVCodecContext *ctx) : f(0),tobefreed(0) { f=avcodec_alloc_frame(); tobefreed=malloc(avpicture_get_size(ctx->pix_fmt, ctx->width, ctx->height)); avpicture_fill((AVPicture *)f, (u_int8_t*)tobefreed, ctx->pix_fmt,ctx->width,ctx->height); #if LIBAVCODEC_VERSION_INT >= (51 << 16) av_picture_copy((AVPicture *)f, (const AVPicture *) src, ctx->pix_fmt, ctx->width, ctx->height); #else img_copy((AVPicture *)f, (const AVPicture *) src, ctx->pix_fmt, ctx->width, ctx->height); #endif f->pict_type = src->pict_type; f->quality = src->quality; f->coded_picture_number = src->coded_picture_number; f->display_picture_number = src->display_picture_number; f->pts = src->pts; f->interlaced_frame = src->interlaced_frame; f->top_field_first = src->top_field_first; f->repeat_pict = src->repeat_pict; f->quality = src->quality; w=ctx->width; h=ctx->height; pix_fmt=ctx->pix_fmt; dw=w*ctx->sample_aspect_ratio.num/ctx->sample_aspect_ratio.den; #ifdef HAVE_LIB_SWSCALE img_convert_ctx=sws_getContext(w, h, pix_fmt, w, h, PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL); #endif } avframe::~avframe() { if (tobefreed) free(tobefreed); if (f) av_free(f); #ifdef HAVE_LIB_SWSCALE if (img_convert_ctx) sws_freeContext(img_convert_ctx); #endif } QImage avframe::getqimage(bool scaled, double viewscalefactor) { #ifdef HAVE_LIB_SWSCALE if (w<=0 || h<=0 || img_convert_ctx==NULL) #else if (w<=0 || h<=0) #endif return QImage(); uint8_t *rgbbuffer=(uint8_t*)malloc(avpicture_get_size(PIX_FMT_RGB24, w, h)+64); int headerlen=sprintf((char *) rgbbuffer, "P6\n%d %d\n255\n", w, h); AVFrame *avframergb=avcodec_alloc_frame(); avpicture_fill((AVPicture*)avframergb, rgbbuffer+headerlen, PIX_FMT_RGB24,w,h); #ifdef HAVE_LIB_SWSCALE sws_scale(img_convert_ctx, f->data, f->linesize, 0, h, avframergb->data, avframergb->linesize); #else img_convert((AVPicture *)avframergb, PIX_FMT_RGB24, (AVPicture*)f, pix_fmt, w, h); #endif QImage im; im.loadFromData(rgbbuffer, headerlen+w*h*3, "PPM"); #ifdef HAVE_LIB_SWSCALE // im = im.swapRGB(); im = im.rgbSwapped(); #endif if ((scaled && w!=dw)||(viewscalefactor!=1.0)) { #ifdef SMOOTHSCALE im = im.smoothScale(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5)); #else // im = im.scale(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5)); im = im.scaled(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5)); #endif } free(rgbbuffer); av_free(avframergb); return (im); }
void EncodeDock::loadPresetFromProperties(Mlt::Properties& preset) { int audioQuality = -1; int videoQuality = -1; QStringList other; ui->disableAudioCheckbox->setChecked(preset.get_int("an")); ui->disableVideoCheckbox->setChecked(preset.get_int("vn")); m_extension.clear(); for (int i = 0; i < preset.count(); i++) { QString name(preset.get_name(i)); if (name == "f") { for (int i = 0; i < ui->formatCombo->count(); i++) if (ui->formatCombo->itemText(i) == preset.get("f")) { ui->formatCombo->blockSignals(true); ui->formatCombo->setCurrentIndex(i); ui->formatCombo->blockSignals(false); break; } } else if (name == "acodec") { for (int i = 0; i < ui->audioCodecCombo->count(); i++) if (ui->audioCodecCombo->itemText(i) == preset.get("acodec")) ui->audioCodecCombo->setCurrentIndex(i); if (ui->audioCodecCombo->currentText() == "libopus") // reset libopus to VBR (its default) ui->audioRateControlCombo->setCurrentIndex(RateControlQuality); } else if (name == "vcodec") { for (int i = 0; i < ui->videoCodecCombo->count(); i++) if (ui->videoCodecCombo->itemText(i) == preset.get("vcodec")) ui->videoCodecCombo->setCurrentIndex(i); } else if (name == "ar") ui->sampleRateCombo->lineEdit()->setText(preset.get("ar")); else if (name == "ab") ui->audioBitrateCombo->lineEdit()->setText(preset.get("ab")); else if (name == "vb") { ui->videoRateControlCombo->setCurrentIndex(RateControlAverage); ui->videoBitrateCombo->lineEdit()->setText(preset.get("vb")); } else if (name == "g") ui->gopSpinner->setValue(preset.get_int("g")); else if (name == "bf") ui->bFramesSpinner->setValue(preset.get_int("bf")); else if (name == "deinterlace") { ui->scanModeCombo->setCurrentIndex(preset.get_int("deinterlace")); ui->scanModeCombo->setEnabled(false); } else if (name == "progressive") { ui->scanModeCombo->setCurrentIndex(preset.get_int("progressive")); ui->scanModeCombo->setEnabled(false); } else if (name == "top_field_first") { ui->fieldOrderCombo->setCurrentIndex(preset.get_int("top_field_first")); } else if (name == "width") { ui->widthSpinner->setValue(preset.get_int("width")); ui->widthSpinner->setEnabled(false); } else if (name == "height") { ui->heightSpinner->setValue(preset.get_int("height")); ui->heightSpinner->setEnabled(false); } else if (name == "aspect") { double dar = preset.get_double("aspect"); switch (int(dar * 100)) { case 133: ui->aspectNumSpinner->setValue(4); ui->aspectDenSpinner->setValue(3); break; case 177: ui->aspectNumSpinner->setValue(16); ui->aspectDenSpinner->setValue(9); break; case 56: ui->aspectNumSpinner->setValue(9); ui->aspectDenSpinner->setValue(16); break; default: ui->aspectNumSpinner->setValue(dar * 1000); ui->aspectDenSpinner->setValue(1000); break; } ui->aspectNumSpinner->setEnabled(false); ui->aspectDenSpinner->setEnabled(false); } else if (name == "r") { ui->fpsSpinner->setValue(preset.get_double("r")); ui->fpsSpinner->setEnabled(false); } else if (name == "pix_fmt") { QString pix_fmt(preset.get("pix_fmt")); if (pix_fmt != "yuv420p") other.append(QString("%1=%2").arg(name).arg(pix_fmt)); } else if (name == "pass") ui->dualPassCheckbox->setChecked(true); else if (name == "aq") { ui->audioRateControlCombo->setCurrentIndex(RateControlQuality); audioQuality = preset.get_int("aq"); } else if (name == "vbr") { // libopus rate mode QString value(preset.get("vbr")); if (value == "off") ui->audioRateControlCombo->setCurrentIndex(RateControlConstant); else if (value == "constrained") ui->audioRateControlCombo->setCurrentIndex(RateControlAverage); else ui->audioRateControlCombo->setCurrentIndex(RateControlQuality); } else if (name == "vq") { ui->videoRateControlCombo->setCurrentIndex(RateControlQuality); videoQuality = preset.get_int("vq"); } else if (name == "qscale") { ui->videoRateControlCombo->setCurrentIndex(RateControlQuality); videoQuality = preset.get_int("qscale"); } else if (name == "crf") { ui->videoRateControlCombo->setCurrentIndex(RateControlQuality); videoQuality = preset.get_int("crf"); } else if (name == "bufsize") { // traditionally this means video only ui->videoRateControlCombo->setCurrentIndex(RateControlConstant); ui->videoBufferSizeSpinner->setValue(getBufferSize(preset, "bufsize")); } else if (name == "vbufsize") { ui->videoRateControlCombo->setCurrentIndex(RateControlConstant); ui->videoBufferSizeSpinner->setValue(getBufferSize(preset, "vbufsize")); } else if (name == "threads") { // TODO: should we save the thread count and restore it if preset is not 1? if (preset.get_int("threads") == 1) ui->videoCodecThreadsSpinner->setValue(1); } else if (name == "meta.preset.extension") { m_extension = preset.get("meta.preset.extension"); } else if (name == "deinterlace_method") { name = preset.get("deinterlace_method"); if (name == "onefield") ui->deinterlacerCombo->setCurrentIndex(0); else if (name == "linearblend") ui->deinterlacerCombo->setCurrentIndex(1); else if (name == "yadif-nospatial") ui->deinterlacerCombo->setCurrentIndex(2); else if (name == "yadif") ui->deinterlacerCombo->setCurrentIndex(3); ui->deinterlacerCombo->setDisabled(true); } else if (name == "rescale") { name = preset.get("rescale"); if (name == "nearest" || name == "neighbor") ui->interpolationCombo->setCurrentIndex(0); else if (name == "bilinear") ui->interpolationCombo->setCurrentIndex(1); else if (name == "bicubic") ui->interpolationCombo->setCurrentIndex(2); else if (name == "hyper" || name == "lanczos") ui->interpolationCombo->setCurrentIndex(3); ui->interpolationCombo->setDisabled(true); } else if (name != "an" && name != "vn" && name != "threads" && !name.startsWith('_') && !name.startsWith("meta.preset.")) { other.append(QString("%1=%2").arg(name).arg(preset.get(i))); } } ui->advancedTextEdit->setPlainText(other.join("\n")); // normalize the quality settings // quality depends on codec if (ui->audioRateControlCombo->currentIndex() == RateControlQuality && audioQuality > -1) { const QString& acodec = ui->audioCodecCombo->currentText(); if (acodec == "libmp3lame") // 0 (best) - 9 (worst) ui->audioQualitySpinner->setValue(TO_RELATIVE(9, 0, audioQuality)); if (acodec == "libvorbis" || acodec == "vorbis") // 0 (worst) - 10 (best) ui->audioQualitySpinner->setValue(TO_RELATIVE(0, 10, audioQuality)); else // aac: 0 (worst) - 500 (best) ui->audioQualitySpinner->setValue(TO_RELATIVE(0, 500, audioQuality)); } if (ui->videoRateControlCombo->currentIndex() == RateControlQuality && videoQuality > -1) { const QString& vcodec = ui->videoCodecCombo->currentText(); //val = min + (max - min) * paramval; if (vcodec == "libx264" || vcodec == "libx265") // 0 (best, 100%) - 51 (worst) ui->videoQualitySpinner->setValue(TO_RELATIVE(51, 0, videoQuality)); else if (vcodec.startsWith("libvpx")) // 0 (best, 100%) - 63 (worst) ui->videoQualitySpinner->setValue(TO_RELATIVE(63, 0, videoQuality)); else // 1 (best, NOT 100%) - 31 (worst) ui->videoQualitySpinner->setValue(TO_RELATIVE(31, 1, videoQuality)); } on_audioRateControlCombo_activated(ui->audioRateControlCombo->currentIndex()); on_videoRateControlCombo_activated(ui->videoRateControlCombo->currentIndex()); }