Commit dfd6eee5 authored by vitor's avatar vitor

Factor bytewidth determination in its own function

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@11907 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 3e99701c
...@@ -805,10 +805,9 @@ void ff_img_copy_plane(uint8_t *dst, int dst_wrap, ...@@ -805,10 +805,9 @@ void ff_img_copy_plane(uint8_t *dst, int dst_wrap,
} }
} }
void av_picture_copy(AVPicture *dst, const AVPicture *src, int av_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane)
int pix_fmt, int width, int height)
{ {
int bwidth, bits, i; int bits;
const PixFmtInfo *pf = &pix_fmt_info[pix_fmt]; const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
pf = &pix_fmt_info[pix_fmt]; pf = &pix_fmt_info[pix_fmt];
...@@ -830,21 +829,42 @@ void av_picture_copy(AVPicture *dst, const AVPicture *src, ...@@ -830,21 +829,42 @@ void av_picture_copy(AVPicture *dst, const AVPicture *src,
bits = pf->depth * pf->nb_channels; bits = pf->depth * pf->nb_channels;
break; break;
} }
bwidth = (width * bits + 7) >> 3; return (width * bits + 7) >> 3;
ff_img_copy_plane(dst->data[0], dst->linesize[0], break;
src->data[0], src->linesize[0], case FF_PIXEL_PLANAR:
bwidth, height); if (plane == 1 || plane == 2)
width >>= pf->x_chroma_shift;
return (width * pf->depth + 7) >> 3;
break;
case FF_PIXEL_PALETTE:
if (plane == 0)
return width;
break; break;
}
return -1;
}
void av_picture_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int i;
const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
pf = &pix_fmt_info[pix_fmt];
switch(pf->pixel_type) {
case FF_PIXEL_PACKED:
case FF_PIXEL_PLANAR: case FF_PIXEL_PLANAR:
for(i = 0; i < pf->nb_channels; i++) { for(i = 0; i < pf->nb_channels; i++) {
int w, h; int w, h;
int bwidth = av_get_plane_bytewidth(pix_fmt, width, i);
w = width; w = width;
h = height; h = height;
if (i == 1 || i == 2) { if (i == 1 || i == 2) {
w >>= pf->x_chroma_shift; w >>= pf->x_chroma_shift;
h >>= pf->y_chroma_shift; h >>= pf->y_chroma_shift;
} }
bwidth = (w * pf->depth + 7) >> 3;
ff_img_copy_plane(dst->data[i], dst->linesize[i], ff_img_copy_plane(dst->data[i], dst->linesize[i],
src->data[i], src->linesize[i], src->data[i], src->linesize[i],
bwidth, h); bwidth, h);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment