Mercurial > libavcodec.hg
comparison pnm_parser.c @ 10459:a6bb56636f90 libavcodec
whitespace cosmetics: K&R coding style, prettyprinting
author | diego |
---|---|
date | Tue, 27 Oct 2009 16:57:35 +0000 |
parents | 04423b2f6e0b |
children |
comparison
equal
deleted
inserted
replaced
10458:511cbeb9fb4b | 10459:a6bb56636f90 |
---|---|
21 | 21 |
22 #include "parser.h" //for ParseContext | 22 #include "parser.h" //for ParseContext |
23 #include "pnm.h" | 23 #include "pnm.h" |
24 | 24 |
25 | 25 |
26 static int pnm_parse(AVCodecParserContext *s, | 26 static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx, |
27 AVCodecContext *avctx, | 27 const uint8_t **poutbuf, int *poutbuf_size, |
28 const uint8_t **poutbuf, int *poutbuf_size, | 28 const uint8_t *buf, int buf_size) |
29 const uint8_t *buf, int buf_size) | |
30 { | 29 { |
31 ParseContext *pc = s->priv_data; | 30 ParseContext *pc = s->priv_data; |
32 PNMContext pnmctx; | 31 PNMContext pnmctx; |
33 int next; | 32 int next; |
34 | 33 |
35 for(; pc->overread>0; pc->overread--){ | 34 for (; pc->overread > 0; pc->overread--) { |
36 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; | 35 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; |
37 } | 36 } |
38 retry: | 37 retry: |
39 if(pc->index){ | 38 if (pc->index) { |
40 pnmctx.bytestream_start= | 39 pnmctx.bytestream_start = |
41 pnmctx.bytestream= pc->buffer; | 40 pnmctx.bytestream = pc->buffer; |
42 pnmctx.bytestream_end= pc->buffer + pc->index; | 41 pnmctx.bytestream_end = pc->buffer + pc->index; |
43 }else{ | 42 } else { |
44 pnmctx.bytestream_start= | 43 pnmctx.bytestream_start = |
45 pnmctx.bytestream= (uint8_t *) buf; /* casts avoid warnings */ | 44 pnmctx.bytestream = (uint8_t *) buf; /* casts avoid warnings */ |
46 pnmctx.bytestream_end= (uint8_t *) buf + buf_size; | 45 pnmctx.bytestream_end = (uint8_t *) buf + buf_size; |
47 } | 46 } |
48 if(ff_pnm_decode_header(avctx, &pnmctx) < 0){ | 47 if (ff_pnm_decode_header(avctx, &pnmctx) < 0) { |
49 if(pnmctx.bytestream < pnmctx.bytestream_end){ | 48 if (pnmctx.bytestream < pnmctx.bytestream_end) { |
50 if(pc->index){ | 49 if (pc->index) { |
51 pc->index=0; | 50 pc->index = 0; |
52 }else{ | 51 } else { |
53 buf++; | 52 buf++; |
54 buf_size--; | 53 buf_size--; |
55 } | 54 } |
56 goto retry; | 55 goto retry; |
57 } | 56 } |
58 #if 0 | 57 #if 0 |
59 if(pc->index && pc->index*2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index){ | 58 if (pc->index && pc->index * 2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index) { |
60 memcpy(pc->buffer + pc->index, buf, pc->index); | 59 memcpy(pc->buffer + pc->index, buf, pc->index); |
61 pc->index += pc->index; | 60 pc->index += pc->index; |
62 buf += pc->index; | 61 buf += pc->index; |
63 buf_size -= pc->index; | 62 buf_size -= pc->index; |
64 goto retry; | 63 goto retry; |
65 } | 64 } |
66 #endif | 65 #endif |
67 next= END_NOT_FOUND; | 66 next = END_NOT_FOUND; |
68 }else{ | 67 } else { |
69 next= pnmctx.bytestream - pnmctx.bytestream_start | 68 next = pnmctx.bytestream - pnmctx.bytestream_start |
70 + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); | 69 + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); |
71 if(pnmctx.bytestream_start!=buf) | 70 if (pnmctx.bytestream_start != buf) |
72 next-= pc->index; | 71 next -= pc->index; |
73 if(next > buf_size) | 72 if (next > buf_size) |
74 next= END_NOT_FOUND; | 73 next = END_NOT_FOUND; |
75 } | 74 } |
76 | 75 |
77 if(ff_combine_frame(pc, next, &buf, &buf_size)<0){ | 76 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { |
78 *poutbuf = NULL; | 77 *poutbuf = NULL; |
79 *poutbuf_size = 0; | 78 *poutbuf_size = 0; |
80 return buf_size; | 79 return buf_size; |
81 } | 80 } |
82 *poutbuf = buf; | 81 *poutbuf = buf; |
83 *poutbuf_size = buf_size; | 82 *poutbuf_size = buf_size; |
84 return next; | 83 return next; |
85 } | 84 } |
86 | 85 |
87 AVCodecParser pnm_parser = { | 86 AVCodecParser pnm_parser = { |