public DecoderStream(MediaFileReader file, ref AVStream stream) { // Initialize instance variables m_disposed = false; m_position = m_bufferUsedSize = 0; m_file = file; m_avStream = stream; m_avCodecCtx = *m_avStream.codec; // Open the decoding codec AVCodec *avCodec = FFmpeg.avcodec_find_decoder(m_avCodecCtx.codec_id); if (avCodec == null) { throw new DecoderException("No decoder found"); } if (FFmpeg.avcodec_open(ref m_avCodecCtx, avCodec) < 0) { throw new DecoderException("Error opening codec"); } m_codecOpen = true; }
/// <summary> /// Constructs a new VideoDecoderStream over a specific filename. /// </summary> /// <param name="Filename">File to decode</param> internal VideoDecoderStream(MediaFileReader file, ref AVStream stream) : base(file, ref stream) { // allocate video frame m_avFrame = FFmpeg.avcodec_alloc_frame(); if (FFmpeg.avpicture_alloc(out m_avPicture, m_avCodecCtx.pix_fmt, m_avCodecCtx.width, m_avCodecCtx.height) != 0) throw new DecoderException("Error allocating AVPicture"); m_avPicture_allocated = true; int buffersize = FFmpeg.avpicture_get_size(m_avCodecCtx.pix_fmt, m_avCodecCtx.width, m_avCodecCtx.height); if (buffersize <= 0) throw new DecoderException("Invalid size returned by avpicture_get_size"); m_buffer = new byte[buffersize]; }
/// <summary> /// Constructs a new VideoDecoderStream over a specific filename. /// </summary> /// <param name="Filename">File to decode</param> internal VideoDecoderStream(MediaFileReader file, ref AVStream stream) : base(file, ref stream) { // allocate video frame m_avFrame = FFmpeg.avcodec_alloc_frame(); if (FFmpeg.avpicture_alloc(out m_avPicture, m_avCodecCtx.pix_fmt, m_avCodecCtx.width, m_avCodecCtx.height) != 0) { throw new DecoderException("Error allocating AVPicture"); } m_avPicture_allocated = true; int buffersize = FFmpeg.avpicture_get_size(m_avCodecCtx.pix_fmt, m_avCodecCtx.width, m_avCodecCtx.height); if (buffersize <= 0) { throw new DecoderException("Invalid size returned by avpicture_get_size"); } m_buffer = new byte[buffersize]; }
public DecoderStream(MediaFileReader file, ref AVStream stream) { // Initialize instance variables m_disposed = false; m_position = m_bufferUsedSize = 0; m_file = file; m_avStream = stream; m_avCodecCtx = *m_avStream.codec; // Open the decoding codec AVCodec* avCodec = FFmpeg.avcodec_find_decoder(m_avCodecCtx.codec_id); if (avCodec == null) throw new DecoderException("No decoder found"); if (FFmpeg.avcodec_open(ref m_avCodecCtx, avCodec) < 0) throw new DecoderException("Error opening codec"); m_codecOpen = true; }
internal AudioDecoderStream(MediaFileReader file, ref AVStream stream) : base(file, ref stream) { m_buffer = new byte[FFmpeg.AVCODEC_MAX_AUDIO_FRAME_SIZE]; }