[FFmpeg-cvslog] mpegvideo: implement ff_put_h264_chroma_mc1 & ff_avg_h264_chroma_mc2
Michael Niedermayer
git at videolan.org
Sun Jun 2 16:55:28 CEST 2013
ffmpeg | branch: release/1.2 | Michael Niedermayer <michaelni at gmx.at> | Sun Jun 2 16:17:09 2013 +0200| [f2361593ca1b542f0e9284d2d4276387f8fec1e3] | committer: Carl Eugen Hoyos
mpegvideo: implement ff_put_h264_chroma_mc1 & ff_avg_h264_chroma_mc2
These are needed for lowres 3
Fixes Ticket2538
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit c2625c26c5e58edfa39360b51125f1ddd593e4db)
Signed-off-by: Carl Eugen Hoyos <cehoyos at ag.or.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2361593ca1b542f0e9284d2d4276387f8fec1e3
---
libavcodec/h264chroma.c | 2 ++
libavcodec/h264chroma.h | 4 ++--
libavcodec/h264chroma_template.c | 28 ++++++++++++++++++++++++++++
libavcodec/mpegvideo.c | 6 +++---
4 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/libavcodec/h264chroma.c b/libavcodec/h264chroma.c
index 3b780a0..8295f19 100644
--- a/libavcodec/h264chroma.c
+++ b/libavcodec/h264chroma.c
@@ -31,9 +31,11 @@
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; \
void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
{
diff --git a/libavcodec/h264chroma.h b/libavcodec/h264chroma.h
index 4e035b0..90a09cc 100644
--- a/libavcodec/h264chroma.h
+++ b/libavcodec/h264chroma.h
@@ -24,8 +24,8 @@
typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
typedef struct H264ChromaContext {
- h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
- h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
+ h264_chroma_mc_func put_h264_chroma_pixels_tab[4];
+ h264_chroma_mc_func avg_h264_chroma_pixels_tab[4];
} H264ChromaContext;
void ff_h264chroma_init(H264ChromaContext *c, int bit_depth);
diff --git a/libavcodec/h264chroma_template.c b/libavcodec/h264chroma_template.c
index 93559d7..b64172a 100644
--- a/libavcodec/h264chroma_template.c
+++ b/libavcodec/h264chroma_template.c
@@ -24,6 +24,34 @@
#include "bit_depth_template.c"
#define H264_CHROMA_MC(OPNAME, OP)\
+static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
+ pixel *dst = (pixel*)_dst;\
+ pixel *src = (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<h; i++){\
+ OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
+ dst+= stride;\
+ src+= stride;\
+ }\
+ }else{\
+ const int E= B+C;\
+ const int step= C ? stride : 1;\
+ for(i=0; i<h; i++){\
+ OP(dst[0], (A*src[0] + E*src[step+0]));\
+ dst+= stride;\
+ src+= stride;\
+ }\
+ }\
+}\
static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
pixel *dst = (pixel*)_dst;\
pixel *src = (pixel*)_src;\
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 5da9c98..3fbe03b 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2102,7 +2102,7 @@ static inline int hpel_motion_lowres(MpegEncContext *s,
int motion_x, int motion_y)
{
const int lowres = s->avctx->lowres;
- const int op_index = FFMIN(lowres, 2);
+ const int op_index = FFMIN(lowres, 3);
const int s_mask = (2 << lowres) - 1;
int emu = 0;
int sx, sy;
@@ -2155,7 +2155,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy,
uvsx, uvsy;
const int lowres = s->avctx->lowres;
- const int op_index = FFMIN(lowres-1+s->chroma_x_shift, 2);
+ const int op_index = FFMIN(lowres-1+s->chroma_x_shift, 3);
const int block_s = 8>>lowres;
const int s_mask = (2 << lowres) - 1;
const int h_edge_pos = s->h_edge_pos >> lowres;
@@ -2279,7 +2279,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
int mx, int my)
{
const int lowres = s->avctx->lowres;
- const int op_index = FFMIN(lowres, 2);
+ const int op_index = FFMIN(lowres, 3);
const int block_s = 8 >> lowres;
const int s_mask = (2 << lowres) - 1;
const int h_edge_pos = s->h_edge_pos >> lowres + 1;
More information about the ffmpeg-cvslog
mailing list