avcodec_decode_video2接收实时流使用问题 我在iphone下使用ffmpeg解实时流,但是解出来的东西 图形丢失太严重了。 代码如下: av_register_all(); pCodecCtx = avcodec_alloc_context(); codecid = avcodec_find_decoder(CODEC_ID_H264); pFrame=avcodec_alloc_frame(); avcodec_open(pCodecCtx,codecid); pCodecCtx->width = 352; pCodecCtx->height = 288; pCodecCtx->pix_fmt = PIX_FMT_YUV420P; self.outputWidth = 704; self.outputHeight = 532; AVPacket packet; av_init_packet(&packet); char *cTest=malloc(10240); memset(cTest, 0, 10240); int temp=0; int nImageSize; while (bYes) { unsigned char cData[4096]; int ref = recv([xteozzdAppDelegate Apple].appSocket.playerSocketID , cData, 4096, 0); if(ref==-1) { break; } NSLog(@"ref:%d",ref); char *cBefore = cTest; memcpy(cBefore+temp, &cData, ref); packet.size = ref+temp; NSLog(@"packet.size:%d",packet.size); packet.data = (unsigned char*)cTest; int got_picture_ptr=0; nImageSize = avcodec_decode_video2(pCodecCtx,pFrame,&got_picture_ptr,&packet); NSLog(@"nImageSize:%d--got_picture_ptr:%d",nImageSize,got_picture_ptr); if(nImageSize>0) { if (!pFrame->data[0]) { continue; } temp = packet.size - nImageSize; NSLog(@"temp:%d---packet.size:%d",temp,packet.size); packet.size -= nImageSize; cTest += temp; [self performSelectorOnMainThreadselector(UpdateImageView) withObject:nil waitUntilDone:YES]; } else { temp = packet.size; } } avcodec_decode_video2这个参数传入的AVPacket 的size 是多少 方法的返回值就是多少 这是我哪个地方设置错误了吗?