Commit d3067047 authored by Diego Biurrun's avatar Diego Biurrun

whitespace cosmetics: K&R coding style, prettyprinting

Originally committed as revision 20381 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent bc8964ef
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "avcodec.h" #include "avcodec.h"
#include "pnm.h" #include "pnm.h"
...@@ -32,10 +33,10 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size) ...@@ -32,10 +33,10 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
int c; int c;
/* skip spaces and comments */ /* skip spaces and comments */
for(;;) { for (;;) {
c = *sc->bytestream++; c = *sc->bytestream++;
if (c == '#') { if (c == '#') {
do { do {
c = *sc->bytestream++; c = *sc->bytestream++;
} while (c != '\n' && sc->bytestream < sc->bytestream_end); } while (c != '\n' && sc->bytestream < sc->bytestream_end);
} else if (!pnm_space(c)) { } else if (!pnm_space(c)) {
...@@ -52,7 +53,8 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size) ...@@ -52,7 +53,8 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
*s = '\0'; *s = '\0';
} }
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
{
char buf1[32], tuple_type[32]; char buf1[32], tuple_type[32];
int h, w, depth, maxval; int h, w, depth, maxval;
...@@ -67,12 +69,12 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){ ...@@ -67,12 +69,12 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
} else if (!strcmp(buf1, "P6")) { } else if (!strcmp(buf1, "P6")) {
avctx->pix_fmt = PIX_FMT_RGB24; avctx->pix_fmt = PIX_FMT_RGB24;
} else if (!strcmp(buf1, "P7")) { } else if (!strcmp(buf1, "P7")) {
w = -1; w = -1;
h = -1; h = -1;
maxval = -1; maxval = -1;
depth = -1; depth = -1;
tuple_type[0] = '\0'; tuple_type[0] = '\0';
for(;;) { for (;;) {
pnm_get(s, buf1, sizeof(buf1)); pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "WIDTH")) { if (!strcmp(buf1, "WIDTH")) {
pnm_get(s, buf1, sizeof(buf1)); pnm_get(s, buf1, sizeof(buf1));
...@@ -98,7 +100,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){ ...@@ -98,7 +100,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || avcodec_check_dimensions(avctx, w, h)) if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || avcodec_check_dimensions(avctx, w, h))
return -1; return -1;
avctx->width = w; avctx->width = w;
avctx->height = h; avctx->height = h;
if (depth == 1) { if (depth == 1) {
if (maxval == 1) if (maxval == 1)
......
...@@ -23,63 +23,62 @@ ...@@ -23,63 +23,62 @@
#include "pnm.h" #include "pnm.h"
static int pnm_parse(AVCodecParserContext *s, static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx,
AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
const uint8_t *buf, int buf_size)
{ {
ParseContext *pc = s->priv_data; ParseContext *pc = s->priv_data;
PNMContext pnmctx; PNMContext pnmctx;
int next; int next;
for(; pc->overread>0; pc->overread--){ for (; pc->overread > 0; pc->overread--) {
pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
} }
retry: retry:
if(pc->index){ if (pc->index) {
pnmctx.bytestream_start= pnmctx.bytestream_start =
pnmctx.bytestream= pc->buffer; pnmctx.bytestream = pc->buffer;
pnmctx.bytestream_end= pc->buffer + pc->index; pnmctx.bytestream_end = pc->buffer + pc->index;
}else{ } else {
pnmctx.bytestream_start= pnmctx.bytestream_start =
pnmctx.bytestream= (uint8_t *) buf; /* casts avoid warnings */ pnmctx.bytestream = (uint8_t *) buf; /* casts avoid warnings */
pnmctx.bytestream_end= (uint8_t *) buf + buf_size; pnmctx.bytestream_end = (uint8_t *) buf + buf_size;
} }
if(ff_pnm_decode_header(avctx, &pnmctx) < 0){ if (ff_pnm_decode_header(avctx, &pnmctx) < 0) {
if(pnmctx.bytestream < pnmctx.bytestream_end){ if (pnmctx.bytestream < pnmctx.bytestream_end) {
if(pc->index){ if (pc->index) {
pc->index=0; pc->index = 0;
}else{ } else {
buf++; buf++;
buf_size--; buf_size--;
} }
goto retry; goto retry;
} }
#if 0 #if 0
if(pc->index && pc->index*2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index){ if (pc->index && pc->index * 2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index) {
memcpy(pc->buffer + pc->index, buf, pc->index); memcpy(pc->buffer + pc->index, buf, pc->index);
pc->index += pc->index; pc->index += pc->index;
buf += pc->index; buf += pc->index;
buf_size -= pc->index; buf_size -= pc->index;
goto retry; goto retry;
} }
#endif #endif
next= END_NOT_FOUND; next = END_NOT_FOUND;
}else{ } else {
next= pnmctx.bytestream - pnmctx.bytestream_start next = pnmctx.bytestream - pnmctx.bytestream_start
+ avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
if(pnmctx.bytestream_start!=buf) if (pnmctx.bytestream_start != buf)
next-= pc->index; next -= pc->index;
if(next > buf_size) if (next > buf_size)
next= END_NOT_FOUND; next = END_NOT_FOUND;
} }
if(ff_combine_frame(pc, next, &buf, &buf_size)<0){ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
*poutbuf = NULL; *poutbuf = NULL;
*poutbuf_size = 0; *poutbuf_size = 0;
return buf_size; return buf_size;
} }
*poutbuf = buf; *poutbuf = buf;
*poutbuf_size = buf_size; *poutbuf_size = buf_size;
return next; return next;
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment