static void LoadChexDeh(void) { char *chex_deh = NULL; char *sep; if (gameversion == exe_chex) { // Look for chex.deh in the same directory as the IWAD file. sep = strrchr(iwadfile, DIR_SEPARATOR); if (sep != NULL) { size_t chex_deh_len = strlen(iwadfile) + 9; chex_deh = malloc(chex_deh_len); M_StringCopy(chex_deh, iwadfile, chex_deh_len); chex_deh[sep - iwadfile + 1] = '\0'; M_StringConcat(chex_deh, "chex.deh", chex_deh_len); } else { chex_deh = strdup("chex.deh"); } // If the dehacked patch isn't found, try searching the WAD // search path instead. We might find it... if (!M_FileExists(chex_deh)) { free(chex_deh); chex_deh = D_FindWADByName("chex.deh"); } // Still not found? if (chex_deh == NULL) { I_Error("Unable to find Chex Quest dehacked file (chex.deh).\n" "The dehacked file is required in order to emulate\n" "chex.exe correctly. It can be found in your nearest\n" "/idgames repository mirror at:\n\n" " utils/exe_edit/patches/chexdeh.zip"); } if (!DEH_LoadFile(chex_deh)) { I_Error("Failed to load chex.deh needed for emulating chex.exe."); } } }
char *D_TryFindWADByName(char *filename) { char *result; result = D_FindWADByName(filename); if (result != NULL) { return result; } else { return filename; } }
char *D_FindIWAD(int mask, GameMission_t *mission) { char *result; char *iwadfile; int iwadparm; int i; // Check for the -iwad parameter //! // Specify an IWAD file to use. // // @arg <file> // iwadparm = M_CheckParmWithArgs("-iwad", 1); if (iwadparm) { // Search through IWAD dirs for an IWAD with the given name. iwadfile = myargv[iwadparm + 1]; result = D_FindWADByName(iwadfile); if (result == NULL) { I_Error("IWAD file '%s' not found!", iwadfile); } *mission = IdentifyIWADByName(result, mask); } else { // Search through the list and look for an IWAD result = NULL; BuildIWADDirList(); for (i=0; result == NULL && i<num_iwad_dirs; ++i) { result = SearchDirectoryForIWAD(iwad_dirs[i], mask, mission); } } return result; }
void D_FindInstalledIWADs(void) { uint32_t i; int32_t result; BuildIWADDirList(); result = 0; for (i=0; i<arrlen(iwads); ++i) { if (D_FindWADByName(iwads[i].name) != NULL) { result |= 1 << i; } } exit(result); }
// // FindIWAD // Checks availability of IWAD files by name, // to determine whether registered/commercial features // should be executed (notably loading PWADs). // char *D_FindIWAD(void) { char *result = NULL; char *iwadfile; int iwadparm = M_CheckParmWithArgs("-iwad", 1); if (iwadparm) { // Search through IWAD dirs for an IWAD with the given name. iwadfile = myargv[iwadparm + 1]; result = D_FindWADByName(iwadfile); if (result == NULL) I_Error("The IWAD file \"%s\" wasn't found!", iwadfile); IdentifyIWADByName(result); } return result; }
// Load dehacked patches needed for certain IWADs. static void LoadIwadDeh(void) { // The Freedoom IWADs have DEHACKED lumps that must be loaded. if (W_CheckNumForName("FREEDOOM") >= 0) { // Old versions of Freedoom (before 2014-09) did not have technically // valid DEHACKED lumps, so ignore errors and just continue if this // is an old IWAD. DEH_LoadLumpByName("DEHACKED", false, true); } // If this is the HACX IWAD, we need to load the DEHACKED lump. if (gameversion == exe_hacx) { if (!DEH_LoadLumpByName("DEHACKED", true, false)) { I_Error("DEHACKED lump not found. Please check that this is the " "Hacx v1.2 IWAD."); } } // Chex Quest needs a separate Dehacked patch which must be downloaded // and installed next to the IWAD. if (gameversion == exe_chex) { char *chex_deh = NULL; char *sep; // Look for chex.deh in the same directory as the IWAD file. sep = strrchr(iwadfile, DIR_SEPARATOR); if (sep != NULL) { size_t chex_deh_len = strlen(iwadfile) + 9; chex_deh = malloc(chex_deh_len); M_StringCopy(chex_deh, iwadfile, chex_deh_len); chex_deh[sep - iwadfile + 1] = '\0'; M_StringConcat(chex_deh, "chex.deh", chex_deh_len); } else { chex_deh = M_StringDuplicate("chex.deh"); } // If the dehacked patch isn't found, try searching the WAD // search path instead. We might find it... if (!M_FileExists(chex_deh)) { free(chex_deh); chex_deh = D_FindWADByName("chex.deh"); } // Still not found? if (chex_deh == NULL) { I_Error("Unable to find Chex Quest dehacked file (chex.deh).\n" "The dehacked file is required in order to emulate\n" "chex.exe correctly. It can be found in your nearest\n" "/idgames repository mirror at:\n\n" " utils/exe_edit/patches/chexdeh.zip"); } if (!DEH_LoadFile(chex_deh)) { I_Error("Failed to load chex.deh needed for emulating chex.exe."); } } }
// // D_DoomMain // void D_DoomMain (void) { int p; char file[256]; char demolumpname[9]; M_FindResponseFile (); // Undocumented "search for IWADs" parameter used by the setup // tool. if (M_CheckParm("-findiwads") > 0) { D_FindInstalledIWADs(); } // print banner PrintBanner(PACKAGE_STRING); DEH_printf("Z_Init: Init zone memory allocation daemon. \n"); Z_Init (); #ifdef FEATURE_MULTIPLAYER //! // @category net // // Start a dedicated server, routing packets but not participating // in the game itself. // if (M_CheckParm("-dedicated") > 0) { printf("Dedicated server mode.\n"); NET_DedicatedServer(); // Never returns } //! // @category net // // Query the Internet master server for a global list of active // servers. // if (M_CheckParm("-search")) { printf("\nSearching for servers on Internet ...\n"); p = NET_MasterQuery(NET_QueryPrintCallback, NULL); printf("\n%i server(s) found.\n", p); exit(0); } //! // @arg <address> // @category net // // Query the status of the server running on the given IP // address. // p = M_CheckParmWithArgs("-query", 1); if (p) { NET_QueryAddress(myargv[p+1]); exit(0); } //! // @category net // // Search the local LAN for running servers. // if (M_CheckParm("-localsearch")) { printf("\nSearching for servers on local LAN ...\n"); p = NET_LANQuery(NET_QueryPrintCallback, NULL); printf("\n%i server(s) found.\n", p); exit(0); } #endif #ifdef FEATURE_DEHACKED printf("DEH_Init: Init Dehacked support.\n"); DEH_Init(); #endif iwadfile = D_FindIWAD(); // *** PID BEGIN *** psdoom1wad = D_FindWADByName("psdoom1.wad"); psdoom2wad = D_FindWADByName("psdoom2.wad"); // *** PID END *** // None found? if (iwadfile == NULL) { I_Error("Game mode indeterminate. No IWAD file was found. Try\n" "specifying one with the '-iwad' command line parameter.\n"); } modifiedgame = false; //! // @vanilla // // Disable monsters. // nomonsters = M_CheckParm ("-nomonsters"); // This keeps a 'no monsters' that is persistant across new games // and level warps. if ( (nomonstersperiod = M_CheckParm("-nomonsters.") ) ) { nomonsters = true; } // This makes items respawn as in -altdeath (ie. no dropped items, // no invis, no invun) respawnitems = M_CheckParm("-respawnitems"); //! // @vanilla // // Monsters respawn after being killed. // respawnparm = M_CheckParm ("-respawn"); //! // @vanilla // // Monsters move faster. // fastparm = M_CheckParm ("-fast"); //! // @vanilla // // Developer mode. F1 saves a screenshot in the current working // directory. // devparm = M_CheckParm ("-devparm"); //! // @category net // @vanilla // // Start a deathmatch game. // if (M_CheckParm ("-deathmatch")) deathmatch = 1; //! // @category net // @vanilla // // Start a deathmatch 2.0 game. Weapons do not stay in place and // all items respawn after 30 seconds. // if (M_CheckParm ("-altdeath")) deathmatch = 2; if (devparm) DEH_printf(D_DEVSTR); // find which dir to use for config files M_SetConfigDir(); //! // @arg <x> // @vanilla // // Turbo mode. The player's speed is multiplied by x%. If unspecified, // x defaults to 200. Values are rounded up to 10 and down to 400. // if ( (p=M_CheckParm ("-turbo")) ) { int scale = 200; extern int forwardmove[2]; extern int sidemove[2]; if (p<myargc-1) scale = atoi (myargv[p+1]); if (scale < 10) scale = 10; if (scale > 400) scale = 400; DEH_printf("turbo scale: %i%%\n", scale); forwardmove[0] = forwardmove[0]*scale/100; forwardmove[1] = forwardmove[1]*scale/100; sidemove[0] = sidemove[0]*scale/100; sidemove[1] = sidemove[1]*scale/100; } // init subsystems DEH_printf("V_Init: allocate screens.\n"); V_Init (); DEH_printf("M_LoadDefaults: Load system defaults.\n"); M_ApplyPlatformDefaults(); M_LoadDefaults (); // load before initing other systems DEH_printf("W_Init: Init WADfiles.\n"); D_AddFile(iwadfile); // *** PID BEGIN *** // If the command-line flag to suppress auto-loading of custom // ps management levels is *not* there, load the appropriate level. p = M_CheckParm ("-nopslev"); if (p) { // Add psdoom1.wad if this is registered (Doom 1) or retail (Ultimite Doom). // If we loaded it, set the flag to true so we can place the monsters in the // correct positions. if ( gamemode == registered || gamemode == retail ){ D_AddFile(iwadfile); ps_level_loaded = true; } // Add psdoom2.wad if this is commercial (Doom 2) and not an add-on pack. // If we loaded it, set the flag to true so we can place the monsters in the // correct positions. if ( gamemode == commercial && gamemission == doom2 ) { D_AddFile(iwadfile); ps_level_loaded = true; } } // *** PID END *** #ifdef FEATURE_WAD_MERGE // Merged PWADs are loaded first, because they are supposed to be // modified IWADs. //! // @arg <files> // @category mod // // Simulates the behavior of deutex's -merge option, merging a PWAD // into the main IWAD. Multiple files may be specified. // p = M_CheckParmWithArgs("-merge", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging %s\n", filename); W_MergeFile(filename); } } // NWT-style merging: // NWT's -merge option: //! // @arg <files> // @category mod // // Simulates the behavior of NWT's -merge option. Multiple files // may be specified. p = M_CheckParmWithArgs("-nwtmerge", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" performing NWT-style merge of %s\n", filename); W_NWTDashMerge(filename); } } // Add flats //! // @arg <files> // @category mod // // Simulates the behavior of NWT's -af option, merging flats into // the main IWAD directory. Multiple files may be specified. // p = M_CheckParmWithArgs("-af", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging flats from %s\n", filename); W_NWTMergeFile(filename, W_NWT_MERGE_FLATS); } } //! // @arg <files> // @category mod // // Simulates the behavior of NWT's -as option, merging sprites // into the main IWAD directory. Multiple files may be specified. // p = M_CheckParmWithArgs("-as", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging sprites from %s\n", filename); W_NWTMergeFile(filename, W_NWT_MERGE_SPRITES); } } //! // @arg <files> // @category mod // // Equivalent to "-af <files> -as <files>". // p = M_CheckParmWithArgs("-aa", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging sprites and flats from %s\n", filename); W_NWTMergeFile(filename, W_NWT_MERGE_SPRITES | W_NWT_MERGE_FLATS); } } #endif //! // @arg <files> // @vanilla // // Load the specified PWAD files. // p = M_CheckParmWithArgs("-file", 1); if (p) { // the parms after p are wadfile/lump names, // until end of parms or another - preceded parm modifiedgame = true; // homebrew levels while (++p != myargc && myargv[p][0] != '-') { char *filename; filename = D_TryFindWADByName(myargv[p]); D_AddFile(filename); } } // Debug: // W_PrintDirectory(); //! // @arg <demo> // @category demo // @vanilla // // Play back the demo named demo.lmp. // p = M_CheckParmWithArgs ("-playdemo", 1); if (!p) { //! // @arg <demo> // @category demo // @vanilla // // Play back the demo named demo.lmp, determining the framerate // of the screen. // p = M_CheckParmWithArgs("-timedemo", 1); } if (p) { if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp")) { strcpy(file, myargv[p + 1]); } else { sprintf (file,"%s.lmp", myargv[p+1]); } if (D_AddFile (file)) { strncpy(demolumpname, lumpinfo[numlumps - 1].name, 8); demolumpname[8] = '\0'; printf("Playing demo %s.\n", file); } else { // If file failed to load, still continue trying to play // the demo in the same way as Vanilla Doom. This makes // tricks like "-playdemo demo1" possible. strncpy(demolumpname, myargv[p + 1], 8); demolumpname[8] = '\0'; } } // Generate the WAD hash table. Speed things up a bit. W_GenerateHashTable(); D_IdentifyVersion(); InitGameVersion(); LoadChexDeh(); LoadHacxDeh(); D_SetGameDescription(); D_SetSaveGameDir(); // Check for -file in shareware if (modifiedgame) { // These are the lumps that will be checked in IWAD, // if any one is not present, execution will be aborted. char name[23][8]= { "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9", "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9", "dphoof","bfgga0","heada1","cybra1","spida1d1" }; int i; if ( gamemode == shareware) I_Error(DEH_String("\nYou cannot -file with the shareware " "version. Register!")); // Check for fake IWAD with right name, // but w/o all the lumps of the registered version. if (gamemode == registered) for (i = 0;i < 23; i++) if (W_CheckNumForName(name[i])<0) I_Error(DEH_String("\nThis is not the registered version.")); } // get skill / episode / map from parms startskill = sk_medium; startepisode = 1; startmap = 1; autostart = false; //! // @arg <skill> // @vanilla // // Set the game skill, 1-5 (1: easiest, 5: hardest). A skill of // 0 disables all monsters. // p = M_CheckParmWithArgs("-skill", 1); if (p) { startskill = myargv[p+1][0]-'1'; autostart = true; } //! // @arg <n> // @vanilla // // Start playing on episode n (1-4) // p = M_CheckParmWithArgs("-episode", 1); if (p) { startepisode = myargv[p+1][0]-'0'; startmap = 1; autostart = true; } timelimit = 0; //! // @arg <n> // @category net // @vanilla // // For multiplayer games: exit each level after n minutes. // p = M_CheckParmWithArgs("-timer", 1); if (p) { timelimit = atoi(myargv[p+1]); } //! // @category net // @vanilla // // Austin Virtual Gaming: end levels after 20 minutes. // p = M_CheckParm ("-avg"); if (p) { timelimit = 20; } //! // @arg [<x> <y> | <xy>] // @vanilla // // Start a game immediately, warping to ExMy (Doom 1) or MAPxy // (Doom 2) // p = M_CheckParmWithArgs("-warp", 1); if (p) { if (gamemode == commercial) startmap = atoi (myargv[p+1]); else { startepisode = myargv[p+1][0]-'0'; if (p + 2 < myargc) { startmap = myargv[p+2][0]-'0'; } else { startmap = 1; } } autostart = true; } // Undocumented: // Invoked by setup to test the controls. p = M_CheckParm("-testcontrols"); if (p > 0) { startepisode = 1; startmap = 1; autostart = true; testcontrols = true; } // Check for load game parameter // We do this here and save the slot number, so that the network code // can override it or send the load slot to other players. //! // @arg <s> // @vanilla // // Load the game in slot s. // p = M_CheckParmWithArgs("-loadgame", 1); if (p) { startloadgame = atoi(myargv[p+1]); } else { // Not loading a game startloadgame = -1; } //! // @category video // // Disable vertical mouse movement. // if (M_CheckParm("-novert")) novert = true; //! // @category video // // Enable vertical mouse movement. // if (M_CheckParm("-nonovert")) novert = false; if (W_CheckNumForName("SS_START") >= 0 || W_CheckNumForName("FF_END") >= 0) { printf ("===========================================================================\n"); printf(" WARNING: The loaded WAD file contains modified sprites or\n" " floor textures. You may want to use the '-merge' command\n" " line option instead of '-file'.\n"); } printf ("===========================================================================\n"); PrintBanner(gamedescription); printf ( "===========================================================================\n" " " PACKAGE_NAME " is free software, covered by the GNU General Public\n" " License. There is NO warranty; not even for MERCHANTABILITY or FITNESS\n" " FOR A PARTICULAR PURPOSE. You are welcome to change and distribute\n" " copies under certain conditions. See the source for more information.\n" "===========================================================================\n" ); PrintDehackedBanners(); DEH_printf("M_Init: Init miscellaneous info.\n"); M_Init (); DEH_printf("R_Init: Init DOOM refresh daemon - "); R_Init (); DEH_printf("\nP_Init: Init Playloop state.\n"); P_Init (); DEH_printf("I_Init: Setting up machine state.\n"); I_Init (); #ifdef FEATURE_MULTIPLAYER printf ("NET_Init: Init network subsystem.\n"); NET_Init (); #endif DEH_printf("S_Init: Setting up sound.\n"); S_Init (sfxVolume * 8, musicVolume * 8); DEH_printf("D_CheckNetGame: Checking network game status.\n"); D_CheckNetGame (); PrintGameVersion(); DEH_printf("HU_Init: Setting up heads up display.\n"); HU_Init (); DEH_printf("ST_Init: Init status bar.\n"); ST_Init (); // If Doom II without a MAP01 lump, this is a store demo. // Moved this here so that MAP01 isn't constantly looked up // in the main loop. if (gamemode == commercial && W_CheckNumForName("map01") < 0) storedemo = true; //! // @arg <x> // @category demo // @vanilla // // Record a demo named x.lmp. // p = M_CheckParmWithArgs("-record", 1); if (p) { G_RecordDemo (myargv[p+1]); autostart = true; } p = M_CheckParmWithArgs("-playdemo", 1); if (p) { singledemo = true; // quit after one demo G_DeferedPlayDemo (demolumpname); D_DoomLoop (); // never returns } p = M_CheckParmWithArgs("-timedemo", 1); if (p) { G_TimeDemo (demolumpname); D_DoomLoop (); // never returns } if (startloadgame >= 0) { strcpy(file, P_SaveGameFile(startloadgame)); G_LoadGame (file); } if (gameaction != ga_loadgame ) { if (autostart || netgame) G_InitNew (startskill, startepisode, startmap); else D_StartTitle (); // start up intro loop } D_DoomLoop (); // never returns }
void D_IdentifyVersion(void) { // gamemission is set up by the D_FindIWAD function. But if // we specify '-iwad', we have to identify using // IdentifyIWADByName. However, if the iwad does not match // any known IWAD name, we may have a dilemma. Try to // identify by its contents. // STRIFE-TODO: some elaborate checks? for now we assume... // The logic in strife1.exe is simple: // * if strife1.wad is found, set isregistered = true // * if strife0.wad is found, set isdemoversion = true // Make sure gamemode is set up correctly gamemode = commercial; gamemission = strife; isregistered = true; // Load voices.wad if(isregistered) { char *name = D_FindWADByName("voices.wad"); if(!name) // not found? { int p; // haleyjd STRIFE-FIXME: Temporary? // If -iwad was used, check and see if voices.wad exists on the // same filepath. if((p = M_CheckParm("-iwad")) && p < myargc - 1) { char *iwad = myargv[p + 1]; size_t len = strlen(iwad) + 24; char *filename = malloc(len); char sepchar; // how the heck is Choco surviving without this routine? sepchar = M_GetFilePath(iwad, filename, len); filename[strlen(filename)] = sepchar; M_StringConcat(filename, "voices.wad", sizeof(filename)); if(!M_FileExists(filename)) disable_voices = 1; else name = filename; // STRIFE-FIXME: memory leak!! } else disable_voices = 1; } if(disable_voices) // voices disabled? { if(devparm) printf("Voices disabled\n"); return; } D_AddFile(name); } }
// // D_TryWADByName // // Searches for a WAD by its filename, or passes through the filename // if not found. // char *D_TryFindWADByName(char *filename) { char *result = D_FindWADByName(filename); return (result ? result : filename); }
void D_IdentifyVersion(void) { // gamemission is set up by the D_FindIWAD function. But if // we specify '-iwad', we have to identify using // IdentifyIWADByName. However, if the iwad does not match // any known IWAD name, we may have a dilemma. Try to // identify by its contents. // STRIFE-TODO: some elaborate checks? for now we assume... // The logic in strife1.exe is simple: // * if strife1.wad is found, set isregistered = true // * if strife0.wad is found, set isdemoversion = true // Make sure gamemode is set up correctly gamemode = commercial; gamemission = strife; isregistered = true; // Load voices.wad if(isregistered) { char *name = D_FindWADByName("voices.wad"); if(!name) // not found? { int p; // haleyjd STRIFE-FIXME: Temporary? // If -iwad was used, check and see if voices.wad exists on the // same filepath. if((p = M_CheckParm("-iwad")) && p < myargc - 1) { char *iwad = myargv[p + 1]; size_t len = strlen(iwad) + 1; char *iwadpath = Z_Malloc(len, PU_STATIC, NULL); char *voiceswad; // extract base path of IWAD parameter M_GetFilePath(iwad, iwadpath, len); // concatenate with /voices.wad voiceswad = M_SafeFilePath(iwadpath, "voices.wad"); Z_Free(iwadpath); if(!M_FileExists(voiceswad)) { disable_voices = 1; Z_Free(voiceswad); } else name = voiceswad; // STRIFE-FIXME: memory leak!! } else disable_voices = 1; } if(disable_voices) // voices disabled? { if(devparm) printf("Voices disabled\n"); return; } D_AddFile(name); } }
static boolean I_AVLoadVideo(const char *filename) { int i; int videoSize; int audioSize; char *filepath; // setup packet queues videoPacketQueue = I_AVAllocQueuePacket(); audioPacketQueue = I_AVAllocQueuePacket(); // setup audio queue audioQueue.mutex = SDL_CreateMutex(); audioQueue.first = NULL; userExit = false; videoFinished = false; audioFinished = false; audioPts = 0; videoClock = 0; audioClock = 0; // not exactly looking for a wad, but this function makes // it easier to find our movie file if(!(filepath = D_FindWADByName((char*)filename))) { return false; } if(avformat_open_input(&formatCtx, filepath, NULL, NULL)) { fprintf(stderr, "I_AVLoadVideo: Couldn't load %s\n", filepath); return false; } if(avformat_find_stream_info(formatCtx, NULL)) { fprintf(stderr, "I_AVLoadVideo: Couldn't find stream info\n"); return false; } #ifdef _DEBUG av_dump_format(formatCtx, 0, filepath, 0); #endif videoStreamIdx = -1; audioStreamIdx = -1; // find the video and audio stream for(i = 0; i < (int)formatCtx->nb_streams; i++) { switch(formatCtx->streams[i]->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: if(videoStreamIdx == -1) { videoStreamIdx = i; } break; case AVMEDIA_TYPE_AUDIO: if(audioStreamIdx == -1) { audioStreamIdx = i; } break; default: break; } } if(videoStreamIdx < 0) { fprintf(stderr, "I_AVLoadVideo: Couldn't find video stream\n"); return false; } if(!I_AVSetupCodecContext(&videoCodecCtx, &videoCodec, videoStreamIdx) || !I_AVSetupCodecContext(&audioCodecCtx, &audioCodec, audioStreamIdx)) { return false; } reqWidth = videoCodecCtx->width; reqHeight = videoCodecCtx->height; // setup texture texture.colorMode = TCR_RGB; texture.origwidth = reqWidth; texture.origheight = reqHeight; texture.width = texture.origwidth; texture.height = texture.origheight; FF_DISABLE_DEPRECATION_WARNINGS videoCodecCtx->get_buffer = I_AVGetBufferProc; videoCodecCtx->release_buffer = I_AVReleaseBufferProc; FF_ENABLE_DEPRECATION_WARNINGS videoFrame = av_frame_alloc(); videoSize = avpicture_get_size(AV_PIX_FMT_YUV444P, reqWidth, reqHeight); audioSize = MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE; videoBuffer = (uint8_t*)av_calloc(1, videoSize * sizeof(uint8_t)); audioBuffer = (uint8_t*)av_calloc(1, audioSize * sizeof(uint8_t)); RB_UploadTexture(&texture, videoBuffer, TC_CLAMP, TF_LINEAR); swsCtx = sws_getContext(videoCodecCtx->width, videoCodecCtx->height, videoCodecCtx->pix_fmt, reqWidth, reqHeight, AV_PIX_FMT_YUV444P, SWS_BICUBIC, NULL, NULL, NULL); // assign appropriate parts of buffer to image planes in videoFrame // Note that videoFrame is an AVFrame, but AVFrame is a superset // of AVPicture avpicture_fill((AVPicture*)videoFrame, videoBuffer, AV_PIX_FMT_YUV444P, reqWidth, reqHeight); currentPts = av_gettime(); frameTime = 1000.0 / av_q2d(videoCodecCtx->framerate); lastFrameTime = frameTime; return true; }