diff options
author | Michael Roitzsch <mroi@users.sourceforge.net> | 2003-05-25 18:34:54 +0000 |
---|---|---|
committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2003-05-25 18:34:54 +0000 |
commit | 8a964239cdbe666e012774c0cd30859579319cf1 (patch) | |
tree | 42013d1fb37cf6dcb1cf8d04b6619162f76be312 /src/libffmpeg/libavcodec | |
parent | e7852acb9ab9af964a59a677186c1da548174500 (diff) | |
download | xine-lib-8a964239cdbe666e012774c0cd30859579319cf1.tar.gz xine-lib-8a964239cdbe666e012774c0cd30859579319cf1.tar.bz2 |
compiling libavcodec's encoding part as an MPEG encoder suitable for the DXR3
* libavcodec/mpegvideo.c has been modified to work without the need to compile
libavcodec/motion_est.c to save compilation time (we don't need motion
estimation when encoding I-frames only anyway)
* the patch to libavcodec/i386/mpegvideo_mmx_template.c has been reverted,
because the encoder crashes with it
CVS patchset: 4930
CVS date: 2003/05/25 18:34:54
Diffstat (limited to 'src/libffmpeg/libavcodec')
-rw-r--r-- | src/libffmpeg/libavcodec/Makefile.am | 9 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c | 76 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/mpegvideo.c | 10 |
3 files changed, 46 insertions, 49 deletions
diff --git a/src/libffmpeg/libavcodec/Makefile.am b/src/libffmpeg/libavcodec/Makefile.am index a27478a5a..14140396a 100644 --- a/src/libffmpeg/libavcodec/Makefile.am +++ b/src/libffmpeg/libavcodec/Makefile.am @@ -3,12 +3,12 @@ include $(top_srcdir)/misc/Makefile.common SUBDIRS = armv4l i386 mlib alpha libpostproc ## we include ppc/* files since auto* doesn't dive into. -EXTRA_DIST = fdctref.c imgresample.c motion_est_template.c svq3.c wmv2.c \ +EXTRA_DIST = fdctref.c motion_est_template.c svq3.c wmv2.c \ ppc/dsputil_ppc.c ppc/libavcodec_ppc_dummy.c ppc/mpegvideo_altivec.c \ ppc/dsputil_altivec.c ppc/fft_altivec.c ppc/Makefile.am ppc/mpegvideo_ppc.c \ ppc/dsputil_altivec.h ppc/idct_altivec.c -AM_CFLAGS = $(LIBFFMPEG_CFLAGS) -DCONFIG_RISKY +AM_CFLAGS = $(LIBFFMPEG_CFLAGS) -DCONFIG_RISKY -DCONFIG_ENCODERS ASFLAGS = noinst_LTLIBRARIES = libavcodec.la @@ -40,12 +40,15 @@ libavcodec_la_SOURCES = \ mpegvideo.c \ msmpeg4.c \ opts.c \ + ratecontrol.c \ rv10.c \ simple_idct.c \ svq1.c \ utils.c \ wmadec.c -#imgresample.c + +# these are currently unneeded +EXTRA_DIST += imgresample.c motion_est.c libavcodec_la_LDFLAGS = \ $(top_builddir)/src/libffmpeg/libavcodec/armv4l/libavcodec_armv4l.la \ diff --git a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c index 8cd91024b..fa1ab579d 100644 --- a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c +++ b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx_template.c @@ -83,25 +83,16 @@ static int RENAME(dct_quantize)(MpegEncContext *s, } if(s->out_format == FMT_H263 && s->mpeg_quant==0){ - - /* the following code is patched using avifile's modifications - to enable -fpic compilation. this patch has not been accepted on - main ffmpeg cvs. */ - + asm volatile( "movd %%eax, %%mm3 \n\t" // last_non_zero_p1 SPREADW(%%mm3) "pxor %%mm7, %%mm7 \n\t" // 0 "pxor %%mm4, %%mm4 \n\t" // 0 - "movq (%1), %%mm5 \n\t" // qmat[0] + "movq (%2), %%mm5 \n\t" // qmat[0] "pxor %%mm6, %%mm6 \n\t" - "psubw (%2), %%mm6 \n\t" // -bias[0] + "psubw (%3), %%mm6 \n\t" // -bias[0] "movl $-128, %%eax \n\t" - : "+a" (last_non_zero_p1) - : "r" (qmat), "r" (bias) - ); - /* CORE */ - asm volatile( ".balign 16 \n\t" "1: \n\t" "pxor %%mm1, %%mm1 \n\t" // 0 @@ -114,7 +105,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, "por %%mm0, %%mm4 \n\t" "pxor %%mm1, %%mm0 \n\t" "psubw %%mm1, %%mm0 \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) - "movq %%mm0, (%3, %%eax) \n\t" + "movq %%mm0, (%5, %%eax) \n\t" "pcmpeqw %%mm7, %%mm0 \n\t" // out==0 ? 0xFF : 0x00 "movq (%4, %%eax), %%mm1 \n\t" "movq %%mm7, (%1, %%eax) \n\t" // 0 @@ -122,11 +113,6 @@ static int RENAME(dct_quantize)(MpegEncContext *s, PMAXW(%%mm0, %%mm3) "addl $8, %%eax \n\t" " js 1b \n\t" - : "+a" (last_non_zero_p1) - : "r" (block+64), "r" (inv_zigzag_direct16+64), "r" (temp_block+64) - ); - /* EPILOGUE */ - asm volatile( "movq %%mm3, %%mm0 \n\t" "psrlq $32, %%mm3 \n\t" PMAXW(%%mm0, %%mm3) @@ -135,46 +121,48 @@ static int RENAME(dct_quantize)(MpegEncContext *s, PMAXW(%%mm0, %%mm3) "movd %%mm3, %%eax \n\t" "movzbl %%al, %%eax \n\t" // last_non_zero_p1 - "movd %2, %%mm1 \n\t" // max_qcoeff + : "+a" (last_non_zero_p1) + : "r" (block+64), "r" (qmat), "r" (bias), + "r" (inv_zigzag_direct16+64), "r" (temp_block+64) + ); + // note the asm is split cuz gcc doesnt like that many operands ... + asm volatile( + "movd %1, %%mm1 \n\t" // max_qcoeff SPREADW(%%mm1) "psubusw %%mm1, %%mm4 \n\t" "packuswb %%mm4, %%mm4 \n\t" - "movd %%mm4, %1 \n\t" // *overflow - : "+a" (last_non_zero_p1), "=r" (*overflow) - : "r" (s->max_qcoeff) - ); + "movd %%mm4, %0 \n\t" // *overflow + : "=g" (*overflow) + : "g" (s->max_qcoeff) + ); }else{ // FMT_H263 asm volatile( - "pushl %%ebp \n\t" - "pushl %%ebx \n\t" - "movl %0, %%ebp \n\t" - "movl (%%ebp), %%ebx \n\t" - "movd %%ebx, %%mm3 \n\t" // last_non_zero_p1 + "movd %%eax, %%mm3 \n\t" // last_non_zero_p1 SPREADW(%%mm3) "pxor %%mm7, %%mm7 \n\t" // 0 "pxor %%mm4, %%mm4 \n\t" // 0 - "movl $-128, %%ebx \n\t" + "movl $-128, %%eax \n\t" ".balign 16 \n\t" "1: \n\t" "pxor %%mm1, %%mm1 \n\t" // 0 - "movq (%1, %%ebx), %%mm0 \n\t" // block[i] + "movq (%1, %%eax), %%mm0 \n\t" // block[i] "pcmpgtw %%mm0, %%mm1 \n\t" // block[i] <= 0 ? 0xFF : 0x00 "pxor %%mm1, %%mm0 \n\t" "psubw %%mm1, %%mm0 \n\t" // ABS(block[i]) - "movq (%3, %%ebx), %%mm6 \n\t" // bias[0] + "movq (%3, %%eax), %%mm6 \n\t" // bias[0] "paddusw %%mm6, %%mm0 \n\t" // ABS(block[i]) + bias[0] - "movq (%2, %%ebx), %%mm5 \n\t" // qmat[i] + "movq (%2, %%eax), %%mm5 \n\t" // qmat[i] "pmulhw %%mm5, %%mm0 \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16 "por %%mm0, %%mm4 \n\t" "pxor %%mm1, %%mm0 \n\t" "psubw %%mm1, %%mm0 \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) - "movq %%mm0, (%5, %%ebx) \n\t" + "movq %%mm0, (%5, %%eax) \n\t" "pcmpeqw %%mm7, %%mm0 \n\t" // out==0 ? 0xFF : 0x00 - "movq (%4, %%ebx), %%mm1 \n\t" - "movq %%mm7, (%1, %%ebx) \n\t" // 0 + "movq (%4, %%eax), %%mm1 \n\t" + "movq %%mm7, (%1, %%eax) \n\t" // 0 "pandn %%mm1, %%mm0 \n\t" PMAXW(%%mm0, %%mm3) - "addl $8, %%ebx \n\t" + "addl $8, %%eax \n\t" " js 1b \n\t" "movq %%mm3, %%mm0 \n\t" "psrlq $32, %%mm3 \n\t" @@ -182,14 +170,10 @@ static int RENAME(dct_quantize)(MpegEncContext *s, "movq %%mm3, %%mm0 \n\t" "psrlq $16, %%mm3 \n\t" PMAXW(%%mm0, %%mm3) - "movd %%mm3, %%ebx \n\t" - "movzbl %%bl, %%ebx \n\t" // last_non_zero_p1 - "movl %%ebx, (%%ebp) \n\t" - "popl %%ebx \n\t" - "popl %%ebp \n\t" - : - : "m" (last_non_zero_p1), - "r" (block+64), "r" (qmat+64), "r" (bias+64), + "movd %%mm3, %%eax \n\t" + "movzbl %%al, %%eax \n\t" // last_non_zero_p1 + : "+a" (last_non_zero_p1) + : "r" (block+64), "r" (qmat+64), "r" (bias+64), "r" (inv_zigzag_direct16+64), "r" (temp_block+64) ); // note the asm is split cuz gcc doesnt like that many operands ... @@ -199,8 +183,8 @@ static int RENAME(dct_quantize)(MpegEncContext *s, "psubusw %%mm1, %%mm4 \n\t" "packuswb %%mm4, %%mm4 \n\t" "movd %%mm4, %0 \n\t" // *overflow - : "=r" (*overflow) - : "r" (s->max_qcoeff) + : "=g" (*overflow) + : "g" (s->max_qcoeff) ); } diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c index c0dd96bbe..d2f3c8e90 100644 --- a/src/libffmpeg/libavcodec/mpegvideo.c +++ b/src/libffmpeg/libavcodec/mpegvideo.c @@ -761,7 +761,9 @@ int MPV_encode_init(AVCodecContext *avctx) if (MPV_common_init(s) < 0) return -1; +#ifdef CONFIG_ENCODERS_FULL ff_init_me(s); +#endif #ifdef CONFIG_ENCODERS #ifdef CONFIG_RISKY @@ -1438,7 +1440,9 @@ int MPV_encode_picture(AVCodecContext *avctx, mjpeg_picture_trailer(s); if(s->flags&CODEC_FLAG_PASS1) +#ifdef CONFIG_ENCODERS_FULL ff_write_pass1_stats(s); +#endif for(i=0; i<4; i++){ avctx->error[i] += s->current_picture_ptr->error[i]; @@ -3014,6 +3018,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) /* Estimate motion for every MB */ s->mb_intra=0; //for the rate distoration & bit compare functions if(s->pict_type != I_TYPE){ +#ifdef CONFIG_ENCODERS_FULL if(s->pict_type != B_TYPE){ if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){ s->me.pre_pass=1; @@ -3051,6 +3056,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) ff_estimate_p_frame_motion(s, mb_x, mb_y); } } +#endif }else /* if(s->pict_type == I_TYPE) */{ /* I-Frame */ //FIXME do we need to zero them? @@ -3087,12 +3093,15 @@ static void encode_picture(MpegEncContext *s, int picture_number) if(!s->umvplus){ if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) { +#ifdef CONFIG_ENCODERS_FULL s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER); ff_fix_long_p_mvs(s); +#endif } if(s->pict_type==B_TYPE){ +#ifdef CONFIG_ENCODERS_FULL int a, b; a = ff_get_best_fcode(s, s->b_forw_mv_table, MB_TYPE_FORWARD); @@ -3107,6 +3116,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) ff_fix_long_b_mvs(s, s->b_back_mv_table, s->b_code, MB_TYPE_BACKWARD); ff_fix_long_b_mvs(s, s->b_bidir_forw_mv_table, s->f_code, MB_TYPE_BIDIR); ff_fix_long_b_mvs(s, s->b_bidir_back_mv_table, s->b_code, MB_TYPE_BIDIR); +#endif } } |