AVFrame* pFrame; // Frame AVCodecContext* pContext; // Codec Context int nUsedBytes = avcodec_decode_video(pContext, pFrame, &nFrame, pSrcBuffer, nSrcLength); if(nUsedBytes > 0) { AVFrame out_pic; SwsContext* img_convert_ctx = sws_getContext(pContext->width, pContext->height, pContext->pix_fmt, nDestW, nDestH,(PixelFormat)PIX_FMT_BGR24,SWS_BICUBIC, NULL, NULL, NULL); if(img_convert_ctx != NULL) { if(avpicture_alloc((AVPicture *)&out_pic, PIX_FMT_RGB24, nDestW, nDestH)>=0) { pFrame->data[0] = pFrame->data[0]+pFrame->linesize[0]*(pContext->height-1); pFrame->data[1] = pFrame->data[1]+pFrame->linesize[0]*pContext->height/4-1; pFrame->data[2] = pFrame->data[2]+pFrame->linesize[0]*pContext->height/4-1; pFrame->linesize[0] *= -1; pFrame->linesize[1] *= -1; pFrame->linesize[2] *= -1; sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, pContext->height, out_pic.data, out_pic.linesize); avpicture_free((AVPicture *)&out_pic); } sws_freeContext(img_convert_ctx); } } AVFrame* pFrame; // Frame AV 你的当前访问异常,请进行认证后继续阅读剩余内容。 提交