comparison imgconvert.c @ 3420:54814e15aa3d libavcodec

Mark some read-only datastructures as const. patch by Stefan Huehner, stefan & at & huehner & dot & org
author diego
date Thu, 06 Jul 2006 13:53:07 +0000
parents 3b785e80ce3e
children 33d29a80bcac
comparison
equal deleted inserted replaced
3419:b4363f96013d 3420:54814e15aa3d
61 uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */ 61 uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */
62 uint8_t depth; /* bit depth of the color components */ 62 uint8_t depth; /* bit depth of the color components */
63 } PixFmtInfo; 63 } PixFmtInfo;
64 64
65 /* this table gives more information about formats */ 65 /* this table gives more information about formats */
66 static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { 66 static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
67 /* YUV formats */ 67 /* YUV formats */
68 [PIX_FMT_YUV420P] = { 68 [PIX_FMT_YUV420P] = {
69 .name = "yuv420p", 69 .name = "yuv420p",
70 .nb_channels = 3, 70 .nb_channels = 3,
71 .color_type = FF_COLOR_YUV, 71 .color_type = FF_COLOR_YUV,
264 /* Picture field are filled with 'ptr' addresses. Also return size */ 264 /* Picture field are filled with 'ptr' addresses. Also return size */
265 int avpicture_fill(AVPicture *picture, uint8_t *ptr, 265 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
266 int pix_fmt, int width, int height) 266 int pix_fmt, int width, int height)
267 { 267 {
268 int size, w2, h2, size2; 268 int size, w2, h2, size2;
269 PixFmtInfo *pinfo; 269 const PixFmtInfo *pinfo;
270 270
271 if(avcodec_check_dimensions(NULL, width, height)) 271 if(avcodec_check_dimensions(NULL, width, height))
272 goto fail; 272 goto fail;
273 273
274 pinfo = &pix_fmt_info[pix_fmt]; 274 pinfo = &pix_fmt_info[pix_fmt];
357 } 357 }
358 358
359 int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height, 359 int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
360 unsigned char *dest, int dest_size) 360 unsigned char *dest, int dest_size)
361 { 361 {
362 PixFmtInfo* pf = &pix_fmt_info[pix_fmt]; 362 const PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
363 int i, j, w, h, data_planes; 363 int i, j, w, h, data_planes;
364 const unsigned char* s; 364 const unsigned char* s;
365 int size = avpicture_get_size(pix_fmt, width, height); 365 int size = avpicture_get_size(pix_fmt, width, height);
366 366
367 if (size > dest_size || size < 0) 367 if (size > dest_size || size < 0)
590 */ 590 */
591 void img_copy(AVPicture *dst, const AVPicture *src, 591 void img_copy(AVPicture *dst, const AVPicture *src,
592 int pix_fmt, int width, int height) 592 int pix_fmt, int width, int height)
593 { 593 {
594 int bwidth, bits, i; 594 int bwidth, bits, i;
595 PixFmtInfo *pf = &pix_fmt_info[pix_fmt]; 595 const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
596 596
597 pf = &pix_fmt_info[pix_fmt]; 597 pf = &pix_fmt_info[pix_fmt];
598 switch(pf->pixel_type) { 598 switch(pf->pixel_type) {
599 case FF_PIXEL_PACKED: 599 case FF_PIXEL_PACKED:
600 switch(pix_fmt) { 600 switch(pix_fmt) {
1721 1721
1722 - PIX_FMT_422 must convert to and from PIX_FMT_422P. 1722 - PIX_FMT_422 must convert to and from PIX_FMT_422P.
1723 1723
1724 The other conversion functions are just optimisations for common cases. 1724 The other conversion functions are just optimisations for common cases.
1725 */ 1725 */
1726 static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = { 1726 static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
1727 [PIX_FMT_YUV420P] = { 1727 [PIX_FMT_YUV420P] = {
1728 [PIX_FMT_YUV422] = { 1728 [PIX_FMT_YUV422] = {
1729 .convert = yuv420p_to_yuv422, 1729 .convert = yuv420p_to_yuv422,
1730 }, 1730 },
1731 [PIX_FMT_RGB555] = { 1731 [PIX_FMT_RGB555] = {
1964 { 1964 {
1965 av_free(picture->data[0]); 1965 av_free(picture->data[0]);
1966 } 1966 }
1967 1967
1968 /* return true if yuv planar */ 1968 /* return true if yuv planar */
1969 static inline int is_yuv_planar(PixFmtInfo *ps) 1969 static inline int is_yuv_planar(const PixFmtInfo *ps)
1970 { 1970 {
1971 return (ps->color_type == FF_COLOR_YUV || 1971 return (ps->color_type == FF_COLOR_YUV ||
1972 ps->color_type == FF_COLOR_YUV_JPEG) && 1972 ps->color_type == FF_COLOR_YUV_JPEG) &&
1973 ps->pixel_type == FF_PIXEL_PLANAR; 1973 ps->pixel_type == FF_PIXEL_PLANAR;
1974 } 1974 }
2053 const AVPicture *src, int src_pix_fmt, 2053 const AVPicture *src, int src_pix_fmt,
2054 int src_width, int src_height) 2054 int src_width, int src_height)
2055 { 2055 {
2056 static int inited; 2056 static int inited;
2057 int i, ret, dst_width, dst_height, int_pix_fmt; 2057 int i, ret, dst_width, dst_height, int_pix_fmt;
2058 PixFmtInfo *src_pix, *dst_pix; 2058 const PixFmtInfo *src_pix, *dst_pix;
2059 ConvertEntry *ce; 2059 const ConvertEntry *ce;
2060 AVPicture tmp1, *tmp = &tmp1; 2060 AVPicture tmp1, *tmp = &tmp1;
2061 2061
2062 if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB || 2062 if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB ||
2063 dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB) 2063 dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB)
2064 return -1; 2064 return -1;
2321 * @return ored mask of FF_ALPHA_xxx constants 2321 * @return ored mask of FF_ALPHA_xxx constants
2322 */ 2322 */
2323 int img_get_alpha_info(const AVPicture *src, 2323 int img_get_alpha_info(const AVPicture *src,
2324 int pix_fmt, int width, int height) 2324 int pix_fmt, int width, int height)
2325 { 2325 {
2326 PixFmtInfo *pf = &pix_fmt_info[pix_fmt]; 2326 const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
2327 int ret; 2327 int ret;
2328 2328
2329 pf = &pix_fmt_info[pix_fmt]; 2329 pf = &pix_fmt_info[pix_fmt];
2330 /* no alpha can be represented in format */ 2330 /* no alpha can be represented in format */
2331 if (!pf->is_alpha) 2331 if (!pf->is_alpha)