avcodec: Constify frame->data pointers for encoders where possible

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
pull/388/head
Andreas Rheinhardt 2 years ago
parent cee40a945a
commit 5828e8209f
  1. 2
      libavcodec/a64multienc.c
  2. 4
      libavcodec/adpcmenc.c
  3. 6
      libavcodec/asvenc.c
  4. 2
      libavcodec/avuienc.c
  5. 3
      libavcodec/bmpenc.c
  6. 15
      libavcodec/cfhdenc.c
  7. 2
      libavcodec/cinepakenc.c
  8. 6
      libavcodec/cljrenc.c
  9. 2
      libavcodec/cngenc.c
  10. 2
      libavcodec/dfpwmenc.c
  11. 4
      libavcodec/dnxhdenc.c
  12. 2
      libavcodec/dnxhdenc.h
  13. 11
      libavcodec/dvenc.c
  14. 6
      libavcodec/exrenc.c
  15. 2
      libavcodec/ffv1enc.c
  16. 4
      libavcodec/fitsenc.c
  17. 5
      libavcodec/flashsvenc.c
  18. 18
      libavcodec/huffyuvenc.c
  19. 12
      libavcodec/j2kenc.c
  20. 12
      libavcodec/libopusenc.c
  21. 6
      libavcodec/ljpegenc.c
  22. 3
      libavcodec/magicyuvenc.c
  23. 4
      libavcodec/mlpenc.c
  24. 4
      libavcodec/mpeg4videoenc.c
  25. 24
      libavcodec/mpegvideo_enc.c
  26. 4
      libavcodec/msvideo1enc.c
  27. 3
      libavcodec/pamenc.c
  28. 18
      libavcodec/pngenc.c
  29. 18
      libavcodec/pnmenc.c
  30. 22
      libavcodec/proresenc_anatoliy.c
  31. 3
      libavcodec/qoienc.c
  32. 8
      libavcodec/r210enc.c
  33. 29
      libavcodec/rpzaenc.c
  34. 6
      libavcodec/sgienc.c
  35. 2
      libavcodec/snow.h
  36. 14
      libavcodec/snowenc.c
  37. 4
      libavcodec/svq1enc.c
  38. 2
      libavcodec/targaenc.c
  39. 4
      libavcodec/tiffenc.c
  40. 4
      libavcodec/utvideoenc.c
  41. 2
      libavcodec/v308enc.c
  42. 2
      libavcodec/v408enc.c
  43. 2
      libavcodec/v410enc.c
  44. 2
      libavcodec/vbnenc.c
  45. 2
      libavcodec/vc2enc.c
  46. 2
      libavcodec/wmaenc.c
  47. 3
      libavcodec/xbmenc.c
  48. 3
      libavcodec/xwdenc.c
  49. 2
      libavcodec/y41penc.c
  50. 2
      libavcodec/yuv4enc.c
  51. 11
      libavcodec/zmbvenc.c

@ -76,7 +76,7 @@ static void to_meta_with_crop(AVCodecContext *avctx,
int luma = 0; int luma = 0;
int height = FFMIN(avctx->height, C64YRES); int height = FFMIN(avctx->height, C64YRES);
int width = FFMIN(avctx->width , C64XRES); int width = FFMIN(avctx->width , C64XRES);
uint8_t *src = p->data[0]; const uint8_t *src = p->data[0];
for (blocky = 0; blocky < C64YRES; blocky += 8) { for (blocky = 0; blocky < C64YRES; blocky += 8) {
for (blockx = 0; blockx < C64XRES; blockx += 8) { for (blockx = 0; blockx < C64XRES; blockx += 8) {

@ -601,13 +601,13 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
{ {
int st, pkt_size, ret; int st, pkt_size, ret;
const int16_t *samples; const int16_t *samples;
int16_t **samples_p; const int16_t *const *samples_p;
uint8_t *dst; uint8_t *dst;
ADPCMEncodeContext *c = avctx->priv_data; ADPCMEncodeContext *c = avctx->priv_data;
int channels = avctx->ch_layout.nb_channels; int channels = avctx->ch_layout.nb_channels;
samples = (const int16_t *)frame->data[0]; samples = (const int16_t *)frame->data[0];
samples_p = (int16_t **)frame->extended_data; samples_p = (const int16_t *const *)frame->extended_data;
st = channels == 2; st = channels == 2;
if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI || if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||

@ -190,9 +190,9 @@ static inline void dct_get(ASV1Context *a, const AVFrame *frame,
int linesize = frame->linesize[0]; int linesize = frame->linesize[0];
int i; int i;
uint8_t *ptr_y = frame->data[0] + (mb_y * 16 * linesize) + mb_x * 16; const uint8_t *ptr_y = frame->data[0] + (mb_y * 16 * linesize) + mb_x * 16;
uint8_t *ptr_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8; const uint8_t *ptr_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;
uint8_t *ptr_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8; const uint8_t *ptr_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;
a->pdsp.get_pixels(block[0], ptr_y, linesize); a->pdsp.get_pixels(block[0], ptr_y, linesize);
a->pdsp.get_pixels(block[1], ptr_y + 8, linesize); a->pdsp.get_pixels(block[1], ptr_y + 8, linesize);

@ -72,7 +72,7 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
for (i = 0; i <= interlaced; i++) { for (i = 0; i <= interlaced; i++) {
uint8_t *src; const uint8_t *src;
if (interlaced && avctx->height == 486) { if (interlaced && avctx->height == 486) {
src = pic->data[0] + (1 - i) * pic->linesize[0]; src = pic->data[0] + (1 - i) * pic->linesize[0];
} else { } else {

@ -72,7 +72,8 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint32_t palette256[256]; uint32_t palette256[256];
int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB; int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
int bit_count = avctx->bits_per_coded_sample; int bit_count = avctx->bits_per_coded_sample;
uint8_t *ptr, *buf; const uint8_t *ptr;
uint8_t *buf;
switch (avctx->pix_fmt) { switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB444: case AV_PIX_FMT_RGB444:

@ -437,7 +437,8 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int a_width = s->plane[plane].band[2][0].a_width; int a_width = s->plane[plane].band[2][0].a_width;
int height = s->plane[plane].band[2][0].height; int height = s->plane[plane].band[2][0].height;
int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane; int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
int16_t *input = (int16_t *)frame->data[act_plane]; const int16_t *input = (int16_t *)frame->data[act_plane];
int16_t *buf;
int16_t *low = s->plane[plane].l_h[6]; int16_t *low = s->plane[plane].l_h[6];
int16_t *high = s->plane[plane].l_h[7]; int16_t *high = s->plane[plane].l_h[7];
ptrdiff_t in_stride = frame->linesize[act_plane] / 2; ptrdiff_t in_stride = frame->linesize[act_plane] / 2;
@ -481,13 +482,13 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
high = s->plane[plane].l_h[4]; high = s->plane[plane].l_h[4];
high_stride = s->plane[plane].band[1][0].a_width; high_stride = s->plane[plane].band[1][0].a_width;
buf = s->plane[plane].l_h[7];
for (int i = 0; i < height * 2; i++) { for (int i = 0; i < height * 2; i++) {
for (int j = 0; j < width * 2; j++) for (int j = 0; j < width * 2; j++)
input[j] /= 4; buf[j] /= 4;
input += a_width * 2; buf += a_width * 2;
} }
input = s->plane[plane].l_h[7];
dsp->horiz_filter(input, low, high, dsp->horiz_filter(input, low, high,
a_width * 2, low_stride, high_stride, a_width * 2, low_stride, high_stride,
width * 2, height * 2); width * 2, height * 2);
@ -518,14 +519,14 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
high_stride = s->plane[plane].band[0][0].a_width; high_stride = s->plane[plane].band[0][0].a_width;
if (avctx->pix_fmt != AV_PIX_FMT_YUV422P10) { if (avctx->pix_fmt != AV_PIX_FMT_YUV422P10) {
int16_t *buf = s->plane[plane].l_h[4];
for (int i = 0; i < height * 2; i++) { for (int i = 0; i < height * 2; i++) {
for (int j = 0; j < width * 2; j++) for (int j = 0; j < width * 2; j++)
input[j] /= 4; buf[j] /= 4;
input += a_width * 2; buf += a_width * 2;
} }
} }
input = s->plane[plane].l_h[4];
dsp->horiz_filter(input, low, high, dsp->horiz_filter(input, low, high,
a_width * 2, low_stride, high_stride, a_width * 2, low_stride, high_stride,
width * 2, height * 2); width * 2, height * 2);

@ -1019,7 +1019,7 @@ static int rd_frame(CinepakEncContext *s, const AVFrame *frame,
// build a copy of the given frame in the correct colorspace // build a copy of the given frame in the correct colorspace
for (y = 0; y < s->h; y += 2) for (y = 0; y < s->h; y += 2)
for (x = 0; x < s->w; x += 2) { for (x = 0; x < s->w; x += 2) {
uint8_t *ir[2]; const uint8_t *ir[2];
int32_t r, g, b, rr, gg, bb; int32_t r, g, b, rr, gg, bb;
ir[0] = frame->data[0] + x * 3 + y * frame->linesize[0]; ir[0] = frame->data[0] + x * 3 + y * frame->linesize[0];
ir[1] = ir[0] + frame->linesize[0]; ir[1] = ir[0] + frame->linesize[0];

@ -63,9 +63,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
init_put_bits(&pb, pkt->data, pkt->size); init_put_bits(&pb, pkt->data, pkt->size);
for (y = 0; y < avctx->height; y++) { for (y = 0; y < avctx->height; y++) {
uint8_t *luma = &p->data[0][y * p->linesize[0]]; const uint8_t *luma = &p->data[0][y * p->linesize[0]];
uint8_t *cb = &p->data[1][y * p->linesize[1]]; const uint8_t *cb = &p->data[1][y * p->linesize[1]];
uint8_t *cr = &p->data[2][y * p->linesize[2]]; const uint8_t *cr = &p->data[2][y * p->linesize[2]];
uint8_t luma_tmp[4]; uint8_t luma_tmp[4];
for (x = 0; x < avctx->width; x += 4) { for (x = 0; x < avctx->width; x += 4) {
switch (a->dither_type) { switch (a->dither_type) {

@ -67,7 +67,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
int ret, i; int ret, i;
double energy = 0; double energy = 0;
int qdbov; int qdbov;
int16_t *samples = (int16_t*) frame->data[0]; const int16_t *samples = (const int16_t*) frame->data[0];
if ((ret = ff_get_encode_buffer(avctx, avpkt, 1 + p->order, 0))) { if ((ret = ff_get_encode_buffer(avctx, avpkt, 1 + p->order, 0))) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");

@ -39,7 +39,7 @@ typedef struct {
// Licensed in the public domain // Licensed in the public domain
// note, len denotes how many compressed bytes there are (uncompressed bytes / 8). // note, len denotes how many compressed bytes there are (uncompressed bytes / 8).
static void au_compress(DFPWMState *state, int len, uint8_t *outbuf, uint8_t *inbuf) static void au_compress(DFPWMState *state, int len, uint8_t *outbuf, const uint8_t *inbuf)
{ {
unsigned d = 0; unsigned d = 0;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {

@ -944,7 +944,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
ctx = ctx->thread[threadnr]; ctx = ctx->thread[threadnr];
if (ctx->bit_depth == 8) { if (ctx->bit_depth == 8) {
uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize); const uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize);
for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) {
unsigned mb = mb_y * ctx->m.mb_width + mb_x; unsigned mb = mb_y * ctx->m.mb_width + mb_x;
int sum; int sum;
@ -973,7 +973,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
} else { // 10-bit } else { // 10-bit
const int linesize = ctx->m.linesize >> 1; const int linesize = ctx->m.linesize >> 1;
for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) { for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) {
uint16_t *pix = (uint16_t *)ctx->thread[0]->src[0] + const uint16_t *pix = (const uint16_t *)ctx->thread[0]->src[0] +
((mb_y << 4) * linesize) + (mb_x << 4); ((mb_y << 4) * linesize) + (mb_x << 4);
unsigned mb = mb_y * ctx->m.mb_width + mb_x; unsigned mb = mb_y * ctx->m.mb_width + mb_x;
int sum = 0; int sum = 0;

@ -86,7 +86,7 @@ typedef struct DNXHDEncContext {
uint16_t (*qmatrix_c16)[2][64]; uint16_t (*qmatrix_c16)[2][64];
unsigned frame_bits; unsigned frame_bits;
uint8_t *src[3]; const uint8_t *src[3];
uint32_t *orig_vlc_codes; uint32_t *orig_vlc_codes;
uint8_t *orig_vlc_bits; uint8_t *orig_vlc_bits;

@ -217,7 +217,7 @@ static av_always_inline PutBitContext *dv_encode_ac(EncBlockInfo *bi,
return pb; return pb;
} }
static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data, static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, const uint8_t *data,
ptrdiff_t linesize) ptrdiff_t linesize)
{ {
if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
@ -506,7 +506,7 @@ static inline void dv_set_class_number_hd(DVVideoContext *s,
bi->cno = 0; bi->cno = 0;
} }
static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, int linesize, static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const uint8_t *data, int linesize,
DVVideoContext *s, int chroma) DVVideoContext *s, int chroma)
{ {
LOCAL_ALIGNED_16(int16_t, blk, [64]); LOCAL_ALIGNED_16(int16_t, blk, [64]);
@ -849,7 +849,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
int mb_index, i, j; int mb_index, i, j;
int mb_x, mb_y, c_offset; int mb_x, mb_y, c_offset;
ptrdiff_t linesize, y_stride; ptrdiff_t linesize, y_stride;
uint8_t *y_ptr; const uint8_t *y_ptr;
uint8_t *dif, *p; uint8_t *dif, *p;
LOCAL_ALIGNED_8(uint8_t, scratch, [128]); LOCAL_ALIGNED_8(uint8_t, scratch, [128]);
EncBlockInfo enc_blks[5 * DV_MAX_BPM]; EncBlockInfo enc_blks[5 * DV_MAX_BPM];
@ -908,14 +908,13 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
c_offset = ((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] + c_offset = ((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] +
(mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) * 8; (mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) * 8;
for (j = 2; j; j--) { for (j = 2; j; j--) {
uint8_t *c_ptr = s->frame->data[j] + c_offset; const uint8_t *c_ptr = s->frame->data[j] + c_offset;
linesize = s->frame->linesize[j]; linesize = s->frame->linesize[j];
y_stride = (mb_y == 134) ? 8 : (s->frame->linesize[j] * (1 << (3*!enc_blk->dct_mode))); y_stride = (mb_y == 134) ? 8 : (s->frame->linesize[j] * (1 << (3*!enc_blk->dct_mode)));
if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) { if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
uint8_t *d;
uint8_t *b = scratch; uint8_t *b = scratch;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
d = c_ptr + linesize * 8; const uint8_t *d = c_ptr + linesize * 8;
b[0] = c_ptr[0]; b[0] = c_ptr[0];
b[1] = c_ptr[1]; b[1] = c_ptr[1];
b[2] = c_ptr[2]; b[2] = c_ptr[2];

@ -253,7 +253,7 @@ static int encode_scanline_rle(EXRContext *s, const AVFrame *frame)
for (int p = 0; p < s->planes; p++) { for (int p = 0; p < s->planes; p++) {
int ch = s->ch_order[p]; int ch = s->ch_order[p];
uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + frame->width * 2 * p); uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + frame->width * 2 * p);
uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]); const uint32_t *src = (const uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
for (int x = 0; x < frame->width; x++) for (int x = 0; x < frame->width; x++)
dst[x] = float2half(src[x], s->basetable, s->shifttable); dst[x] = float2half(src[x], s->basetable, s->shifttable);
@ -321,7 +321,7 @@ static int encode_scanline_zip(EXRContext *s, const AVFrame *frame)
for (int p = 0; p < s->planes; p++) { for (int p = 0; p < s->planes; p++) {
int ch = s->ch_order[p]; int ch = s->ch_order[p];
uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + scanline_size * l + p * frame->width * 2); uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + scanline_size * l + p * frame->width * 2);
uint32_t *src = (uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]); const uint32_t *src = (const uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]);
for (int x = 0; x < frame->width; x++) for (int x = 0; x < frame->width; x++)
dst[x] = float2half(src[x], s->basetable, s->shifttable); dst[x] = float2half(src[x], s->basetable, s->shifttable);
@ -479,7 +479,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream2_put_le32(pb, s->planes * avctx->width * 2); bytestream2_put_le32(pb, s->planes * avctx->width * 2);
for (int p = 0; p < s->planes; p++) { for (int p = 0; p < s->planes; p++) {
int ch = s->ch_order[p]; int ch = s->ch_order[p];
uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]); const uint32_t *src = (const uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
for (int x = 0; x < frame->width; x++) for (int x = 0; x < frame->width; x++)
bytestream2_put_le16(pb, float2half(src[x], s->basetable, s->shifttable)); bytestream2_put_le16(pb, float2half(src[x], s->basetable, s->shifttable));

@ -270,7 +270,7 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state,
#define RENAME(name) name ## 32 #define RENAME(name) name ## 32
#include "ffv1enc_template.c" #include "ffv1enc_template.c"
static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h, static int encode_plane(FFV1Context *s, const uint8_t *src, int w, int h,
int stride, int plane_index, int pixel_stride) int stride, int plane_index, int pixel_stride)
{ {
int x, y, i, ret; int x, y, i, ret;

@ -38,7 +38,7 @@
static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet) const AVFrame *p, int *got_packet)
{ {
uint8_t *bytestream, *ptr; uint8_t *bytestream;
const uint16_t flip = (1 << 15); const uint16_t flip = (1 << 15);
uint64_t data_size = 0, padded_data_size = 0; uint64_t data_size = 0, padded_data_size = 0;
int ret, bitpix, naxis3 = 1, i, j, k, bytes_left; int ret, bitpix, naxis3 = 1, i, j, k, bytes_left;
@ -87,7 +87,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
for (k = 0; k < naxis3; k++) { for (k = 0; k < naxis3; k++) {
for (i = 0; i < avctx->height; i++) { for (i = 0; i < avctx->height; i++) {
ptr = p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]]; const uint8_t *ptr = p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]];
if (bitpix == 16) { if (bitpix == 16) {
for (j = 0; j < avctx->width; j++) { for (j = 0; j < avctx->width; j++) {
// subtracting bzero is equivalent to first bit flip // subtracting bzero is equivalent to first bit flip

@ -66,16 +66,15 @@ typedef struct FlashSVContext {
uint8_t tmpblock[3 * 256 * 256]; uint8_t tmpblock[3 * 256 * 256];
} FlashSVContext; } FlashSVContext;
static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy, static int copy_region_enc(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
int h, int w, int stride, uint8_t *pfptr) int h, int w, int stride, uint8_t *pfptr)
{ {
int i, j; int i, j;
uint8_t *nsptr;
uint8_t *npfptr; uint8_t *npfptr;
int diff = 0; int diff = 0;
for (i = dx + h; i > dx; i--) { for (i = dx + h; i > dx; i--) {
nsptr = sptr + i * stride + dy * 3; const uint8_t *nsptr = sptr + i * stride + dy * 3;
npfptr = pfptr + i * stride + dy * 3; npfptr = pfptr + i * stride + dy * 3;
for (j = 0; j < w * 3; j++) { for (j = 0; j < w * 3; j++) {
diff |= npfptr[j] ^ nsptr[j]; diff |= npfptr[j] ^ nsptr[j];

@ -119,7 +119,7 @@ static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst,
} }
static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst, static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
uint8_t *src, int w, const uint8_t *src, int w,
int *red, int *green, int *blue) int *red, int *green, int *blue)
{ {
int i; int i;
@ -789,7 +789,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
y++; cy++; y++; cy++;
for (; y < height; y++,cy++) { for (; y < height; y++,cy++) {
uint8_t *ydst, *udst, *vdst; const uint8_t *ydst, *udst, *vdst;
if (s->bitstream_bpp == 12) { if (s->bitstream_bpp == 12) {
while (2 * cy > y) { while (2 * cy > y) {
@ -812,7 +812,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
} else { } else {
for (cy = y = 1; y < height; y++, cy++) { for (cy = y = 1; y < height; y++, cy++) {
uint8_t *ydst, *udst, *vdst; const uint8_t *ydst, *udst, *vdst;
/* encode a luma only line & y++ */ /* encode a luma only line & y++ */
if (s->bitstream_bpp == 12) { if (s->bitstream_bpp == 12) {
@ -852,7 +852,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
} }
} else if(avctx->pix_fmt == AV_PIX_FMT_RGB32) { } else if(avctx->pix_fmt == AV_PIX_FMT_RGB32) {
uint8_t *data = p->data[0] + (height - 1) * p->linesize[0]; const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
const int stride = -p->linesize[0]; const int stride = -p->linesize[0];
const int fake_stride = -fake_ystride; const int fake_stride = -fake_ystride;
int y; int y;
@ -868,7 +868,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
encode_bgra_bitstream(s, width - 1, 4); encode_bgra_bitstream(s, width - 1, 4);
for (y = 1; y < s->height; y++) { for (y = 1; y < s->height; y++) {
uint8_t *dst = data + y*stride; const uint8_t *dst = data + y*stride;
if (s->predictor == PLANE && s->interlaced < y) { if (s->predictor == PLANE && s->interlaced < y) {
s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4); s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4);
sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width, sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width,
@ -880,7 +880,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
encode_bgra_bitstream(s, width, 4); encode_bgra_bitstream(s, width, 4);
} }
} else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) { } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
uint8_t *data = p->data[0] + (height - 1) * p->linesize[0]; const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
const int stride = -p->linesize[0]; const int stride = -p->linesize[0];
const int fake_stride = -fake_ystride; const int fake_stride = -fake_ystride;
int y; int y;
@ -896,7 +896,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
encode_bgra_bitstream(s, width-1, 3); encode_bgra_bitstream(s, width-1, 3);
for (y = 1; y < s->height; y++) { for (y = 1; y < s->height; y++) {
uint8_t *dst = data + y * stride; const uint8_t *dst = data + y * stride;
if (s->predictor == PLANE && s->interlaced < y) { if (s->predictor == PLANE && s->interlaced < y) {
s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride,
width * 3); width * 3);
@ -939,7 +939,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
lefttop = p->data[plane][0]; lefttop = p->data[plane][0];
for (; y < h; y++) { for (; y < h; y++) {
uint8_t *dst = p->data[plane] + p->linesize[plane] * y; const uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
sub_median_prediction(s, s->temp[0], dst - fake_stride, dst, w , &left, &lefttop); sub_median_prediction(s, s->temp[0], dst - fake_stride, dst, w , &left, &lefttop);
@ -947,7 +947,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
} else { } else {
for (y = 1; y < h; y++) { for (y = 1; y < h; y++) {
uint8_t *dst = p->data[plane] + p->linesize[plane] * y; const uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
if (s->predictor == PLANE && s->interlaced < y) { if (s->predictor == PLANE && s->interlaced < y) {
diff_bytes(s, s->temp[1], dst, dst - fake_stride, w); diff_bytes(s, s->temp[1], dst, dst - fake_stride, w);

@ -507,7 +507,7 @@ static int init_tiles(Jpeg2000EncoderContext *s)
static void copy_frame_ ##D(Jpeg2000EncoderContext *s) \ static void copy_frame_ ##D(Jpeg2000EncoderContext *s) \
{ \ { \
int tileno, compno, i, y, x; \ int tileno, compno, i, y, x; \
PIXEL *line; \ const PIXEL *line; \
for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ \ for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ \
Jpeg2000Tile *tile = s->tile + tileno; \ Jpeg2000Tile *tile = s->tile + tileno; \
if (s->planar){ \ if (s->planar){ \
@ -515,23 +515,23 @@ static int init_tiles(Jpeg2000EncoderContext *s)
Jpeg2000Component *comp = tile->comp + compno; \ Jpeg2000Component *comp = tile->comp + compno; \
int *dst = comp->i_data; \ int *dst = comp->i_data; \
int cbps = s->cbps[compno]; \ int cbps = s->cbps[compno]; \
line = (PIXEL*)s->picture->data[compno] \ line = (const PIXEL*)s->picture->data[compno] \
+ comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL)) \ + comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL)) \
+ comp->coord[0][0]; \ + comp->coord[0][0]; \
for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \ for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \
PIXEL *ptr = line; \ const PIXEL *ptr = line; \
for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \ for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \
*dst++ = *ptr++ - (1 << (cbps - 1)); \ *dst++ = *ptr++ - (1 << (cbps - 1)); \
line += s->picture->linesize[compno] / sizeof(PIXEL); \ line += s->picture->linesize[compno] / sizeof(PIXEL); \
} \ } \
} \ } \
} else{ \ } else{ \
line = (PIXEL*)s->picture->data[0] + tile->comp[0].coord[1][0] * (s->picture->linesize[0] / sizeof(PIXEL)) \ line = (const PIXEL*)(s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0]) \
+ tile->comp[0].coord[0][0] * s->ncomponents; \ + tile->comp[0].coord[0][0] * s->ncomponents; \
\ \
i = 0; \ i = 0; \
for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){ \ for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){ \
PIXEL *ptr = line; \ const PIXEL *ptr = line; \
for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){ \ for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){ \
for (compno = 0; compno < s->ncomponents; compno++){ \ for (compno = 0; compno < s->ncomponents; compno++){ \
int cbps = s->cbps[compno]; \ int cbps = s->cbps[compno]; \
@ -1597,7 +1597,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
update_size(chunkstart, s->buf); update_size(chunkstart, s->buf);
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
int i; int i;
uint8_t *palette = pict->data[1]; const uint8_t *palette = pict->data[1];
chunkstart = s->buf; chunkstart = s->buf;
bytestream_put_be32(&s->buf, 0); bytestream_put_be32(&s->buf, 0);
bytestream_put_buffer(&s->buf, "pclr", 4); bytestream_put_buffer(&s->buf, "pclr", 4);

@ -459,7 +459,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
const int bytes_per_sample = av_get_bytes_per_sample(avctx->sample_fmt); const int bytes_per_sample = av_get_bytes_per_sample(avctx->sample_fmt);
const int channels = avctx->ch_layout.nb_channels; const int channels = avctx->ch_layout.nb_channels;
const int sample_size = channels * bytes_per_sample; const int sample_size = channels * bytes_per_sample;
uint8_t *audio; const uint8_t *audio;
int ret; int ret;
int discard_padding; int discard_padding;
@ -470,18 +470,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
if (opus->encoder_channel_map != NULL) { if (opus->encoder_channel_map != NULL) {
audio = opus->samples; audio = opus->samples;
libopus_copy_samples_with_channel_map( libopus_copy_samples_with_channel_map(
audio, frame->data[0], opus->encoder_channel_map, opus->samples, frame->data[0], opus->encoder_channel_map,
channels, frame->nb_samples, bytes_per_sample); channels, frame->nb_samples, bytes_per_sample);
} else if (frame->nb_samples < opus->opts.packet_size) { } else if (frame->nb_samples < opus->opts.packet_size) {
audio = opus->samples; audio = opus->samples;
memcpy(audio, frame->data[0], frame->nb_samples * sample_size); memcpy(opus->samples, frame->data[0], frame->nb_samples * sample_size);
} else } else
audio = frame->data[0]; audio = frame->data[0];
} else { } else {
if (!opus->afq.remaining_samples || (!opus->afq.frame_alloc && !opus->afq.frame_count)) if (!opus->afq.remaining_samples || (!opus->afq.frame_alloc && !opus->afq.frame_count))
return 0; return 0;
audio = opus->samples; audio = opus->samples;
memset(audio, 0, opus->opts.packet_size * sample_size); memset(opus->samples, 0, opus->opts.packet_size * sample_size);
} }
/* Maximum packet size taken from opusenc in opus-tools. 120ms packets /* Maximum packet size taken from opusenc in opus-tools. 120ms packets
@ -491,11 +491,11 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
return ret; return ret;
if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT)
ret = opus_multistream_encode_float(opus->enc, (float *)audio, ret = opus_multistream_encode_float(opus->enc, (const float *)audio,
opus->opts.packet_size, opus->opts.packet_size,
avpkt->data, avpkt->size); avpkt->data, avpkt->size);
else else
ret = opus_multistream_encode(opus->enc, (opus_int16 *)audio, ret = opus_multistream_encode(opus->enc, (const opus_int16 *)audio,
opus->opts.packet_size, opus->opts.packet_size,
avpkt->data, avpkt->size); avpkt->data, avpkt->size);

@ -78,7 +78,7 @@ static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
const int modified_predictor = y ? s->pred : 1; const int modified_predictor = y ? s->pred : 1;
uint8_t *ptr = frame->data[0] + (linesize * y); const uint8_t *ptr = frame->data[0] + (linesize * y);
if (put_bytes_left(pb, 0) < width * 4 * 4) { if (put_bytes_left(pb, 0) < width * 4 * 4) {
av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
@ -132,7 +132,7 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
if (mb_x == 0 || mb_y == 0) { if (mb_x == 0 || mb_y == 0) {
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
uint8_t *ptr; const uint8_t *ptr;
int x, y, h, v, linesize; int x, y, h, v, linesize;
h = s->hsample[i]; h = s->hsample[i];
v = s->vsample[i]; v = s->vsample[i];
@ -166,7 +166,7 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
} }
} else { } else {
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
uint8_t *ptr; const uint8_t *ptr;
int x, y, h, v, linesize; int x, y, h, v, linesize;
h = s->hsample[i]; h = s->hsample[i];
v = s->vsample[i]; v = s->vsample[i];

@ -458,11 +458,12 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
if (s->correlate) { if (s->correlate) {
uint8_t *r, *g, *b, *decorrelated[2] = { s->decorrelate_buf[0], uint8_t *decorrelated[2] = { s->decorrelate_buf[0],
s->decorrelate_buf[1] }; s->decorrelate_buf[1] };
const int decorrelate_linesize = FFALIGN(width, 16); const int decorrelate_linesize = FFALIGN(width, 16);
const uint8_t *const data[4] = { decorrelated[0], frame->data[0], const uint8_t *const data[4] = { decorrelated[0], frame->data[0],
decorrelated[1], frame->data[3] }; decorrelated[1], frame->data[3] };
const uint8_t *r, *g, *b;
const int linesize[4] = { decorrelate_linesize, frame->linesize[0], const int linesize[4] = { decorrelate_linesize, frame->linesize[0],
decorrelate_linesize, frame->linesize[3] }; decorrelate_linesize, frame->linesize[3] };

@ -1202,7 +1202,7 @@ static void input_data_internal(MLPEncodeContext *ctx, const uint8_t *samples,
} }
/** Wrapper function for inputting data in two different bit-depths. */ /** Wrapper function for inputting data in two different bit-depths. */
static void input_data(MLPEncodeContext *ctx, void *samples, int nb_samples) static void input_data(MLPEncodeContext *ctx, const void *samples, int nb_samples)
{ {
input_data_internal(ctx, samples, nb_samples, ctx->avctx->sample_fmt == AV_SAMPLE_FMT_S32); input_data_internal(ctx, samples, nb_samples, ctx->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
} }
@ -2069,7 +2069,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
int bytes_written = 0; int bytes_written = 0;
int channels = avctx->ch_layout.nb_channels; int channels = avctx->ch_layout.nb_channels;
int restart_frame, ret; int restart_frame, ret;
uint8_t *data; const uint8_t *data;
if (!frame && !ctx->last_frames) if (!frame && !ctx->last_frames)
ctx->last_frames = (ctx->afq.remaining_samples + avctx->frame_size - 1) / avctx->frame_size; ctx->last_frames = (ctx->afq.remaining_samples + avctx->frame_size - 1) / avctx->frame_size;

@ -639,7 +639,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
if (s->max_b_frames > 0) { if (s->max_b_frames > 0) {
int i; int i;
int x, y, offset; int x, y, offset;
uint8_t *p_pic; const uint8_t *p_pic;
x = s->mb_x * 16; x = s->mb_x * 16;
y = s->mb_y * 16; y = s->mb_y * 16;
@ -649,7 +649,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
s->mb_skipped = 1; s->mb_skipped = 1;
for (i = 0; i < s->max_b_frames; i++) { for (i = 0; i < s->max_b_frames; i++) {
uint8_t *b_pic; const uint8_t *b_pic;
int diff; int diff;
Picture *pic = s->reordered_input_picture[i + 1]; Picture *pic = s->reordered_input_picture[i + 1];

@ -953,7 +953,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
return 0; return 0;
} }
static int get_sae(uint8_t *src, int ref, int stride) static int get_sae(const uint8_t *src, int ref, int stride)
{ {
int x,y; int x,y;
int acc = 0; int acc = 0;
@ -967,8 +967,8 @@ static int get_sae(uint8_t *src, int ref, int stride)
return acc; return acc;
} }
static int get_intra_count(MpegEncContext *s, uint8_t *src, static int get_intra_count(MpegEncContext *s, const uint8_t *src,
uint8_t *ref, int stride) const uint8_t *ref, int stride)
{ {
int x, y, w, h; int x, y, w, h;
int acc = 0; int acc = 0;
@ -1087,7 +1087,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
int v_shift = i ? v_chroma_shift : 0; int v_shift = i ? v_chroma_shift : 0;
int w = s->width >> h_shift; int w = s->width >> h_shift;
int h = s->height >> v_shift; int h = s->height >> v_shift;
uint8_t *src = pic_arg->data[i]; const uint8_t *src = pic_arg->data[i];
uint8_t *dst = pic->f->data[i]; uint8_t *dst = pic->f->data[i];
int vpad = 16; int vpad = 16;
@ -1149,7 +1149,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
return 0; return 0;
} }
static int skip_check(MpegEncContext *s, Picture *p, Picture *ref) static int skip_check(MpegEncContext *s, const Picture *p, const Picture *ref)
{ {
int x, y, plane; int x, y, plane;
int score = 0; int score = 0;
@ -1161,8 +1161,8 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
for (y = 0; y < s->mb_height * bw; y++) { for (y = 0; y < s->mb_height * bw; y++) {
for (x = 0; x < s->mb_width * bw; x++) { for (x = 0; x < s->mb_width * bw; x++) {
int off = p->shared ? 0 : 16; int off = p->shared ? 0 : 16;
uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off; const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off;
uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride);
int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8); int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8);
switch (FFABS(s->frame_skip_exp)) { switch (FFABS(s->frame_skip_exp)) {
@ -1190,7 +1190,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
return 0; return 0;
} }
static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt) static int encode_frame(AVCodecContext *c, const AVFrame *frame, AVPacket *pkt)
{ {
int ret; int ret;
int size = 0; int size = 0;
@ -1990,7 +1990,7 @@ static inline void clip_coeffs(MpegEncContext *s, int16_t *block,
overflow, minlevel, maxlevel); overflow, minlevel, maxlevel);
} }
static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride) static void get_visual_weight(int16_t *weight, const uint8_t *ptr, int stride)
{ {
int x, y; int x, y;
// FIXME optimize // FIXME optimize
@ -2035,7 +2035,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
int skip_dct[12]; int skip_dct[12];
int dct_offset = s->linesize * 8; // default for progressive frames int dct_offset = s->linesize * 8; // default for progressive frames
int uv_dct_offset = s->uvlinesize * 8; int uv_dct_offset = s->uvlinesize * 8;
uint8_t *ptr_y, *ptr_cb, *ptr_cr; const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
ptrdiff_t wrap_y, wrap_c; ptrdiff_t wrap_y, wrap_c;
for (i = 0; i < mb_block_count; i++) for (i = 0; i < mb_block_count; i++)
@ -2534,7 +2534,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
} }
} }
static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){ static int sse(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride){
const uint32_t *sq = ff_square_tab + 256; const uint32_t *sq = ff_square_tab + 256;
int acc=0; int acc=0;
int x,y; int x,y;
@ -2641,7 +2641,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
for(mb_x=0; mb_x < s->mb_width; mb_x++) { for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xx = mb_x * 16; int xx = mb_x * 16;
int yy = mb_y * 16; int yy = mb_y * 16;
uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx; const uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx;
int varc; int varc;
int sum = s->mpvencdsp.pix_sum(pix, s->linesize); int sum = s->mpvencdsp.pix_sum(pix, s->linesize);

@ -69,7 +69,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
{ {
Msvideo1EncContext * const c = avctx->priv_data; Msvideo1EncContext * const c = avctx->priv_data;
const AVFrame *p = pict; const AVFrame *p = pict;
uint16_t *src; const uint16_t *src;
uint8_t *prevptr; uint8_t *prevptr;
uint8_t *dst, *buf; uint8_t *dst, *buf;
int keyframe = 0; int keyframe = 0;
@ -85,7 +85,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if(!c->prev) if(!c->prev)
c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3)); c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3));
prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1); prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1);
src = (uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1)); src = (const uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1));
if(c->keyint >= avctx->keyint_min) if(c->keyint >= avctx->keyint_min)
keyframe = 1; keyframe = 1;

@ -28,7 +28,8 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet) const AVFrame *p, int *got_packet)
{ {
int i, h, w, n, linesize, depth, maxval, ret, header_size; int i, h, w, n, linesize, depth, maxval, ret, header_size;
uint8_t *bytestream, *ptr; uint8_t *bytestream;
const uint8_t *ptr;
const char *tuple_type; const char *tuple_type;
char header[100]; char header[100];

@ -120,7 +120,7 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size,
} }
} }
static void sub_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, static void sub_png_paeth_prediction(uint8_t *dst, const uint8_t *src, const uint8_t *top,
int w, int bpp) int w, int bpp)
{ {
int i; int i;
@ -165,7 +165,7 @@ static void sub_left_prediction(PNGEncContext *c, uint8_t *dst, const uint8_t *s
} }
static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type, static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type,
uint8_t *src, uint8_t *top, int size, int bpp) const uint8_t *src, const uint8_t *top, int size, int bpp)
{ {
int i; int i;
@ -194,7 +194,7 @@ static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type,
} }
static uint8_t *png_choose_filter(PNGEncContext *s, uint8_t *dst, static uint8_t *png_choose_filter(PNGEncContext *s, uint8_t *dst,
uint8_t *src, uint8_t *top, int size, int bpp) const uint8_t *src, const uint8_t *top, int size, int bpp)
{ {
int pred = s->filter_type; int pred = s->filter_type;
av_assert0(bpp || !pred); av_assert0(bpp || !pred);
@ -486,7 +486,7 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
const AVFrame *const p = pict; const AVFrame *const p = pict;
int y, len, ret; int y, len, ret;
int row_size, pass_row_size; int row_size, pass_row_size;
uint8_t *ptr, *top, *crow_buf, *crow; uint8_t *crow_buf, *crow;
uint8_t *crow_base = NULL; uint8_t *crow_base = NULL;
uint8_t *progressive_buf = NULL; uint8_t *progressive_buf = NULL;
uint8_t *top_buf = NULL; uint8_t *top_buf = NULL;
@ -520,10 +520,10 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
* output */ * output */
pass_row_size = ff_png_pass_row_size(pass, s->bits_per_pixel, pict->width); pass_row_size = ff_png_pass_row_size(pass, s->bits_per_pixel, pict->width);
if (pass_row_size > 0) { if (pass_row_size > 0) {
top = NULL; uint8_t *top = NULL;
for (y = 0; y < pict->height; y++) for (y = 0; y < pict->height; y++)
if ((ff_png_pass_ymask[pass] << (y & 7)) & 0x80) { if ((ff_png_pass_ymask[pass] << (y & 7)) & 0x80) {
ptr = p->data[0] + y * p->linesize[0]; const uint8_t *ptr = p->data[0] + y * p->linesize[0];
FFSWAP(uint8_t *, progressive_buf, top_buf); FFSWAP(uint8_t *, progressive_buf, top_buf);
png_get_interlaced_row(progressive_buf, pass_row_size, png_get_interlaced_row(progressive_buf, pass_row_size,
s->bits_per_pixel, pass, s->bits_per_pixel, pass,
@ -536,9 +536,9 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
} }
} }
} else { } else {
top = NULL; const uint8_t *top = NULL;
for (y = 0; y < pict->height; y++) { for (y = 0; y < pict->height; y++) {
ptr = p->data[0] + y * p->linesize[0]; const uint8_t *ptr = p->data[0] + y * p->linesize[0];
crow = png_choose_filter(s, crow_buf, ptr, top, crow = png_choose_filter(s, crow_buf, ptr, top,
row_size, s->bits_per_pixel >> 3); row_size, s->bits_per_pixel >> 3);
png_write_row(avctx, crow, row_size + 1); png_write_row(avctx, crow, row_size + 1);
@ -723,7 +723,7 @@ static int apng_do_inverse_blend(AVFrame *output, const AVFrame *input,
} }
for (y = topmost_y; y < bottommost_y; ++y) { for (y = topmost_y; y < bottommost_y; ++y) {
uint8_t *foreground = input->data[0] + input_linesize * y + bpp * leftmost_x; const uint8_t *foreground = input->data[0] + input_linesize * y + bpp * leftmost_x;
uint8_t *background = output->data[0] + output_linesize * y + bpp * leftmost_x; uint8_t *background = output->data[0] + output_linesize * y + bpp * leftmost_x;
output_data = output->data[0] + output_linesize * (y - topmost_y); output_data = output->data[0] + output_linesize * (y - topmost_y);
for (x = leftmost_x; x < rightmost_x; ++x, foreground += bpp, background += bpp, output_data += bpp) { for (x = leftmost_x; x < rightmost_x; ++x, foreground += bpp, background += bpp, output_data += bpp) {

@ -40,7 +40,6 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
PHMEncContext *s = avctx->priv_data; PHMEncContext *s = avctx->priv_data;
uint8_t *bytestream, *bytestream_start, *bytestream_end; uint8_t *bytestream, *bytestream_start, *bytestream_end;
int i, h, h1, c, n, linesize, ret; int i, h, h1, c, n, linesize, ret;
uint8_t *ptr, *ptr1, *ptr2;
int size = av_image_get_buffer_size(avctx->pix_fmt, int size = av_image_get_buffer_size(avctx->pix_fmt,
avctx->width, avctx->height, 1); avctx->width, avctx->height, 1);
@ -135,9 +134,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if ((avctx->pix_fmt == AV_PIX_FMT_GBRPF32LE || if ((avctx->pix_fmt == AV_PIX_FMT_GBRPF32LE ||
avctx->pix_fmt == AV_PIX_FMT_GBRPF32BE) && c == 'F') { avctx->pix_fmt == AV_PIX_FMT_GBRPF32BE) && c == 'F') {
float *r = (float *)p->data[2]; const float *r = (const float *)p->data[2];
float *g = (float *)p->data[0]; const float *g = (const float *)p->data[0];
float *b = (float *)p->data[1]; const float *b = (const float *)p->data[1];
for (int i = 0; i < avctx->height; i++) { for (int i = 0; i < avctx->height; i++) {
for (int j = 0; j < avctx->width; j++) { for (int j = 0; j < avctx->width; j++) {
@ -164,9 +163,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
g += p->linesize[0] / 4; g += p->linesize[0] / 4;
} }
} else if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 && c == 'H') { } else if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 && c == 'H') {
float *r = (float *)p->data[2]; const float *r = (const float *)p->data[2];
float *g = (float *)p->data[0]; const float *g = (const float *)p->data[0];
float *b = (float *)p->data[1]; const float *b = (const float *)p->data[1];
for (int i = 0; i < avctx->height; i++) { for (int i = 0; i < avctx->height; i++) {
for (int j = 0; j < avctx->width; j++) { for (int j = 0; j < avctx->width; j++) {
@ -192,7 +191,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
g += p->linesize[0] / 4; g += p->linesize[0] / 4;
} }
} else { } else {
ptr = p->data[0]; const uint8_t *ptr = p->data[0];
linesize = p->linesize[0]; linesize = p->linesize[0];
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
memcpy(bytestream, ptr, n); memcpy(bytestream, ptr, n);
@ -202,10 +201,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
if (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16BE) { if (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16BE) {
const uint8_t *ptr1 = p->data[1], *ptr2 = p->data[2];
h >>= 1; h >>= 1;
n >>= 1; n >>= 1;
ptr1 = p->data[1];
ptr2 = p->data[2];
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
memcpy(bytestream, ptr1, n); memcpy(bytestream, ptr1, n);
bytestream += n; bytestream += n;

@ -305,7 +305,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
} }
} }
static void get(uint8_t *pixels, int stride, int16_t* block) static void get(const uint8_t *pixels, int stride, int16_t* block)
{ {
int i; int i;
@ -317,13 +317,13 @@ static void get(uint8_t *pixels, int stride, int16_t* block)
} }
} }
static void fdct_get(FDCTDSPContext *fdsp, uint8_t *pixels, int stride, int16_t* block) static void fdct_get(FDCTDSPContext *fdsp, const uint8_t *pixels, int stride, int16_t* block)
{ {
get(pixels, stride, block); get(pixels, stride, block);
fdsp->fdct(block); fdsp->fdct(block);
} }
static void calc_plane_dct(FDCTDSPContext *fdsp, uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422) static void calc_plane_dct(FDCTDSPContext *fdsp, const uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422)
{ {
int16_t *block; int16_t *block;
int i; int i;
@ -473,7 +473,7 @@ static av_always_inline int encode_alpha_slice_data(AVCodecContext *avctx, int8_
} }
} }
static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsigned y, static inline void subimage_with_fill_template(const uint16_t *src, unsigned x, unsigned y,
unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned stride, unsigned width, unsigned height, uint16_t *dst,
unsigned dst_width, unsigned dst_height, int is_alpha_plane, unsigned dst_width, unsigned dst_height, int is_alpha_plane,
int is_interlaced, int is_top_field) int is_interlaced, int is_top_field)
@ -521,7 +521,7 @@ static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsign
} }
} }
static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y, static void subimage_with_fill(const uint16_t *src, unsigned x, unsigned y,
unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned stride, unsigned width, unsigned height, uint16_t *dst,
unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field) unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
{ {
@ -529,7 +529,7 @@ static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y,
} }
/* reorganize alpha data and convert 10b -> 16b */ /* reorganize alpha data and convert 10b -> 16b */
static void subimage_alpha_with_fill(uint16_t *src, unsigned x, unsigned y, static void subimage_alpha_with_fill(const uint16_t *src, unsigned x, unsigned y,
unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned stride, unsigned width, unsigned height, uint16_t *dst,
unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field) unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
{ {
@ -544,7 +544,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
ProresContext* ctx = avctx->priv_data; ProresContext* ctx = avctx->priv_data;
int hdr_size = 6 + (ctx->need_alpha * 2); /* v data size is write when there is alpha */ int hdr_size = 6 + (ctx->need_alpha * 2); /* v data size is write when there is alpha */
int ret = 0, slice_size; int ret = 0, slice_size;
uint8_t *dest_y, *dest_u, *dest_v; const uint8_t *dest_y, *dest_u, *dest_v;
unsigned y_data_size = 0, u_data_size = 0, v_data_size = 0, a_data_size = 0; unsigned y_data_size = 0, u_data_size = 0, v_data_size = 0, a_data_size = 0;
FDCTDSPContext *fdsp = &ctx->fdsp; FDCTDSPContext *fdsp = &ctx->fdsp;
int tgt_bits = (mb_count * bitrate_table[avctx->profile]) >> 2; int tgt_bits = (mb_count * bitrate_table[avctx->profile]) >> 2;
@ -577,13 +577,13 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
} }
if (unsafe) { if (unsafe) {
subimage_with_fill((uint16_t *) pic->data[0], mb_x << 4, mb_y << 4, subimage_with_fill((const uint16_t *) pic->data[0], mb_x << 4, mb_y << 4,
luma_stride, avctx->width, avctx->height, luma_stride, avctx->width, avctx->height,
(uint16_t *) ctx->fill_y, mb_count << 4, 16, is_interlaced, is_top_field); (uint16_t *) ctx->fill_y, mb_count << 4, 16, is_interlaced, is_top_field);
subimage_with_fill((uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4, subimage_with_fill((const uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4,
chroma_stride, avctx->width >> ctx->is_422, avctx->height, chroma_stride, avctx->width >> ctx->is_422, avctx->height,
(uint16_t *) ctx->fill_u, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field); (uint16_t *) ctx->fill_u, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field);
subimage_with_fill((uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4, subimage_with_fill((const uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4,
chroma_stride, avctx->width >> ctx->is_422, avctx->height, chroma_stride, avctx->width >> ctx->is_422, avctx->height,
(uint16_t *) ctx->fill_v, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field); (uint16_t *) ctx->fill_v, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field);
@ -640,7 +640,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
if (ctx->need_alpha) { if (ctx->need_alpha) {
AV_WB16(buf + 6, v_data_size); /* write v data size only if there is alpha */ AV_WB16(buf + 6, v_data_size); /* write v data size only if there is alpha */
subimage_alpha_with_fill((uint16_t *) pic->data[3], mb_x << 4, mb_y << 4, subimage_alpha_with_fill((const uint16_t *) pic->data[3], mb_x << 4, mb_y << 4,
alpha_stride, avctx->width, avctx->height, alpha_stride, avctx->width, avctx->height,
(uint16_t *) ctx->fill_a, mb_count << 4, 16, is_interlaced, is_top_field); (uint16_t *) ctx->fill_a, mb_count << 4, 16, is_interlaced, is_top_field);
ret = encode_alpha_slice_data(avctx, ctx->fill_a, mb_count, ret = encode_alpha_slice_data(avctx, ctx->fill_a, mb_count,

@ -33,7 +33,8 @@ static int qoi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint8_t px[4] = { 0, 0, 0, 255 }; uint8_t px[4] = { 0, 0, 0, 255 };
uint8_t index[64][4] = { 0 }; uint8_t index[64][4] = { 0 };
int64_t packet_size; int64_t packet_size;
uint8_t *buf, *src; uint8_t *buf;
const uint8_t *src;
int ret, run = 0; int ret, run = 0;
packet_size = avctx->width * avctx->height * (channels + 1LL) + 14LL + 8LL; packet_size = avctx->width * avctx->height * (channels + 1LL) + 14LL + 8LL;

@ -47,7 +47,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int aligned_width = FFALIGN(avctx->width, int aligned_width = FFALIGN(avctx->width,
avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64); avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64);
int pad = (aligned_width - avctx->width) * 4; int pad = (aligned_width - avctx->width) * 4;
uint8_t *srcr_line, *srcg_line, *srcb_line; const uint8_t *srcr_line, *srcg_line, *srcb_line;
uint8_t *dst; uint8_t *dst;
ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0); ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0);
@ -60,9 +60,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
dst = pkt->data; dst = pkt->data;
for (i = 0; i < avctx->height; i++) { for (i = 0; i < avctx->height; i++) {
uint16_t *srcr = (uint16_t *)srcr_line; const uint16_t *srcr = (const uint16_t *)srcr_line;
uint16_t *srcg = (uint16_t *)srcg_line; const uint16_t *srcg = (const uint16_t *)srcg_line;
uint16_t *srcb = (uint16_t *)srcb_line; const uint16_t *srcb = (const uint16_t *)srcb_line;
for (j = 0; j < avctx->width; j++) { for (j = 0; j < avctx->width; j++) {
uint32_t pixel; uint32_t pixel;
unsigned r = *srcr++; unsigned r = *srcr++;

@ -84,7 +84,7 @@ typedef struct BlockInfo {
int total_blocks; int total_blocks;
} BlockInfo; } BlockInfo;
static void get_colors(uint8_t *min, uint8_t *max, uint8_t color4[4][3]) static void get_colors(const uint8_t *min, const uint8_t *max, uint8_t color4[4][3])
{ {
uint8_t step; uint8_t step;
@ -135,7 +135,7 @@ static int get_block_info(BlockInfo *bi, int block)
return block ? (bi->col * 4) + (bi->row * bi->rowstride * 4) : 0; return block ? (bi->col * 4) + (bi->row * bi->rowstride * 4) : 0;
} }
static uint16_t rgb24_to_rgb555(uint8_t *rgb24) static uint16_t rgb24_to_rgb555(const uint8_t *rgb24)
{ {
uint16_t rgb555 = 0; uint16_t rgb555 = 0;
uint32_t r, g, b; uint32_t r, g, b;
@ -154,7 +154,7 @@ static uint16_t rgb24_to_rgb555(uint8_t *rgb24)
/* /*
* Returns the total difference between two 24 bit color values * Returns the total difference between two 24 bit color values
*/ */
static int diff_colors(uint8_t *colorA, uint8_t *colorB) static int diff_colors(const uint8_t *colorA, const uint8_t *colorB)
{ {
int tot; int tot;
@ -168,7 +168,7 @@ static int diff_colors(uint8_t *colorA, uint8_t *colorB)
/* /*
* Returns the maximum channel difference * Returns the maximum channel difference
*/ */
static int max_component_diff(uint16_t *colorA, uint16_t *colorB) static int max_component_diff(const uint16_t *colorA, const uint16_t *colorB)
{ {
int diff, max = 0; int diff, max = 0;
@ -192,7 +192,7 @@ static int max_component_diff(uint16_t *colorA, uint16_t *colorB)
* color values. Put the minimum value in min, maximum in max and the channel * color values. Put the minimum value in min, maximum in max and the channel
* in chan. * in chan.
*/ */
static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr, static void get_max_component_diff(const BlockInfo *bi, const uint16_t *block_ptr,
uint8_t *min, uint8_t *max, channel_offset *chan) uint8_t *min, uint8_t *max, channel_offset *chan)
{ {
int x, y; int x, y;
@ -242,7 +242,8 @@ static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr,
* blocks is greater than the thresh parameter. Returns -1 if difference * blocks is greater than the thresh parameter. Returns -1 if difference
* exceeds threshold or zero otherwise. * exceeds threshold or zero otherwise.
*/ */
static int compare_blocks(uint16_t *block1, uint16_t *block2, BlockInfo *bi, int thresh) static int compare_blocks(const uint16_t *block1, const uint16_t *block2,
const BlockInfo *bi, int thresh)
{ {
int x, y, diff = 0; int x, y, diff = 0;
for (y = 0; y < bi->block_height; y++) { for (y = 0; y < bi->block_height; y++) {
@ -262,7 +263,7 @@ static int compare_blocks(uint16_t *block1, uint16_t *block2, BlockInfo *bi, int
* Determine the fit of one channel to another within a 4x4 block. This * Determine the fit of one channel to another within a 4x4 block. This
* is used to determine the best palette choices for 4-color encoding. * is used to determine the best palette choices for 4-color encoding.
*/ */
static int leastsquares(uint16_t *block_ptr, BlockInfo *bi, static int leastsquares(const uint16_t *block_ptr, const BlockInfo *bi,
channel_offset xchannel, channel_offset ychannel, channel_offset xchannel, channel_offset ychannel,
double *slope, double *y_intercept, double *correlation_coef) double *slope, double *y_intercept, double *correlation_coef)
{ {
@ -315,7 +316,7 @@ static int leastsquares(uint16_t *block_ptr, BlockInfo *bi,
/* /*
* Determine the amount of error in the leastsquares fit. * Determine the amount of error in the leastsquares fit.
*/ */
static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi, static int calc_lsq_max_fit_error(const uint16_t *block_ptr, const BlockInfo *bi,
int min, int max, int tmp_min, int tmp_max, int min, int max, int tmp_min, int tmp_max,
channel_offset xchannel, channel_offset ychannel) channel_offset xchannel, channel_offset ychannel)
{ {
@ -356,7 +357,7 @@ static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi,
/* /*
* Find the closest match to a color within the 4-color palette * Find the closest match to a color within the 4-color palette
*/ */
static int match_color(uint16_t *color, uint8_t colors[4][3]) static int match_color(const uint16_t *color, uint8_t colors[4][3])
{ {
int ret = 0; int ret = 0;
int smallest_variance = INT_MAX; int smallest_variance = INT_MAX;
@ -383,8 +384,8 @@ static int match_color(uint16_t *color, uint8_t colors[4][3])
* blocks encoded (until we implement multi-block 4 color runs this will * blocks encoded (until we implement multi-block 4 color runs this will
* always be 1) * always be 1)
*/ */
static int encode_four_color_block(uint8_t *min_color, uint8_t *max_color, static int encode_four_color_block(const uint8_t *min_color, const uint8_t *max_color,
PutBitContext *pb, uint16_t *block_ptr, BlockInfo *bi) PutBitContext *pb, const uint16_t *block_ptr, const BlockInfo *bi)
{ {
int x, y, idx; int x, y, idx;
uint8_t color4[4][3]; uint8_t color4[4][3];
@ -441,7 +442,7 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels,
* the statistics of this block. Otherwise, the stats are unchanged * the statistics of this block. Otherwise, the stats are unchanged
* and don't include the current block. * and don't include the current block.
*/ */
static int update_block_stats(RpzaContext *s, BlockInfo *bi, uint16_t *block, static int update_block_stats(RpzaContext *s, const BlockInfo *bi, const uint16_t *block,
uint8_t min_color[3], uint8_t max_color[3], uint8_t min_color[3], uint8_t max_color[3],
int *total_rgb, int *total_pixels, int *total_rgb, int *total_pixels,
uint8_t avg_color[3], int first_block) uint8_t avg_color[3], int first_block)
@ -562,7 +563,7 @@ static void rpza_encode_stream(RpzaContext *s, const AVFrame *pict)
int pixel_count; int pixel_count;
uint8_t min_color[3], max_color[3]; uint8_t min_color[3], max_color[3];
double slope, y_intercept, correlation_coef; double slope, y_intercept, correlation_coef;
uint16_t *src_pixels = (uint16_t *)pict->data[0]; const uint16_t *src_pixels = (const uint16_t *)pict->data[0];
uint16_t *prev_pixels = (uint16_t *)s->prev_frame->data[0]; uint16_t *prev_pixels = (uint16_t *)s->prev_frame->data[0];
/* Number of 4x4 blocks in frame. */ /* Number of 4x4 blocks in frame. */
@ -728,7 +729,7 @@ post_skip :
} }
if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK
uint16_t *row_ptr; const uint16_t *row_ptr;
int rgb555; int rgb555;
block_offset = get_block_info(&bi, block_counter); block_offset = get_block_info(&bi, block_counter);

@ -96,7 +96,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
SgiContext *s = avctx->priv_data; SgiContext *s = avctx->priv_data;
const AVFrame * const p = frame; const AVFrame * const p = frame;
PutByteContext pbc; PutByteContext pbc;
uint8_t *in_buf, *encode_buf; uint8_t *encode_buf;
int x, y, z, length, tablesize, ret, i; int x, y, z, length, tablesize, ret, i;
unsigned int width, height, depth, dimension; unsigned int width, height, depth, dimension;
unsigned int bytes_per_channel, pixmax, put_be; unsigned int bytes_per_channel, pixmax, put_be;
@ -200,7 +200,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (z = 0; z < depth; z++) { for (z = 0; z < depth; z++) {
in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel; const uint8_t *in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc)); bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));
@ -231,7 +231,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
av_free(encode_buf); av_free(encode_buf);
} else { } else {
for (z = 0; z < depth; z++) { for (z = 0; z < depth; z++) {
in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel; const uint8_t *in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
for (x = 0; x < width * depth; x += depth) for (x = 0; x < width * depth; x += depth)

@ -486,7 +486,7 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in
} }
} }
static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){ static inline void init_ref(MotionEstContext *c, const uint8_t *const src[3], uint8_t *const ref[3], uint8_t *const ref2[3], int x, int y, int ref_index){
SnowContext *s = c->avctx->priv_data; SnowContext *s = c->avctx->priv_data;
const int offset[3]= { const int offset[3]= {
y*c-> stride + x, y*c-> stride + x,

@ -151,7 +151,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
} }
//near copy & paste from dsputil, FIXME //near copy & paste from dsputil, FIXME
static int pix_sum(uint8_t * pix, int line_size, int w, int h) static int pix_sum(const uint8_t * pix, int line_size, int w, int h)
{ {
int s, i, j; int s, i, j;
@ -167,7 +167,7 @@ static int pix_sum(uint8_t * pix, int line_size, int w, int h)
} }
//near copy & paste from dsputil, FIXME //near copy & paste from dsputil, FIXME
static int pix_norm1(uint8_t * pix, int line_size, int w) static int pix_norm1(const uint8_t * pix, int line_size, int w)
{ {
int s, i, j; int s, i, j;
const uint32_t *sq = ff_square_tab + 256; const uint32_t *sq = ff_square_tab + 256;
@ -245,7 +245,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
int l,cr,cb; int l,cr,cb;
const int stride= s->current_picture->linesize[0]; const int stride= s->current_picture->linesize[0];
const int uvstride= s->current_picture->linesize[1]; const int uvstride= s->current_picture->linesize[1];
uint8_t *current_data[3]= { s->input_picture->data[0] + (x + y* stride)*block_w, const uint8_t *const current_data[3] = { s->input_picture->data[0] + (x + y* stride)*block_w,
s->input_picture->data[1] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift), s->input_picture->data[1] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift),
s->input_picture->data[2] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift)}; s->input_picture->data[2] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift)};
int P[10][2]; int P[10][2];
@ -508,7 +508,7 @@ static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){
const uint8_t *obmc = plane_index ? ff_obmc_tab[s->block_max_depth+s->chroma_h_shift] : ff_obmc_tab[s->block_max_depth]; const uint8_t *obmc = plane_index ? ff_obmc_tab[s->block_max_depth+s->chroma_h_shift] : ff_obmc_tab[s->block_max_depth];
const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
const int ref_stride= s->current_picture->linesize[plane_index]; const int ref_stride= s->current_picture->linesize[plane_index];
uint8_t *src= s-> input_picture->data[plane_index]; const uint8_t *src = s->input_picture->data[plane_index];
IDWTELEM *dst= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned IDWTELEM *dst= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned
const int b_stride = s->b_width << s->block_max_depth; const int b_stride = s->b_width << s->block_max_depth;
const int w= p->width; const int w= p->width;
@ -603,7 +603,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin
const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
const int ref_stride= s->current_picture->linesize[plane_index]; const int ref_stride= s->current_picture->linesize[plane_index];
uint8_t *dst= s->current_picture->data[plane_index]; uint8_t *dst= s->current_picture->data[plane_index];
uint8_t *src= s-> input_picture->data[plane_index]; const uint8_t *src = s->input_picture->data[plane_index];
IDWTELEM *pred= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; IDWTELEM *pred= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4;
uint8_t *cur = s->scratchbuf; uint8_t *cur = s->scratchbuf;
uint8_t *tmp = s->emu_edge_buffer; uint8_t *tmp = s->emu_edge_buffer;
@ -706,7 +706,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){
const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
const int ref_stride= s->current_picture->linesize[plane_index]; const int ref_stride= s->current_picture->linesize[plane_index];
uint8_t *dst= s->current_picture->data[plane_index]; uint8_t *dst= s->current_picture->data[plane_index];
uint8_t *src= s-> input_picture->data[plane_index]; const uint8_t *src = s->input_picture->data[plane_index];
//FIXME zero_dst is const but add_yblock changes dst if add is 0 (this is never the case for dst=zero_dst //FIXME zero_dst is const but add_yblock changes dst if add is 0 (this is never the case for dst=zero_dst
// const has only been removed from zero_dst to suppress a warning // const has only been removed from zero_dst to suppress a warning
static IDWTELEM zero_dst[4096]; //FIXME static IDWTELEM zero_dst[4096]; //FIXME
@ -1076,7 +1076,7 @@ static void iterative_me(SnowContext *s){
//skip stuff outside the picture //skip stuff outside the picture
if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){ if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){
uint8_t *src= s-> input_picture->data[0]; const uint8_t *src = s->input_picture->data[0];
uint8_t *dst= s->current_picture->data[0]; uint8_t *dst= s->current_picture->data[0];
const int stride= s->current_picture->linesize[0]; const int stride= s->current_picture->linesize[0];
const int block_w= MB_SIZE >> s->block_max_depth; const int block_w= MB_SIZE >> s->block_max_depth;

@ -248,7 +248,7 @@ static void init_block_index(MpegEncContext *s){
} }
static int svq1_encode_plane(SVQ1EncContext *s, int plane, static int svq1_encode_plane(SVQ1EncContext *s, int plane,
unsigned char *src_plane, const unsigned char *src_plane,
unsigned char *ref_plane, unsigned char *ref_plane,
unsigned char *decoded_plane, unsigned char *decoded_plane,
int width, int height, int src_stride, int stride) int width, int height, int src_stride, int stride)
@ -371,7 +371,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
int count[2][6]; int count[2][6];
int offset = y * 16 * stride + x * 16; int offset = y * 16 * stride + x * 16;
uint8_t *decoded = decoded_plane + offset; uint8_t *decoded = decoded_plane + offset;
uint8_t *ref = ref_plane + offset; const uint8_t *ref = ref_plane + offset;
int score[4] = { 0, 0, 0, 0 }, best; int score[4] = { 0, 0, 0, 0 }, best;
uint8_t *temp = s->scratchbuf; uint8_t *temp = s->scratchbuf;

@ -72,7 +72,7 @@ static int targa_encode_normal(uint8_t *outbuf, const AVFrame *pic, int bpp, int
{ {
int i, n = bpp * w; int i, n = bpp * w;
uint8_t *out = outbuf; uint8_t *out = outbuf;
uint8_t *ptr = pic->data[0]; const uint8_t *ptr = pic->data[0];
for(i=0; i < h; i++) { for(i=0; i < h; i++) {
memcpy(out, ptr, n); memcpy(out, ptr, n);

@ -207,8 +207,8 @@ static void pack_yuv(TiffEncoderContext *s, const AVFrame *p,
{ {
int i, j, k; int i, j, k;
int w = (s->width - 1) / s->subsampling[0] + 1; int w = (s->width - 1) / s->subsampling[0] + 1;
uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]]; const uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]]; const uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) { if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) {
for (i = 0; i < w; i++) { for (i = 0; i < w; i++) {
for (j = 0; j < s->subsampling[1]; j++) for (j = 0; j < s->subsampling[1]; j++)

@ -277,7 +277,7 @@ static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride,
#undef B #undef B
/* Write data to a plane with median prediction */ /* Write data to a plane with median prediction */
static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, static void median_predict(UtvideoContext *c, const uint8_t *src, uint8_t *dst,
ptrdiff_t stride, int width, int height) ptrdiff_t stride, int width, int height)
{ {
int i, j; int i, j;
@ -376,7 +376,7 @@ static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size,
return put_bytes_output(&pb); return put_bytes_output(&pb);
} }
static int encode_plane(AVCodecContext *avctx, uint8_t *src, static int encode_plane(AVCodecContext *avctx, const uint8_t *src,
uint8_t *dst, ptrdiff_t stride, int plane_no, uint8_t *dst, ptrdiff_t stride, int plane_no,
int width, int height, PutByteContext *pb) int width, int height, PutByteContext *pb)
{ {

@ -43,7 +43,7 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet) const AVFrame *pic, int *got_packet)
{ {
uint8_t *dst; uint8_t *dst;
uint8_t *y, *u, *v; const uint8_t *y, *u, *v;
int i, j, ret; int i, j, ret;
ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0); ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0);

@ -40,7 +40,7 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet) const AVFrame *pic, int *got_packet)
{ {
uint8_t *dst; uint8_t *dst;
uint8_t *y, *u, *v, *a; const uint8_t *y, *u, *v, *a;
int i, j, ret; int i, j, ret;
ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0);

@ -44,7 +44,7 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet) const AVFrame *pic, int *got_packet)
{ {
uint8_t *dst; uint8_t *dst;
uint16_t *y, *u, *v; const uint16_t *y, *u, *v;
uint32_t val; uint32_t val;
int i, j, ret; int i, j, ret;

@ -116,7 +116,7 @@ static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt,
ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE; ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE;
avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count); avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count);
} else { } else {
uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1); const uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1);
av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height); av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height);
} }

@ -117,7 +117,7 @@ typedef struct SliceArgs {
typedef struct TransformArgs { typedef struct TransformArgs {
void *ctx; void *ctx;
Plane *plane; Plane *plane;
void *idata; const void *idata;
ptrdiff_t istride; ptrdiff_t istride;
int field; int field;
VC2TransformContext t; VC2TransformContext t;

@ -110,7 +110,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame) static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
{ {
WMACodecContext *s = avctx->priv_data; WMACodecContext *s = avctx->priv_data;
float **audio = (float **) frame->extended_data; const float *const *audio = (const float *const *) frame->extended_data;
int len = frame->nb_samples; int len = frame->nb_samples;
int window_index = s->frame_len_bits - s->block_len_bits; int window_index = s->frame_len_bits - s->block_len_bits;
FFTContext *mdct = &s->mdct_ctx[window_index]; FFTContext *mdct = &s->mdct_ctx[window_index];

@ -32,7 +32,8 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet) const AVFrame *p, int *got_packet)
{ {
int i, j, l, commas, ret, size, linesize, lineout, rowsout; int i, j, l, commas, ret, size, linesize, lineout, rowsout;
uint8_t *ptr, *buf; const uint8_t *ptr;
uint8_t *buf;
linesize = lineout = (avctx->width + 7) / 8; linesize = lineout = (avctx->width + 7) / 8;
commas = avctx->height * linesize; commas = avctx->height * linesize;

@ -39,7 +39,8 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint32_t rgb[3] = { 0 }, bitorder = 0; uint32_t rgb[3] = { 0 }, bitorder = 0;
uint32_t header_size; uint32_t header_size;
int i, out_size, ret; int i, out_size, ret;
uint8_t *ptr, *buf; const uint8_t *ptr;
uint8_t *buf;
uint32_t pal[256]; uint32_t pal[256];
pixdepth = av_get_bits_per_pixel(desc); pixdepth = av_get_bits_per_pixel(desc);

@ -42,7 +42,7 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet) const AVFrame *pic, int *got_packet)
{ {
uint8_t *dst; uint8_t *dst;
uint8_t *y, *u, *v; const uint8_t *y, *u, *v;
int i, j, ret; int i, j, ret;
ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 1.5, 0); ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 1.5, 0);

@ -28,7 +28,7 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet) const AVFrame *pic, int *got_packet)
{ {
uint8_t *dst; uint8_t *dst;
uint8_t *y, *u, *v; const uint8_t *y, *u, *v;
int i, j, ret; int i, j, ret;
ret = ff_get_encode_buffer(avctx, pkt, 6 * (avctx->width + 1 >> 1) ret = ff_get_encode_buffer(avctx, pkt, 6 * (avctx->width + 1 >> 1)

@ -84,8 +84,8 @@ typedef struct ZmbvEncContext {
/** Block comparing function /** Block comparing function
* XXX should be optimized and moved to DSPContext * XXX should be optimized and moved to DSPContext
*/ */
static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride, static inline int block_cmp(ZmbvEncContext *c, const uint8_t *src, int stride,
uint8_t *src2, int stride2, int bw, int bh, const uint8_t *src2, int stride2, int bw, int bh,
int *xored) int *xored)
{ {
int sum = 0; int sum = 0;
@ -119,7 +119,7 @@ static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
/** Motion estimation function /** Motion estimation function
* TODO make better ME decisions * TODO make better ME decisions
*/ */
static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev, static int zmbv_me(ZmbvEncContext *c, const uint8_t *src, int sstride, const uint8_t *prev,
int pstride, int x, int y, int *mx, int *my, int *xored) int pstride, int x, int y, int *mx, int *my, int *xored)
{ {
int dx, dy, txored, tv, bv, bw, bh; int dx, dy, txored, tv, bv, bw, bh;
@ -171,7 +171,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ZmbvEncContext * const c = avctx->priv_data; ZmbvEncContext * const c = avctx->priv_data;
z_stream *const zstream = &c->zstream.zstream; z_stream *const zstream = &c->zstream.zstream;
const AVFrame * const p = pict; const AVFrame * const p = pict;
uint8_t *src, *prev, *buf; const uint8_t *src;
uint8_t *prev, *buf;
uint32_t *palptr; uint32_t *palptr;
int keyframe, chpal; int keyframe, chpal;
int fl; int fl;
@ -218,7 +219,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
} }
}else{ }else{
int x, y, bh2, bw2, xored; int x, y, bh2, bw2, xored;
uint8_t *tsrc, *tprev; const uint8_t *tsrc, *tprev;
uint8_t *mv; uint8_t *mv;
int mx = 0, my = 0; int mx = 0, my = 0;

Loading…
Cancel
Save