Mercurial > libavcore.hg
comparison imgutils.h @ 16:1a1faa090ff1 libavcore
Implement inline function av_fill_image_max_pixstep() and use it for
factorizing code.
author | stefano |
---|---|
date | Wed, 18 Aug 2010 21:02:38 +0000 |
parents | 665cb0c97133 |
children | 046c1e516605 |
comparison
equal
deleted
inserted
replaced
15:665cb0c97133 | 16:1a1faa090ff1 |
---|---|
22 /** | 22 /** |
23 * @file | 23 * @file |
24 * misc image utilities | 24 * misc image utilities |
25 */ | 25 */ |
26 | 26 |
27 #include "libavutil/pixfmt.h" | 27 #include "libavutil/pixdesc.h" |
28 #include "avcore.h" | 28 #include "avcore.h" |
29 | |
30 /** | |
31 * Compute the max pixel step for each plane of an image with a | |
32 * format described by pixdesc | |
33 * | |
34 * The pixel step is the distance in bytes between the first byte of | |
35 * the group of bytes which describe a pixel component and the first | |
36 * byte of the successive group in the same plane for the same | |
37 * component. | |
38 * | |
39 * @param max_pixstep an array which is filled with the max pixel step | |
40 * for each plane. Since a plane may contain different pixel | |
41 * components, the computed max_pixstep[plane] is relative to the | |
42 * component in the plane with the max pixel step. | |
43 * @param max_pixstep_comp an array which is filled with the component | |
44 * for each plane which has the max pixel step. May be NULL. | |
45 */ | |
46 static inline void av_fill_image_max_pixstep(int max_pixstep[4], int max_pixstep_comp[4], | |
47 const AVPixFmtDescriptor *pixdesc) | |
48 { | |
49 int i; | |
50 memset(max_pixstep, 0, 4*sizeof(max_pixstep[0])); | |
51 if (max_pixstep_comp) | |
52 memset(max_pixstep_comp, 0, 4*sizeof(max_pixstep_comp[0])); | |
53 | |
54 for (i = 0; i < 4; i++) { | |
55 const AVComponentDescriptor *comp = &(pixdesc->comp[i]); | |
56 if ((comp->step_minus1+1) > max_pixstep[comp->plane]) { | |
57 max_pixstep[comp->plane] = comp->step_minus1+1; | |
58 if (max_pixstep_comp) | |
59 max_pixstep_comp[comp->plane] = i; | |
60 } | |
61 } | |
62 } | |
29 | 63 |
30 /** | 64 /** |
31 * Compute the size of an image line with format pix_fmt and width | 65 * Compute the size of an image line with format pix_fmt and width |
32 * width for the plane plane. | 66 * width for the plane plane. |
33 * | 67 * |