public static void InitInputFrame(AVFrame **frame) { if ((*frame = ffmpeg.av_frame_alloc()) == null) { throw new FFmpegException(ffmpeg.AVERROR(ffmpeg.ENOMEM), "Failed to allocate input frame."); } }
/** * Initialize one input frame for writing to the output file. * The frame will be exactly frame_size samples large. * @param[out] frame Frame to be initialized * @param output_codec_context Codec context of the output file * @param frame_size Size of the frame * @return Error code (0 if successful) */ int init_output_frame(AVFrame **frame, AVCodecContext *output_codec_context, int frame_size) { int error; /* Create a new frame to store the audio samples. */ if ((*frame = av_frame_alloc()) == null) { Console.WriteLine("error: Could not allocate output frame"); return(AVERROR_EXIT); } /* Set the frame's parameters, especially its size and format. * av_frame_get_buffer needs this to allocate memory for the * audio samples of the frame. * Default channel layouts based on the number of channels * are assumed for simplicity. */ (*frame)->nb_samples = frame_size; (*frame)->channel_layout = output_codec_context->channel_layout; (*frame)->format = (int)output_codec_context->sample_fmt; (*frame)->sample_rate = output_codec_context->sample_rate; /* Allocate the samples of the created frame. This call will make * sure that the audio frame can hold as many samples as specified. */ if ((error = av_frame_get_buffer(*frame, 0)) < 0) { Console.WriteLine($"error: Could not allocate output frame samples (error '{LibAVErrorToString(error)}')"); av_frame_free(frame); return(error); } return(0); }
/** * Initialize one audio frame for reading from the input file. * @param[out] frame Frame to be initialized * @return Error code (0 if successful) */ int init_input_frame(AVFrame **frame) { if ((*frame = av_frame_alloc()) == null) { Console.WriteLine("error: Could not allocate input frame"); return(AVERROR(ENOMEM)); } return(0); }
protected override void DisposeOverride() { FFmpegInvoke.avcodec_close(_pDecodingContext); AVFrame * frameOnStack = _pFrame; AVFrame **frame = &frameOnStack; FFmpegInvoke.av_frame_free(frame); }
public static void InitOutputFrame(AVFrame **frame, AudioEncoder encoder, int maxFrameSize) { if ((*frame = ffmpeg.av_frame_alloc()) == null) { throw new FFmpegException(ffmpeg.AVERROR(ffmpeg.ENOMEM), "Failed to allocate output frame."); } (*frame)->nb_samples = Math.Min(maxFrameSize, encoder.FrameSize); (*frame)->channel_layout = encoder.ChannelLayout; (*frame)->format = (int)encoder.SampleFormat; (*frame)->sample_rate = encoder.SampleRate; int ret; if ((ret = ffmpeg.av_frame_get_buffer(*frame, 0)) < 0) { ffmpeg.av_frame_free(frame); throw new FFmpegException(ret, "Failed to allocate output frame samples."); } }
private static extern void av_frame_free(AVFrame **frame);
internal static extern void av_frame_free(AVFrame **frame);
public static extern void av_frame_free(AVFrame **frame);