Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. I have variables:
  2. LPDDSURFACEDESCX pddsDesc
  3.  
  4. if (lpfnavcodec_decode_video2!=NULL)
  5. { iRes = lpfnavcodec_decode_video2( m_lpCodecCtx, m_lpFrame, &iFrameFinished, &m_lpPacket);
  6. }
  7.  
  8. if (iFrameFinished)
  9. { if (lpfnav_image_fill_linesizes!= NULL)
  10. { lpfnav_image_fill_linesizes(m_lpFrame->linesize, PIX_FMT_YUV420P,dwWidth+32);
  11. }
  12. memset(&m_lpPict , 0, sizeof(AVPicture));
  13. if (lpfnavpicture_fill!=NULL)
  14. { lpfnavpicture_fill( &m_lpPict, lpDIBData, PIX_FMT_RGB32, dwWidth, dwHeight);
  15. }
  16. // Convert the image into RGB and copy to the surface.
  17. img_convert( &m_lpPict, PIX_FMT_RGB32, dwWidth, dwHeight, (AVPicture*)m_lpFrame, PIX_FMT_YUV420P, m_lpCodecCtx->width, m_lpCodecCtx->height, pddsDesc->dwLinearSize);
  18.  
  19.  
  20. //////////////////////////////////////////////////////////////////////////////////////////////////////
  21. int img_convert( AVPicture* dst, PixelFormat dst_pix_fmt, int dstWidth, int dstHeight, AVPicture* src, PixelFormat src_pix_fmt, int srcWidth, int srcHeight, DWORD dwStride)
  22. //////////////////////////////////////////////////////////////////////////////////////////////////////
  23. { int result = 0;
  24.  
  25. // Init linesize on video card stride
  26. if (dst->linesize[0] == 0)
  27. dst->linesize[0] = dwStride;
  28.  
  29. if (lpfnsws_getContext!=NULL)
  30. { SwsContext* img_convert_ctx = lpfnsws_getContext( srcWidth, srcHeight, src_pix_fmt, dstWidth, dstHeight, dst_pix_fmt, SWS_BICUBIC, NULL, NULL, NULL);
  31. if (img_convert_ctx != NULL)
  32. { if (lpfnsws_scale!=NULL)
  33. { result = lpfnsws_scale( img_convert_ctx, (const uint8_t* const*)src->data, src->linesize, 0, srcHeight, dst->data, dst->linesize);
  34. if(result != dstHeight)
  35. { printf("sws_scale ERROR\r\n");
  36. }
  37. }
  38.  
  39. if (lpfnsws_freeContext != NULL)
  40. { lpfnsws_freeContext(img_convert_ctx);
  41. }
  42. }
  43. }
  44. return result;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement