title: avcodec_decode_video2 crashes, when avpkt.size is assigned
body: <p>the avcodec_decode_video2 method crashes, when I try to assign the avpkt.size. When I set it to 0 it works, but it doesn't decode anything (the return value is 0). Am I somthing missing, or what value has to be assigned to avpklt.size? I want to decode one Frame that is encoded in the istream parameter.</p>
  
  <p>Thank you</p>
  
  <pre><code>    int DecodeVideoFFMPEG::dec_main( void *istream, void *outstream,  int width, int height )
  {
  
      avcodec_register_all();
      int got_picture;
  
      int BYTEPIC = width * height * 3;
      AVCodecContext *d;
      AVCodec *decodec = avcodec_find_encoder(CODEC_ID_WMV1);
  
  
      d = avcodec_alloc_context3(decodec);
      d-&gt;codec_id = CODEC_ID_WMV1;
      d-&gt;pix_fmt = PIX_FMT_YUV420P;
      d-&gt;width = width;
      d-&gt;height = height;
      d-&gt;time_base.num = 1;
      d-&gt;time_base.den = 25;
  
      int status = avcodec_open2(d, decodec, NULL);
  
      AVFrame *picture2 = alloc_picture420P(width, height);
      AVFrame *pictureBGR = alloc_pictureBGR24(width, height);
  
      AVPacket avpkt;
      av_init_packet(&amp;avpkt);
  
      unsigned char *image = new unsigned char[BYTEPIC];
      memcpy(image, istream, BYTEPIC);
  
      avpkt.data = image;
      avpkt.size = BYTEPIC;  // ????
  
      //prepare for changing color space
      struct SwsContext *img_convert_ctx2 =
      sws_getContext(width, height, PIX_FMT_YUV420P,
      width, height, PIX_FMT_BGR24,
      SWS_BICUBIC, NULL, NULL, NULL);
  
      int len = avcodec_decode_video2(d, picture2, &amp;got_picture, &amp;avpkt);
  
      sws_scale(img_convert_ctx2, picture2-&gt;data, picture2-&gt;linesize, 0, height, pictureBGR-&gt;data, pictureBGR-&gt;linesize);
  
      outstream = pictureBGR-&gt;data;
  
      return len;
  }
  </code></pre>