Originally committed as revision 24827 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -27,7 +27,7 @@ |
| 27 | 27 |
#include <libavutil/avutil.h> |
| 28 | 28 |
|
| 29 | 29 |
#define LIBAVCORE_VERSION_MAJOR 0 |
| 30 |
-#define LIBAVCORE_VERSION_MINOR 4 |
|
| 30 |
+#define LIBAVCORE_VERSION_MINOR 5 |
|
| 31 | 31 |
#define LIBAVCORE_VERSION_MICRO 0 |
| 32 | 32 |
|
| 33 | 33 |
#define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \ |
| ... | ... |
@@ -29,21 +29,12 @@ int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane) |
| 29 | 29 |
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; |
| 30 | 30 |
int max_step [4]; /* max pixel step for each plane */ |
| 31 | 31 |
int max_step_comp[4]; /* the component for each plane which has the max pixel step */ |
| 32 |
- int s, i; |
|
| 32 |
+ int s; |
|
| 33 | 33 |
|
| 34 | 34 |
if (desc->flags & PIX_FMT_BITSTREAM) |
| 35 | 35 |
return (width * (desc->comp[0].step_minus1+1) + 7) >> 3; |
| 36 | 36 |
|
| 37 |
- memset(max_step , 0, sizeof(max_step )); |
|
| 38 |
- memset(max_step_comp, 0, sizeof(max_step_comp)); |
|
| 39 |
- for (i = 0; i < 4; i++) {
|
|
| 40 |
- const AVComponentDescriptor *comp = &(desc->comp[i]); |
|
| 41 |
- if ((comp->step_minus1+1) > max_step[comp->plane]) {
|
|
| 42 |
- max_step [comp->plane] = comp->step_minus1+1; |
|
| 43 |
- max_step_comp[comp->plane] = i; |
|
| 44 |
- } |
|
| 45 |
- } |
|
| 46 |
- |
|
| 37 |
+ av_fill_image_max_pixstep(max_step, max_step_comp, desc); |
|
| 47 | 38 |
s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->log2_chroma_w : 0; |
| 48 | 39 |
return max_step[plane] * (((width + (1 << s) - 1)) >> s); |
| 49 | 40 |
} |
| ... | ... |
@@ -65,16 +56,7 @@ int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int widt |
| 65 | 65 |
return 0; |
| 66 | 66 |
} |
| 67 | 67 |
|
| 68 |
- memset(max_step , 0, sizeof(max_step )); |
|
| 69 |
- memset(max_step_comp, 0, sizeof(max_step_comp)); |
|
| 70 |
- for (i = 0; i < 4; i++) {
|
|
| 71 |
- const AVComponentDescriptor *comp = &(desc->comp[i]); |
|
| 72 |
- if ((comp->step_minus1+1) > max_step[comp->plane]) {
|
|
| 73 |
- max_step [comp->plane] = comp->step_minus1+1; |
|
| 74 |
- max_step_comp[comp->plane] = i; |
|
| 75 |
- } |
|
| 76 |
- } |
|
| 77 |
- |
|
| 68 |
+ av_fill_image_max_pixstep(max_step, max_step_comp, desc); |
|
| 78 | 69 |
for (i = 0; i < 4; i++) {
|
| 79 | 70 |
int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0; |
| 80 | 71 |
linesizes[i] = max_step[i] * (((width + (1 << s) - 1)) >> s); |
| ... | ... |
@@ -24,10 +24,44 @@ |
| 24 | 24 |
* misc image utilities |
| 25 | 25 |
*/ |
| 26 | 26 |
|
| 27 |
-#include "libavutil/pixfmt.h" |
|
| 27 |
+#include "libavutil/pixdesc.h" |
|
| 28 | 28 |
#include "avcore.h" |
| 29 | 29 |
|
| 30 | 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 |
+} |
|
| 63 |
+ |
|
| 64 |
+/** |
|
| 31 | 65 |
* Compute the size of an image line with format pix_fmt and width |
| 32 | 66 |
* width for the plane plane. |
| 33 | 67 |
* |
| ... | ... |
@@ -24,7 +24,7 @@ |
| 24 | 24 |
*/ |
| 25 | 25 |
|
| 26 | 26 |
#include "avfilter.h" |
| 27 |
-#include "libavutil/pixdesc.h" |
|
| 27 |
+#include "libavcore/imgutils.h" |
|
| 28 | 28 |
|
| 29 | 29 |
typedef struct {
|
| 30 | 30 |
int x; ///< x offset of the non-cropped area with respect to the input area |
| ... | ... |
@@ -83,15 +83,8 @@ static int config_input(AVFilterLink *link) |
| 83 | 83 |
AVFilterContext *ctx = link->dst; |
| 84 | 84 |
CropContext *crop = ctx->priv; |
| 85 | 85 |
const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[link->format]; |
| 86 |
- int i; |
|
| 87 |
- |
|
| 88 |
- memset(crop->max_step, 0, sizeof(crop->max_step)); |
|
| 89 |
- for (i = 0; i < 4; i++) {
|
|
| 90 |
- const AVComponentDescriptor *comp = &(pix_desc->comp[i]); |
|
| 91 |
- if ((comp->step_minus1+1) > crop->max_step[comp->plane]) |
|
| 92 |
- crop->max_step[comp->plane] = comp->step_minus1+1; |
|
| 93 |
- } |
|
| 94 | 86 |
|
| 87 |
+ av_fill_image_max_pixstep(crop->max_step, NULL, pix_desc); |
|
| 95 | 88 |
crop->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; |
| 96 | 89 |
crop->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; |
| 97 | 90 |
|
| ... | ... |
@@ -27,6 +27,7 @@ |
| 27 | 27 |
#include "avfilter.h" |
| 28 | 28 |
#include "libavutil/pixdesc.h" |
| 29 | 29 |
#include "libavutil/intreadwrite.h" |
| 30 |
+#include "libavcore/imgutils.h" |
|
| 30 | 31 |
|
| 31 | 32 |
typedef struct {
|
| 32 | 33 |
int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes |
| ... | ... |
@@ -68,15 +69,8 @@ static int config_props(AVFilterLink *inlink) |
| 68 | 68 |
{
|
| 69 | 69 |
FlipContext *flip = inlink->dst->priv; |
| 70 | 70 |
const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]; |
| 71 |
- int i; |
|
| 72 |
- |
|
| 73 |
- memset(flip->max_step, 0, sizeof(flip->max_step)); |
|
| 74 |
- for (i = 0; i < 4; i++) {
|
|
| 75 |
- const AVComponentDescriptor *comp = &(pix_desc->comp[i]); |
|
| 76 |
- if ((comp->step_minus1+1) > flip->max_step[comp->plane]) |
|
| 77 |
- flip->max_step[comp->plane] = comp->step_minus1+1; |
|
| 78 |
- } |
|
| 79 | 71 |
|
| 72 |
+ av_fill_image_max_pixstep(flip->max_step, NULL, pix_desc); |
|
| 80 | 73 |
flip->hsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; |
| 81 | 74 |
flip->vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; |
| 82 | 75 |
|