]> granicus.if.org Git - handbrake/commitdiff
libhb: when doing main feature search, skip prohibited buttons.
authorjstebbins <jstebbins.hb@gmail.com>
Wed, 6 Jul 2011 20:41:47 +0000 (20:41 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Wed, 6 Jul 2011 20:41:47 +0000 (20:41 +0000)
There is a field in the prohibited user operations PCI flags that
says when the user can push buttons.  If they are prohibited, we
shouldn't push them when searching for the main feature since they
would not be accessible on a dvd player.

This fixes selection of "fake" titles on some discs.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4085 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/dvdnav.c

index 9ccaffc8fe1a87f2330e8f4071b7921c1a9b7c4b..60e1d81f0422d1afbcc5d836b3a2df35e04784b3 100644 (file)
@@ -917,6 +917,10 @@ static int try_button( dvdnav_t * dvdnav, int menu_id, int button, hb_list_t * l
     int longest = -1;
 
     pci_t *pci = dvdnav_get_current_nav_pci( dvdnav );
+    int prohibit_button = *(uint32_t*)&pci->pci_gi.vobu_uop_ctl & (1 << 17);
+    if ( prohibit_button )
+        return -1;
+
     result = dvdnav_button_select_and_activate( dvdnav, pci, button + 1 );
     if (result != DVDNAV_STATUS_OK)
     {
@@ -958,7 +962,7 @@ static int try_button( dvdnav_t * dvdnav, int menu_id, int button, hb_list_t * l
             if ( result == DVDNAV_STATUS_ERR )
             {
                 hb_error("dvdnav: Read Error, %s", dvdnav_err_to_string(dvdnav));
-                return 0;
+                return -1;
             }
             switch ( event )
             {
@@ -1012,7 +1016,7 @@ static int try_button( dvdnav_t * dvdnav, int menu_id, int button, hb_list_t * l
                 break;
 
             case DVDNAV_STOP:
-                return 0;
+                return -1;
 
             case DVDNAV_HOP_CHANNEL:
                 break;
@@ -1156,48 +1160,52 @@ static int try_menu(
                 if ( pci == NULL ) break;
 
                 buttons = pci->hli.hl_gi.btn_ns;
-                if ( cur_title == 0 && buttons > 1 )
+                int prohibit_button = *(uint32_t*)&pci->pci_gi.vobu_uop_ctl & (1 << 17);
+                if ( !prohibit_button )
                 {
-                    int menu_title, menu_id;
-                    result = dvdnav_current_title_info( d->dvdnav, &menu_title, &menu_id );
-                    if (result != DVDNAV_STATUS_OK)
-                        hb_log("dvdnav cur pgcn err: %s", dvdnav_err_to_string(d->dvdnav));
-                    for (kk = 0; kk < buttons; kk++)
+                    if ( cur_title == 0 && buttons > 1 )
                     {
-                        dvdnav_t *dvdnav_copy;
-
-                        result = dvdnav_dup( &dvdnav_copy, d->dvdnav );
+                        int menu_title, menu_id;
+                        result = dvdnav_current_title_info( d->dvdnav, &menu_title, &menu_id );
                         if (result != DVDNAV_STATUS_OK)
+                            hb_log("dvdnav cur pgcn err: %s", dvdnav_err_to_string(d->dvdnav));
+                        for (kk = 0; kk < buttons; kk++)
                         {
-                            hb_log("dvdnav dup failed: %s", dvdnav_err_to_string(d->dvdnav));
-                            goto done;
-                        }
-                        title = try_button( dvdnav_copy, menu_id, kk, list_title );
-                        dvdnav_free_dup( dvdnav_copy );
+                            dvdnav_t *dvdnav_copy;
 
-                        if ( title >= 0 )
-                        {
-                            hb_title_t * hbtitle;
-                            int index;
-                            index = find_title( list_title, title );
-                            hbtitle = hb_list_item( list_title, index );
-                            if ( hbtitle != NULL )
+                            result = dvdnav_dup( &dvdnav_copy, d->dvdnav );
+                            if (result != DVDNAV_STATUS_OK)
+                            {
+                                hb_log("dvdnav dup failed: %s", dvdnav_err_to_string(d->dvdnav));
+                                goto done;
+                            }
+                            title = try_button( dvdnav_copy, menu_id, kk, list_title );
+                            dvdnav_free_dup( dvdnav_copy );
+
+                            if ( title >= 0 )
                             {
-                                if ( hbtitle->duration > longest_duration )
+                                hb_title_t * hbtitle;
+                                int index;
+                                index = find_title( list_title, title );
+                                hbtitle = hb_list_item( list_title, index );
+                                if ( hbtitle != NULL )
                                 {
-                                    longest_duration = hbtitle->duration;
-                                    longest = title;
-                                    if ((float)fallback_duration * 0.75 < longest_duration)
-                                        goto done;
+                                    if ( hbtitle->duration > longest_duration )
+                                    {
+                                        longest_duration = hbtitle->duration;
+                                        longest = title;
+                                        if ((float)fallback_duration * 0.75 < longest_duration)
+                                            goto done;
+                                    }
                                 }
                             }
                         }
+                        goto done;
+                    }
+                    if ( cur_title == 0 && buttons == 1 )
+                    {
+                        dvdnav_button_select_and_activate( d->dvdnav, pci, 1 );
                     }
-                    goto done;
-                }
-                if ( cur_title == 0 && buttons == 1 )
-                {
-                    dvdnav_button_select_and_activate( d->dvdnav, pci, 1 );
                 }
             } break;