Skip to content

Commit

Permalink
Basic refactor to let VideoDecoder decoder Audio/Video at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
hwsmm committed Sep 21, 2024
1 parent eefb825 commit 9781021
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 131 deletions.
4 changes: 2 additions & 2 deletions osu.Framework/Audio/SDL3AudioDecoderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ protected override int LoadFromStreamInternal(out byte[] decoded)
SDL3.SDL_AUDIO_ISFLOAT(AudioSpec.format), SDL3.SDL_AUDIO_BITSIZE(AudioSpec.format), SDL3.SDL_AUDIO_ISSIGNED(AudioSpec.format));

ffmpeg.PrepareDecoding();
ffmpeg.RecreateCodecContext();
ffmpeg.OpenAudioStream();

Bitrate = (int)ffmpeg.Bitrate;
Bitrate = (int)ffmpeg.AudioBitrate;
Length = ffmpeg.Duration;
ByteLength = (long)Math.Ceiling(ffmpeg.Duration / 1000.0d * AudioSpec.freq) * AudioSpec.channels * (SDL3.SDL_AUDIO_BITSIZE(AudioSpec.format) / 8); // FIXME

Expand Down
3 changes: 3 additions & 0 deletions osu.Framework/Graphics/Video/FFmpegFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public unsafe class FFmpegFuncs

public delegate long AvGetDefaultChannelLayoutDelegate(int nbChannels);

public delegate AVCodec* AvCodecFindDecoderDelegate(AVCodecID id);

#endregion

[CanBeNull]
Expand Down Expand Up @@ -163,6 +165,7 @@ public unsafe class FFmpegFuncs
public SwrGetDelayDelegate swr_get_delay;
public AvSamplesGetBufferSizeDelegate av_samples_get_buffer_size;
public AvGetDefaultChannelLayoutDelegate av_get_default_channel_layout;
public AvCodecFindDecoderDelegate avcodec_find_decoder;

// Touching AutoGen.ffmpeg or its LibraryLoader in any way on non-Desktop platforms
// will cause it to throw in static constructor, which can't be bypassed.
Expand Down
Loading

0 comments on commit 9781021

Please sign in to comment.