Mercurial > libavcodec.hg
comparison imgconvert.c @ 12468:443f38ceeaad libavcodec
Reimplement av_picture_data_copy() avoiding the use of PixFmtInfo
information.
Required for moving the function to libavcore.
author | stefano |
---|---|
date | Tue, 07 Sep 2010 21:23:52 +0000 |
parents | 94275c8cd57d |
children | 9471234fb8ea |
comparison
equal
deleted
inserted
replaced
12467:94275c8cd57d | 12468:443f38ceeaad |
---|---|
797 | 797 |
798 void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4], | 798 void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4], |
799 uint8_t *src_data[4], int src_linesize[4], | 799 uint8_t *src_data[4], int src_linesize[4], |
800 enum PixelFormat pix_fmt, int width, int height) | 800 enum PixelFormat pix_fmt, int width, int height) |
801 { | 801 { |
802 int i; | |
803 const PixFmtInfo *pf = &pix_fmt_info[pix_fmt]; | |
804 const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; | 802 const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; |
805 | 803 |
806 switch(pf->pixel_type) { | 804 if (desc->flags & PIX_FMT_HWACCEL) |
807 case FF_PIXEL_PACKED: | 805 return; |
808 case FF_PIXEL_PLANAR: | 806 |
809 for(i = 0; i < pf->nb_channels; i++) { | 807 if (desc->flags & PIX_FMT_PAL) { |
810 int h; | 808 av_image_copy_plane(dst_data[0], dst_linesize[0], |
809 src_data[0], src_linesize[0], | |
810 width, height); | |
811 /* copy the palette */ | |
812 memcpy(dst_data[1], src_data[1], 4*256); | |
813 } else { | |
814 int i, planes_nb = 0; | |
815 | |
816 for (i = 0; i < desc->nb_components; i++) | |
817 planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1); | |
818 | |
819 for (i = 0; i < planes_nb; i++) { | |
820 int h = height; | |
811 int bwidth = av_image_get_linesize(pix_fmt, width, i); | 821 int bwidth = av_image_get_linesize(pix_fmt, width, i); |
812 h = height; | |
813 if (i == 1 || i == 2) { | 822 if (i == 1 || i == 2) { |
814 h= -((-height)>>desc->log2_chroma_h); | 823 h= -((-height)>>desc->log2_chroma_h); |
815 } | 824 } |
816 av_image_copy_plane(dst_data[i], dst_linesize[i], | 825 av_image_copy_plane(dst_data[i], dst_linesize[i], |
817 src_data[i], src_linesize[i], | 826 src_data[i], src_linesize[i], |
818 bwidth, h); | 827 bwidth, h); |
819 } | 828 } |
820 break; | |
821 case FF_PIXEL_PALETTE: | |
822 av_image_copy_plane(dst_data[0], dst_linesize[0], | |
823 src_data[0], src_linesize[0], | |
824 width, height); | |
825 /* copy the palette */ | |
826 memcpy(dst_data[1], src_data[1], 4*256); | |
827 break; | |
828 } | 829 } |
829 } | 830 } |
830 | 831 |
831 void av_picture_copy(AVPicture *dst, const AVPicture *src, | 832 void av_picture_copy(AVPicture *dst, const AVPicture *src, |
832 enum PixelFormat pix_fmt, int width, int height) | 833 enum PixelFormat pix_fmt, int width, int height) |