public bool TryDecode(ref AVPacket packet, ref AVFrame frame)
 {
   int gotPicture;
   fixed (AVPacket* pPacket = &packet)
   fixed (AVFrame* pFrame = &frame)
   {
     int decodedSize = FFmpegInvoke.avcodec_decode_video2(_pDecodingContext, pFrame, &gotPicture, pPacket);
     if (decodedSize < 0)
       Trace.TraceWarning("Error while decoding frame.");
   }
   return gotPicture == 1;
 }
    public byte[] ConvertFrame(ref AVFrame frame)
    {
      if (_initialized == false)
        Initialize(frame.width, frame.height, (AVPixelFormat)frame.format);

      fixed (AVFrame* pFrame = &frame)
      fixed (byte* pOutputData = &_outputData[0])
      {
        byte** pSrcData = &(pFrame)->data_0;
        byte** pDstData = &(_pCurrentFrame)->data_0;
        _pCurrentFrame->data_0 = pOutputData;
        FFmpegInvoke.sws_scale(_pContext, pSrcData, pFrame->linesize, 0, frame.height, pDstData, _pCurrentFrame->linesize);
      }
      return _outputData;
    }
 public static extern int avcodec_fill_audio_frame(AVFrame* frame, int nb_channels, AVSampleFormat sample_fmt, byte* buf, int buf_size, int align);
 public static extern int avcodec_encode_video(AVCodecContext* avctx, byte* buf, int buf_size, AVFrame* pict);
 public static extern int avcodec_decode_audio4(AVCodecContext* avctx, AVFrame* frame, int* got_frame_ptr, AVPacket* avpkt);
 public static extern void avcodec_default_release_buffer(AVCodecContext* s, AVFrame* pic);
 public static extern void avcodec_get_frame_defaults(AVFrame* frame);
 public static extern int av_frame_get_pkt_size(AVFrame* frame);
 public static extern long av_frame_get_channel_layout(AVFrame* frame);
 public static extern void av_frame_set_pkt_pos(AVFrame* frame, long val);
 public static extern long av_frame_get_pkt_pos(AVFrame* frame);
 public static extern long av_frame_get_pkt_duration(AVFrame* frame);
 public static extern void av_frame_set_best_effort_timestamp(AVFrame* frame, long val);
 public static extern long av_frame_get_best_effort_timestamp(AVFrame* frame);
 public static extern int av_frame_get_decode_error_flags(AVFrame* frame);
 public static extern void av_frame_set_channel_layout(AVFrame* frame, long val);
 public static extern void av_frame_set_decode_error_flags(AVFrame* frame, int val);
 public static extern int av_frame_get_channels(AVFrame* frame);
 public static extern void av_frame_set_pkt_size(AVFrame* frame, int val);
 public static extern void av_frame_set_channels(AVFrame* frame, int val);
 public static extern void avcodec_free_frame(AVFrame** frame);
 public static extern int av_frame_get_sample_rate(AVFrame* frame);
 public static extern int avcodec_default_reget_buffer(AVCodecContext* s, AVFrame* pic);
 public static extern void av_frame_set_sample_rate(AVFrame* frame, int val);
 public static extern int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture, int* got_picture_ptr, AVPacket* avpkt);
 public static extern AVDictionary* av_frame_get_metadata(AVFrame* frame);
 public static extern int avcodec_encode_video2(AVCodecContext* avctx, AVPacket* avpkt, AVFrame* frame, int* got_packet_ptr);
 public static extern void av_frame_set_metadata(AVFrame* frame, AVDictionary* val);
 public static extern AVRational av_guess_sample_aspect_ratio(AVFormatContext* format, AVStream* stream, AVFrame* frame);
 public VideoPacketDecoder(PixelFormat pixelFormat)
 {
   _pixelFormat = pixelFormat;
   _avFrame = new AVFrame();
   _avPacket = new AVPacket();
 }