You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/pnmdec, pnm_parser: Improve const-correctness
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -38,7 +38,7 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
|
|||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int c;
|
int c;
|
||||||
uint8_t *bs = sc->bytestream;
|
const uint8_t *bs = sc->bytestream;
|
||||||
const uint8_t *end = sc->bytestream_end;
|
const uint8_t *end = sc->bytestream_end;
|
||||||
|
|
||||||
/* skip spaces and comments */
|
/* skip spaces and comments */
|
||||||
|
@@ -25,9 +25,9 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
|
||||||
typedef struct PNMContext {
|
typedef struct PNMContext {
|
||||||
uint8_t *bytestream;
|
const uint8_t *bytestream;
|
||||||
uint8_t *bytestream_start;
|
const uint8_t *bytestream_start;
|
||||||
uint8_t *bytestream_end;
|
const uint8_t *bytestream_end;
|
||||||
int maxval; ///< maximum value of a pixel
|
int maxval; ///< maximum value of a pixel
|
||||||
int type;
|
int type;
|
||||||
int endian;
|
int endian;
|
||||||
|
@@ -65,8 +65,8 @@ retry:
|
|||||||
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 + skip; /* casts avoid warnings */
|
pnmctx.bytestream = buf + skip;
|
||||||
pnmctx.bytestream_end = (uint8_t *) buf + buf_size - skip;
|
pnmctx.bytestream_end = buf + buf_size - skip;
|
||||||
}
|
}
|
||||||
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) {
|
||||||
@@ -81,9 +81,9 @@ retry:
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
} else if (pnmctx.type < 4) {
|
} else if (pnmctx.type < 4) {
|
||||||
uint8_t *bs = pnmctx.bytestream;
|
const uint8_t *bs = pnmctx.bytestream;
|
||||||
const uint8_t *end = pnmctx.bytestream_end;
|
const uint8_t *end = pnmctx.bytestream_end;
|
||||||
uint8_t *sync = bs;
|
const uint8_t *sync = bs;
|
||||||
|
|
||||||
if (pc->index) {
|
if (pc->index) {
|
||||||
av_assert0(pnmpc->ascii_scan <= end - bs);
|
av_assert0(pnmpc->ascii_scan <= end - bs);
|
||||||
|
@@ -52,8 +52,8 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
|
|||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
s->bytestream_start =
|
s->bytestream_start =
|
||||||
s->bytestream = (uint8_t *)buf;
|
s->bytestream = buf;
|
||||||
s->bytestream_end = (uint8_t *)buf + buf_size;
|
s->bytestream_end = buf + buf_size;
|
||||||
|
|
||||||
if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
|
if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user