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 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
#include "pnm.h"
......@@ -32,10 +33,10 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
int c;
/* skip spaces and comments */
for(;;) {
for (;;) {
c = *sc->bytestream++;
if (c == '#') {
do {
do {
c = *sc->bytestream++;
} while (c != '\n' && sc->bytestream < sc->bytestream_end);
} else if (!pnm_space(c)) {
......@@ -52,7 +53,8 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
*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];
int h, w, depth, maxval;
......@@ -67,12 +69,12 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
} else if (!strcmp(buf1, "P6")) {
avctx->pix_fmt = PIX_FMT_RGB24;
} else if (!strcmp(buf1, "P7")) {
w = -1;
h = -1;
w = -1;
h = -1;
maxval = -1;
depth = -1;
depth = -1;
tuple_type[0] = '\0';
for(;;) {
for (;;) {
pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "WIDTH")) {
pnm_get(s, buf1, sizeof(buf1));
......@@ -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))
return -1;
avctx->width = w;
avctx->width = w;
avctx->height = h;
if (depth == 1) {
if (maxval == 1)
......
......@@ -23,63 +23,62 @@
#include "pnm.h"
static int pnm_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
ParseContext *pc = s->priv_data;
PNMContext pnmctx;
int next;
for(; pc->overread>0; pc->overread--){
for (; pc->overread > 0; pc->overread--) {
pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
}
retry:
if(pc->index){
pnmctx.bytestream_start=
pnmctx.bytestream= pc->buffer;
pnmctx.bytestream_end= pc->buffer + pc->index;
}else{
pnmctx.bytestream_start=
pnmctx.bytestream= (uint8_t *) buf; /* casts avoid warnings */
pnmctx.bytestream_end= (uint8_t *) buf + buf_size;
if (pc->index) {
pnmctx.bytestream_start =
pnmctx.bytestream = pc->buffer;
pnmctx.bytestream_end = pc->buffer + pc->index;
} else {
pnmctx.bytestream_start =
pnmctx.bytestream = (uint8_t *) buf; /* casts avoid warnings */
pnmctx.bytestream_end = (uint8_t *) buf + buf_size;
}
if(ff_pnm_decode_header(avctx, &pnmctx) < 0){
if(pnmctx.bytestream < pnmctx.bytestream_end){
if(pc->index){
pc->index=0;
}else{
if (ff_pnm_decode_header(avctx, &pnmctx) < 0) {
if (pnmctx.bytestream < pnmctx.bytestream_end) {
if (pc->index) {
pc->index = 0;
} else {
buf++;
buf_size--;
}
goto retry;
}
#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);
pc->index += pc->index;
buf += pc->index;
buf_size -= pc->index;
buf += pc->index;
buf_size -= pc->index;
goto retry;
}
#endif
next= END_NOT_FOUND;
}else{
next= pnmctx.bytestream - pnmctx.bytestream_start
+ avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
if(pnmctx.bytestream_start!=buf)
next-= pc->index;
if(next > buf_size)
next= END_NOT_FOUND;
next = END_NOT_FOUND;
} else {
next = pnmctx.bytestream - pnmctx.bytestream_start
+ avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
if (pnmctx.bytestream_start != buf)
next -= pc->index;
if (next > buf_size)
next = END_NOT_FOUND;
}
if(ff_combine_frame(pc, next, &buf, &buf_size)<0){
*poutbuf = NULL;
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
*poutbuf = buf;
*poutbuf = buf;
*poutbuf_size = buf_size;
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