红联Linux门户
Linux帮助

uvc_stream

发布时间:2014-08-11 10:37:12来源:红联作者:akumar
int print_picture(FILE* file, unsigned char *buf, int size)
{
unsigned char *ptdeb, *ptcur = buf;
int sizein;

if (!is_huffman(buf)) {
ptdeb = ptcur = buf;
while (((ptcur[0] << 8) | ptcur[1]) != 0xffc0)
ptcur++;
sizein = ptcur - ptdeb;
if( fwrite(buf, sizein, 1, file) <= 0) return -1;
//printf();
if( fwrite(dht_data, DHT_SIZE, 1, file) <= 0) return -1;
if( fwrite(ptcur, size - sizein, 1, file) <= 0) return -1;
} else {
if( fwrite(ptcur, size, 1, file) <= 0) return -1; /* ptcur was uninit -wsr */
}

return 0;
文章评论

共有 2 条评论

  1. akumar 于 2014-08-11 14:24:52发表:

    int is_huffman(unsigned char *buf)
    {
    unsigned char *ptbuf;
    int i = 0;
    ptbuf = buf;
    while (((ptbuf[0] << 8) | ptbuf[1]) != 0xffda) {
    if (i++ > 2048)
    return 0;
    if (((ptbuf[0] << 8) | ptbuf[1]) == 0xffc4)
    return 1;
    ptbuf++;
    }
    return 0;
    }还有这段

  2. akumar 于 2014-08-11 14:14:25发表:

    这段代码理解不了啊,有什么作用,哪个大神可以教下