赞 | 12 |
VIP | 107 |
好人卡 | 6 |
积分 | 4 |
经验 | 31122 |
最后登录 | 2024-6-29 |
在线时间 | 1606 小时 |
Lv2.观梦者 傻♂逼
- 梦石
- 0
- 星屑
- 374
- 在线时间
- 1606 小时
- 注册时间
- 2007-3-13
- 帖子
- 6562
 
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 yangff 于 2011-11-5 17:49 编辑
- int __declspec(dllexport) NextFrame(int Bitmap,int playerHandle)
- {
- int * pBitmap=(int *)Bitmap;
- if (GetNextFrame(pFormatCtx, pCodecCtx, videoStream, pFrame))
- {
- //struct SwsContext * img_convert_ctx;
- //img_convert_ctx=sws_getContext( pCodecCtx->width/12, pCodecCtx->height/12,PIX_FMT_RGB32,pCodecCtx->width,pCodecCtx->height,PIX_FMT_YUV420P,2,NULL,NULL,NULL);
- uint8_t *data = malloc (3*pCodecCtx->width*pCodecCtx->height);
- uint8_t *src[3]= {data, data+pCodecCtx->width*pCodecCtx->height, data+pCodecCtx->width*pCodecCtx->height+pCodecCtx->width*pCodecCtx->height};
- //int stride[3]={pCodecCtx->width, pCodecCtx->width, pCodecCtx->width};
- //sws_scale(img_convert_ctx,(const uint8_t* const*)pFrame->data,pFrame->linesize,0,pCodecCtx->height,src,stride);
- int p=0;
- int r,g,b=0;
- double y,u,v;
- int off=pCodecCtx->width*pCodecCtx->height;
- int off1=pCodecCtx->width*pCodecCtx->height*1;
- frame(pCodecCtx->height,pCodecCtx->width,data,pFrame);
- //pBitmap[pCodecCtx->width*pCodecCtx->height-1]=0xffffaaff;
- for (int i=pCodecCtx->height-1;i>=0;i--){
- for (int j=0;j<pCodecCtx->width;j++)
- { //if (i*pCodecCtx->width+j<pCodecCtx->height*pCodecCtx->width)
- pBitmap[p]=0xff000000 ;
- y=(double)src[0][i*pCodecCtx->width+j];//pFrame->pp;//data[0][p+off];
- u=(double)src[1][(i/2*pCodecCtx->width+j)/2];//pFrame->pp;//data[0][p+off1];
- v=(double)src[2][(i/2*pCodecCtx->width+j)/2];//pFrame->pp//data[0][p+off1+off];
- r=(int)(1.164f*(y-16)+1.596f*(v-128));
- g=(int)(1.164f*(y-16)-0.813f*(v - 128) - 0.391f*(u - 128));
- b=(int)(1.164f*(y-16)+2.018f*(u - 128));
- if (r>255) r=255; if (r<0) r=0;
- if (g>255) g=255; if (g<0) g=0;
- if (b>255) b=255; if (b<0) b=0;
- pBitmap[p]|= b; //b
- pBitmap[p]|= g << 8; // g
- pBitmap[p]|= r << 16; // r
- // | data[((j+i*pCodecCtx->width+pCodecCtx->width*pCodecCtx->height) << 8)];// | data[((j+i*pCodecCtx->width+pCodecCtx->width*pCodecCtx->height*2) << 16)] | (0xff << 24);
- p++;
- }}
- free(data);
- return 1; }
-
- return -1;
- }
复制代码 |
|