Hi

A smallish patch for the transcode_1_0 branch.

There is a problem with import_mov allocating too little memory
for some formats. I've replaced the the mallocs with lqt_rows_alloc so
lqt takes care of that, which means the module will require
libquicktime >= 0.9.8 though.

Kicked out raw audio handling because that was dropped in 0.9.4.

Made import_mov the handler for files with the "    ftyp" head. It's
mostly used in .mp4 files but some programs use that for .mov files too
(like recent lqt) and lqt can read .mp4 files (sometimes).

some formating here and there

I'll look into moving the stuff to 1.1 too.

Does lqt actually fit into that new module system thing? It seems like
transcode is moving towards seperating container and codec, which lqt
isn't really designed for.

stefan
diff -aur ../transcode/configure.in transcode/configure.in
--- ../transcode/configure.in	2007-01-14 16:17:28.000000000 +0100
+++ transcode/configure.in	2007-01-14 18:44:35.000000000 +0100
@@ -1011,14 +1011,8 @@
 dnl
 LIBQUICKTIME_EXTRA_LIBS="$LIBQUICKTIME_EXTRA_LIBS -lpng -lz $PTHREAD_LIBS -lm $LIBDV_LIBS"
 TC_PKG_CHECK(libquicktime, no, LIBQUICKTIME, lqt-config, [quicktime.h],
- quicktime, quicktime_open, libquicktime,
+ quicktime, lqt_rows_alloc, libquicktime,
  [http://libquicktime.sourceforge.net/])
-if test x"$have_libquicktime" = x"yes" ; then
-  AC_CHECK_LIB(quicktime, lqt_encode_video,
-    [AC_DEFINE([LIBQUICKTIME_000904], [1], [Have libquicktime 0.9.4 or newer])],
-    [], 
-    [$LIBQUICKTIME_EXTRA_LIBS])
-fi
 TC_PKG_HAVE(libquicktime, LIBQUICKTIME)
 
 dnl
diff -aur ../transcode/export/export_mov.c transcode/export/export_mov.c
--- ../transcode/export/export_mov.c	2007-01-14 16:17:30.000000000 +0100
+++ transcode/export/export_mov.c	2007-01-14 19:27:55.000000000 +0100
@@ -276,16 +276,11 @@
             return(TC_EXPORT_ERROR);
         }
 
-#if !defined(LIBQUICKTIME_000904)
-        /* set proposed video codec */
-        lqt_set_video(qtfile, 1, w, h, vob->ex_fps,qt_codec_info[0]);
-#else
 	fprintf(stderr, "\n \n  %i \n \n", tc_quicktime_get_timescale(vob->ex_fps));
         /* set proposed video codec */
         lqt_set_video(qtfile, 1, w, h,
 		tc_quicktime_get_timescale(vob->ex_fps) / vob->ex_fps+0.5,
 		tc_quicktime_get_timescale(vob->ex_fps), qt_codec_info[0]);
-#endif
     }
 
     /* set color model */
diff -aur ../transcode/import/decode_mov.c transcode/import/decode_mov.c
--- ../transcode/import/decode_mov.c	2007-01-14 16:17:34.000000000 +0100
+++ transcode/import/decode_mov.c	2007-01-14 18:17:22.000000000 +0100
@@ -121,7 +121,7 @@
 					p_write (decode->fd_out, p_buffer, s_buff_size);
 				}
 			}
-      			else 
+            else 
 			{
 				s_sample >>= 1;
 				p_mask1=(short *)p_buffer;
@@ -153,29 +153,7 @@
 				free(p_mask2);
 			}
 			free(p_buffer);
-		} 
-#if !defined(LIBQUICKTIME_000904)
-		else if((strcasecmp(p_a_codec,QUICKTIME_RAW)==0) || (strcasecmp(p_a_codec,QUICKTIME_TWOS)==0)) 
-		{
-			s_sample=(1.00 * s_channel * s_bits *s_audio_rate)/(s_fps*8);
-			s_buff_size=s_sample * sizeof(short);
-			p_buffer=(char *)malloc(s_buff_size);
-			s_qt_pos=quicktime_audio_position(p_qt_structure,0);
-			quicktime_set_audio_position(p_qt_structure,s_qt_pos+decode->frame_limit[0],0);
-			for (;s_audio_size>0;s_audio_size-=s_buff_size)
-			{
-				if ( quicktime_read_audio(p_qt_structure,p_buffer, s_buff_size, 0) < 0)
-				{
-					quicktime_close(p_qt_structure);
-					fprintf(stderr,"(%s) error: reading quicktime audio frame\n",__FILE__);
-					import_exit(1);
-				}
-				p_write (decode->fd_out, p_buffer, s_buff_size);
-			}
-			quicktime_close(p_qt_structure);
-			free(p_buffer);
 		}
-#endif
 		else 
 		{
 			quicktime_close(p_qt_structure);
Nur in transcode/import: decode_mov.c~.
diff -aur ../transcode/import/fileinfo.c transcode/import/fileinfo.c
--- ../transcode/import/fileinfo.c	2007-01-14 16:17:34.000000000 +0100
+++ transcode/import/fileinfo.c	2007-01-14 17:20:16.000000000 +0100
@@ -433,6 +433,7 @@
   if(strncasecmp(buf+4,"moov", 4) ==0 ||
      strncasecmp(buf+4,"cmov", 4) ==0 ||
      strncasecmp(buf+4,"mdat", 4) ==0 ||
+     strncasecmp(buf+4,"ftyp", 4) ==0 ||
      strncasecmp(buf+4,"pnot", 4) ==0) {
     id = TC_MAGIC_MOV;
     goto exit;
diff -aur ../transcode/import/import_mov.c transcode/import/import_mov.c
--- ../transcode/import/import_mov.c	2007-01-14 16:17:34.000000000 +0100
+++ transcode/import/import_mov.c	2007-01-14 19:18:02.000000000 +0100
@@ -50,9 +50,6 @@
 /* raw or decode frame */
 static int rawVideoMode = 0;
 
-/* raw or decode audio */
-static int rawAudioMode = 0;
-
 /* frame size */
 static int w=0, h=0;
 
@@ -138,18 +135,7 @@
     }
 
     /* check if audio compressor is supported */
-    if(quicktime_supported_audio(qt_audio, 0)!=0) {
-      rawAudioMode = 0;
-    } 
-#if !defined(LIBQUICKTIME_000904)
-    /* RAW PCM is directly supported */
-    else if(strcasecmp(codec,QUICKTIME_RAW)==0) {
-      rawAudioMode = 1;
-      fprintf(stderr,"[%s] using RAW audio mode!\n",MOD_NAME);
-    }
-#endif
-    /* unsupported codec */
-    else {
+    if(!quicktime_supported_audio(qt_audio, 0)) {
       fprintf(stderr, "error: quicktime audio codec '%s' not supported!\n",
 	      codec);
       return(TC_IMPORT_ERROR);
@@ -162,7 +148,9 @@
     double fps;
     char *codec;
     int numTrk;
-
+    int rowspan = 0;
+    int rowspan_uv = 0;
+    
     param->fd = NULL;
 
     /* open movie for video extraction */
@@ -207,20 +195,19 @@
 	     return(TC_IMPORT_ERROR);
     }
 
-
     /* set color model */
     switch(vob->im_v_codec) {
         case CODEC_RGB:
               /* use raw mode when possible */
               /* not working ?*/
-              /*if (strcmp(qt_codec, "raw ")) rawVideo=1; */
-	      	    /* allocate buffer for row pointers */
-	      	    row_ptr = malloc(h*sizeof(char *));
-	      	    if(row_ptr==0) {
-		        fprintf(stderr,"error: can't alloc row pointers\n");
-			return(TC_IMPORT_ERROR);
-	      	    }
-
+              /* if (strcmp(qt_codec, "raw ")) rawVideo=1; */
+              /* allocate buffer for row pointers */
+              row_ptr = lqt_rows_alloc(w, h, BC_RGB888, &rowspan, &rowspan_uv);
+              if(row_ptr==0) {
+                  fprintf(stderr,"error: can't alloc row pointers\n");
+                  return(TC_IMPORT_ERROR);
+              }
+              
               quicktime_set_cmodel(qt_video, BC_RGB888); qt_cm = BC_RGB888;
               break;
               
@@ -228,15 +215,16 @@
               /* use raw mode when possible */
               /* not working ?*/
               /* if (strcmp(qt_codec, "yv12")) rawVideo=1; */
-	      	    /* allocate buffer for row pointers */
-	      	    row_ptr = malloc(3*sizeof(char *));
-                    if(row_ptr==0) {
-		        fprintf(stderr,"error: can't alloc row pointers\n");
-			return(TC_IMPORT_ERROR);
-	      	    }
-
+              /* allocate buffer for row pointers */
+              row_ptr = lqt_rows_alloc(w, h, BC_YUV420P, &rowspan, &rowspan_uv);
+              if(row_ptr==0) {
+                  fprintf(stderr,"error: can't alloc row pointers\n");
+                  return(TC_IMPORT_ERROR);
+              }
+              
               quicktime_set_cmodel(qt_video, BC_YUV420P); qt_cm = BC_YUV420P;
               break;
+
 /*TODO: implement YUV2  / Passthrough has issues */
         case CODEC_YUV422:
               /*fprintf(stderr," using yuv422\n"); */                 
@@ -342,80 +330,71 @@
       param->size=0;
       return(TC_IMPORT_OK);
     }
+    
+    /* decode audio mode */
+    long pos = quicktime_audio_position(qt_audio,0);
+    long samples = param->size;
+
+    if(bits==16) samples >>= 1;
+
+    /* mono */
+    if(chan==1) {
+      /* direct copy */
+      bytes_read = quicktime_decode_audio(qt_audio,
+                          (int16_t *)param->buffer,NULL,
+                          samples,0);
+
+      /* check result */
+      if(bytes_read<0) {
+        if(verbose & TC_DEBUG) 
+          fprintf(stderr,"error: reading quicktime audio frame!\n");
+        return(TC_IMPORT_ERROR);
+      }
+    }
+    /* stereo */
+    else {
+      int16_t *tgt;
+      int16_t *tmp;
+      int s,t;
+      
+      samples >>= 1;
+      tgt = (int16_t *)param->buffer;
+      tmp = (int16_t *)malloc(samples*sizeof(int16_t));
+      
+      /* read first channel into target buffer */
+      bytes_read = quicktime_decode_audio(qt_audio,tgt,NULL,samples,0);
+      if(bytes_read<0) {
+        if(verbose & TC_DEBUG) 
+          fprintf(stderr,"error: reading quicktime audio frame!\n");
+        return(TC_IMPORT_ERROR);
+      }
 
-    /* raw read mode */
-#if !defined(LIBQUICKTIME_000904)
-    if(rawAudioMode) {
-      bytes_read = quicktime_read_audio(qt_audio, 
-					param->buffer, param->size, 0);
-    } else
-#endif
-    {
-      /* decode audio mode */
-      long pos = quicktime_audio_position(qt_audio,0);
-      long samples = param->size;
-      if(bits==16)
-	samples >>= 1;
-
-      /* mono */
-      if(chan==1) {
-	/* direct copy */
-	bytes_read = quicktime_decode_audio(qt_audio,
-					    (int16_t *)param->buffer,NULL,
-					    samples,0);
-
-	/* check result */
-	if(bytes_read<0) {
-	  if(verbose & TC_DEBUG) 
-	    fprintf(stderr,"error: reading quicktime audio frame!\n");
-	  return(TC_IMPORT_ERROR);
-	}
+      /* read second channel in temp buffer */
+      quicktime_set_audio_position(qt_audio,pos,0);
+      bytes_read = quicktime_decode_audio(qt_audio,tmp,NULL,samples,1);
+      if(bytes_read<0) {
+        if(verbose & TC_DEBUG) 
+          fprintf(stderr,"error: reading quicktime audio frame!\n");
+        return(TC_IMPORT_ERROR);
       }
-      /* stereo */
-      else {
-	int16_t *tgt;
-	int16_t *tmp;
-	int s,t;
-
-	samples >>= 1;
-	tgt = (int16_t *)param->buffer;
-	tmp = (int16_t *)malloc(samples*sizeof(int16_t));
-
-	/* read first channel into target buffer */
-	bytes_read = quicktime_decode_audio(qt_audio,tgt,NULL,samples,0);
-	if(bytes_read<0) {
-	  if(verbose & TC_DEBUG) 
-	    fprintf(stderr,"error: reading quicktime audio frame!\n");
-	  return(TC_IMPORT_ERROR);
-	}
-
-	/* read second channel in temp buffer */
-	quicktime_set_audio_position(qt_audio,pos,0);
-	bytes_read = quicktime_decode_audio(qt_audio,tmp,NULL,samples,1);
-	if(bytes_read<0) {
-	  if(verbose & TC_DEBUG) 
-	    fprintf(stderr,"error: reading quicktime audio frame!\n");
-	  return(TC_IMPORT_ERROR);
-	}
-
-	/* spread first channel */
-	for(s=samples-1;s>=0;s--)
-	  tgt[s<<1] = tgt[s];
-
-	/* fill in second channel from temp buffer */
-	t = 1;
-	for(s=0;s<samples;s++) {
-	  tgt[t] = tmp[s];
-	  t += 2;
-	}
 
-	free(tmp);
+      /* spread first channel */
+      for(s=samples-1;s>=0;s--)
+        tgt[s<<1] = tgt[s];
+
+      /* fill in second channel from temp buffer */
+      t = 1;
+      for(s=0;s<samples;s++) {
+        tgt[t] = tmp[s];
+        t += 2;
       }
-      quicktime_set_audio_position(qt_audio,pos+samples,0);
+      
+      free(tmp);
     }
+    quicktime_set_audio_position(qt_audio,pos+samples,0);
 
     return(TC_IMPORT_OK);
-  }
+    }
 
   return(TC_IMPORT_ERROR);
 }

Reply via email to