diff options
-rw-r--r-- | gtk/src/Makefile.am | 2 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 11 | ||||
-rw-r--r-- | gtk/src/ghb.m4 | 974 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 69 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 1 | ||||
-rw-r--r-- | gtk/src/internal_defaults.json | 1 | ||||
-rw-r--r-- | gtk/src/main.c | 15 | ||||
-rw-r--r-- | gtk/src/makedeps.py | 11 | ||||
-rw-r--r-- | gtk/src/presets.c | 26 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 17 | ||||
-rw-r--r-- | gtk/src/settings.h | 1 | ||||
-rw-r--r-- | gtk/src/videohandler.c | 56 | ||||
-rw-r--r-- | gtk/src/x264handler.c | 1110 | ||||
-rw-r--r-- | gtk/src/x264handler.h | 36 |
14 files changed, 13 insertions, 2317 deletions
diff --git a/gtk/src/Makefile.am b/gtk/src/Makefile.am index 9c3ed6b05..3aa246c3d 100644 --- a/gtk/src/Makefile.am +++ b/gtk/src/Makefile.am @@ -74,8 +74,6 @@ ghb_SOURCES = \ audiohandler.h \ subtitlehandler.c \ subtitlehandler.h \ - x264handler.c \ - x264handler.h \ main.c \ settings.c \ settings.h \ diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index ee778de34..103dc7694 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -88,7 +88,6 @@ #include "hb-backend.h" #include "ghb-dvd.h" #include "ghbcellrenderertext.h" -#include "x264handler.h" static void update_queue_labels(signal_user_data_t *ud); static void load_all_titles(signal_user_data_t *ud, int titleindex); @@ -4980,16 +4979,6 @@ hbfd_action_cb(GSimpleAction *action, GVariant *value, signal_user_data_t *ud) } G_MODULE_EXPORT void -advanced_video_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - g_debug("advanced_video_changed_cb"); - ghb_widget_to_setting(ud->prefs, widget); - const gchar *name = ghb_get_setting_key(widget); - ghb_pref_set(ud->prefs, name); - ghb_show_hide_advanced_video(ud); -} - -G_MODULE_EXPORT void activity_font_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4 index 5aa339cb1..e4f80c39b 100644 --- a/gtk/src/ghb.m4 +++ b/gtk/src/ghb.m4 @@ -3694,26 +3694,6 @@ to make bitrate allocation decisions.</property> <property name="margin-end">0</property> <property name="vexpand">True</property> <child> - <object class="GtkCheckButton" id="x264UseAdvancedOptions"> - <property name="label" translatable="yes">Use Advanced Options</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Use advanced options Tab for x264 settings. - -Use at your own risk!</property> - <property name="halign">start</property> - <property name="draw_indicator">True</property> - <property name="margin-top">2</property> - <property name="margin-bottom">2</property> - <signal name="toggled" handler="x264_use_advanced_options_changed_cb" swapped="no"/> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> <object class="GtkGrid" id="VideoSettingsTable"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -3744,7 +3724,7 @@ Use at your own risk!</property> <property name="tooltip_text" translatable="yes">Adjusts encoder settings to trade off compression efficiency against encoding speed. This establishes your default encoder settings. -Tunes, profiles, levels and advanced option string will be applied to this. +Tunes, profiles, levels and extra options string will be applied to this. You should generally set this option to the slowest you can bear since slower settings will result in better quality or smaller files.</property> <property name="adjustment">VideoPresetRange</property> @@ -3968,7 +3948,7 @@ Colon separated list of encoder options.</property> </child> </object> <packing> - <property name="position">1</property> + <property name="position">0</property> </packing> </child> </object> @@ -5408,928 +5388,6 @@ for determining subtitle selection settings when there is foreign audio.</proper </packing> </child> <child> - <object class="GtkBox" id="advanced_video_tab"> - <property name="orientation">horizontal</property> - <property name="visible">False</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <child> - <object class="GtkBox" id="x264_box"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="hexpand">True</property> - <child> - <object class="GtkBox" id="hbox73"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="spacing">2</property> - <child> - <object class="GtkBox" id="vbox21"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="hexpand">True</property> - <child> - <object class="GtkFrame" id="frame10"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkGrid" id="table6"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="column_spacing">4</property> - <property name="row-spacing">2</property> - <property name="margin-top">6</property> - <property name="margin-bottom">2</property> - <property name="margin-start">12</property> - <property name="margin-end">2</property> - <child> - <object class="GtkLabel" id="label49"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Reference Frames:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="x264_refs"> - <property name="halign">center</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Sane values are ~1-6. The more you add, the better the compression, but the slower the encode. -Cel animation tends to benefit from more reference frames a lot more than film content. - -Note that many hardware devices have limitations on the number of supported reference -frames, so if you're encoding for a handheld or standalone player, don't touch this unless -you're absolutely sure you know what you're doing!</property> - <property name="adjustment">adjustment8</property> - <signal name="value-changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label51"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Maximum B-Frames:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="x264_bframes"> - <property name="halign">center</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Sane values are ~2-5. This specifies the maximum number of sequential B-frames that the encoder can use. - -Large numbers generally won't help significantly unless Adaptive B-frames is set to Optimal. -Cel-animated source material and B-pyramid also significantly increase the usefulness of larger -values. - -Baseline profile, as required for iPods and similar devices, requires B-frames to be set to 0 (off).</property> - <property name="adjustment">adjustment9</property> - <signal name="value-changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label50"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Pyramidal B-Frames:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_bpyramid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">B-pyramid improves compression by creating a pyramidal structure (hence the name) -of B-frames, allowing B-frames to reference each other to improve compression. - -Requires Max B-frames greater than 1; optimal adaptive B-frames is strongly recommended for full compression benefit.</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label40"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Weighted P-Frames:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">3</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_weighted_pframes"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Performs extra analysis to decide upon weighting parameters for each frame. - -This improves overall compression slightly and improves the quality of fades greatly. - -Baseline profile, as required for iPods and similar devices, requires weighted P-frame -prediction to be disabled. Note that some devices and players, even those that support -Main Profile, may have problems with Weighted P-frame prediction: the Apple TV is -completely incompatible with it, for example.</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">3</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="x264_8x8dct"> - <property name="label" translatable="yes">8x8 Transform</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">The 8x8 transform is the single most useful feature of x264 in terms of compression-per-speed. - -It improves compression by at least 5% at a very small speed cost and may -provide an unusually high visual quality benefit compared to its compression -gain. However, it requires High Profile, which many devices may not support.</property> - <property name="halign">start</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">4</property> - <property name="left_attach">0</property> - <property name="width">2</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="x264_cabac"> - <property name="label" translatable="yes">CABAC Entropy Encoding</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">After the encoder has done its work, it has a bunch of data that -needs to be compressed losslessly, similar to ZIP or RAR. H.264 provides -two options for this: CAVLC and CABAC. CABAC decodes a lot slower but -compresses significantly better (10-30%), especially at lower bitrates. - -If you're looking to minimize CPU requirements for video playback, disable this option. -Baseline profile, as required for iPods and similar devices, requires CABAC to be disabled.</property> - <property name="halign">start</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">5</property> - <property name="left_attach">0</property> - <property name="width">2</property> - <property name="height">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label53"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes"><small><b>Encoding Features</b></small></property> - <property name="use_markup">True</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="vbox25"> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="hexpand">True</property> - <child> - <object class="GtkFrame" id="frame12"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <property name="margin-top">2</property> - <property name="margin-bottom">2</property> - <child> - <object class="GtkBox" id="hbox84"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="margin-start">12</property> - <child> - <object class="GtkGrid" id="table5"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="column_spacing">4</property> - <property name="row-spacing">2</property> - <property name="hexpand">True</property> - <child> - <object class="GtkLabel" id="label55"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Motion Est. Method:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_me"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Controls the motion estimation method. - -Motion estimation is how the encoder estimates how each block of pixels in a frame has moved. -A better motion search method improves compression at the cost of speed. - -Diamond: performs an extremely fast and simple search using a diamond pattern. -Hexagon: performs a somewhat more effective but slightly slower search using a hexagon pattern. -Uneven Multi-Hex: performs a very wide search using a variety of patterns, more accurately capturing complex motion. -Exhaustive: performs a "dumb" search of every pixel in a wide area. Significantly slower for only a small compression gain. -Transformed Exhaustive: Like exhaustive, but makes even more accurate decisions. Accordingly, somewhat slower, also for only a small improvement.</property> - <signal name="changed" handler="x264_me_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label58"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Subpel ME &amp; Mode:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_subme"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_markup" translatable="yes">This setting controls both subpixel-precision motion estimation and mode decision methods. - -Subpixel motion estimation is used for refining motion estimates beyond mere pixel accuracy, improving compression. -Mode decision is the method used to choose how to encode each block of the frame: a very important decision. -SAD is the fastest method, followed by SATD, RD, RD refinement, and the slowest, QPRD. -6 or higher is strongly recommended: Psy-RD, a very powerful psy optimization that helps retain detail, requires RD. -11 disables all early terminations in analysis. -10 and 11, the most powerful and slowest options, require adaptive quantization (aq-mode > 0) and trellis 2 (always).</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label57"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Motion Est. Range:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="x264_merange"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">This is the distance x264 searches from its initial guess at the -motion of a block in order to try to find its actual motion. - -The default is fine for most content, but extremely high motion video, -especially at HD resolutions, may benefit from higher ranges, albeit at -a high speed cost.</property> - <property name="adjustment">adjustment10</property> - <signal name="value-changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label52"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Adaptive Direct Mode:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">3</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_direct"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">H.264 allows for two different prediction modes, spatial and temporal, in B-frames. - -Spatial, the default, is almost always better, but temporal is sometimes useful too. -x264 can, at the cost of a small amount of speed (and accordingly for a small compression gain), -adaptively select which is better for each particular frame.</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">3</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label84"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Adaptive B-Frames:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">4</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_b_adapt"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_markup" translatable="yes">x264 has a variety of algorithms to decide when to use B-frames and how many to use. - -Fast mode takes roughly the same amount of time no matter how many B-frames you specify. -However, while fast, its decisions are often suboptimal. - -Optimal mode gets slower as the maximum number of B-Frames increases, -but makes much more accurate decisions, especially when used with B-pyramid.</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">4</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkGrid" id="table3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="column_spacing">4</property> - <property name="row-spacing">2</property> - <property name="margin-start">6</property> - <property name="hexpand">True</property> - <child> - <object class="GtkLabel" id="label59"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Partitions:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_analyse"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Mode decision picks from a variety of options to make its decision: -this option chooses what options those are. - -Fewer partitions to check means faster encoding, at the cost of worse -decisions, since the best option might have been one that was turned off.</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label62"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Trellis:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="x264_trellis"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Trellis fine-tunes the rounding of transform coefficients to -squeeze out 3-5% more compression at the cost of some speed. - -"Always" uses trellis not only during the main encoding process, but also -during analysis, which improves compression even more, albeit at great speed cost. - -Trellis costs more speed at higher bitrates and requires CABAC.</property> - <signal name="changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label60"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes"><small><b>Analysis</b></small></property> - <property name="use_markup">True</property> - </object> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkFrame" id="frame13"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkBox" id="vbox27"> - <property name="margin-top">6</property> - <property name="margin-bottom">2</property> - <property name="margin-start">12</property> - <property name="margin-end">2</property> - <property name="orientation">vertical</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <child> - <object class="GtkGrid" id="table9"> - <property name="row-spacing">2</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <child> - <object class="GtkLabel" id="label73"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Adaptive Quantization Strength:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkScale" id="x264_aq_strength"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Adaptive quantization controls how the encoder distributes bits across the frame. - -Higher values take more bits away from edges and complex areas to improve areas with finer detail.</property> - <property name="adjustment">adjustment34</property> - <property name="restrict_to_fill_level">False</property> - <property name="value_pos">right</property> - <signal name="format-value" handler="x264_format_slider_cb" swapped="no"/> - <signal name="value-changed" handler="x264_slider_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">0</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label82"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Psychovisual Rate Distortion:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkScale" id="x264_psy_rd"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Psychovisual rate-distortion optimization takes advantage of the characteristics of human -vision to dramatically improve apparent detail and sharpness. -The effect can be made weaker or stronger by adjusting the strength. -Being an RD algorithm, it requires mode decision to be at least "6".</property> - <property name="adjustment">adjustment22</property> - <property name="restrict_to_fill_level">False</property> - <property name="value_pos">right</property> - <signal name="format-value" handler="x264_format_slider_cb" swapped="no"/> - <signal name="value-changed" handler="x264_slider_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label83"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><small>Psychovisual Trellis:</small></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkScale" id="x264_psy_trell"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">Psychovisual trellis is an experimental algorithm to further -improve sharpness and detail retention beyond what Psychovisual RD does. - -Recommended values are around 0.2, though higher values may help for very -grainy video or lower bitrate encodes. Not recommended for cel animation -and other sharp-edged graphics.</property> - <property name="adjustment">adjustment23</property> - <property name="restrict_to_fill_level">False</property> - <property name="digits">2</property> - <property name="value_pos">right</property> - <signal name="format-value" handler="x264_format_slider_cb" swapped="no"/> - <signal name="value-changed" handler="x264_slider_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="hbox39"> - <property name="orientation">horizontal</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <child> - <object class="GtkLabel" id="label61"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="halign">start</property> - <property name="label" translatable="yes">Deblocking: </property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="x264_deblock_alpha"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_markup" translatable="yes">H.264 deblocking filter. - -h.264 has a built-in deblocking filter that smooths out blocking artifacts -after decoding each frame. This not only improves visual quality, but also -helps compression significantly. The deblocking filter takes a lot of CPU power, -so if you're looking to minimize CPU requirements for video playback, disable it. - -The deblocking filter has two adjustable parameters, "strength" (Alpha) and "threshold" (Beta). -The former controls how strong (or weak) the deblocker is, while the latter controls how many -(or few) edges it applies to. Lower values mean less deblocking, higher values mean more deblocking. -The default is 0 (normal strength) for both parameters.</property> - <property name="adjustment">adjustment11</property> - <signal name="value-changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="x264_deblock_beta"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_markup" translatable="yes">H.264 deblocking filter. - -h.264 has a built-in deblocking filter that smooths out blocking artifacts -after decoding each frame. This not only improves visual quality, but also -helps compression significantly. The deblocking filter takes a lot of CPU power, -so if you're looking to minimize CPU requirements for video playback, disable it. - -The deblocking filter has two adjustable parameters, "strength" (Alpha) and "threshold" (Beta). -The former controls how strong (or weak) the deblocker is, while the latter controls how many -(or few) edges it applies to. Lower values mean less deblocking, higher values mean more deblocking. -The default is 0 (normal strength) for both parameters.</property> - <property name="adjustment">adjustment12</property> - <signal name="value-changed" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="x264_no_dct_decimate"> - <property name="label" translatable="yes">No DCT Decimate</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip_text" translatable="yes">x264 normally zeroes out nearly-empty data blocks to save bits to -be better used for some other purpose in the video. However, this can -sometimes have slight negative effects on retention of subtle grain and -dither. - -Don't touch this unless you're having banding issues or other such cases -where you are having trouble keeping fine noise.</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <property name="hexpand">True</property> - <property name="halign">start</property> - <property name="margin-start">20</property> - <signal name="toggled" handler="x264_widget_changed_cb" swapped="no"/> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label63"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes"><small><b>Psychovisual</b></small></property> - <property name="use_markup">True</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkFrame" id="frame11"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <property name="vexpand">True</property> - <property name="margin-top">2</property> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow6"> - <property name="height_request">40</property> - <property name="margin-start">12</property> - <property name="margin-end">12</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="shadow_type">etched-in</property> - <property name="vexpand">True</property> - <child> - <object class="GtkTextView" id="x264Option"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip_text" translatable="yes">Your selected options will appear here. -You can edit these and add additional options. - -Default values will not be shown. The defaults are: -ref=3:bframes=3:b-adapt=fast:direct=spatial: -b-pyramid=normal:weightp=2:me=hex:merange=16: -subme=7:partitions=p8x8,b8x8,i8x8,i4x4:8x8dct=1: -deblock=0,0:trellis=1:psy-rd=1,0:aq-strength=1.0: -no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> - <property name="wrap_mode">char</property> - <property name="accepts_tab">False</property> - <property name="vexpand">True</property> - <signal name="focus-out-event" handler="x264_focus_out_cb" swapped="no"/> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label54"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes"><small><b>Current x264 Advanced Option String</b></small></property> - <property name="use_markup">True</property> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="position">6</property> - <property name="name">advanced_video_tab</property> - <property name="title" translatable="yes">Advanced Video</property> - </packing> - </child> - <child> <object class="GtkBox" id="chapters_tab"> <property name="orientation">vertical</property> <property name="visible">True</property> @@ -6384,7 +5442,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> </child> </object> <packing> - <property name="position">7</property> + <property name="position">6</property> <property name="name">chapters_tab</property> <property name="title" translatable="yes">Chapters</property> </packing> @@ -6688,7 +5746,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> </child> </object> <packing> - <property name="position">8</property> + <property name="position">7</property> <property name="name">metadata_tab</property> <property name="title" translatable="yes">Tags</property> </packing> @@ -7852,26 +6910,6 @@ filter_output([ </packing> </child> <child> - <object class="GtkCheckButton" id="HideAdvancedVideoSettings"> - <property name="label" translatable="yes">Hide Advanced Video Options Tab</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Use advanced video options at your own risk. -We recommend that you use the controls available -on the Video tab instead.</property> - <property name="halign">start</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="advanced_video_changed_cb" swapped="no"/> - </object> - <packing> - <property name="top_attach">7</property> - <property name="left_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> <object class="GtkCheckButton" id="RemoveFinishedJobs"> <property name="label" translatable="yes">Delete completed jobs from queue</property> <property name="visible">True</property> @@ -7884,7 +6922,7 @@ Check this if you want the queue to clean itself up by deleting completed jobs.< <signal name="toggled" handler="pref_changed_cb" swapped="no"/> </object> <packing> - <property name="top_attach">8</property> + <property name="top_attach">7</property> <property name="left_attach">0</property> <property name="width">1</property> <property name="height">1</property> @@ -7905,7 +6943,7 @@ Uncheck this if you want to allow changing each title's settings independently.< <signal name="toggled" handler="pref_changed_cb" swapped="no"/> </object> <packing> - <property name="top_attach">9</property> + <property name="top_attach">8</property> <property name="left_attach">0</property> <property name="width">1</property> <property name="height">1</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 3a6936fb7..6277f0106 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -35,7 +35,6 @@ #include "subtitlehandler.h" #include "audiohandler.h" #include "videohandler.h" -#include "x264handler.h" #include "preview.h" #include "presets.h" #include "values.h" @@ -608,54 +607,6 @@ combo_name_map_t combo_name_map[] = generic_opt_get }, { - "x264_direct", - &direct_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_b_adapt", - &badapt_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_bpyramid", - &bpyramid_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_weighted_pframes", - &weightp_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_me", - &me_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_subme", - &subme_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_analyse", - &analyse_opts, - small_opts_set, - generic_opt_get - }, - { - "x264_trellis", - &trellis_opts, - small_opts_set, - generic_opt_get - }, - { "AudioBitrate", NULL, audio_bitrate_opts_set, @@ -1248,8 +1199,6 @@ ghb_grey_combo_options(signal_user_data_t *ud) mux_id = ghb_dict_get_string(ud->settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); - grey_builder_combo_box_item(ud->builder, "x264_analyse", 4, TRUE); - const hb_encoder_t *enc; for (enc = hb_audio_encoder_get_next(NULL); enc != NULL; enc = hb_audio_encoder_get_next(enc)) @@ -3155,24 +3104,6 @@ init_ui_combo_boxes(GtkBuilder *builder) } } -// Construct the advanced options string -// The result is allocated, so someone must free it at some point. -const gchar* -ghb_build_advanced_opts_string(GhbValue *settings) -{ - gint vcodec; - vcodec = ghb_settings_video_encoder_codec(settings, "VideoEncoder"); - switch (vcodec) - { - case HB_VCODEC_X264_8BIT: - case HB_VCODEC_X264_10BIT: - return ghb_dict_get_string(settings, "x264Option"); - - default: - return NULL; - } -} - void ghb_part_duration(const hb_title_t *title, gint sc, gint ec, gint *hh, gint *mm, gint *ss) { diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 22b5c9629..7346c3d12 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -145,7 +145,6 @@ void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex); gint ghb_find_subtitle_track(const hb_title_t * title, const gchar * lang, int start); gint ghb_pick_subtitle_track(signal_user_data_t *ud); gint ghb_longest_title(void); -const gchar* ghb_build_advanced_opts_string(GhbValue *settings); GdkPixbuf* ghb_get_preview_image( const hb_title_t *title, gint index, signal_user_data_t *ud, gint *out_width, gint *out_height); diff --git a/gtk/src/internal_defaults.json b/gtk/src/internal_defaults.json index 7f7528100..5bc643eb1 100644 --- a/gtk/src/internal_defaults.json +++ b/gtk/src/internal_defaults.json @@ -75,7 +75,6 @@ "DiskFreeLimit": 10000, "RemoveFinishedJobs": false, "SyncTitleSettings": true, - "HideAdvancedVideoSettings": true, "AutoScan": false, "AddCC": false, "EncodeLogLocation": false, diff --git a/gtk/src/main.c b/gtk/src/main.c index 2203011b8..36e07e3eb 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -58,7 +58,6 @@ #include "queuehandler.h" #include "audiohandler.h" #include "subtitlehandler.h" -#include "x264handler.h" #include "settings.h" #include "resources.h" #include "presets.h" @@ -714,7 +713,6 @@ watch_volumes(signal_user_data_t *ud) #endif } -G_MODULE_EXPORT void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud); G_MODULE_EXPORT void video_option_changed_cb(GtkWidget *widget, signal_user_data_t *ud); G_MODULE_EXPORT void plot_changed_cb(GtkWidget *widget, signal_user_data_t *ud); G_MODULE_EXPORT void position_overlay_cb(GtkWidget *widget, signal_user_data_t *ud); @@ -1039,13 +1037,8 @@ ghb_activate_cb(GApplication * app, signal_user_data_t * ud) HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); - // Need to connect x264_options textview buffer to the changed signal - // since it can't be done automatically - GtkTextView *textview; - GtkTextBuffer *buffer; - textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "x264Option")); - buffer = gtk_text_view_get_buffer(textview); - g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); + GtkTextView * textview; + GtkTextBuffer * buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "VideoOptionExtra")); buffer = gtk_text_view_get_buffer(textview); @@ -1076,9 +1069,6 @@ ghb_activate_cb(GApplication * app, signal_user_data_t * ud) ghb_init_audio_defaults_ui(ud); ghb_init_subtitle_defaults_ui(ud); - // Parsing x264 options "" initializes x264 widgets to proper defaults - ghb_x264_init(ud); - // Load prefs before presets. Some preset defaults may depend // on preference settings. // First load default values @@ -1349,7 +1339,6 @@ main(int argc, char *argv[]) ghb_value_free(&ud->settings_array); ghb_value_free(&ud->prefs); ghb_value_free(&ud->globals); - ghb_value_free(&ud->x264_priv); if (ud->activity_log != NULL) g_io_channel_unref(ud->activity_log); diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index 4dae9d0e0..bd3da2efc 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -50,20 +50,9 @@ dep_map = ( DepEntry("PictureAutoCrop", "PictureBottomCrop", "0", False, False), DepEntry("PictureAutoCrop", "PictureLeftCrop", "0", False, False), DepEntry("PictureAutoCrop", "PictureRightCrop", "0", False, False), - DepEntry("x264_bframes", "x264_bpyramid", "<2", True, False), - DepEntry("x264_bframes", "x264_direct", "0", True, False), - DepEntry("x264_bframes", "x264_b_adapt", "0", True, False), - DepEntry("x264_subme", "x264_psy_rd", "<6", True, False), - DepEntry("x264_subme", "x264_psy_trell", "<6", True, False), - DepEntry("x264_trellis", "x264_psy_trell", "0", True, False), DepEntry("VideoEncoder", "x264FastDecode", "x264|x264_10bit", False, True), - DepEntry("VideoEncoder", "x264UseAdvancedOptions", "x264|x264_10bit", False, True), - DepEntry("HideAdvancedVideoSettings", "x264UseAdvancedOptions", "1", True, True), DepEntry("VideoEncoder", "VideoOptionExtraWindow", "x264|x264_10bit|x265|x265_10bit|x265_12bit|x265_16bit|mpeg4|mpeg2|VP8|VP9", False, True), DepEntry("VideoEncoder", "VideoOptionExtraLabel", "x264|x264_10bit|x265|x265_10bit|x265_12bit|x265_16bit|mpeg4|mpeg2|VP8|VP9", False, True), - DepEntry("x264UseAdvancedOptions", "VideoSettingsTable", "1", True, False), - DepEntry("VideoEncoder", "x264_box", "x264|x264_10bit", False, True), - DepEntry("x264UseAdvancedOptions", "x264_box", "0", True, False), DepEntry("auto_name", "autoname_box", "1", False, False), DepEntry("PresetCategory", "PresetCategoryName", "new", False, True), DepEntry("PresetCategory", "PresetCategoryEntryLabel", "new", False, True), diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 84c2d20a8..81b998a75 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -240,7 +240,7 @@ preset_is_folder(hb_preset_index_t *path) void ghb_preset_to_settings(GhbValue *settings, GhbValue *preset) { - // Remove troublesome x264Option + // Remove legacy x264Option ghb_dict_remove(settings, "x264Option"); // Initialize defaults @@ -318,21 +318,6 @@ ghb_preset_to_settings(GhbValue *settings, GhbValue *preset) ghb_dict_set_bool(settings, "VideoFramerateVFR", TRUE); } - if (ghb_dict_get_bool(settings, "x264UseAdvancedOptions")) - { - // Force preset/tune/profile/level/opts to conform to option string - ghb_dict_set_string(settings, "VideoPreset", "medium"); - ghb_dict_set_string(settings, "VideoTune", "none"); - ghb_dict_set_string(settings, "VideoProfile", "auto"); - ghb_dict_set_string(settings, "VideoLevel", "auto"); - ghb_dict_set(settings, "VideoOptionExtra", ghb_value_dup( - ghb_dict_get_value(settings, "x264Option"))); - } - else - { - ghb_dict_remove(settings, "x264Option"); - } - int encoder; const char *videoPreset; @@ -1725,15 +1710,6 @@ ghb_settings_to_preset(GhbValue *settings) GhbValue *copy_mask = ghb_create_copy_mask(preset); ghb_dict_set(preset, "AudioCopyMask", copy_mask); - if (ghb_dict_get_bool(preset, "x264UseAdvancedOptions")) - { - ghb_dict_remove(preset, "VideoPreset"); - ghb_dict_remove(preset, "VideoTune"); - ghb_dict_remove(preset, "VideoProfile"); - ghb_dict_remove(preset, "VideoLevel"); - ghb_dict_remove(preset, "VideoOptionExtra"); - } - GString *str = g_string_new(""); const char *sep = ""; const char *tune = ghb_dict_get_string(preset, "VideoTune"); diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index fe78fe342..46d31ebcb 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -569,8 +569,7 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite // Next line in the display (Video Encoder Options) // Video Options: Preset - Tune - Profile - Level - if ((video_encoder->codec & HB_VCODEC_X264_MASK) && - !ghb_dict_get_bool(uiDict, "x264UseAdvancedOptions")) + if (video_encoder->codec & HB_VCODEC_X264_MASK) { const gchar *extra_opt = NULL; @@ -626,20 +625,10 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict, GtkTreeIter *pite } // Next line in the display (Video Encoder Options) - // Video Advanced Options: detailed settings + // Video Extra Options: detailed settings if (extra_opt != NULL && extra_opt[0] != 0) { - XPRINT(_("<b>Advanced Options:</b> <small>%s</small>\n"), extra_opt); - } - } - else if (video_encoder->codec & HB_VCODEC_X264_MASK) - { - // Next line in the display (Video Encoder Options) - // Video Advanced Options: detailed settings - const gchar *opts = ghb_build_advanced_opts_string(uiDict); - if (opts != NULL && opts[0] != 0) - { - XPRINT(_("<b>Advanced Options:</b> <small>%s</small>\n"), opts); + XPRINT(_("<b>Extra Options:</b> <small>%s</small>\n"), extra_opt); } } diff --git a/gtk/src/settings.h b/gtk/src/settings.h index 38e2b1a40..d2ab79ee8 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -63,7 +63,6 @@ typedef struct gboolean scale_busy; gint cancel_encode; GtkBuilder * builder; - GhbValue * x264_priv; GhbValue * globals; GhbValue * prefs; GhbValue * settings; diff --git a/gtk/src/videohandler.c b/gtk/src/videohandler.c index a02e58426..152f5afb5 100644 --- a/gtk/src/videohandler.c +++ b/gtk/src/videohandler.c @@ -31,7 +31,6 @@ #include "presets.h" #include "preview.h" #include "hb-backend.h" -#include "x264handler.h" int ghb_get_video_encoder(GhbValue *settings) { @@ -106,12 +105,6 @@ vcodec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_set_video_preset(ud->settings, encoder, "medium"); GhbValue *gval = ghb_dict_get_value(ud->settings, "VideoPresetSlider"); ghb_ui_settings_update(ud, ud->settings, "VideoPresetSlider", gval); - - // Advanced options are only for x264 - if (!(encoder & HB_VCODEC_X264_MASK)) - { - ghb_ui_update(ud, "x264UseAdvancedOptions", ghb_boolean_value(FALSE)); - } } char *video_option_tooltip = NULL; @@ -126,8 +119,7 @@ update_adv_settings_tooltip(signal_user_data_t *ud) } int encoder = ghb_get_video_encoder(ud->settings); - if (!ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions") && - (encoder & HB_VCODEC_X264_MASK)) + if (encoder & HB_VCODEC_X264_MASK) { GString *str = g_string_new(""); const char *preset; @@ -195,10 +187,6 @@ update_adv_settings_tooltip(signal_user_data_t *ud) } new_opts = hb_x264_param_unparse(hb_video_encoder_get_depth(encoder), preset, tunes, opts, profile, level, w, h); - if (new_opts) - ghb_update_x264Option(ud, new_opts); - else - ghb_update_x264Option(ud, ""); GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); @@ -216,21 +204,6 @@ update_adv_settings_tooltip(signal_user_data_t *ud) g_free(tunes); } - else if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) - { - const char *opts = ghb_dict_get_string(ud->settings, "x264Option"); - - GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); - char * tt; - if (opts) - tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"%s\""), - video_option_tooltip, opts); - else - tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"\""), - video_option_tooltip); - gtk_widget_set_tooltip_text(eo, tt); - g_free(tt); - } } G_MODULE_EXPORT void @@ -280,33 +253,6 @@ video_setting_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } G_MODULE_EXPORT void -x264_use_advanced_options_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - ghb_widget_to_setting(ud->settings, widget); - - if (ghb_dict_get_bool(ud->prefs, "HideAdvancedVideoSettings") && - ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) - { - ghb_ui_update(ud, "x264UseAdvancedOptions", ghb_boolean_value(FALSE)); - return; - } - - if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) - { - ghb_ui_update(ud, "VideoPresetSlider", ghb_int_value(5)); - ghb_ui_update(ud, "VideoTune", ghb_string_value("none")); - ghb_ui_update(ud, "VideoProfile", ghb_string_value("auto")); - ghb_ui_update(ud, "VideoLevel", ghb_string_value("auto")); - - const char *options = ghb_dict_get_string(ud->settings, "x264Option"); - ghb_ui_update(ud, "VideoOptionExtra", ghb_string_value(options)); - } - - ghb_check_dependency(ud, widget, NULL); - ghb_clear_presets_selection(ud); -} - -G_MODULE_EXPORT void video_option_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { GtkWidget *textview; diff --git a/gtk/src/x264handler.c b/gtk/src/x264handler.c deleted file mode 100644 index c0fbb054a..000000000 --- a/gtk/src/x264handler.c +++ /dev/null @@ -1,1110 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * x264handler.c - * Copyright (C) John Stebbins 2008-2018 <stebbins@stebbins> - * - * x264handler.c is free software. - * - * You may redistribute it and/or modify it under the terms of the - * GNU General Public License, as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * x264handler.c is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with main.c. If not, write to: - * The Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301, USA. - */ - -#include <glib/gi18n.h> -#include "ghbcompat.h" -#include <string.h> -#include "settings.h" -#include "values.h" -#include "callbacks.h" -#include "presets.h" -#include "hb-backend.h" -#include "x264handler.h" -#include "videohandler.h" - -gint ghb_lookup_bframes(const gchar *options); -static void x264_opt_update(signal_user_data_t *ud, GtkWidget *widget); -static gchar* sanitize_x264opts(signal_user_data_t *ud, const gchar *options); - -// Flag needed to prevent x264 options processing from chasing its tail -static gboolean ignore_options_update = FALSE; - -void ghb_show_hide_advanced_video( signal_user_data_t *ud ) -{ - gboolean hide; - - hide = ghb_dict_get_bool(ud->prefs, "HideAdvancedVideoSettings"); - if (hide) - { - ghb_ui_update(ud, "x264UseAdvancedOptions", ghb_boolean_value(FALSE)); - } - - GtkWidget *widget; - GtkWidget *at = GHB_WIDGET(ud->builder, "advanced_video_tab"); - - gtk_widget_set_visible(at, !hide); - widget = GHB_WIDGET(ud->builder, "x264UseAdvancedOptions"); - gtk_widget_set_visible(widget, !hide); -} - -G_MODULE_EXPORT void -x264_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - ghb_widget_to_setting(ud->x264_priv, widget); - if (!ignore_options_update) - { - ignore_options_update = TRUE; - x264_opt_update(ud, widget); - ignore_options_update = FALSE; - } - ghb_check_dependency(ud, widget, NULL); - ghb_clear_presets_selection(ud); -} - -G_MODULE_EXPORT void -x264_slider_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - ghb_widget_to_setting(ud->x264_priv, widget); - - // Lock slider values to multiples of step_increment - GtkAdjustment * adj = gtk_range_get_adjustment(GTK_RANGE(widget)); - gdouble step = gtk_adjustment_get_step_increment(adj); - gdouble val = gtk_range_get_value(GTK_RANGE(widget)); - gdouble new_val = ((int)((val + step / 2) / step)) * step; - gdouble diff = val - new_val; - if ( diff > 0.0001 || diff < -0.0001 ) - { - gtk_range_set_value(GTK_RANGE(widget), new_val); - } - else if (!ignore_options_update) - { - ignore_options_update = TRUE; - x264_opt_update(ud, widget); - ignore_options_update = FALSE; - } - ghb_check_dependency(ud, widget, NULL); - ghb_clear_presets_selection(ud); -} - -G_MODULE_EXPORT gchar* -x264_format_slider_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) -{ - return g_strdup_printf("%-6.6g", val); -} - - -G_MODULE_EXPORT void -x264_me_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - gint me; - - ghb_widget_to_setting(ud->x264_priv, widget); - if (!ignore_options_update) - { - ignore_options_update = TRUE; - x264_opt_update(ud, widget); - ignore_options_update = FALSE; - } - ghb_check_dependency(ud, widget, NULL); - ghb_clear_presets_selection(ud); - widget = GHB_WIDGET(ud->builder, "x264_merange"); - me = ghb_settings_combo_int(ud->x264_priv, "x264_me"); - if (me < 2) - { // me < umh - // me_range 4 - 16 - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 4, 16); - } - else - { - // me_range 4 - 64 - gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 4, 64); - } -} - -extern char *video_option_tooltip; - -G_MODULE_EXPORT void -x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) -{ - g_debug("x264_entry_changed_cb ()"); - - if (video_option_tooltip == NULL) - { - GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); - video_option_tooltip = gtk_widget_get_tooltip_text(eo); - } - - if (!ignore_options_update) - { - GtkWidget *textview; - const gchar *options; - - textview = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264Option")); - ghb_widget_to_setting(ud->settings, textview); - options = ghb_dict_get_string(ud->settings, "x264Option"); - - ignore_options_update = TRUE; - ghb_x264_parse_options(ud, options); - if (!gtk_widget_has_focus(textview)) - { - gchar *sopts; - - sopts = sanitize_x264opts(ud, options); - ghb_update_x264Option(ud, sopts); - ghb_x264_parse_options(ud, sopts); - - if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) - { - GtkWidget *eo; - eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); - char * tt; - if (sopts) - tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"%s\""), - video_option_tooltip, sopts); - else - tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"\""), - video_option_tooltip); - gtk_widget_set_tooltip_text(eo, tt); - g_free(tt); - } - - g_free(sopts); - } - ignore_options_update = FALSE; - } -} - -G_MODULE_EXPORT gboolean -x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, - signal_user_data_t *ud) -{ - const gchar *options; - gchar *sopts; - - ghb_widget_to_setting(ud->settings, widget); - options = ghb_dict_get_string(ud->settings, "x264Option"); - sopts = sanitize_x264opts(ud, options); - ignore_options_update = TRUE; - if (sopts != NULL && strcmp(sopts, options) != 0) - { - ghb_ui_update(ud, "x264Option", ghb_string_value(sopts)); - ghb_x264_parse_options(ud, sopts); - } - g_free(sopts); - ignore_options_update = FALSE; - return FALSE; -} - -enum -{ - X264_OPT_NONE, - X264_OPT_BOOL_NONE, - X264_OPT_INT_NONE, - X264_OPT_DEBLOCK, - X264_OPT_PSY, - X264_OPT_INT, - X264_OPT_DOUBLE, - X264_OPT_COMBO, - X264_OPT_BOOL, - X264_OPT_TRANS, -}; - -typedef struct -{ - gchar *x264_val; - char *ui_val; -} trans_entry_t; - -typedef struct -{ - gint count; - gint x264_type; - gint ui_type; - trans_entry_t *map; -} trans_table_t; - -static gchar * -trans_x264_val(trans_table_t *trans, char *val) -{ - int ii; - - if (val == NULL) - return NULL; - for (ii = 0; ii < trans->count; ii++) - { - if (strcmp(val, trans->map[ii].x264_val) == 0) - { - return trans->map[ii].ui_val; - } - } - return NULL; -} - -static gchar * -trans_ui_val(trans_table_t *trans, char *val) -{ - int ii; - - if (val == NULL) - return NULL; - for (ii = 0; ii < trans->count; ii++) - { - if (strcmp(val, trans->map[ii].ui_val) == 0) - { - return trans->map[ii].x264_val; - } - } - return NULL; -} - -struct x264_opt_map_s -{ - gchar **opt_syns; - gchar *name; - gchar *def_val; - gint type; - trans_table_t *translation; - gboolean found; -}; - -static gchar *x264_ref_syns[] = {"ref", "frameref", NULL}; -static gchar *x264_bframes_syns[] = {"bframes", NULL}; -static gchar *x264_badapt_syns[] = {"b-adapt", "b_adapt", NULL}; -static gchar *x264_direct_syns[] = - {"direct", "direct-pred", "direct_pred", NULL}; -static gchar *x264_weightp_syns[] = {"weightp", NULL}; -static gchar *x264_bpyramid_syns[] = {"b-pyramid", "b_pyramid", NULL}; -static gchar *x264_me_syns[] = {"me", NULL}; -static gchar *x264_merange_syns[] = {"merange", "me-range", "me_range", NULL}; -static gchar *x264_subme_syns[] = {"subme", "subq", NULL}; -static gchar *x264_aqmode_syns[] = {"aq-mode", NULL}; -static gchar *x264_analyse_syns[] = {"partitions", "analyse", NULL}; -static gchar *x264_8x8dct_syns[] = {"8x8dct", NULL}; -static gchar *x264_deblock_syns[] = {"deblock", "filter", NULL}; -static gchar *x264_trellis_syns[] = {"trellis", NULL}; -static gchar *x264_pskip_syns[] = {"no-fast-pskip", "no_fast_pskip", NULL}; -static gchar *x264_psy_syns[] = {"psy-rd", "psy_rd", NULL}; -static gchar *x264_aq_strength_syns[] = {"aq-strength", "aq_strength", NULL}; -static gchar *x264_mbtree_syns[] = {"mbtree", NULL}; -static gchar *x264_decimate_syns[] = - {"no-dct-decimate", "no_dct_decimate", NULL}; -static gchar *x264_cabac_syns[] = {"cabac", NULL}; - -static gint -find_syn_match(const gchar *opt, gchar **syns) -{ - gint ii; - for (ii = 0; syns[ii] != NULL; ii++) - { - if (strcmp(opt, syns[ii]) == 0) - return ii; - } - return -1; -} - -struct x264_opt_map_s x264_opt_map[] = -{ - {x264_ref_syns, "x264_refs", "3", X264_OPT_INT}, - {x264_bframes_syns, "x264_bframes", "3", X264_OPT_INT}, - {x264_direct_syns, "x264_direct", "spatial", X264_OPT_COMBO}, - {x264_badapt_syns, "x264_b_adapt", "1", X264_OPT_COMBO}, - {x264_weightp_syns, "x264_weighted_pframes", "2", X264_OPT_COMBO}, - {x264_bpyramid_syns, "x264_bpyramid", "normal", X264_OPT_COMBO}, - {x264_me_syns, "x264_me", "hex", X264_OPT_COMBO}, - {x264_merange_syns, "x264_merange", "16", X264_OPT_INT}, - {x264_subme_syns, "x264_subme", "7", X264_OPT_COMBO}, - {x264_aqmode_syns, "x264_aqmode", "1", X264_OPT_INT_NONE}, - {x264_analyse_syns, "x264_analyse", "p8x8,b8x8,i8x8,i4x4", X264_OPT_COMBO}, - {x264_8x8dct_syns, "x264_8x8dct", "1", X264_OPT_BOOL}, - {x264_deblock_syns, "x264_deblock_alpha", "0,0", X264_OPT_DEBLOCK}, - {x264_deblock_syns, "x264_deblock_beta", "0,0", X264_OPT_DEBLOCK}, - {x264_trellis_syns, "x264_trellis", "1", X264_OPT_COMBO}, - {x264_pskip_syns, "x264_no_fast_pskip", "0", X264_OPT_BOOL}, - {x264_decimate_syns, "x264_no_dct_decimate", "0", X264_OPT_BOOL}, - {x264_cabac_syns, "x264_cabac", "1", X264_OPT_BOOL}, - {x264_aq_strength_syns, "x264_aq_strength", "1", X264_OPT_DOUBLE}, - {x264_psy_syns, "x264_psy_rd", "1|0", X264_OPT_PSY}, - {x264_psy_syns, "x264_psy_trell", "1|0", X264_OPT_PSY}, - {x264_mbtree_syns, "x264_mbtree", "1", X264_OPT_BOOL_NONE}, -}; -#define X264_OPT_MAP_SIZE (sizeof(x264_opt_map)/sizeof(struct x264_opt_map_s)) - -static const gchar* -x264_opt_get_default(const gchar *opt) -{ - gint jj; - for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++) - { - if (find_syn_match(opt, x264_opt_map[jj].opt_syns) >= 0) - { - return x264_opt_map[jj].def_val; - } - } - return ""; -} - -static void -x264_update_double(signal_user_data_t *ud, const gchar *name, const gchar *val) -{ - gdouble dval; - - if (val == NULL) return; - dval = g_strtod (val, NULL); - ghb_dict_set_double(ud->x264_priv, name, dval); -} - -static void -x264_update_int(signal_user_data_t *ud, const gchar *name, const gchar *val) -{ - gint ival; - - if (val == NULL) return; - ival = g_strtod (val, NULL); - ghb_dict_set_int(ud->x264_priv, name, ival); -} - -static void -x264_update_int_setting(signal_user_data_t *ud, const gchar *name, const gchar *val) -{ - gint ival; - - if (val == NULL) return; - ival = g_strtod (val, NULL); - ghb_dict_set(ud->x264_priv, name, ghb_int_value_new(ival)); - ghb_check_dependency(ud, NULL, name); -} - -static gchar *true_str[] = -{ - "true", - "yes", - "1", - NULL -}; - -static gboolean -str_is_true(const gchar *str) -{ - gint ii; - for (ii = 0; true_str[ii]; ii++) - { - if (g_ascii_strcasecmp(str, true_str[ii]) == 0) - return TRUE; - } - return FALSE; -} - -static void -x264_update_bool(signal_user_data_t *ud, const gchar *name, const gchar *val) -{ - if (val == NULL) - ghb_dict_set_bool(ud->x264_priv, name, TRUE); - else - ghb_dict_set_bool(ud->x264_priv, name, str_is_true(val)); -} - -static void -x264_update_bool_setting(signal_user_data_t *ud, const gchar *name, const gchar *val) -{ - if (val == NULL) - ghb_dict_set_bool(ud->x264_priv, name, TRUE); - else - ghb_dict_set_bool(ud->x264_priv, name, str_is_true(val)); - - ghb_check_dependency(ud, NULL, name); -} - -static void -x264_update_combo(signal_user_data_t *ud, const gchar *name, const gchar *val) -{ - ghb_dict_set_string(ud->x264_priv, name, val); -} - -static void -x264_update_deblock(signal_user_data_t *ud, const gchar *xval) -{ - int avalue, bvalue; - gchar *end; - gchar *val; - gchar *bval = NULL; - - if (xval == NULL) return; - val = g_strdup(xval); - bvalue = avalue = 0; - if (val != NULL) - { - gchar *pos = strchr(val, ','); - if (pos != NULL) - { - bval = pos + 1; - *pos = 0; - } - avalue = (int)g_strtod(val, &end); - if (bval != NULL) - { - bvalue = (int)g_strtod(bval, &end); - } - } - g_free(val); - ghb_dict_set_int(ud->x264_priv, "x264_deblock_alpha", avalue); - ghb_dict_set_int(ud->x264_priv, "x264_deblock_beta", bvalue); -} - -static void -x264_parse_psy(const gchar *psy, gdouble *psy_rd, gdouble *psy_trell) -{ - *psy_rd = 0.; - *psy_trell = 0.; - if (psy == NULL) return; - if (2 == sscanf(psy, "%lf|%lf", psy_rd, psy_trell) || - 2 == sscanf(psy, "%lf,%lf", psy_rd, psy_trell)) - { - } -} - -static void -x264_update_psy(signal_user_data_t *ud, const gchar *xval) -{ - gdouble rd_value, trell_value; - - if (xval == NULL) return; - x264_parse_psy(xval, &rd_value, &trell_value); - ghb_dict_set_double(ud->x264_priv, "x264_psy_rd", rd_value); - ghb_dict_set_double(ud->x264_priv, "x264_psy_trell", trell_value); -} - -static void do_update(signal_user_data_t *ud, char *name, gint type, char *val) -{ - switch(type) - { - case X264_OPT_INT: - x264_update_int(ud, name, val); - break; - case X264_OPT_DOUBLE: - x264_update_double(ud, name, val); - break; - case X264_OPT_BOOL: - x264_update_bool(ud, name, val); - break; - case X264_OPT_COMBO: - x264_update_combo(ud, name, val); - break; - case X264_OPT_BOOL_NONE: - x264_update_bool_setting(ud, name, val); - break; - case X264_OPT_INT_NONE: - x264_update_int_setting(ud, name, val); - break; - } -} - -void -ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options) -{ - gchar **split = g_strsplit(options, ":", -1); - if (split == NULL) return; - - gint ii; - gint jj; - - for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++) - x264_opt_map[jj].found = FALSE; - - for (ii = 0; split[ii] != NULL; ii++) - { - gchar *val = NULL; - gchar *pos = strchr(split[ii], '='); - if (pos != NULL) - { - val = pos + 1; - *pos = 0; - } - for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++) - { - if (find_syn_match(split[ii], x264_opt_map[jj].opt_syns) >= 0) - { - x264_opt_map[jj].found = TRUE; - switch(x264_opt_map[jj].type) - { - case X264_OPT_INT: - x264_update_int(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_DOUBLE: - x264_update_double(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_BOOL: - x264_update_bool(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_COMBO: - x264_update_combo(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_DEBLOCK: - // dirty little hack. mark deblock_beta found as well - x264_opt_map[jj+1].found = TRUE; - x264_update_deblock(ud, val); - break; - case X264_OPT_PSY: - // dirty little hack. mark psy_trell found as well - x264_opt_map[jj+1].found = TRUE; - x264_update_psy(ud, val); - break; - case X264_OPT_BOOL_NONE: - x264_update_bool_setting(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_INT_NONE: - x264_update_int_setting(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_TRANS: - if (x264_opt_map[jj].translation == NULL) - break; - val = trans_x264_val(x264_opt_map[jj].translation, val); - if (val != NULL) - { - do_update(ud, x264_opt_map[jj].name, - x264_opt_map[jj].translation->ui_type, val); - // TODO un-grey the ui control - } - else - { - // TODO grey out the ui control - } - break; - } - break; - } - } - } - // For any options not found in the option string, set ui to - // default values - for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++) - { - if (!x264_opt_map[jj].found) - { - gchar *val = strdup(x264_opt_map[jj].def_val); - switch(x264_opt_map[jj].type) - { - case X264_OPT_INT: - x264_update_int(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_DOUBLE: - x264_update_double(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_BOOL: - x264_update_bool(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_COMBO: - x264_update_combo(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_DEBLOCK: - x264_update_deblock(ud, val); - break; - case X264_OPT_PSY: - x264_update_psy(ud, val); - break; - case X264_OPT_BOOL_NONE: - x264_update_bool_setting(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_INT_NONE: - x264_update_int_setting(ud, x264_opt_map[jj].name, val); - break; - case X264_OPT_TRANS: - if (x264_opt_map[jj].translation == NULL) - break; - val = g_strdup(trans_x264_val(x264_opt_map[jj].translation, val)); - if (val != NULL) - { - do_update(ud, x264_opt_map[jj].name, - x264_opt_map[jj].translation->ui_type, val); - // TODO un-grey the ui control - } - else - { - // TODO grey out the ui control - } - break; - } - x264_opt_map[jj].found = TRUE; - g_free(val); - } - } - g_strfreev(split); - ghb_settings_to_ui(ud, ud->x264_priv); -} - -gchar* -get_deblock_val(signal_user_data_t *ud) -{ - int alpha, beta; - gchar *result; - alpha = ghb_dict_get_int(ud->x264_priv, "x264_deblock_alpha"); - beta = ghb_dict_get_int(ud->x264_priv, "x264_deblock_beta"); - result = g_strdup_printf("%d,%d", alpha, beta); - return result; -} - -gchar* -get_psy_val(signal_user_data_t *ud) -{ - gdouble rd, trell; - gchar *result; - rd = ghb_dict_get_double(ud->x264_priv, "x264_psy_rd"); - trell = ghb_dict_get_double(ud->x264_priv, "x264_psy_trell"); - result = g_strdup_printf("%g|%g", rd, trell); - return result; -} - -static void -x264_opt_update(signal_user_data_t *ud, GtkWidget *widget) -{ - gint jj; - const gchar *name = ghb_get_setting_key(widget); - gchar **opt_syns = NULL; - const gchar *def_val = NULL; - gint type; - trans_table_t *trans; - - for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++) - { - if (strcmp(name, x264_opt_map[jj].name) == 0) - { - // found the options that needs updating - opt_syns = x264_opt_map[jj].opt_syns; - def_val = x264_opt_map[jj].def_val; - type = x264_opt_map[jj].type; - trans = x264_opt_map[jj].translation; - break; - } - } - if (opt_syns != NULL) - { - GString *x264opts = g_string_new(""); - const gchar *options; - gchar **split = NULL; - gint ii; - gboolean foundit = FALSE; - - options = ghb_dict_get_string(ud->settings, "x264Option"); - if (options) - { - split = g_strsplit(options, ":", -1); - } - for (ii = 0; split && split[ii] != NULL; ii++) - { - gint syn; - gchar *val = NULL; - gchar *pos = strchr(split[ii], '='); - if (pos != NULL) - { - val = pos + 1; - *pos = 0; - } - syn = find_syn_match(split[ii], opt_syns); - if (syn >= 0) - { // Updating this option - gchar *val; - foundit = TRUE; - if (type == X264_OPT_DEBLOCK) - val = get_deblock_val(ud); - else if (type == X264_OPT_PSY) - val = get_psy_val(ud); - else - { - GhbValue *gval; - gval = ghb_widget_value(widget); - if (ghb_value_type(gval) == GHB_BOOL) - { - if (ghb_value_get_bool(gval)) - val = g_strdup("1"); - else - val = g_strdup("0"); - } - else - { - val = ghb_widget_string(widget); - } - ghb_value_free(&gval); - } - if (type == X264_OPT_TRANS) - { - gchar *tmp; - tmp = g_strdup(trans_ui_val(trans, val)); - if (tmp) - { - g_free(val); - val = tmp; - } - } - if (strcmp(def_val, val) != 0) - { - g_string_append_printf(x264opts, "%s=%s:", opt_syns[syn], val); - } - g_free(val); - } - else if (val != NULL) - g_string_append_printf(x264opts, "%s=%s:", split[ii], val); - else - g_string_append_printf(x264opts, "%s:", split[ii]); - - } - if (split) g_strfreev(split); - if (!foundit) - { - gchar *val; - if (type == X264_OPT_DEBLOCK) - val = get_deblock_val(ud); - else if (type == X264_OPT_PSY) - val = get_psy_val(ud); - else - { - GhbValue *gval; - gval = ghb_widget_value(widget); - if (ghb_value_type(gval) == GHB_BOOL) - { - if (ghb_value_get_bool(gval)) - val = g_strdup("1"); - else - val = g_strdup("0"); - } - else - { - val = ghb_widget_string(widget); - } - ghb_value_free(&gval); - } - if (type == X264_OPT_TRANS) - { - gchar *tmp; - tmp = g_strdup(trans_ui_val(trans, val)); - if (tmp) - { - g_free(val); - val = tmp; - } - } - if (strcmp(def_val, val) != 0) - { - g_string_append_printf(x264opts, "%s=%s:", opt_syns[0], val); - } - g_free(val); - } - // Update the options value - // strip the trailing ":" - gchar *result; - gint len; - result = g_string_free(x264opts, FALSE); - len = strlen(result); - if (len > 0) result[len - 1] = 0; - gchar *sopts; - sopts = sanitize_x264opts(ud, result); - ghb_update_x264Option(ud, sopts); - ghb_x264_parse_options(ud, sopts); - g_free(sopts); - g_free(result); - } -} - -static gint -x264_find_opt(gchar **opts, gchar **opt_syns) -{ - gint ii; - for (ii = 0; opts[ii] != NULL; ii++) - { - gchar *opt; - opt = g_strdup(opts[ii]); - gchar *pos = strchr(opt, '='); - if (pos != NULL) - { - *pos = 0; - } - if (find_syn_match(opt, opt_syns) >= 0) - { - g_free(opt); - return ii; - } - g_free(opt); - } - return -1; -} - -static void -x264_remove_opt(gchar **opts, gchar **opt_syns) -{ - gint ii; - for (ii = 0; opts[ii] != NULL; ii++) - { - gchar *opt; - opt = g_strdup(opts[ii]); - gchar *pos = strchr(opt, '='); - if (pos != NULL) - { - *pos = 0; - } - if (find_syn_match(opt, opt_syns) >= 0) - { - // Mark as deleted - opts[ii][0] = 0; - } - g_free(opt); - } -} - -static gchar* -x264_lookup_value(gchar **opts, gchar **opt_syns) -{ - gchar *ret = NULL; - gint pos; - - const gchar *def_val = x264_opt_get_default(opt_syns[0]); - - pos = x264_find_opt(opts, opt_syns); - if (pos >= 0) - { - gchar *cpos = strchr(opts[pos], '='); - if (cpos != NULL) - { - ret = g_strdup(cpos+1); - } - else - { - ret = g_strdup(""); - } - } - else if (def_val != NULL) - { - ret = g_strdup(def_val); - } - return ret; -} - -gint -ghb_lookup_badapt(const gchar *options) -{ - gint ret = 0; - gchar *result; - gchar **split; - - if (options == NULL) - options = ""; - - split = g_strsplit(options, ":", -1); - - result = x264_lookup_value(split, x264_badapt_syns); - g_strfreev(split); - if (result != NULL) - { - ret = g_strtod(result, NULL); - g_free(result); - } - return ret; -} - -gint -ghb_lookup_aqmode(const gchar *options) -{ - gint ret = 0; - gchar *result; - gchar **split; - - if (options == NULL) - options = ""; - - split = g_strsplit(options, ":", -1); - - result = x264_lookup_value(split, x264_aqmode_syns); - g_strfreev(split); - if (result != NULL) - { - ret = g_strtod(result, NULL); - g_free(result); - } - return ret; -} - -gint -ghb_lookup_bframes(const gchar *options) -{ - gint ret = 0; - gchar *result; - gchar **split; - - if (options == NULL) - options = ""; - - split = g_strsplit(options, ":", -1); - - result = x264_lookup_value(split, x264_bframes_syns); - g_strfreev(split); - if (result != NULL) - { - ret = g_strtod(result, NULL); - g_free(result); - } - return ret; -} - -gint -ghb_lookup_mbtree(const gchar *options) -{ - gint ret = ghb_lookup_bframes(options) != 0; - gchar *result; - gchar **split; - - if (options == NULL) - options = ""; - - split = g_strsplit(options, ":", -1); - - result = x264_lookup_value(split, x264_mbtree_syns); - g_strfreev(split); - if (result != NULL) - { - ret = g_strtod(result, NULL); - g_free(result); - } - return ret; -} - -// Construct the x264 options string -// The result is allocated, so someone must free it at some point. -static gchar* -sanitize_x264opts(signal_user_data_t *ud, const gchar *options) -{ - GString *x264opts = g_string_new(""); - gchar **split = g_strsplit(options, ":", -1); - gint ii; - - // Fix up option dependencies - gint subme = ghb_settings_combo_int(ud->x264_priv, "x264_subme"); - if (subme < 6) - { - x264_remove_opt(split, x264_psy_syns); - } - gint trell = ghb_settings_combo_int(ud->x264_priv, "x264_trellis"); - if (subme >= 10) - { - gint aqmode = ghb_lookup_aqmode(options); - if (trell != 2 || aqmode == 0) - { - gint pos = x264_find_opt(split, x264_subme_syns); - g_free(split[pos]); - split[pos] = g_strdup_printf("subme=9"); - } - } - if (trell < 1) - { - gint psy; - gdouble psy_rd = 0., psy_trell; - - psy = x264_find_opt(split, x264_psy_syns); - if (psy >= 0) - { - gchar *pos = strchr(split[psy], '='); - if (pos != NULL) - { - x264_parse_psy(pos+1, &psy_rd, &psy_trell); - } - g_free(split[psy]); - split[psy] = g_strdup_printf("psy-rd=%g|0", psy_rd); - } - } - gint bframes = ghb_dict_get_int(ud->x264_priv, "x264_bframes"); - if (bframes == 0) - { - x264_remove_opt(split, x264_direct_syns); - x264_remove_opt(split, x264_badapt_syns); - } - if (bframes <= 1) - { - x264_remove_opt(split, x264_bpyramid_syns); - } - // Remove entries that match the defaults - for (ii = 0; split[ii] != NULL; ii++) - { - gchar *val = NULL; - gchar *opt = g_strdup(split[ii]); - gchar *pos = strchr(opt, '='); - if (pos != NULL) - { - val = pos + 1; - *pos = 0; - } - else - { - val = "1"; - } - const gchar *def_val; - def_val = x264_opt_get_default(opt); - if (strcmp(val, def_val) == 0) - { - // Matches the default, so remove it - split[ii][0] = 0; - } - g_free(opt); - } - for (ii = 0; split[ii] != NULL; ii++) - { - if (split[ii][0] != 0) - g_string_append_printf(x264opts, "%s:", split[ii]); - } - g_strfreev(split); - // strip the trailing ":" - gchar *result; - gint len; - result = g_string_free(x264opts, FALSE); - len = strlen(result); - if (len > 0) result[len - 1] = 0; - return result; -} - -void -ghb_x264_init(signal_user_data_t *ud) -{ - ud->x264_priv = ghb_dict_new(); -} - -gboolean -ghb_background_refresh_x264Option(signal_user_data_t *ud) -{ - const char *opt; - opt = ghb_dict_get_string(ud->settings, "x264Option"); - - GtkWidget *widget; - GtkTextBuffer *buffer; - GtkTextIter start, end; - gchar *str; - - widget = GHB_WIDGET(ud->builder, "x264Option"); - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); - gtk_text_buffer_get_bounds(buffer, &start, &end); - str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); - - // If the value has changed, then update it - if (opt != NULL) - { - if (str == NULL || strcmp(str, opt)) - { - ud->dont_clear_presets = 1; - ghb_ui_update(ud, "x264Option", ghb_string_value(opt)); - ud->dont_clear_presets = 0; - } - } - free(str); - return FALSE; -} - -void ghb_update_x264Option(signal_user_data_t *ud, const char *opt) -{ - ghb_dict_set_string(ud->settings, "x264Option", opt); - g_idle_add((GSourceFunc)ghb_background_refresh_x264Option, ud); -} diff --git a/gtk/src/x264handler.h b/gtk/src/x264handler.h deleted file mode 100644 index 41969cbf0..000000000 --- a/gtk/src/x264handler.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * x264handler.h - * Copyright (C) John Stebbins 2008-2018 <stebbins@stebbins> - * - * x264handler.h is free software. - * - * You may redistribute it and/or modify it under the terms of the - * GNU General Public License, as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * x264handler.h is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with callbacks.h. If not, write to: - * The Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301, USA. - */ - -#if !defined(_X264HANDLER_H_) -#define _X264HANDLER_H_ - -#include "settings.h" - -void ghb_x264_init(signal_user_data_t *ud); -void ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options); -gint ghb_lookup_badapt(const gchar *options); -void ghb_show_hide_advanced_video( signal_user_data_t *ud ); -void ghb_update_x264Option(signal_user_data_t *ud, const char *opt); - -#endif // _X264HANDLER_H_ |