OSDN Git Service

MacGui: Auto resize picture window to reflect proper anamorphic size in the Picture...
[handbrake-jp/handbrake-jp-git.git] / libhb / decmpeg2.c
index 77c6c0b..0c5d2ec 100644 (file)
@@ -25,7 +25,7 @@
 #define BTB_PROG 64
 #define TB_PROG 128
 #define TBT_PROG 256
-int cadence[6];
+int cadence[12];
 int flag = 0;
 
 /**********************************************************************
@@ -126,7 +126,7 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
         }
         else if( state == STATE_GOP && m->look_for_break == 2)
         {
-            printf("MPEG2: Group of pictures found, searching for I-Frame\n");
+            hb_log("MPEG2: Group of pictures found, searching for I-Frame");
             m->look_for_break = 1;
         }
         else if( ( state == STATE_SLICE || state == STATE_END ) &&
@@ -140,7 +140,7 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                 // If we are looking for a break, insert the chapter break on an I-Frame
                 if( m->look_for_break == 1 )
                 {
-                    printf("MPEG2: I-Frame Found\n");
+                    hb_log("MPEG2: I-Frame Found");
                     m->look_for_break = 0;
                     chap_break = 1;
                 }
@@ -154,7 +154,7 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                 // Was a good break point found?
                 if( chap_break )
                 {
-                    printf("MPEG2: Chapter Break Inserted\n");
+                    hb_log("MPEG2: Chapter Break Inserted");
                     chap_break = 0;
                     buf->new_chap = 1;
                 }
@@ -213,11 +213,11 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                 hb_log("fields: %d", m->info->display_picture->nb_fields);
 */             
                 /*  Rotate the cadence tracking. */
-                cadence[5] = cadence[4];
-                cadence[4] = cadence[3];
-                cadence[3] = cadence[2];
-                cadence[2] = cadence[1];
-                cadence[1] = cadence[0];
+                int i = 0;
+                for(i=11; i > 0; i--)
+                {
+                    cadence[i] = cadence[i-1];
+                }
                
                 if ( !(flag & PROGRESSIVE) && !(flag & TOP_FIRST) )
                 {
@@ -273,10 +273,10 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                     cadence[0] = TBT_PROG;
                 }
                                                
-                if ( (cadence[2] <= TB) && (cadence[1] <= TB) && (cadence[0] > TB) && (cadence[0]) && (cadence[1]) )
-                    hb_log("PTS %lld: Interlaced -> Progressive", buf->start);
-                if ( (cadence[2] > TB) && (cadence[1] <= TB) && (cadence[0] <= TB) && (cadence[0]) && (cadence[1]) )
-                    hb_log("PTS %lld: Progressive -> Interlaced", buf->start);
+                if ( (cadence[2] <= TB) && (cadence[1] <= TB) && (cadence[0] > TB) && (cadence[11]) )
+                    hb_log("%fs: Interlaced -> Progressive", (float)buf->start / 90000);
+                if ( (cadence[2] > TB) && (cadence[1] <= TB) && (cadence[0] <= TB) && (cadence[11]) )
+                    hb_log("%fs: Progressive -> Interlaced", (float)buf->start / 90000);
 
                 /* Store picture flags for later use by filters */
                 buf->flags = m->info->display_picture->flags;
@@ -378,7 +378,7 @@ int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
     // stream. We need to shift it.
     if( (*buf_in)->new_chap )
     {
-        printf("MPEG2: Chapter Break Cell Found, searching for GOP\n");
+        hb_log("MPEG2: Chapter Break Cell Found, searching for GOP");
         pv->libmpeg2->look_for_break = 2;
         (*buf_in)->new_chap = 0;
     }