Mercurial > libavcodec.hg
comparison imgconvert.c @ 3245:c2c29be6282e libavcodec
remove mpegvideo.c img resample dependancy
author | michael |
---|---|
date | Fri, 31 Mar 2006 20:43:37 +0000 |
parents | 870bbd067df8 |
children | 63f61b09dcee |
comparison
equal
deleted
inserted
replaced
3244:b9a0ca749833 | 3245:c2c29be6282e |
---|---|
570 if (loss_ptr) | 570 if (loss_ptr) |
571 *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha); | 571 *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha); |
572 return dst_pix_fmt; | 572 return dst_pix_fmt; |
573 } | 573 } |
574 | 574 |
575 static void img_copy_plane(uint8_t *dst, int dst_wrap, | 575 void ff_img_copy_plane(uint8_t *dst, int dst_wrap, |
576 const uint8_t *src, int src_wrap, | 576 const uint8_t *src, int src_wrap, |
577 int width, int height) | 577 int width, int height) |
578 { | 578 { |
579 if((!dst) || (!src)) | 579 if((!dst) || (!src)) |
580 return; | 580 return; |
610 default: | 610 default: |
611 bits = pf->depth * pf->nb_channels; | 611 bits = pf->depth * pf->nb_channels; |
612 break; | 612 break; |
613 } | 613 } |
614 bwidth = (width * bits + 7) >> 3; | 614 bwidth = (width * bits + 7) >> 3; |
615 img_copy_plane(dst->data[0], dst->linesize[0], | 615 ff_img_copy_plane(dst->data[0], dst->linesize[0], |
616 src->data[0], src->linesize[0], | 616 src->data[0], src->linesize[0], |
617 bwidth, height); | 617 bwidth, height); |
618 break; | 618 break; |
619 case FF_PIXEL_PLANAR: | 619 case FF_PIXEL_PLANAR: |
620 for(i = 0; i < pf->nb_channels; i++) { | 620 for(i = 0; i < pf->nb_channels; i++) { |
624 if (i == 1 || i == 2) { | 624 if (i == 1 || i == 2) { |
625 w >>= pf->x_chroma_shift; | 625 w >>= pf->x_chroma_shift; |
626 h >>= pf->y_chroma_shift; | 626 h >>= pf->y_chroma_shift; |
627 } | 627 } |
628 bwidth = (w * pf->depth + 7) >> 3; | 628 bwidth = (w * pf->depth + 7) >> 3; |
629 img_copy_plane(dst->data[i], dst->linesize[i], | 629 ff_img_copy_plane(dst->data[i], dst->linesize[i], |
630 src->data[i], src->linesize[i], | 630 src->data[i], src->linesize[i], |
631 bwidth, h); | 631 bwidth, h); |
632 } | 632 } |
633 break; | 633 break; |
634 case FF_PIXEL_PALETTE: | 634 case FF_PIXEL_PALETTE: |
635 img_copy_plane(dst->data[0], dst->linesize[0], | 635 ff_img_copy_plane(dst->data[0], dst->linesize[0], |
636 src->data[0], src->linesize[0], | 636 src->data[0], src->linesize[0], |
637 width, height); | 637 width, height); |
638 /* copy the palette */ | 638 /* copy the palette */ |
639 img_copy_plane(dst->data[1], dst->linesize[1], | 639 ff_img_copy_plane(dst->data[1], dst->linesize[1], |
640 src->data[1], src->linesize[1], | 640 src->data[1], src->linesize[1], |
641 4, 256); | 641 4, 256); |
642 break; | 642 break; |
643 } | 643 } |
644 } | 644 } |
1208 dst += dst_wrap; | 1208 dst += dst_wrap; |
1209 } | 1209 } |
1210 } | 1210 } |
1211 | 1211 |
1212 /* 2x2 -> 1x1 */ | 1212 /* 2x2 -> 1x1 */ |
1213 static void shrink22(uint8_t *dst, int dst_wrap, | 1213 void ff_shrink22(uint8_t *dst, int dst_wrap, |
1214 const uint8_t *src, int src_wrap, | 1214 const uint8_t *src, int src_wrap, |
1215 int width, int height) | 1215 int width, int height) |
1216 { | 1216 { |
1217 int w; | 1217 int w; |
1218 const uint8_t *s1, *s2; | 1218 const uint8_t *s1, *s2; |
1241 dst += dst_wrap; | 1241 dst += dst_wrap; |
1242 } | 1242 } |
1243 } | 1243 } |
1244 | 1244 |
1245 /* 4x4 -> 1x1 */ | 1245 /* 4x4 -> 1x1 */ |
1246 static void shrink44(uint8_t *dst, int dst_wrap, | 1246 void ff_shrink44(uint8_t *dst, int dst_wrap, |
1247 const uint8_t *src, int src_wrap, | 1247 const uint8_t *src, int src_wrap, |
1248 int width, int height) | 1248 int width, int height) |
1249 { | 1249 { |
1250 int w; | 1250 int w; |
1251 const uint8_t *s1, *s2, *s3, *s4; | 1251 const uint8_t *s1, *s2, *s3, *s4; |
1271 src += 4 * src_wrap; | 1271 src += 4 * src_wrap; |
1272 dst += dst_wrap; | 1272 dst += dst_wrap; |
1273 } | 1273 } |
1274 } | 1274 } |
1275 | 1275 |
1276 /* 8x8 -> 1x1 */ | |
1277 void ff_shrink88(uint8_t *dst, int dst_wrap, | |
1278 const uint8_t *src, int src_wrap, | |
1279 int width, int height) | |
1280 { | |
1281 int w, i; | |
1282 | |
1283 for(;height > 0; height--) { | |
1284 for(w = width;w > 0; w--) { | |
1285 int tmp=0; | |
1286 for(i=0; i<8; i++){ | |
1287 tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7]; | |
1288 src += src_wrap; | |
1289 } | |
1290 *(dst++) = (tmp + 32)>>6; | |
1291 src += 8 - 8*src_wrap; | |
1292 } | |
1293 src += 8*src_wrap - 8*width; | |
1294 dst += dst_wrap - width; | |
1295 } | |
1296 } | |
1297 | |
1276 static void grow21_line(uint8_t *dst, const uint8_t *src, | 1298 static void grow21_line(uint8_t *dst, const uint8_t *src, |
1277 int width) | 1299 int width) |
1278 { | 1300 { |
1279 int w; | 1301 int w; |
1280 const uint8_t *s1; | 1302 const uint8_t *s1; |
2021 src_pix_fmt == PIX_FMT_GRAY8) { | 2043 src_pix_fmt == PIX_FMT_GRAY8) { |
2022 int w, h, y; | 2044 int w, h, y; |
2023 uint8_t *d; | 2045 uint8_t *d; |
2024 | 2046 |
2025 if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { | 2047 if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { |
2026 img_copy_plane(dst->data[0], dst->linesize[0], | 2048 ff_img_copy_plane(dst->data[0], dst->linesize[0], |
2027 src->data[0], src->linesize[0], | 2049 src->data[0], src->linesize[0], |
2028 dst_width, dst_height); | 2050 dst_width, dst_height); |
2029 } else { | 2051 } else { |
2030 img_apply_table(dst->data[0], dst->linesize[0], | 2052 img_apply_table(dst->data[0], dst->linesize[0], |
2031 src->data[0], src->linesize[0], | 2053 src->data[0], src->linesize[0], |
2049 | 2071 |
2050 /* YUV to gray */ | 2072 /* YUV to gray */ |
2051 if (is_yuv_planar(src_pix) && | 2073 if (is_yuv_planar(src_pix) && |
2052 dst_pix_fmt == PIX_FMT_GRAY8) { | 2074 dst_pix_fmt == PIX_FMT_GRAY8) { |
2053 if (src_pix->color_type == FF_COLOR_YUV_JPEG) { | 2075 if (src_pix->color_type == FF_COLOR_YUV_JPEG) { |
2054 img_copy_plane(dst->data[0], dst->linesize[0], | 2076 ff_img_copy_plane(dst->data[0], dst->linesize[0], |
2055 src->data[0], src->linesize[0], | 2077 src->data[0], src->linesize[0], |
2056 dst_width, dst_height); | 2078 dst_width, dst_height); |
2057 } else { | 2079 } else { |
2058 img_apply_table(dst->data[0], dst->linesize[0], | 2080 img_apply_table(dst->data[0], dst->linesize[0], |
2059 src->data[0], src->linesize[0], | 2081 src->data[0], src->linesize[0], |
2087 xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf); | 2109 xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf); |
2088 /* there must be filters for conversion at least from and to | 2110 /* there must be filters for conversion at least from and to |
2089 YUV444 format */ | 2111 YUV444 format */ |
2090 switch(xy_shift) { | 2112 switch(xy_shift) { |
2091 case 0x00: | 2113 case 0x00: |
2092 resize_func = img_copy_plane; | 2114 resize_func = ff_img_copy_plane; |
2093 break; | 2115 break; |
2094 case 0x10: | 2116 case 0x10: |
2095 resize_func = shrink21; | 2117 resize_func = shrink21; |
2096 break; | 2118 break; |
2097 case 0x20: | 2119 case 0x20: |
2099 break; | 2121 break; |
2100 case 0x01: | 2122 case 0x01: |
2101 resize_func = shrink12; | 2123 resize_func = shrink12; |
2102 break; | 2124 break; |
2103 case 0x11: | 2125 case 0x11: |
2104 resize_func = shrink22; | 2126 resize_func = ff_shrink22; |
2105 break; | 2127 break; |
2106 case 0x22: | 2128 case 0x22: |
2107 resize_func = shrink44; | 2129 resize_func = ff_shrink44; |
2108 break; | 2130 break; |
2109 case 0xf0: | 2131 case 0xf0: |
2110 resize_func = grow21; | 2132 resize_func = grow21; |
2111 break; | 2133 break; |
2112 case 0xe0: | 2134 case 0xe0: |
2124 default: | 2146 default: |
2125 /* currently not handled */ | 2147 /* currently not handled */ |
2126 goto no_chroma_filter; | 2148 goto no_chroma_filter; |
2127 } | 2149 } |
2128 | 2150 |
2129 img_copy_plane(dst->data[0], dst->linesize[0], | 2151 ff_img_copy_plane(dst->data[0], dst->linesize[0], |
2130 src->data[0], src->linesize[0], | 2152 src->data[0], src->linesize[0], |
2131 dst_width, dst_height); | 2153 dst_width, dst_height); |
2132 | 2154 |
2133 for(i = 1;i <= 2; i++) | 2155 for(i = 1;i <= 2; i++) |
2134 resize_func(dst->data[i], dst->linesize[i], | 2156 resize_func(dst->data[i], dst->linesize[i], |