1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)

Originally committed as revision 2318 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Drew Hess 2003-09-29 15:44:59 +00:00 committed by Michael Niedermayer
parent 6c8e0d4d46
commit da64ecc3e7
4 changed files with 85 additions and 70 deletions

View File

@ -520,7 +520,7 @@ typedef struct AVCodecContext {
* @param offset offset into the AVFrame.data from which the slice should be read
*/
void (*draw_horiz_band)(struct AVCodecContext *s,
AVFrame *src, int offset[4],
const AVFrame *src, int offset[4],
int y, int type, int height);
/* audio only */
@ -1483,13 +1483,13 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int leftBand, int rightBand);
void img_resample(ImgReSampleContext *s,
AVPicture *output, AVPicture *input);
AVPicture *output, const AVPicture *input);
void img_resample_close(ImgReSampleContext *s);
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height);
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
unsigned char *dest, int dest_size);
int avpicture_get_size(int pix_fmt, int width, int height);
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
@ -1510,15 +1510,16 @@ int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
int img_get_alpha_info(const AVPicture *src,
int pix_fmt, int width, int height);
/* convert among pixel formats */
int img_convert(AVPicture *dst, int dst_pix_fmt,
AVPicture *src, int pix_fmt,
const AVPicture *src, int pix_fmt,
int width, int height);
/* deinterlace a picture */
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height);
/* external high level API */

View File

@ -236,7 +236,7 @@ enum PixelFormat avcodec_get_pix_fmt(const char* name)
/* Picture field are filled with 'ptr' addresses. Also return size */
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height)
int pix_fmt, int width, int height)
{
int size, w2, h2, size2;
PixFmtInfo *pinfo;
@ -313,12 +313,12 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
}
}
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
unsigned char *dest, int dest_size)
{
PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
int i, j, w, h, data_planes;
unsigned char* s;
const unsigned char* s;
int size = avpicture_get_size(pix_fmt, width, height);
if (size > dest_size)
@ -535,7 +535,7 @@ static void img_copy_plane(uint8_t *dst, int dst_wrap,
/**
* Copy image 'src' to 'dst'.
*/
void img_copy(AVPicture *dst, AVPicture *src,
void img_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int bwidth, bits, i;
@ -588,7 +588,7 @@ void img_copy(AVPicture *dst, AVPicture *src,
/* XXX: totally non optimized */
static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@ -644,7 +644,7 @@ static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
}
}
static void yuv422_to_yuv422p(AVPicture *dst, AVPicture *src,
static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@ -677,7 +677,7 @@ static void yuv422_to_yuv422p(AVPicture *dst, AVPicture *src,
}
}
static void yuv422p_to_yuv422(AVPicture *dst, AVPicture *src,
static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *p, *p1;
@ -1286,7 +1286,7 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
#include "imgconvert_template.h"
static void mono_to_gray(AVPicture *dst, AVPicture *src,
static void mono_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height, int xor_mask)
{
const unsigned char *p;
@ -1327,19 +1327,19 @@ static void mono_to_gray(AVPicture *dst, AVPicture *src,
}
}
static void monowhite_to_gray(AVPicture *dst, AVPicture *src,
static void monowhite_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height)
{
mono_to_gray(dst, src, width, height, 0xff);
}
static void monoblack_to_gray(AVPicture *dst, AVPicture *src,
static void monoblack_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height)
{
mono_to_gray(dst, src, width, height, 0x00);
}
static void gray_to_mono(AVPicture *dst, AVPicture *src,
static void gray_to_mono(AVPicture *dst, const AVPicture *src,
int width, int height, int xor_mask)
{
int n;
@ -1383,20 +1383,21 @@ static void gray_to_mono(AVPicture *dst, AVPicture *src,
}
}
static void gray_to_monowhite(AVPicture *dst, AVPicture *src,
static void gray_to_monowhite(AVPicture *dst, const AVPicture *src,
int width, int height)
{
gray_to_mono(dst, src, width, height, 0xff);
}
static void gray_to_monoblack(AVPicture *dst, AVPicture *src,
static void gray_to_monoblack(AVPicture *dst, const AVPicture *src,
int width, int height)
{
gray_to_mono(dst, src, width, height, 0x00);
}
typedef struct ConvertEntry {
void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
void (*convert)(AVPicture *dst,
const AVPicture *src, int width, int height);
} ConvertEntry;
/* Add each new convertion function in this table. In order to be able
@ -1644,7 +1645,7 @@ static inline int is_yuv_planar(PixFmtInfo *ps)
/* XXX: always use linesize. Return -1 if not supported */
int img_convert(AVPicture *dst, int dst_pix_fmt,
AVPicture *src, int src_pix_fmt,
const AVPicture *src, int src_pix_fmt,
int src_width, int src_height)
{
static int inited;
@ -1877,7 +1878,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
}
/* NOTE: we scan all the pixels to have an exact information */
static int get_alpha_info_pal8(AVPicture *src, int width, int height)
static int get_alpha_info_pal8(const AVPicture *src, int width, int height)
{
const unsigned char *p;
int src_wrap, ret, x, y;
@ -1906,7 +1907,8 @@ static int get_alpha_info_pal8(AVPicture *src, int width, int height)
* Tell if an image really has transparent alpha values.
* @return ored mask of FF_ALPHA_xxx constants
*/
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
int img_get_alpha_info(const AVPicture *src,
int pix_fmt, int width, int height)
{
PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
int ret;
@ -1981,8 +1983,11 @@ int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
#endif
/* filter parameters: [-1 4 2 4 -1] // 8 */
static void deinterlace_line(uint8_t *dst, uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
int size)
static void deinterlace_line(uint8_t *dst,
const uint8_t *lum_m4, const uint8_t *lum_m3,
const uint8_t *lum_m2, const uint8_t *lum_m1,
const uint8_t *lum,
int size)
{
#ifndef HAVE_MMX
uint8_t *cm = cropTbl + MAX_NEG_CROP;
@ -2071,10 +2076,10 @@ static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *
top field is copied as is, but the bottom field is deinterlaced
against the top field. */
static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
uint8_t *src1, int src_wrap,
const uint8_t *src1, int src_wrap,
int width, int height)
{
uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
int y;
src_m2 = src1;
@ -2100,7 +2105,7 @@ static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
}
static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
int width, int height)
int width, int height)
{
uint8_t *src_m1, *src_0, *src_p1, *src_p2;
int y;
@ -2126,7 +2131,7 @@ static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
/* deinterlace - if not supported return -1 */
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int i;
@ -2157,7 +2162,7 @@ int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
}
}
if (src == dst) {
deinterlace_bottom_field_inplace(src->data[i], src->linesize[i],
deinterlace_bottom_field_inplace(dst->data[i], dst->linesize[i],
width, height);
} else {
deinterlace_bottom_field(dst->data[i],dst->linesize[i],

View File

@ -21,10 +21,11 @@
#define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff)
#endif
static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
uint8_t *d, *d1, *d2;
int w, y, cb, cr, r_add, g_add, b_add, width2;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
@ -114,10 +115,11 @@ static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
uint8_t *d, *d1, *d2;
int w, y, cb, cr, r_add, g_add, b_add, width2;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
@ -207,7 +209,7 @@ static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, AVPicture *src,
static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int wrap, wrap3, width2;
@ -314,7 +316,7 @@ static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, AVPicture *src,
}
}
static void glue(RGB_NAME, _to_gray)(AVPicture *dst, AVPicture *src,
static void glue(RGB_NAME, _to_gray)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@ -340,7 +342,7 @@ static void glue(RGB_NAME, _to_gray)(AVPicture *dst, AVPicture *src,
}
}
static void glue(gray_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@ -366,7 +368,7 @@ static void glue(gray_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@ -409,7 +411,7 @@ static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
#if !defined(FMT_RGBA32) && defined(RGBA_OUT)
/* alpha support */
static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@ -439,7 +441,7 @@ static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, AVPicture *src,
static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@ -469,7 +471,7 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, AVPicture *src,
#ifndef FMT_RGB24
static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@ -497,7 +499,7 @@ static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
}
}
static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, AVPicture *src,
static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@ -529,10 +531,11 @@ static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, AVPicture *src,
#ifdef FMT_RGB24
static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
uint8_t *d, *d1;
int w, y, cb, cr, r_add, g_add, b_add;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
@ -561,10 +564,11 @@ static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
}
}
static void yuvj444p_to_rgb24(AVPicture *dst, AVPicture *src,
static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
uint8_t *d, *d1;
int w, y, cb, cr, r_add, g_add, b_add;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
@ -593,7 +597,7 @@ static void yuvj444p_to_rgb24(AVPicture *dst, AVPicture *src,
}
}
static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,
static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int src_wrap, x, y;
@ -625,7 +629,7 @@ static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,
}
}
static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int wrap, wrap3, width2;
@ -732,7 +736,7 @@ static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
}
}
static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,
static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int src_wrap, x, y;
@ -768,7 +772,7 @@ static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,
#if defined(FMT_RGB24) || defined(FMT_RGBA32)
static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const unsigned char *p;
@ -816,7 +820,8 @@ static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
#ifdef RGBA_IN
static int glue(get_alpha_info_, RGB_NAME)(AVPicture *src, int width, int height)
static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
int width, int height)
{
const unsigned char *p;
int src_wrap, ret, x, y;

View File

@ -58,11 +58,12 @@ static inline int get_phase(int pos)
}
/* This function must be optimized */
static void h_resample_fast(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
int src_start, int src_incr, int16_t *filters)
static void h_resample_fast(uint8_t *dst, int dst_width, const uint8_t *src,
int src_width, int src_start, int src_incr,
int16_t *filters)
{
int src_pos, phase, sum, i;
uint8_t *s;
const uint8_t *s;
int16_t *filter;
src_pos = src_start;
@ -101,11 +102,11 @@ static void h_resample_fast(uint8_t *dst, int dst_width, uint8_t *src, int src_w
}
/* This function must be optimized */
static void v_resample(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
int16_t *filter)
static void v_resample(uint8_t *dst, int dst_width, const uint8_t *src,
int wrap, int16_t *filter)
{
int sum, i;
uint8_t *s;
const uint8_t *s;
s = src;
for(i=0;i<dst_width;i++) {
@ -160,11 +161,12 @@ static void v_resample(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
#define DUMP(reg) movq_r2m(reg, tmp); printf(#reg "=%016Lx\n", tmp.uq);
/* XXX: do four pixels at a time */
static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
static void h_resample_fast4_mmx(uint8_t *dst, int dst_width,
const uint8_t *src, int src_width,
int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase;
uint8_t *s;
const uint8_t *s;
int16_t *filter;
mmx_t tmp;
@ -204,11 +206,11 @@ static void h_resample_fast4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int
emms();
}
static void v_resample4_mmx(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
int16_t *filter)
static void v_resample4_mmx(uint8_t *dst, int dst_width, const uint8_t *src,
int wrap, int16_t *filter)
{
int sum, i, v;
uint8_t *s;
const uint8_t *s;
mmx_t tmp;
mmx_t coefs[4];
@ -280,11 +282,11 @@ typedef union {
signed short s[8];
} vec_ss_t;
void v_resample16_altivec(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
int16_t *filter)
void v_resample16_altivec(uint8_t *dst, int dst_width, const uint8_t *src,
int wrap, int16_t *filter)
{
int sum, i;
uint8_t *s;
const uint8_t *s;
vector unsigned char *tv, tmp, dstv, zero;
vec_ss_t srchv[4], srclv[4], fv[4];
vector signed short zeros, sumhv, sumlv;
@ -397,11 +399,12 @@ void v_resample16_altivec(uint8_t *dst, int dst_width, uint8_t *src, int wrap,
#endif
/* slow version to handle limit cases. Does not need optimisation */
static void h_resample_slow(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
static void h_resample_slow(uint8_t *dst, int dst_width,
const uint8_t *src, int src_width,
int src_start, int src_incr, int16_t *filters)
{
int src_pos, phase, sum, j, v, i;
uint8_t *s, *src_end;
const uint8_t *s, *src_end;
int16_t *filter;
src_end = src + src_width;
@ -432,8 +435,9 @@ static void h_resample_slow(uint8_t *dst, int dst_width, uint8_t *src, int src_w
}
}
static void h_resample(uint8_t *dst, int dst_width, uint8_t *src, int src_width,
int src_start, int src_incr, int16_t *filters)
static void h_resample(uint8_t *dst, int dst_width, const uint8_t *src,
int src_width, int src_start, int src_incr,
int16_t *filters)
{
int n, src_end;
@ -607,7 +611,7 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
}
void img_resample(ImgReSampleContext *s,
AVPicture *output, AVPicture *input)
AVPicture *output, const AVPicture *input)
{
int i, shift;