[Mplayer-cvslog] CVS: main/libmpcodecs vd_ffmpeg.c,1.8,1.9

Arpi of Ize arpi at mplayer.dev.hu
Thu Apr 4 01:59:57 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mplayer:/var/tmp.root/cvs-serv7041

Modified Files:
	vd_ffmpeg.c 
Log Message:
libavcodec slices support

Index: vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- vd_ffmpeg.c	1 Apr 2002 17:12:10 -0000	1.8
+++ vd_ffmpeg.c	3 Apr 2002 23:59:54 -0000	1.9
@@ -33,7 +33,9 @@
 
 typedef struct {
     AVCodecContext *avctx;
-    int last_aspect;    
+    int last_aspect;
+    int do_slices;
+    int vo_inited;
 } vd_ffmpeg_ctx;
 
 //#ifdef FF_POSTPROCESS
@@ -67,6 +69,10 @@
 	mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh->codec->dll);
 	return 0;
     }
+
+// currently buggy with B frames...    
+//    if(vd_use_slices && lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND)
+//	ctx->do_slices=1;
     
     ctx->avctx = malloc(sizeof(AVCodecContext));
     memset(ctx->avctx, 0, sizeof(AVCodecContext));
@@ -83,7 +89,8 @@
         return 0;
     }
     mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n");
-    return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12);
+    ctx->last_aspect=-3;
+    return 1; //mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12);
 }
 
 // uninit driver
@@ -99,7 +106,20 @@
 	free(ctx);
 }
 
-//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
+#include "libvo/video_out.h"	// FIXME!!!
+
+static void draw_slice(struct AVCodecContext *s,
+                	UINT8 **src, int linesize,
+                	int y, int width, int height){
+    vo_functions_t * output = s->opaque;
+    int stride[3];
+
+    stride[0]=linesize;
+    stride[1]=stride[2]=stride[0]/2;
+
+    output->draw_slice (src, stride, width, height, 0, y);
+    
+}
 
 // decode a frame
 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
@@ -108,17 +128,32 @@
     AVPicture lavc_picture;
     vd_ffmpeg_ctx *ctx = sh->context;
     AVCodecContext *avctx = ctx->avctx;
-    mp_image_t* mpi;
+    mp_image_t* mpi=NULL;
 
     if(len<=0) return NULL; // skipped frame
     
+    if(ctx->vo_inited){
+	mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE |
+	    (ctx->do_slices?MP_IMGFLAG_DRAW_CALLBACK:0),
+	    sh->disp_w, sh->disp_h);
+	if(mpi && mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
+	    // vd core likes slices!
+	    avctx->draw_horiz_band=draw_slice;
+	    avctx->opaque=sh->video_out;
+	} else
+	    avctx->draw_horiz_band=NULL;
+    }
+    
     ret = avcodec_decode_video(avctx, &lavc_picture,
 	     &got_picture, data, len);
     
     if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n");
     if(!got_picture) return NULL;	// skipped image
 
-    if (avctx->aspect_ratio_info != ctx->last_aspect)
+    if (avctx->aspect_ratio_info != ctx->last_aspect ||
+	avctx->width != sh->disp_w ||
+	avctx->height != sh->disp_h ||
+	!ctx->vo_inited)
     {
 	ctx->last_aspect = avctx->aspect_ratio_info;
 	switch(avctx->aspect_ratio_info)
@@ -136,24 +171,14 @@
 		sh->aspect = 0.0;
 		break;
 	}
-	/* config only if width && height isn't changed */
-	/* else it will config twice */
-	if ((sh->aspect > 0.01) && (avctx->width == sh->disp_w) &&
-	    (avctx->height == sh->disp_h))
-    	    if (mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12))
-    		return NULL;
-    }
-    
-    if ((avctx->width != sh->disp_w) ||
-	(avctx->height != sh->disp_h))
-    {
-	/* and what about the sh->bih (BitmapInfoHeader) width/height values? */
 	sh->disp_w = avctx->width;
 	sh->disp_h = avctx->height;
-	if (mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12))
-	    return NULL;
+	ctx->vo_inited=1;
+    	if (mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12))
+    		return NULL;
     }
     
+    if(!mpi)
     mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE,
 	avctx->width, avctx->height);
     if(!mpi){	// temporary!




More information about the MPlayer-cvslog mailing list