changeset 31718:56e3df9c8aaa

Generate a ImageDescription if none is passed neither via ImageDesc nor extradata. Makes the ProRes decoder work with -demuxer lavf.
author reimar
date Sat, 24 Jul 2010 16:33:22 +0000
parents 9c9d8fe59b53
children 7a3b616b2dfb
files libmpcodecs/vd_qtvideo.c
diffstat 1 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_qtvideo.c	Sat Jul 24 15:14:43 2010 +0000
+++ b/libmpcodecs/vd_qtvideo.c	Sat Jul 24 16:33:22 2010 +0000
@@ -98,11 +98,11 @@
 // init driver
 static int init(sh_video_t *sh){
     OSErr result = 1;
+    int extradata_size = sh->bih ? sh->bih->biSize - sizeof(BITMAPINFOHEADER) : 0;
+    void *extradata = sh->bih + 1;
 
-    if (sh->ImageDesc == NULL) {
-        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"sh->ImageDesc not set, cannot use binary QuickTime codecs (try -demuxer mov?)\n");
-        return 0;
-    }
+    if (!sh->ImageDesc)
+        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"sh->ImageDesc not set, try -demuxer mov if this fails.\n");
 
 #ifndef CONFIG_QUICKTIME
 #ifdef WIN32_LOADER
@@ -156,10 +156,25 @@
 
     //Fill the imagedescription for our SVQ3 frame
     //we can probably get this from Demuxer
-    if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI
+    if (!sh->ImageDesc && extradata_size >= sizeof(ImageDescription) &&
+        ((ImageDescription *)extradata)->idSize <= extradata_size)
+        sh->ImageDesc = extradata;
+    if (sh->ImageDesc) {
     mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
     framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
     memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
+    } else {
+        // assume extradata consists only of the atoms, build the other parts
+        ImageDescription *idesc;
+        int size = sizeof(*idesc) + extradata_size;
+        mp_msg(MSGT_DECVIDEO, MSGL_V, "Generating a ImageDescription\n");
+        framedescHandle=(ImageDescriptionHandle)NewHandleClear(size);
+        idesc = *framedescHandle;
+        memcpy(idesc + 1, extradata, extradata_size);
+        idesc->idSize = size;
+        idesc->width  = sh->disp_w;
+        idesc->height = sh->disp_h;
+    }
     dump_ImageDescription(*framedescHandle);
 
     (**framedescHandle).cType = bswap_32(sh->format);