changeset 5171:7145d6aba6cd

init_video() changed - now it handles codec selection
author arpi
date Mon, 18 Mar 2002 01:47:14 +0000
parents 5d54fdcf066d
children 0dab2d783817
files libmpcodecs/dec_video.c
diffstat 1 files changed, 29 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/dec_video.c	Mon Mar 18 01:00:43 2002 +0000
+++ b/libmpcodecs/dec_video.c	Mon Mar 18 01:47:14 2002 +0000
@@ -116,34 +116,36 @@
     sh_video->inited=0;
 }
 
-int init_video(sh_video_t *sh_video,int *pitches)
-{
-//unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx];
-int i;
-//pitches[0] = pitches[1] =pitches[2] = 0; /* fake unknown */
-
-//sh_video->our_out_buffer=NULL;
-//sh_video->our_out_buffer_size=0U;
-
-  for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)
-    if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver){
-	mpvdec=mpcodecs_vd_drivers[i]; break;
+int init_video(sh_video_t *sh_video,char* codecname,int vfm,int status){
+    sh_video->codec=NULL;
+    while((sh_video->codec=find_codec(sh_video->format,
+      sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,
+      sh_video->codec,0) )){
+	// ok we found one codec
+	int i;
+	if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc
+	if(vfm>=0 && sh_video->codec->driver!=vfm) continue; // vfm doesn't match
+	if(sh_video->codec->status<status) continue; // too unstable
+	// ok, it matches all rules, let's find the driver!
+	for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)
+	    if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
+	mpvdec=mpcodecs_vd_drivers[i];
+	if(!mpvdec){ // driver not available (==compiled in)
+	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Requested video codec family [%s] (vfm=%d) not available (enable it at compile time!)\n",
+		sh_video->codec->name, sh_video->codec->driver);
+	    continue;
+	}
+	// it's available, let's try to init!
+	printf("Opening Video Decoder: [%s] %s\n",mpvdec->info->short_name,mpvdec->info->name);
+	if(!mpvdec->init(sh_video)){
+	    printf("VDecoder init failed :(\n");
+	    continue; // try next...
+	}
+	// Yeah! We got it!
+	sh_video->inited=1;
+	return 1;
     }
-  if(!mpvdec){
-      mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Requested video codec family [%s] (vfm=%d) not available (enable it at compile time!)\n",
-          sh_video->codec->name, sh_video->codec->driver);
-      return 0; // no such driver
-  }
-  
-  printf("Selecting Video Decoder: [%s] %s\n",mpvdec->info->short_name,mpvdec->info->name);
-  
-  if(!mpvdec->init(sh_video)){
-      printf("VDecoder init failed :(\n");
-      return 0;
-  }
-  
-  sh_video->inited=1;
-  return 1;
+    return 0;
 }
 
 extern int vaa_use_dr;