Mercurial > libavcodec.hg
comparison imgconvert.c @ 3179:870bbd067df8 libavcodec
Fix cropping, depending on enc pix fmt
author | bcoudurier |
---|---|
date | Fri, 10 Mar 2006 13:55:48 +0000 |
parents | 0b546eab515d |
children | c2c29be6282e |
comparison
equal
deleted
inserted
replaced
3178:bd995b8c64fd | 3179:870bbd067df8 |
---|---|
1949 return (ps->color_type == FF_COLOR_YUV || | 1949 return (ps->color_type == FF_COLOR_YUV || |
1950 ps->color_type == FF_COLOR_YUV_JPEG) && | 1950 ps->color_type == FF_COLOR_YUV_JPEG) && |
1951 ps->pixel_type == FF_PIXEL_PLANAR; | 1951 ps->pixel_type == FF_PIXEL_PLANAR; |
1952 } | 1952 } |
1953 | 1953 |
1954 /** | |
1955 * Crop image top and left side | |
1956 */ | |
1957 int img_crop(AVPicture *dst, const AVPicture *src, | |
1958 int pix_fmt, int top_band, int left_band) | |
1959 { | |
1960 int y_shift; | |
1961 int x_shift; | |
1962 | |
1963 if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt])) | |
1964 return -1; | |
1965 | |
1966 y_shift = pix_fmt_info[pix_fmt].y_chroma_shift; | |
1967 x_shift = pix_fmt_info[pix_fmt].x_chroma_shift; | |
1968 | |
1969 dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; | |
1970 dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift); | |
1971 dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift); | |
1972 | |
1973 dst->linesize[0] = src->linesize[0]; | |
1974 dst->linesize[1] = src->linesize[1]; | |
1975 dst->linesize[2] = src->linesize[2]; | |
1976 return 0; | |
1977 } | |
1978 | |
1954 /* XXX: always use linesize. Return -1 if not supported */ | 1979 /* XXX: always use linesize. Return -1 if not supported */ |
1955 int img_convert(AVPicture *dst, int dst_pix_fmt, | 1980 int img_convert(AVPicture *dst, int dst_pix_fmt, |
1956 const AVPicture *src, int src_pix_fmt, | 1981 const AVPicture *src, int src_pix_fmt, |
1957 int src_width, int src_height) | 1982 int src_width, int src_height) |
1958 { | 1983 { |