dvd::rip

->ABOUT / NEWS

->DOCUMENTATION
-TABLE OF CONTENTS
-INSTALLATION
-USING THE GUI
-CLUSTER MODE
-FAQ

->KEY FEATURES

->DOWNLOAD

->SUPPORT

->TRANSLATIONS

->MAILING LIST
-SEARCH ARCHIVE

->CHANGE LOG

->CREDITS

->TODO

->LINKS

http://www.exit1.org/


Re: [dvd::rip] Patch: add "auto clip only" as a zoom/clip preset

Subject: Re: [dvd::rip] Patch: add "auto clip only" as a zoom/clip preset
From: Jörn Reder <joern@xxxxxx>
Date: Sun, 13 Jan 2008 15:07:21 +0100
Marc Sherman wrote:

> The attached patch adds a new zoom/clip preset, which does auto-clipping 
> but no zooming. It also sets the "additional options" for the transcode 
> command to the appropriate --export_par setting according to the probed 
> aspect ratio of the title.

Hmm, it also adds AC3 passthrough and 192kb audio bitrate by default, 
but Ok ;)

Thanks for your patch. I had to modify it a bit, because the 
--export_par option has to be set (and probably cleared) everytime the 
user applies a (another) preset. Also it must take the current 
resolution (NTSC/PAL) into account, not just the aspect ratio of the 
original video. As well --export_par should be set if the user decides 
to keep the original anamorph picture size completely unchanged. In 
simple words: it has to be used if the user decides not to resize the 
picture (regardless wether using your new "Autoadjust, Clipping only" 
preset or not).

Attached you find my version of the patch against vanilla 0.98.8.

This patch also adds a new preset option "Default Clip & Zoom preset", 
amongst others to satisfy Mate SOOS being so unsatisfied by transcode's
fast resizing and the dvd::rip developer's default preset decision ;)

Funny enough, with this --export_par/anamorph patch image resizing is 
not necessary anymore at all ;) (asuming your player is able to detect 
the aspect ratio written into the avi/ogg file correctly).

Please test the patch. It will be part of the next dvd::rip release, if
nobody reports problems.

> Is the the right way to submit patches? Or would you prefer something 
> different?

Submitting patches is always the right way ;). Either to the list or 
straight to me.

Regards,

Jörn

-- 
LINUX - Linux Is Not gnU linuX
Index: lib/Video/DVDRip/Config.pm
===================================================================
RCS file: /home/cvsroot/dvdrip/lib/Video/DVDRip/Config.pm,v
retrieving revision 1.67.2.1
diff -u -r1.67.2.1 Config.pm
--- lib/Video/DVDRip/Config.pm  9 Aug 2007 21:34:30 -0000       1.67.2.1
+++ lib/Video/DVDRip/Config.pm  13 Jan 2008 14:06:59 -0000
@@ -306,6 +306,12 @@
             [ 0       => __"Don't grab subtitles" ],
         ],
     },
+    default_preset => {
+        label   => __"Default Clip & Zoom preset",
+        type    => "popup",
+        value   => "auto_medium_fast",
+        presets => [],
+    },
     preferred_lang => {
         label   => __ "Preferred language",
         type    => 'popup',
@@ -363,6 +369,7 @@
             default_container
             ogg_file_ext
             default_bpp
+            default_preset
             default_subtitle_grab
             workaround_nptl_bugs nptl_ld_assume_kernel
             )
@@ -373,13 +380,11 @@
 
 sub new {
     my $type             = shift;
-    my %config_parameter = %CONFIG_PARAMETER;
-    my @config_order     = @CONFIG_ORDER;
 
     my @presets = (
         Video::DVDRip::Preset->new(
             name              => "nopreset",
-            title             => __ "- No Modifications -",
+            title             => __ "- No Modifications (anamorph) -",
             tc_clip1_top      => 0,
             tc_clip1_bottom   => 0,
             tc_clip1_left     => 0,
@@ -394,6 +399,11 @@
             tc_fast_bisection => 0,
         ),
         Video::DVDRip::Preset->new(
+            name           => "auto_clip",
+            title          => __ "Autoadjust, Clipping only (anamorph)",
+            auto_clip      => 1,
+        ),
+        Video::DVDRip::Preset->new(
             name           => "auto_big",
             title          => __ "Autoadjust, Big Frame Size, HQ Resize",
             tc_fast_resize => 0,
@@ -629,6 +639,16 @@
         ),
     );
 
+    my $default_presets_lref = $CONFIG_PARAMETER{"default_preset"}->{presets};
+    
+    foreach my $preset ( @presets ) {
+        push @{$default_presets_lref}, 
+            [ $preset->name, $preset->title ];
+    }
+
+    my %config_parameter = %CONFIG_PARAMETER;
+    my @config_order     = @CONFIG_ORDER;
+
     my $self = {
         config  => \%config_parameter,
         order   => \@config_order,
Index: lib/Video/DVDRip/Preset.pm
===================================================================
RCS file: /home/cvsroot/dvdrip/lib/Video/DVDRip/Preset.pm,v
retrieving revision 1.11
diff -u -r1.11 Preset.pm
--- lib/Video/DVDRip/Preset.pm  16 Aug 2006 19:34:38 -0000      1.11
+++ lib/Video/DVDRip/Preset.pm  13 Jan 2008 14:06:59 -0000
@@ -19,6 +19,7 @@
 sub name                       { shift->{name}                         }
 sub title                      { shift->{title}                        }
 sub auto                       { shift->{auto}                         }
+sub auto_clip                  { shift->{auto_clip}                    }
 sub frame_size                 { shift->{frame_size}                   }
 
 sub tc_clip1_top               { shift->{tc_clip1_top}                 }
@@ -36,6 +37,7 @@
 sub set_name                   { shift->{name}                 = $_[1] }
 sub set_title                  { shift->{title}                = $_[1] }
 sub set_auto                   { shift->{auto}                 = $_[1] }
+sub set_auto_clip              { shift->{auto_clip}            = $_[1] }
 sub set_frame_size             { shift->{frame_size}           = $_[1] }
 sub set_tc_clip1_top           { shift->{tc_clip1_top}         = $_[1] }
 sub set_tc_clip1_bottom                { shift->{tc_clip1_bottom}      = $_[1] 
}
@@ -68,12 +70,13 @@
         'tc_clip2_top',  'tc_clip2_bottom',
         'tc_clip2_left', 'tc_clip2_right'
         };
-    my ( $auto, $frame_size ) = @par{ 'auto', 'frame_size' };
+    my ( $auto, $auto_clip, $frame_size ) = @par{ 'auto', 'auto_clip', 
'frame_size' };
 
     my $self = {
         name            => $name,
         title           => $title,
         auto            => $auto,
+        auto_clip       => $auto_clip,
         frame_size      => $frame_size,
         tc_clip1_top    => $tc_clip1_top,
         tc_clip1_bottom => $tc_clip1_bottom,
Index: lib/Video/DVDRip/Title.pm
===================================================================
RCS file: /home/cvsroot/dvdrip/lib/Video/DVDRip/Title.pm,v
retrieving revision 1.180.2.5
diff -u -r1.180.2.5 Title.pm
--- lib/Video/DVDRip/Title.pm   5 Aug 2007 16:59:15 -0000       1.180.2.5
+++ lib/Video/DVDRip/Title.pm   13 Jan 2008 14:06:59 -0000
@@ -680,6 +680,11 @@
     return $self->tc_container eq 'vcd';
 }
 
+sub is_resized {
+    my $self = shift;
+    return $self->tc_zoom_width != 0 and $self->tc_zoom_height != 0;
+}
+
 sub has_vbr_audio {
     my $self = shift;
 
@@ -1107,21 +1112,31 @@
 
     $self->set_last_applied_preset( $preset->name );
 
-    if ( $preset->auto ) {
+    if ( $preset->auto_clip ) {
+        $self->auto_adjust_clip_only;
+    }
+    elsif ( $preset->auto ) {
         $self->auto_adjust_clip_zoom(
             frame_size  => $preset->frame_size,
             fast_resize => $preset->tc_fast_resize,
         );
-        return 1;
     }
-
-    my $attributes = $preset->attributes;
-    my $set_method;
-    foreach my $attr ( @{$attributes} ) {
-        $set_method = "set_$attr";
-        $self->$set_method( $preset->$attr() );
+    else {
+        my $attributes = $preset->attributes;
+        my $set_method;
+        foreach my $attr ( @{$attributes} ) {
+            $set_method = "set_$attr";
+            $self->$set_method( $preset->$attr() );
+        }
     }
-
+    
+    if ( $self->is_resized ) {
+        $self->clear_export_par;
+    }
+    else {
+        $self->calc_export_par;
+    }
+    
     1;
 }
 
@@ -1236,6 +1251,67 @@
     return ( $clip2_width, $clip2_height, $zoom_ratio );
 }
 
+sub clear_export_par {
+    my $self = shift;
+    
+    my $tc_options = $self->tc_options;
+    $tc_options =~ s/--export_par\s+[^\s]+/ /;
+    $self->set_tc_options($tc_options);
+
+    1;
+}
+
+sub calc_export_par {
+    my $self = shift;
+
+    my %export_par_table = (
+        "ntsc-16:9" => 5,
+        "ntsc-4:3"  => 3,
+        "pal-16:9"  => 4,
+        "pal-4:3"   => 2,
+    );
+
+    $self->clear_export_par;
+
+    my $export_par = 
$export_par_table{$self->video_mode."-".$self->aspect_ratio};
+    return unless $export_par;
+    
+    my $tc_options = $self->tc_options." --export_par $export_par";
+    $tc_options =~ s/\s+//;
+    $self->set_tc_options($tc_options);
+
+    1;
+}
+
+sub auto_adjust_clip_only {
+    my $self = shift;
+
+    $self->set_tc_fast_resize(1);
+
+    my $result = $self->get_zoom_parameters(
+        target_width        => undef,
+        target_height       => undef,
+        fast_resize_align   => 16,
+        result_align        => 16,
+        result_align_clip2  => 1,
+        auto_clip           => 1,
+        use_clip1           => 0,
+    );
+
+    $self->set_tc_zoom_width( undef );
+    $self->set_tc_zoom_height( undef );
+    $self->set_tc_clip1_left( 0 );
+    $self->set_tc_clip1_right( 0 );
+    $self->set_tc_clip1_top( 0 );
+    $self->set_tc_clip1_bottom( 0 );
+    $self->set_tc_clip2_left( $result->{clip2_left} );
+    $self->set_tc_clip2_right( $result->{clip2_right} );
+    $self->set_tc_clip2_top( $result->{clip2_top} );
+    $self->set_tc_clip2_bottom( $result->{clip2_bottom} );
+
+    1;
+}
+
 sub auto_adjust_clip_zoom {
     my $self = shift;
     my %par  = @_;
@@ -2060,7 +2136,7 @@
         $self->set_tc_container('vcd');
     }
 
-    $self->set_preset("auto_medium_fast")
+    $self->set_preset($self->config("default_preset"))
         unless $self->last_applied_preset;
 
     my $subtitle_langs = $self->get_subtitle_languages;
@@ -4038,7 +4114,7 @@
     croak "msg:" . __ "No subtitle selected" if not $subtitle;
 
     my $clip2_bottom = $self->tc_clip2_bottom;
-    my $zoom_height  = $self->tc_zoom_height;
+    my $zoom_height  = $self->tc_zoom_height || $self->height;
     my $pre_zoom_height
         = $self->height - $self->tc_clip1_top - $self->tc_clip1_bottom;
     my $scale = $pre_zoom_height / $zoom_height;

Attachment: pgpr86EUSDF1Y.pgp
Description: PGP signature

 

Archive powered by MHonArc. Search powered by ht://dig.

[ top ]