Signed-off-by: Thomas Mundt <loud...@yahoo.de> --- libavfilter/vf_colormatrix.c | 49 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 28 deletions(-)
diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c index 6840b91..5fe9ce3 100644 --- a/libavfilter/vf_colormatrix.c +++ b/libavfilter/vf_colormatrix.c @@ -38,7 +38,6 @@ #include "libavutil/avstring.h" #define NS(n) ((n) < 0 ? (int)((n)*65536.0-0.5+DBL_EPSILON) : (int)((n)*65536.0+0.5)) -#define CB(n) av_clip_uint8(n) static const double yuv_coeff_luma[5][3] = { { +0.7152, +0.0722, +0.2126 }, // Rec.709 (0) @@ -61,10 +60,8 @@ enum ColorMode { typedef struct { const AVClass *class; int yuv_convert[25][3][3]; - int interlaced; int source, dest; ///< ColorMode int mode; - int hsub, vsub; } ColorMatrixContext; typedef struct ThreadData { @@ -227,11 +224,11 @@ static int process_slice_uyvy422(AVFilterContext *ctx, void *arg, int jobnr, int for (x = 0; x < width; x += 4) { const int u = srcp[x + 0] - 128; const int v = srcp[x + 2] - 128; - const int uvval = c2 * u + c3 * v + 1081344; - dstp[x + 0] = CB((c4 * u + c5 * v + 8421376) >> 16); - dstp[x + 1] = CB((65536 * (srcp[x + 1] - 16) + uvval) >> 16); - dstp[x + 2] = CB((c6 * u + c7 * v + 8421376) >> 16); - dstp[x + 3] = CB((65536 * (srcp[x + 3] - 16) + uvval) >> 16); + const int uvval = (c2 * u + c3 * v + 32768) >> 16; + dstp[x + 0] = av_clip_uint8((c4 * u + c5 * v + 8421376) >> 16); + dstp[x + 1] = av_clip_uint8(srcp[x + 1] + uvval); + dstp[x + 2] = av_clip_uint8((c6 * u + c7 * v + 8421376) >> 16); + dstp[x + 3] = av_clip_uint8(srcp[x + 3] + uvval); } srcp += src_pitch; dstp += dst_pitch; @@ -271,10 +268,10 @@ static int process_slice_yuv444p(AVFilterContext *ctx, void *arg, int jobnr, int for (x = 0; x < width; x++) { const int u = srcpU[x] - 128; const int v = srcpV[x] - 128; - const int uvval = c2 * u + c3 * v + 1081344; - dstpY[x] = CB((65536 * (srcpY[x] - 16) + uvval) >> 16); - dstpU[x] = CB((c4 * u + c5 * v + 8421376) >> 16); - dstpV[x] = CB((c6 * u + c7 * v + 8421376) >> 16); + const int uvval = (c2 * u + c3 * v + 32768) >> 16; + dstpY[x] = av_clip_uint8(srcpY[x] + uvval); + dstpU[x] = av_clip_uint8((c4 * u + c5 * v + 8421376) >> 16); + dstpV[x] = av_clip_uint8((c6 * u + c7 * v + 8421376) >> 16); } srcpY += src_pitchY; dstpY += dst_pitchY; @@ -318,11 +315,11 @@ static int process_slice_yuv422p(AVFilterContext *ctx, void *arg, int jobnr, int for (x = 0; x < width; x += 2) { const int u = srcpU[x >> 1] - 128; const int v = srcpV[x >> 1] - 128; - const int uvval = c2 * u + c3 * v + 1081344; - dstpY[x + 0] = CB((65536 * (srcpY[x + 0] - 16) + uvval) >> 16); - dstpY[x + 1] = CB((65536 * (srcpY[x + 1] - 16) + uvval) >> 16); - dstpU[x >> 1] = CB((c4 * u + c5 * v + 8421376) >> 16); - dstpV[x >> 1] = CB((c6 * u + c7 * v + 8421376) >> 16); + const int uvval = (c2 * u + c3 * v + 32768) >> 16; + dstpY[x + 0] = av_clip_uint8(srcpY[x + 0] + uvval); + dstpY[x + 1] = av_clip_uint8(srcpY[x + 1] + uvval); + dstpU[x >> 1] = av_clip_uint8((c4 * u + c5 * v + 8421376) >> 16); + dstpV[x >> 1] = av_clip_uint8((c6 * u + c7 * v + 8421376) >> 16); } srcpY += src_pitchY; dstpY += dst_pitchY; @@ -368,13 +365,13 @@ static int process_slice_yuv420p(AVFilterContext *ctx, void *arg, int jobnr, int for (x = 0; x < width; x += 2) { const int u = srcpU[x >> 1] - 128; const int v = srcpV[x >> 1] - 128; - const int uvval = c2 * u + c3 * v + 1081344; - dstpY[x + 0] = CB((65536 * (srcpY[x + 0] - 16) + uvval) >> 16); - dstpY[x + 1] = CB((65536 * (srcpY[x + 1] - 16) + uvval) >> 16); - dstpN[x + 0] = CB((65536 * (srcpN[x + 0] - 16) + uvval) >> 16); - dstpN[x + 1] = CB((65536 * (srcpN[x + 1] - 16) + uvval) >> 16); - dstpU[x >> 1] = CB((c4 * u + c5 * v + 8421376) >> 16); - dstpV[x >> 1] = CB((c6 * u + c7 * v + 8421376) >> 16); + const int uvval = (c2 * u + c3 * v + 32768) >> 16; + dstpY[x + 0] = av_clip_uint8(srcpY[x + 0] + uvval); + dstpY[x + 1] = av_clip_uint8(srcpY[x + 1] + uvval); + dstpN[x + 0] = av_clip_uint8(srcpN[x + 0] + uvval); + dstpN[x + 1] = av_clip_uint8(srcpN[x + 1] + uvval); + dstpU[x >> 1] = av_clip_uint8((c4 * u + c5 * v + 8421376) >> 16); + dstpV[x >> 1] = av_clip_uint8((c6 * u + c7 * v + 8421376) >> 16); } srcpY += src_pitchY << 1; dstpY += dst_pitchY << 1; @@ -393,10 +390,6 @@ static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; ColorMatrixContext *color = ctx->priv; - const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); - - color->hsub = pix_desc->log2_chroma_w; - color->vsub = pix_desc->log2_chroma_h; av_log(ctx, AV_LOG_VERBOSE, "%s -> %s\n", color_modes[color->source], color_modes[color->dest]); -- 2.7.4.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel