Beispiel #1
0
 /// <summary>
 /// </summary>
 /// <param name="channelLayout">see <see cref="AVChannelLayout"/></param>
 /// <param name="nbSamples">recommended use <see cref="AVCodecContext.frame_size"/></param>
 /// <param name="format"><see cref="AVCodecContext.sample_fmt"/></param>
 /// <param name="sampleRate"></param>
 /// <param name="align">
 /// Required buffer size alignment. If equal to 0, alignment will be chosen automatically for
 /// the current CPU. It is highly recommended to pass 0 here unless you know what you are doing.
 /// </param>
 public AudioFrame(AVChannelLayout channelLayout, int nbSamples, AVSampleFormat format, int sampleRate = 0, int align = 0)
     : this(ffmpeg.av_get_channel_layout_nb_channels((ulong)channelLayout), nbSamples, format, sampleRate, align)
 {
     unsafe
     {
         pFrame->channel_layout = (ulong)channelLayout;
     }
 }
Beispiel #2
0
 public AudioFormat(int sampleRate, AVChannelLayout channelLayout, AVSampleFormat sampleFormat)
 {
     SampleRate         = sampleRate;
     ChannelLayout      = channelLayout;
     SampleFormat       = sampleFormat;
     BitsPerSample      = GetBytePerSample(sampleFormat) * 8;
     ValidBitsPerSample = SampleFormat.EqualsType(AVSampleFormat.Int32) ? 24 : BitsPerSample;
 }
Beispiel #3
0
 public void Init(AVChannelLayout channelLayout, int nbSamples, AVSampleFormat format, int sampleRate = 0, int align = 0)
 {
     Clear();
     AllocBuffer(ffmpeg.av_get_channel_layout_nb_channels((ulong)channelLayout), nbSamples, format, sampleRate, align);
     unsafe
     {
         pFrame->channel_layout = (ulong)channelLayout;
     }
 }
Beispiel #4
0
 public AudioFormat(int sampleRate, AVChannelLayout channelLayout, AVSampleFormat sampleFormat)
 {
     SampleRate         = sampleRate;
     ChannelLayout      = channelLayout;
     SampleFormat       = sampleFormat;
     Channels           = GetChannels(channelLayout);
     BitsPerSample      = GetBytePerSample(sampleFormat) * 8;
     SampleType         = GetSampleType(sampleFormat);
     IsPlanarFormat     = sampleFormat.IsPlanar();
     LineCount          = IsPlanarFormat ? Channels : 1;
     LineBlock          = IsPlanarFormat ? (BitsPerSample >> 3) : (BitsPerSample >> 3) * Channels;
     ValidBitsPerSample = SampleFormat.EqualsType(AVSampleFormat.Int32) ? 24 : BitsPerSample;
 }
Beispiel #5
0
        public AudioFormat Match(IEnumerable <int> sampleRates, IEnumerable <AVSampleFormat> sampleFormats, IEnumerable <AVChannelLayout> channelLayouts)
        {
            int sampleRate = SampleRate;

            if (sampleRates != null)
            {
                foreach (var sr in sampleRates.OrderBy(sr => sr))
                {
                    sampleRate = sr;
                    if (sr >= SampleRate)
                    {
                        break;
                    }
                }
            }

            AVSampleFormat sampleFormat = SampleFormat;

            if (sampleFormats != null)
            {
                foreach (var sf in sampleFormats.OrderBy(sf => GetBytePerSample(sf)))
                {
                    sampleFormat = sf;
                    if (GetBytePerSample(sf) >= BitsPerSample >> 3)
                    {
                        break;
                    }
                }
            }

            AVChannelLayout channelLayout = ChannelLayout;

            if (channelLayouts != null)
            {
                foreach (var cl in channelLayouts.OrderBy(cl => GetChannels(cl)))
                {
                    channelLayout = cl;
                    if (GetChannels(cl) >= Channels)
                    {
                        break;
                    }
                }
            }

            return(new AudioFormat(sampleRate, channelLayout, sampleFormat));
        }
Beispiel #6
0
 /// <summary>
 /// Return the number of channels in the channel layout use <see cref="ffmpeg.av_get_channel_layout_nb_channels(ulong)"/>
 /// </summary>
 /// <param name="channelLayout"></param>
 /// <returns></returns>
 public static int ToChannels(this AVChannelLayout channelLayout)
 {
     return(ffmpeg.av_get_channel_layout_nb_channels((ulong)channelLayout));
 }
Beispiel #7
0
 public static extern SwrContext *swr_alloc_set_opts(SwrContext *s, AVChannelLayout out_ch_layout, AVSampleFormat out_sample_fmt, int out_sample_rate, AVChannelLayout in_ch_layout, AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx);
Beispiel #8
0
 public static extern byte *av_get_channel_description(AVChannelLayout channel);
Beispiel #9
0
 public static extern byte *av_get_channel_name(AVChannelLayout channel);
Beispiel #10
0
 public static extern AVChannelLayout av_channel_layout_extract_channel(AVChannelLayout channel_layout, int index);
Beispiel #11
0
 public static extern int av_get_channel_layout_channel_index(AVChannelLayout channel_layout, AVChannelLayout channel);
Beispiel #12
0
 public static extern int av_get_channel_layout_nb_channels(AVChannelLayout channel_layout);
Beispiel #13
0
 public static extern void av_get_channel_layout_string(byte *buf, int buf_size, int nb_channels, AVChannelLayout channel_layout);
Beispiel #14
0
 public static int GetChannels(AVChannelLayout channelLayout)
 {
     return(Internal.FFmpeg.av_get_channel_layout_nb_channels(channelLayout));
 }
 public extern static int swr_build_matrix(AVChannelLayout in_layout, AVChannelLayout out_layout, double center_mix_level, double surround_mix_level, double lfe_mix_level, double rematrix_maxval, double rematrix_volume, double *matrix, int stride, AVMatrixEncoding matrix_encoding, void *log_ctx);