avcodec: Add const to decoder packet data pointers

The packets given to decoder need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-07-04 18:49:37 +02:00
parent d5a0eba8a2
commit 4ad686269d
10 changed files with 20 additions and 19 deletions

View File

@ -54,8 +54,8 @@ static int cpia_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
CpiaContext* const cpia = avctx->priv_data;
int i,j,ret;
uint8_t* const header = avpkt->data;
uint8_t* src;
const uint8_t *const header = avpkt->data;
const uint8_t *src;
int src_size;
uint16_t linelength;
uint8_t skip;

View File

@ -38,7 +38,8 @@ typedef struct {
// DFPWM codec from https://github.com/ChenThread/dfpwm/blob/master/1a/
// Licensed in the public domain
static void au_decompress(DFPWMState *state, int fs, int len, uint8_t *outbuf, uint8_t *inbuf)
static void au_decompress(DFPWMState *state, int fs, int len,
uint8_t *outbuf, const uint8_t *inbuf)
{
unsigned d;
for (int i = 0; i < len; i++) {

View File

@ -64,7 +64,7 @@ static int getbit(GetByteContext *gb, uint32_t *bitbuf, int *bits)
return ret;
}
static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src,
static void unpack_intraframe(AVCodecContext *avctx, const uint8_t *src,
uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
@ -147,7 +147,7 @@ static void copy_processed_frame(AVCodecContext *avctx, AVFrame *frame)
}
}
static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t size)
static int decode_interframe_v4(AVCodecContext *avctx, const uint8_t *src, uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
GetByteContext gb;
@ -276,7 +276,7 @@ static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t si
return 0;
}
static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
static void decode_interframe_v4a(AVCodecContext *avctx, const uint8_t *src,
uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;
@ -355,7 +355,7 @@ static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
}
}
static void hnm_update_palette(AVCodecContext *avctx, uint8_t *src,
static void hnm_update_palette(AVCodecContext *avctx, const uint8_t *src,
uint32_t size)
{
Hnm4VideoContext *hnm = avctx->priv_data;

View File

@ -135,7 +135,7 @@ static int libcodec2_decode(AVCodecContext *avctx, AVFrame *frame,
{
LibCodec2Context *c2 = avctx->priv_data;
int ret, nframes, i;
uint8_t *input;
const uint8_t *input;
int16_t *output;
nframes = pkt->size / avctx->block_align;

View File

@ -199,7 +199,7 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img,
}
static int decode_frame(AVCodecContext *avctx, vpx_codec_ctx_t *decoder,
uint8_t *data, uint32_t data_sz)
const uint8_t *data, uint32_t data_sz)
{
if (vpx_codec_decode(decoder, data, data_sz, NULL, 0) != VPX_CODEC_OK) {
const char *error = vpx_codec_error(decoder);

View File

@ -581,7 +581,7 @@ static void handler(vbi_event *ev, void *user_data)
vbi_unref_page(&page);
}
static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size)
static int slice_to_vbi_lines(TeletextContext *ctx, const uint8_t *buf, int size)
{
int lines = 0;
while (size >= 2 && lines < MAX_SLICES) {

View File

@ -159,7 +159,7 @@ static void set_src_position(PAFVideoDecContext *c,
*pend = c->frame[page] + c->frame_size;
}
static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
static int decode_0(PAFVideoDecContext *c, const uint8_t *pkt, uint8_t code)
{
uint32_t opcode_size, offset;
uint8_t *dst, *dend, mask = 0, color = 0;

View File

@ -198,7 +198,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size,
return get_bits_count(bc) >> 3;
}
static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
static int read_high_coeffs(AVCodecContext *avctx, const uint8_t *src, int16_t *dst,
int size, int c, int a, int d,
int width, ptrdiff_t stride)
{
@ -313,7 +313,7 @@ static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
return get_bits_count(bc) >> 3;
}
static int read_highpass(AVCodecContext *avctx, uint8_t *ptr,
static int read_highpass(AVCodecContext *avctx, const uint8_t *ptr,
int plane, AVFrame *frame)
{
PixletContext *ctx = avctx->priv_data;

View File

@ -200,7 +200,7 @@ typedef struct WebPContext {
int has_alpha; /* has a separate alpha chunk */
enum AlphaCompression alpha_compression; /* compression type for alpha chunk */
enum AlphaFilter alpha_filter; /* filtering method for alpha chunk */
uint8_t *alpha_data; /* alpha chunk data */
const uint8_t *alpha_data; /* alpha chunk data */
int alpha_data_size; /* alpha chunk data size */
int has_exif; /* set after an EXIF chunk has been processed */
int has_iccp; /* set after an ICCP chunk has been processed */
@ -1084,7 +1084,7 @@ static void update_canvas_size(AVCodecContext *avctx, int w, int h)
}
static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
int *got_frame, uint8_t *data_start,
int *got_frame, const uint8_t *data_start,
unsigned int data_size, int is_alpha_chunk)
{
WebPContext *s = avctx->priv_data;
@ -1240,7 +1240,7 @@ static void alpha_inverse_prediction(AVFrame *frame, enum AlphaFilter m)
}
static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
uint8_t *data_start,
const uint8_t *data_start,
unsigned int data_size)
{
WebPContext *s = avctx->priv_data;

View File

@ -40,9 +40,9 @@ typedef struct YopDecContext {
int first_color[2];
int frame_data_length;
uint8_t *low_nibble;
uint8_t *srcptr;
uint8_t *src_end;
const uint8_t *low_nibble;
const uint8_t *srcptr;
const uint8_t *src_end;
uint8_t *dstptr;
uint8_t *dstbuf;
} YopDecContext;