diff --git a/libavcodec/h264chroma.c b/libavcodec/h264chroma.c index 1eeab7bc40..5000c89aa7 100644 --- a/libavcodec/h264chroma.c +++ b/libavcodec/h264chroma.c @@ -32,11 +32,9 @@ c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c; \ c->put_h264_chroma_pixels_tab[1] = put_h264_chroma_mc4_ ## depth ## _c; \ c->put_h264_chroma_pixels_tab[2] = put_h264_chroma_mc2_ ## depth ## _c; \ - c->put_h264_chroma_pixels_tab[3] = put_h264_chroma_mc1_ ## depth ## _c; \ c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_ ## depth ## _c; \ c->avg_h264_chroma_pixels_tab[1] = avg_h264_chroma_mc4_ ## depth ## _c; \ c->avg_h264_chroma_pixels_tab[2] = avg_h264_chroma_mc2_ ## depth ## _c; \ - c->avg_h264_chroma_pixels_tab[3] = avg_h264_chroma_mc1_ ## depth ## _c; \ av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth) { diff --git a/libavcodec/h264chroma_template.c b/libavcodec/h264chroma_template.c index b9d24f5a0c..b58be192cd 100644 --- a/libavcodec/h264chroma_template.c +++ b/libavcodec/h264chroma_template.c @@ -26,40 +26,6 @@ #include "bit_depth_template.c" #define H264_CHROMA_MC(OPNAME, OP)\ -static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst /*align 8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y){\ - pixel *dst = (pixel*)_dst;\ - const pixel *src = (const pixel*)_src;\ - const int A=(8-x)*(8-y);\ - const int B=( x)*(8-y);\ - const int C=(8-x)*( y);\ - const int D=( x)*( y);\ - int i;\ - stride >>= sizeof(pixel)-1;\ - \ - av_assert2(x<8 && y<8 && x>=0 && y>=0);\ -\ - if(D){\ - for(i=0; i= 0 && y >= 0);\ +\ + if (D) {\ + for (int i = 0; i < h; ++i) {\ + OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ + dst += stride;\ + src += stride;\ + }\ + } else if (B + C) {\ + const int E = B + C;\ + const int step = C ? stride : 1;\ + for (int i = 0; i < h; ++i) {\ + OP(dst[0], (A*src[0] + E*src[step+0]));\ + dst += stride;\ + src += stride;\ + }\ + } else {\ + for (int i = 0; i < h; ++i) {\ + OP(dst[0], (A*src[0]));\ + dst += stride;\ + src += stride;\ + }\ + }\ +}\ + +#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1) +#define op_put(a, b) a = (((b) + 32)>>6) + +H264_CHROMA_MC(put_, op_put) +H264_CHROMA_MC(avg_, op_avg) + av_cold int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) { enum ThreadingStatus thread_status; @@ -62,6 +101,8 @@ av_cold int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) ff_mpv_idct_init(s); ff_h264chroma_init(&s->h264chroma, 8); //for lowres + s->h264chroma.avg_h264_chroma_pixels_tab[3] = avg_h264_chroma_mc1; + s->h264chroma.put_h264_chroma_pixels_tab[3] = put_h264_chroma_mc1; if (s->picture_pool) // VC-1 can call this multiple times return 0; diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c index 9579fceab7..52aa220152 100644 --- a/tests/checkasm/h264chroma.c +++ b/tests/checkasm/h264chroma.c @@ -51,7 +51,7 @@ static void check_chroma_mc(void) for (int bit_depth = 8; bit_depth <= 10; bit_depth++) { ff_h264chroma_init(&h, bit_depth); randomize_buffers(bit_depth); - for (int size = 0; size < 4; size++) { + for (int size = 0; size < 3; size++) { #define CHECK_CHROMA_MC(name) \ do { \