]> granicus.if.org Git - handbrake/commitdiff
This patch from superdump lets muxmp4.c set a Height Ratio for the QuickTime transfor...
authorjbrjake <jb.rubin@gmail.com>
Tue, 16 Oct 2007 18:29:11 +0000 (18:29 +0000)
committerjbrjake <jb.rubin@gmail.com>
Tue, 16 Oct 2007 18:29:11 +0000 (18:29 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1027 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/muxmp4.c

index 4f7c4ebc271b6029cbf099c6659dc8f71f69411b..2f375e8324b3c639f4aaf6c5a927a8c1c41c44f5 100644 (file)
@@ -252,21 +252,34 @@ static int MP4Init( hb_mux_object_t * m )
                        memcpy(nval, val, size);
 
                        float width, height;
-                       float widthRatio;
                        width = job->pixel_aspect_width;
                        height = job->pixel_aspect_height;
-                       widthRatio = (width / height) * 0x10000;
 
-                       uint32_t widthRatioInt;
-                       widthRatioInt = (uint32_t)widthRatio;
+           uint32_t pixelRatioInt;
+           if (width >= height)
+           {
+               pixelRatioInt = (uint32_t)((width / height) * 0x10000);
 
 #ifdef WORDS_BIGENDIAN
-                       ptr32[0] = widthRatioInt;
+               ptr32[0] = pixelRatioInt;
 #else
-                       /* we need to switch the endianness, as the file format expects big endian */
-                       ptr32[0] = ((widthRatioInt & 0x000000FF) << 24) + ((widthRatioInt & 0x0000FF00) << 8) + ((widthRatioInt & 0x00FF0000) >> 8) + ((widthRatioInt & 0xFF000000) >> 24);
+               /* we need to switch the endianness, as the file format expects big endian */
+               ptr32[0] = ((pixelRatioInt & 0x000000FF) << 24) + ((pixelRatioInt & 0x0000FF00) << 8) + ((pixelRatioInt & 0x00FF0000) >> 8) + ((pixelRatioInt & 0xFF000000) >> 24);
 #endif
 
+           }
+           else
+           {
+               pixelRatioInt = (uint32_t)((height / width) * 0x10000);
+#ifdef WORDS_BIGENDIAN
+               ptr32[4] = pixelRatioInt;
+#else
+                /* we need to switch the endianness, as the file format expects big endian */
+                ptr32[4] = ((pixelRatioInt & 0x000000FF) << 24) + ((pixelRatioInt & 0x0000FF00) << 8) + ((pixelRatioInt & 0x00FF0000) >> 8) + ((pixelRatioInt & 0xFF000000) >> 24);
+#endif
+            }
+
+
                        if(!MP4SetBytesProperty(m->file, "moov.trak.tkhd.reserved3", nval, size)) {
                                hb_log("Problem setting transform matrix");
                        }