[MPlayer-dev-eng] [PATCH] dvdnav part 3 - emptyframe

Michael Niedermayer michaelni at gmx.at
Wed Aug 1 01:37:18 CEST 2007


Hi

On Tue, Jul 31, 2007 at 09:21:16PM +0200, Reimar Döffinger wrote:
> Hello,
> On Tue, Jul 31, 2007 at 03:42:06PM +0200, Michael Niedermayer wrote:
> > On Tue, Jul 31, 2007 at 01:56:00PM +0200, Reimar Döffinger wrote:
> > > On Tue, Jul 31, 2007 at 12:16:42PM +0200, Michael Niedermayer wrote:
> > > > On Tue, Jul 31, 2007 at 11:17:27AM +0200, Reimar Döffinger wrote:
> > > > > On Tue, Jul 31, 2007 at 12:05:22AM +0200, Diego Biurrun wrote:
> > > > > [...]
> > > > > > libmpeg2 used to be faster than FFmpeg.  The last time I made benchmarks
> > > > > > years ago this was indeed still the case, but FFmpeg was catching up.
> > > > > > Baptiste keeps telling me that FFmpeg is faster nowadays, but we really
> > > > > > need extensive benchmarks to confirm or deny this.
> > > > > 
> > > > > Just yesterday I was shocked to see that ffmpeg12 + vo_gl on Windows is
> > > > > about 30% slower than libmpeg2 + vo_gl.
> > > > > Probably I am doing something stupid in vo_gl (I guess that with
> > > > > PCI-Express slice-based rendering becomes very slow in comparison), but
> > > > > it still is a huge difference.
> > > > 
> > > > uhm ... 30% ...
> > > > 
> > > > it would be interresting to know what exactly causes this speed difference
> 
> Seem the 30% were -vc mpeg12 -noslices vs. -vf ffmpeg12 -slices, which
> is not a fair comparison, at least not with OpenGL under Windows Vista,
> seems like texture uploads have a really massive overhead there.
> Still, ffmpeg12 has a slow but consistent disadvantage in all cases.
> 
> > > -noslices fixes it mostly btw. I didn't make proper measurements though.
> > 
> > if you do, dont forget to try -lavdopts idct=4
> 
> One of the runs is with that option, made things slower though.
> See attached file.
> Sample file used is available at
> http://samples.mplayerhq.hu/HDTV/Van_Helsing.ts

ok, ffmpeg12-libmpeg2 slowdown is reproduceable here

a patch which cuts the difference in half is attached
libmpeg2: 84.854s
oldff12 : 92.416s
newff12 : 88.158s
(all just -vo null no slice/dr related cmd line options)

the patch simply if(0) some code unrelated to mpeg12 decoding or which
libmpeg2 doesnt support ...
it needs to be cleaned up so it can coexist with other codecs
any volunteers for that? aurelian?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
Index: mpegvideo_common.h
===================================================================
--- mpegvideo_common.h	(revision 9830)
+++ mpegvideo_common.h	(working copy)
@@ -38,6 +38,8 @@
 #include "faandct.h"
 #include <limits.h>
 
+#define MPEG12 1
+
 int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
 int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
 void  denoise_dct_c(MpegEncContext *s, DCTELEM *block);
@@ -263,7 +265,7 @@
     src_x = s->mb_x* 16               + (motion_x >> 1);
     src_y =(s->mb_y<<(4-field_based)) + (motion_y >> 1);
 
-    if (s->out_format == FMT_H263) {
+    if (!MPEG12 && s->out_format == FMT_H263) {
         if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){
             mx = (motion_x>>1)|(motion_x&1);
             my = motion_y >>1;
@@ -275,7 +277,7 @@
             uvsrc_x = src_x>>1;
             uvsrc_y = src_y>>1;
         }
-    }else if(s->out_format == FMT_H261){//even chroma mv's are full pel in H261
+    }else if(!MPEG12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261
         mx = motion_x / 4;
         my = motion_y / 4;
         uvdxy = 0;
@@ -310,7 +312,7 @@
 
     if(   (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 16
        || (unsigned)src_y >    v_edge_pos - (motion_y&1) - h){
-            if(s->codec_id == CODEC_ID_MPEG2VIDEO ||
+            if(MPEG12 || s->codec_id == CODEC_ID_MPEG2VIDEO ||
                s->codec_id == CODEC_ID_MPEG1VIDEO){
                 av_log(s->avctx,AV_LOG_DEBUG,"MPEG motion vector out of boundary\n");
                 return ;
@@ -343,11 +345,11 @@
 
     pix_op[0][dxy](dest_y, ptr_y, linesize, h);
 
-    if(!(s->flags&CODEC_FLAG_GRAY)){
+    if(MPEG12 || !(s->flags&CODEC_FLAG_GRAY)){
         pix_op[s->chroma_x_shift][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
         pix_op[s->chroma_x_shift][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
     }
-    if((ENABLE_H261_ENCODER || ENABLE_H261_DECODER) && s->out_format == FMT_H261){
+    if(!MPEG12 && (ENABLE_H261_ENCODER || ENABLE_H261_DECODER) && s->out_format == FMT_H261){
         ff_h261_loop_filter(s);
     }
 }
@@ -608,7 +610,7 @@
 
     prefetch_motion(s, ref_picture, dir);
 
-    if(s->obmc && s->pict_type != B_TYPE){
+    if(!MPEG12 && s->obmc && s->pict_type != B_TYPE){
         int16_t mv_cache[4][4][2];
         const int xy= s->mb_x + s->mb_y*s->mb_stride;
         const int mot_stride= s->b8_stride;
@@ -671,7 +673,7 @@
 
     switch(s->mv_type) {
     case MV_TYPE_16X16:
-        if(s->mcsel){
+        if(!MPEG12 && s->mcsel){
             if(s->real_sprite_warping_points==1){
                 gmc1_motion(s, dest_y, dest_cb, dest_cr,
                             ref_picture);
@@ -679,12 +681,12 @@
                 gmc_motion(s, dest_y, dest_cb, dest_cr,
                             ref_picture);
             }
-        }else if(s->quarter_sample){
+        }else if(!MPEG12 && s->quarter_sample){
             qpel_motion(s, dest_y, dest_cb, dest_cr,
                         0, 0, 0,
                         ref_picture, pix_op, qpix_op,
                         s->mv[dir][0][0], s->mv[dir][0][1], 16);
-        }else if(ENABLE_WMV2 && s->mspel){
+        }else if(!MPEG12 && ENABLE_WMV2 && s->mspel){
             ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
                         ref_picture, pix_op,
                         s->mv[dir][0][0], s->mv[dir][0][1], 16);
@@ -697,6 +699,7 @@
         }
         break;
     case MV_TYPE_8X8:
+if(!MPEG12){
         mx = 0;
         my = 0;
         if(s->quarter_sample){
@@ -747,10 +750,11 @@
 
         if(!(s->flags&CODEC_FLAG_GRAY))
             chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
+}
         break;
     case MV_TYPE_FIELD:
         if (s->picture_structure == PICT_FRAME) {
-            if(s->quarter_sample){
+            if(!MPEG12 && s->quarter_sample){
                 for(i=0; i<2; i++){
                     qpel_motion(s, dest_y, dest_cb, dest_cr,
                                 1, i, s->field_select[dir][i],
Index: mpegvideo.c
===================================================================
--- mpegvideo.c	(revision 9830)
+++ mpegvideo.c	(working copy)
@@ -1847,7 +1847,7 @@
     mb_x = s->mb_x;
     mb_y = s->mb_y;
 
-    if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
+    if(!MPEG12 && s->avctx->debug&FF_DEBUG_DCT_COEFF) {
        /* save DCT coefficients */
        int i,j;
        DCTELEM *dct = &s->current_picture.dct_coeff[mb_xy*64*6];
@@ -1860,7 +1860,7 @@
 
     /* update DC predictors for P macroblocks */
     if (!s->mb_intra) {
-        if (s->h263_pred || s->h263_aic) {
+        if (!MPEG12 && (s->h263_pred || s->h263_aic)) {
             if(s->mbintra_table[mb_xy])
                 ff_clean_intra_table_entries(s);
         } else {
@@ -1869,10 +1869,10 @@
             s->last_dc[2] = 128 << s->intra_dc_precision;
         }
     }
-    else if (s->h263_pred || s->h263_aic)
+    else if (!MPEG12 && (s->h263_pred || s->h263_aic))
         s->mbintra_table[mb_xy]=1;
 
-    if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
+    if (MPEG12 || (s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
         uint8_t *dest_y, *dest_cb, *dest_cr;
         int dct_linesize, dct_offset;
         op_pixels_func (*op_pix)[4];
@@ -1884,7 +1884,7 @@
 
         /* avoid copy if macroblock skipped in last frame too */
         /* skip only during decoding as we might trash the buffers during encoding a bit */
-        if(!s->encoding){
+        if(MPEG12 || !s->encoding){
             uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
             const int age= s->current_picture.age;
 
@@ -1925,8 +1925,8 @@
         if (!s->mb_intra) {
             /* motion handling */
             /* decoding or more than one mb_type (MC was already done otherwise) */
-            if(!s->encoding){
-                if(lowres_flag){
+            if(MPEG12 || !s->encoding){
+                if(!MPEG12 && lowres_flag){
                     h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab;
 
                     if (s->mv_dir & MV_DIR_FORWARD) {
@@ -1938,7 +1938,7 @@
                     }
                 }else{
                     op_qpix= s->me.qpel_put;
-                    if ((!s->no_rounding) || s->pict_type==B_TYPE){
+                    if (MPEG12 || (!s->no_rounding) || s->pict_type==B_TYPE){
                         op_pix = s->dsp.put_pixels_tab;
                     }else{
                         op_pix = s->dsp.put_no_rnd_pixels_tab;
@@ -1955,8 +1955,8 @@
             }
 
             /* skip dequant / idct if we are really late ;) */
-            if(s->hurry_up>1) goto skip_idct;
-            if(s->avctx->skip_idct){
+            if(!MPEG12 && s->hurry_up>1) goto skip_idct;
+            if(!MPEG12 && s->avctx->skip_idct){
                 if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == B_TYPE)
                    ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != I_TYPE)
                    || s->avctx->skip_idct >= AVDISCARD_ALL)
@@ -1964,8 +1964,8 @@
             }
 
             /* add dct residue */
-            if(s->encoding || !(   s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO
-                                || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){
+            if(!MPEG12 && (s->encoding || !(   s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO
+                                || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant)))){
                 add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
                 add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
                 add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
@@ -1984,13 +1984,13 @@
                         add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
                     }
                 }
-            } else if(s->codec_id != CODEC_ID_WMV2){
+            } else if(MPEG12 || s->codec_id != CODEC_ID_WMV2){
                 add_dct(s, block[0], 0, dest_y                          , dct_linesize);
                 add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
                 add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
                 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
 
-                if(!(s->flags&CODEC_FLAG_GRAY)){
+                if(MPEG12 || !(s->flags&CODEC_FLAG_GRAY)){
                     if(s->chroma_y_shift){//Chroma420
                         add_dct(s, block[4], 4, dest_cb, uvlinesize);
                         add_dct(s, block[5], 5, dest_cr, uvlinesize);
@@ -2017,7 +2017,7 @@
             }
         } else {
             /* dct only in intra block */
-            if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){
+            if(!MPEG12 && (s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO))){
                 put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
                 put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
                 put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
@@ -2042,7 +2042,7 @@
                 s->dsp.idct_put(dest_y + dct_offset             , dct_linesize, block[2]);
                 s->dsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
 
-                if(!(s->flags&CODEC_FLAG_GRAY)){
+                if(MPEG12 || !(s->flags&CODEC_FLAG_GRAY)){
                     if(s->chroma_y_shift){
                         s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
                         s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20070801/7a5935c7/attachment.pgp>


More information about the MPlayer-dev-eng mailing list