1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

avcodec/h264chroma: Move mc1 function to mpegvideo_dec.c

It is only used by mpegvideo decoders (for lowres). It is also only used
for bitdepth == 8, so don't build the bitdepth == 16 function at all any
more.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-10-30 15:40:02 +01:00
parent e59d964a3c
commit c6efe1abda
4 changed files with 42 additions and 37 deletions

View File

@@ -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)
{

View File

@@ -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<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(i=0; i<h; i++){\
OP(dst[0], (A*src[0] + E*src[step+0]));\
dst+= stride;\
src+= stride;\
}\
} else {\
for(i=0; i<h; i++){\
OP(dst[0], (A*src[0]));\
dst+= stride;\
src+= stride;\
}\
}\
}\
static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst /*align 8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
{\
pixel *dst = (pixel*)_dst;\

View File

@@ -44,6 +44,45 @@
#include "threadprogress.h"
#include "wmv2dec.h"
#define H264_CHROMA_MC(OPNAME, OP)\
static void OPNAME ## h264_chroma_mc1(uint8_t *dst /*align 8*/, const uint8_t *src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
{\
const int A = (8-x) * (8-y);\
const int B = ( x) * (8-y);\
const int C = (8-x) * ( y);\
const int D = ( x) * ( y);\
\
av_assert2(x < 8 && y < 8 && x >= 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;

View File

@@ -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 { \