|
大家好!
我想反DSP(EVMDM6437)采集到的YUV422图像通过网络发送到Windows xp上,结果出现了图像扭曲。
发送代码如下:
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- setsockopt( sudp, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) );
- setsockopt( sudp, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
- bytesRemaining = h264_size;//图片大小
- sendbuf = h264_buf;//存放图片的Buf
- bytesWritten = 0;
- datasendpertime = 1472;//由于图片比较大,所以将图片分开发:每次发1472
- printf("start send 422\n");
- while (bytesRemaining > 0)
- {
- /* send a chunk of data */
- xmtSize = sendto( sudp, sendbuf, datasendpertime, 0, (PSA)&sin1, sizeof(sin1));
-
- /* bail out if there was a write error */
- if (xmtSize <= 0) {
- printf("could not send picture data to PC --- %d \n",fdError());
- goto leave;
- }
- /* update some parametters */
- bytesWritten += xmtSize;
- bytesRemaining -= xmtSize;
- sendbuf += xmtSize;
- if(bytesRemaining < 1472) {
- datasendpertime = bytesRemaining;
- }
- }//while bytesremain
-
复制代码
接收端代码如下:
- while(1)
- {
- char resv[1472];
- int len= sizeof(sin);
- int n=0;
- n=recvfrom(s,resv,1472,0,(struct sockaddr *)&sin, &len);
- if(n>0)
- {
- fp=fopen("my.yuv","a");
- fwrite(resv,n,1,fp);
- fclose(fp);
- }
- }
复制代码
望高手指点!!
|
|