[FFmpeg-devel] NC4600 camera code

Stefano Sabatini stefano.sabatini-lala
Sat Dec 13 20:16:35 CET 2008


On date Saturday 2008-12-13 13:56:09 -0500, nicolas martin encoded:
>> On Sat, Dec 13, 2008 at 12:21:52PM -0500, nicolas martin wrote:
[...]
> I made some changes in the comments and functions.

[...]
> +int nc4600_get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
> +{
> +    int len, t;
> +    int cnt = 0;
> +
> +    if(size<0)
> +       return -1;

nit: 
     if (size < 0)
         return -1;
    
> +    len = s->buf_end - s->buf_ptr;
> +
> +    if (len==0) {
> +       fill_buffer(s);
> +       len = s->buf_end - s->buf_ptr;
> +    }

Weird indent.

> +
> +    if (s->copied == s->packet_size) {
> +       //we have copied the full packet
> +       //now we must get the size of the new packet
> +       cnt = FFMIN(len, 16-s->header_pos);
> +       if (cnt >0) {
> +           memcpy(s->header + s->header_pos, s->buf_ptr, cnt);
> +           s->header_pos += cnt;
> +           s->buf_ptr += cnt;
> +           len = s->buf_end - s->buf_ptr;
> +       }

Maybe count is more clear.

> +       if (s->header_pos == 16) {
> +           s->packet_size = nc4600_ident_packet(s->header);
> +           s->header_pos = 0;
> +           if (s->packet_size > 0) {
> +               s->copied = 0;
> +           } else {
> +               //we should do something this is not supposed to happen ...
> +               av_log(NULL, AV_LOG_DEBUG, "there is a bug ...\n");
> +           }
> +       }
> +    }
> +
> +    t = s->packet_size-s->copied;
> +    if (len > t) len = t;
> +    if (len > size) len = size;
> +
> +    if (len != 0) {
> +       memcpy(buf, s->buf_ptr, len);
> +       s->buf_ptr += len;
> +       s->copied += len;
> +    }

Again weird indent.

[...]

Regards.
-- 
FFmpeg = Fundamental and Free Mysterious Peaceful Evangelical Gorilla




More information about the ffmpeg-devel mailing list