mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	FFmpegDL: Added external_dlls folder to user folder
AACDecoder: addressed reviews
This commit is contained in:
		
							parent
							
								
									45b5de7a18
								
							
						
					
					
						commit
						847003cc1c
					
				
					 5 changed files with 27 additions and 18 deletions
				
			
		|  | @ -9,7 +9,7 @@ namespace AudioCore::HLE { | |||
| 
 | ||||
| class AACDecoder::Impl { | ||||
| public: | ||||
|     Impl(Memory::MemorySystem& memory); | ||||
|     explicit Impl(Memory::MemorySystem& memory); | ||||
|     ~Impl(); | ||||
|     std::optional<BinaryResponse> ProcessRequest(const BinaryRequest& request); | ||||
| 
 | ||||
|  | @ -77,8 +77,12 @@ std::optional<BinaryResponse> AACDecoder::Impl::Initalize(const BinaryRequest& r | |||
|         Clear(); | ||||
|     } | ||||
| 
 | ||||
|     BinaryResponse response; | ||||
|     std::memcpy(&response, &request, sizeof(response)); | ||||
|     response.unknown1 = 0x0; | ||||
| 
 | ||||
|     if (!have_ffmpeg_dl) { | ||||
|         return {}; | ||||
|         return response; | ||||
|     } | ||||
| 
 | ||||
|     av_packet = av_packet_alloc_dl(); | ||||
|  | @ -86,31 +90,27 @@ std::optional<BinaryResponse> AACDecoder::Impl::Initalize(const BinaryRequest& r | |||
|     codec = avcodec_find_decoder_dl(AV_CODEC_ID_AAC); | ||||
|     if (!codec) { | ||||
|         LOG_ERROR(Audio_DSP, "Codec not found\n"); | ||||
|         return {}; | ||||
|         return response; | ||||
|     } | ||||
| 
 | ||||
|     parser = av_parser_init_dl(codec->id); | ||||
|     if (!parser) { | ||||
|         LOG_ERROR(Audio_DSP, "Parser not found\n"); | ||||
|         return {}; | ||||
|         return response; | ||||
|     } | ||||
| 
 | ||||
|     av_context = avcodec_alloc_context3_dl(codec); | ||||
|     if (!av_context) { | ||||
|         LOG_ERROR(Audio_DSP, "Could not allocate audio codec context\n"); | ||||
|         return {}; | ||||
|         return response; | ||||
|     } | ||||
| 
 | ||||
|     if (avcodec_open2_dl(av_context, codec, NULL) < 0) { | ||||
|         LOG_ERROR(Audio_DSP, "Could not open codec\n"); | ||||
|         return {}; | ||||
|         return response; | ||||
|     } | ||||
| 
 | ||||
|     initalized = true; | ||||
| 
 | ||||
|     BinaryResponse response; | ||||
|     std::memcpy(&response, &request, sizeof(response)); | ||||
|     response.unknown1 = 0x0; | ||||
|     return response; | ||||
| } | ||||
| 
 | ||||
|  | @ -139,7 +139,8 @@ std::optional<BinaryResponse> AACDecoder::Impl::Decode(const BinaryRequest& requ | |||
|         return response; | ||||
|     } | ||||
| 
 | ||||
|     if (request.src_addr < Memory::FCRAM_PADDR) { | ||||
|     if (request.src_addr < Memory::FCRAM_PADDR || | ||||
|         request.src_addr + request.size > Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) { | ||||
|         LOG_ERROR(Audio_DSP, "Got out of bounds src_addr {:08x}", request.src_addr); | ||||
|         return {}; | ||||
|     } | ||||
|  | @ -190,7 +191,7 @@ std::optional<BinaryResponse> AACDecoder::Impl::Decode(const BinaryRequest& requ | |||
| 
 | ||||
|                 std::size_t size = bytes_per_sample * (decoded_frame->nb_samples); | ||||
| 
 | ||||
|                 // FFmpeg converts to 32 signed floating point PCM, we need s32 PCM so we need to
 | ||||
|                 // FFmpeg converts to 32 signed floating point PCM, we need s16 PCM so we need to
 | ||||
|                 // convert it
 | ||||
|                 f32 val_float; | ||||
|                 for (std::size_t current_pos(0); current_pos < size;) { | ||||
|  | @ -207,14 +208,16 @@ std::optional<BinaryResponse> AACDecoder::Impl::Decode(const BinaryRequest& requ | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (request.dst_addr_ch0 < Memory::FCRAM_PADDR) { | ||||
|     if (request.dst_addr_ch0 < Memory::FCRAM_PADDR || | ||||
|         request.dst_addr_ch0 + out_streams[0].size() > Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) { | ||||
|         LOG_ERROR(Audio_DSP, "Got out of bounds dst_addr_ch0 {:08x}", request.dst_addr_ch0); | ||||
|         return {}; | ||||
|     } | ||||
|     std::memcpy(memory.GetFCRAMPointer(request.dst_addr_ch0 - Memory::FCRAM_PADDR), | ||||
|                 out_streams[0].data(), out_streams[0].size()); | ||||
| 
 | ||||
|     if (request.dst_addr_ch1 < Memory::FCRAM_PADDR) { | ||||
|     if (request.dst_addr_ch1 < Memory::FCRAM_PADDR || | ||||
|         request.dst_addr_ch1 + out_streams[1].size() > Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) { | ||||
|         LOG_ERROR(Audio_DSP, "Got out of bounds dst_addr_ch1 {:08x}", request.dst_addr_ch1); | ||||
|         return {}; | ||||
|     } | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| #include <windows.h> | ||||
| #endif // _WIN32
 | ||||
| 
 | ||||
| #include "common/file_util.h" | ||||
| #include "common/logging/log.h" | ||||
| 
 | ||||
| extern "C" { | ||||
|  | @ -20,9 +21,8 @@ template <typename T> | |||
| struct FuncDL { | ||||
|     FuncDL() = default; | ||||
|     FuncDL(HMODULE dll, const char* name) { | ||||
|         ptr_function = nullptr; | ||||
|         if (dll) { | ||||
|             *(void**)&ptr_function = (void*)GetProcAddress(dll, name); | ||||
|             ptr_function = reinterpret_cast<T*>(GetProcAddress(dll, name)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -35,7 +35,6 @@ struct FuncDL { | |||
|     } | ||||
| 
 | ||||
|     T* ptr_function = nullptr; | ||||
|     ; | ||||
| }; | ||||
| 
 | ||||
| FuncDL<int(AVSampleFormat)> av_get_bytes_per_sample_dl; | ||||
|  | @ -56,6 +55,10 @@ FuncDL<int(AVCodecParserContext*, AVCodecContext*, uint8_t**, int*, const uint8_ | |||
| FuncDL<void(AVCodecParserContext*)> av_parser_close_dl; | ||||
| 
 | ||||
| bool InitFFmpegDL() { | ||||
| 
 | ||||
|     FileUtil::CreateDir(FileUtil::GetUserPath(FileUtil::UserPath::DLLDir)); | ||||
|     SetDllDirectoryA(FileUtil::GetUserPath(FileUtil::UserPath::DLLDir).c_str()); | ||||
| 
 | ||||
|     HMODULE dll_util = nullptr; | ||||
|     dll_util = LoadLibrary("avutil-56.dll"); | ||||
|     if (!dll_util) { | ||||
|  |  | |||
|  | @ -38,6 +38,7 @@ | |||
| #define SYSDATA_DIR "sysdata" | ||||
| #define LOG_DIR "log" | ||||
| #define CHEATS_DIR "cheats" | ||||
| #define DLL_DIR "external_dlls" | ||||
| 
 | ||||
| // Filenames
 | ||||
| // Files in the directory returned by GetUserPath(UserPath::LogDir)
 | ||||
|  |  | |||
|  | @ -711,6 +711,7 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) { | |||
|         // TODO: Put the logs in a better location for each OS
 | ||||
|         paths.emplace(UserPath::LogDir, user_path + LOG_DIR DIR_SEP); | ||||
|         paths.emplace(UserPath::CheatsDir, user_path + CHEATS_DIR DIR_SEP); | ||||
|         paths.emplace(UserPath::DLLDir, user_path + DLL_DIR DIR_SEP); | ||||
|     } | ||||
| 
 | ||||
|     if (!new_path.empty()) { | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ enum class UserPath { | |||
|     CacheDir, | ||||
|     CheatsDir, | ||||
|     ConfigDir, | ||||
|     DLLDir, | ||||
|     LogDir, | ||||
|     NANDDir, | ||||
|     RootDir, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue