Originally committed as revision 24827 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 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) · 28 unmodified lines | ||
| 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 · 15 unmodified lines | ||
| 65 | 56 | return 0; |
| 66 | 57 | } |
| 67 | 58 | |
| 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 | − | |
| 59 | + av_fill_image_max_pixstep(max_step, max_step_comp, desc); | |
| 78 | 60 | for (i = 0; i < 4; i++) { |
| 79 | 61 | int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0; |
| 80 | 62 | linesizes[i] = max_step[i] * (((width + (1 << s) - 1)) >> s); |
| @@ -24,9 +24,43 @@ · 23 unmodified lines | ||
| 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 | +/** | |
| 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 | + | |
| 30 | 64 | /** |
| 31 | 65 | * Compute the size of an image line with format pix_fmt and width |
| 32 | 66 | * width for the plane plane. |
| @@ -24,7 +24,7 @@ · 23 unmodified lines | ||
| 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) · 52 unmodified lines | ||
| 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 @@ · 26 unmodified lines | ||
| 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) · 35 unmodified lines | ||
| 68 | 69 | { |
| 69 | 70 | FlipContext *flip = inlink->dst->priv; |
| 70 | 71 | 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 | 72 | |
| 73 | + av_fill_image_max_pixstep(flip->max_step, NULL, pix_desc); | |
| 80 | 74 | flip->hsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; |
| 81 | 75 | flip->vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; |
| 82 | 76 | |