Skip to content

Commit

Permalink
preset: Add CLI Default preset. (HandBrake#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleysepos authored Jun 27, 2016
1 parent b4c23bf commit 9905eb7
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 5 deletions.
30 changes: 25 additions & 5 deletions libhb/preset.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int hb_preset_version_micro;
static hb_value_t *hb_preset_template = NULL;
static hb_value_t *hb_presets = NULL;
static hb_value_t *hb_presets_builtin = NULL;
static hb_value_t *hb_presets_cli_default = NULL;

static void preset_clean(hb_value_t *preset, hb_value_t *template);
static int preset_import(hb_value_t *preset, int major, int minor,
Expand Down Expand Up @@ -2906,6 +2907,17 @@ void hb_presets_builtin_init(void)
hb_value_free(&dict);
}

int hb_presets_cli_default_init(void)
{
hb_value_t * dict = hb_value_json(hb_builtin_presets_json);
hb_presets_cli_default = hb_value_dup(hb_dict_get(dict, "PresetCLIDefault"));
hb_presets_clean(hb_presets_cli_default);

int result = hb_presets_add_internal(hb_presets_cli_default);
hb_value_free(&dict);
return result;
}

void hb_presets_current_version(int *major, int* minor, int *micro)
{
*major = hb_preset_version_major;
Expand Down Expand Up @@ -3097,15 +3109,11 @@ void hb_presets_builtin_update(void)
hb_value_free(&builtin);
}

int hb_presets_add(hb_value_t *preset)
int hb_presets_add_internal(hb_value_t *preset)
{
hb_preset_index_t *path;
int added = 0;

if (preset == NULL)
return -1;

preset = presets_unpackage(preset);
if (preset == NULL)
return -1;

Expand Down Expand Up @@ -3147,6 +3155,18 @@ int hb_presets_add(hb_value_t *preset)
return index;
}

int hb_presets_add(hb_value_t *preset)
{
if (preset == NULL)
return -1;

preset = presets_unpackage(preset);
if (preset == NULL)
return -1;

return hb_presets_add_internal(preset);
}

int hb_presets_add_json(const char *json)
{
hb_value_t *preset = hb_value_json(json);
Expand Down
3 changes: 3 additions & 0 deletions libhb/preset.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void hb_presets_free(void);

#endif // __LIBHB__

// Add the default CLI preset(s) to the currently loaded presets
int hb_presets_cli_default_init(void);

// Get the currently supported preset format version
void hb_presets_current_version(int *major, int* minor, int *micro);

Expand Down
105 changes: 105 additions & 0 deletions libhb/preset_builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -6620,6 +6620,111 @@ const char hb_builtin_presets_json[] =
" \"Type\": 0\n"
" }\n"
" ], \n"
" \"PresetCLIDefault\": [\n"
" {\n"
" \"ChildrenArray\": [\n"
" {\n"
" \"AudioCopyMask\": [\n"
" \"copy:aac\"\n"
" ], \n"
" \"AudioEncoderFallback\": \"aac\", \n"
" \"AudioLanguageList\": [], \n"
" \"AudioList\": [\n"
" {\n"
" \"AudioBitrate\": 128, \n"
" \"AudioCompressionLevel\": -1.0, \n"
" \"AudioDitherMethod\": \"auto\", \n"
" \"AudioEncoder\": \"aac\", \n"
" \"AudioMixdown\": \"dpl2\", \n"
" \"AudioNormalizeMixLevel\": false, \n"
" \"AudioSamplerate\": \"auto\", \n"
" \"AudioTrackDRCSlider\": 0.0, \n"
" \"AudioTrackGainSlider\": 0.0, \n"
" \"AudioTrackQuality\": -1.0, \n"
" \"AudioTrackQualityEnable\": false\n"
" }\n"
" ], \n"
" \"AudioSecondaryEncoderMode\": true, \n"
" \"AudioTrackSelectionBehavior\": \"first\", \n"
" \"ChapterMarkers\": true, \n"
" \"ChildrenArray\": [], \n"
" \"Default\": true, \n"
" \"FileFormat\": \"mp4\", \n"
" \"Folder\": false, \n"
" \"FolderOpen\": false, \n"
" \"Mp4HttpOptimize\": false, \n"
" \"Mp4iPodCompatible\": false, \n"
" \"PictureAutoCrop\": true, \n"
" \"PictureBottomCrop\": 0, \n"
" \"PictureCombDetectCustom\": \"\", \n"
" \"PictureCombDetectPreset\": \"off\", \n"
" \"PictureDARWidth\": 0, \n"
" \"PictureDeblock\": 0, \n"
" \"PictureDeblockCustom\": \"qp=0:mode=2\", \n"
" \"PictureDeinterlaceCustom\": \"\", \n"
" \"PictureDeinterlaceFilter\": \"off\", \n"
" \"PictureDeinterlacePreset\": \"default\", \n"
" \"PictureDenoiseCustom\": \"\", \n"
" \"PictureDenoiseFilter\": \"off\", \n"
" \"PictureDenoisePreset\": \"medium\", \n"
" \"PictureDenoiseTune\": \"none\", \n"
" \"PictureDetelecine\": \"off\", \n"
" \"PictureDetelecineCustom\": \"\", \n"
" \"PictureForceHeight\": 0, \n"
" \"PictureForceWidth\": 0, \n"
" \"PictureHeight\": 0, \n"
" \"PictureItuPAR\": false, \n"
" \"PictureKeepRatio\": true, \n"
" \"PictureLeftCrop\": 0, \n"
" \"PictureLooseCrop\": false, \n"
" \"PictureModulus\": 2, \n"
" \"PicturePAR\": \"strict\", \n"
" \"PicturePARHeight\": 720, \n"
" \"PicturePARWidth\": 853, \n"
" \"PictureRightCrop\": 0, \n"
" \"PictureRotate\": \"angle=0:hflip=0\", \n"
" \"PictureTopCrop\": 0, \n"
" \"PictureWidth\": 0, \n"
" \"PresetDescription\": \"\", \n"
" \"PresetName\": \"CLI Default\", \n"
" \"SubtitleAddCC\": false, \n"
" \"SubtitleAddForeignAudioSearch\": false, \n"
" \"SubtitleAddForeignAudioSubtitle\": false, \n"
" \"SubtitleBurnBDSub\": false, \n"
" \"SubtitleBurnBehavior\": \"none\", \n"
" \"SubtitleBurnDVDSub\": false, \n"
" \"SubtitleLanguageList\": [], \n"
" \"SubtitleTrackSelectionBehavior\": \"none\", \n"
" \"Type\": 0, \n"
" \"UsesPictureFilters\": true, \n"
" \"UsesPictureSettings\": 2, \n"
" \"VideoAvgBitrate\": 6000, \n"
" \"VideoColorMatrixCode\": 0, \n"
" \"VideoEncoder\": \"x264\", \n"
" \"VideoFramerate\": \"\", \n"
" \"VideoFramerateMode\": \"vfr\", \n"
" \"VideoGrayScale\": false, \n"
" \"VideoLevel\": \"auto\", \n"
" \"VideoOptionExtra\": \"\", \n"
" \"VideoPreset\": \"medium\", \n"
" \"VideoProfile\": \"auto\", \n"
" \"VideoQSVAsyncDepth\": 4, \n"
" \"VideoQSVDecode\": false, \n"
" \"VideoQualitySlider\": 22.0, \n"
" \"VideoQualityType\": 2, \n"
" \"VideoScaler\": \"swscale\", \n"
" \"VideoTune\": \"\", \n"
" \"VideoTurboTwoPass\": false, \n"
" \"VideoTwoPass\": false, \n"
" \"x264Option\": \"\", \n"
" \"x264UseAdvancedOptions\": false\n"
" }\n"
" ], \n"
" \"Folder\": true, \n"
" \"PresetName\": \"CLI Defaults\", \n"
" \"Type\": 0\n"
" }\n"
" ], \n"
" \"PresetTemplate\": {\n"
" \"Preset\": {\n"
" \"AudioCopyMask\": [\n"
Expand Down
1 change: 1 addition & 0 deletions preset/preset_builtin.list
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<json name="Preset" file="preset_template.json" />
</section>
<json name="PresetBuiltin" file="preset_builtin.json" />
<json name="PresetCLIDefault" file="preset_cli_default.json" />
</resources>
109 changes: 109 additions & 0 deletions preset/preset_cli_default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[
{
"ChildrenArray": [
{
"AudioCopyMask": [
"copy:aac"
],
"AudioEncoderFallback": "aac",
"AudioLanguageList": [
],
"AudioList": [
{
"AudioBitrate": 128,
"AudioCompressionLevel": -1.0,
"AudioDitherMethod": "auto",
"AudioEncoder": "aac",
"AudioMixdown": "dpl2",
"AudioNormalizeMixLevel": false,
"AudioSamplerate": "auto",
"AudioTrackQualityEnable": false,
"AudioTrackQuality": -1.0,
"AudioTrackGainSlider": 0.0,
"AudioTrackDRCSlider": 0.0
}
],
"AudioSecondaryEncoderMode": true,
"AudioTrackSelectionBehavior": "first",
"ChapterMarkers": true,
"ChildrenArray": [
],
"Default": true,
"FileFormat": "mp4",
"Folder": false,
"FolderOpen": false,
"Mp4HttpOptimize": false,
"Mp4iPodCompatible": false,
"PictureAutoCrop": true,
"PictureBottomCrop": 0,
"PictureLeftCrop": 0,
"PictureRightCrop": 0,
"PictureTopCrop": 0,
"PictureDARWidth": 0,
"PictureDeblock": 0,
"PictureDeblockCustom": "qp=0:mode=2",
"PictureCombDetectCustom": "",
"PictureCombDetectPreset": "off",
"PictureDeinterlaceCustom": "",
"PictureDeinterlaceFilter": "off",
"PictureDeinterlacePreset": "default",
"PictureDenoiseCustom": "",
"PictureDenoiseFilter": "off",
"PictureDenoisePreset": "medium",
"PictureDenoiseTune": "none",
"PictureDetelecine": "off",
"PictureDetelecineCustom": "",
"PictureItuPAR": false,
"PictureKeepRatio": true,
"PictureLooseCrop": false,
"PictureModulus": 2,
"PicturePAR": "strict",
"PicturePARWidth": 853,
"PicturePARHeight": 720,
"PictureRotate": "angle=0:hflip=0",
"PictureWidth": 0,
"PictureHeight": 0,
"PictureForceHeight": 0,
"PictureForceWidth": 0,
"PresetDescription": "",
"PresetName": "CLI Default",
"Type": 0,
"UsesPictureFilters": true,
"UsesPictureSettings": 2,
"SubtitleAddCC": false,
"SubtitleAddForeignAudioSearch": false,
"SubtitleAddForeignAudioSubtitle": false,
"SubtitleBurnBehavior": "none",
"SubtitleBurnBDSub": false,
"SubtitleBurnDVDSub": false,
"SubtitleLanguageList": [
],
"SubtitleTrackSelectionBehavior": "none",
"VideoAvgBitrate": 6000,
"VideoColorMatrixCode": 0,
"VideoEncoder": "x264",
"VideoFramerate": "",
"VideoFramerateMode": "vfr",
"VideoGrayScale": false,
"VideoScaler": "swscale",
"VideoPreset": "medium",
"VideoTune": "",
"VideoProfile": "auto",
"VideoLevel": "auto",
"VideoOptionExtra": "",
"VideoQualityType": 2,
"VideoQualitySlider": 22.0,
"VideoQSVDecode": false,
"VideoQSVAsyncDepth": 4,
"VideoTwoPass": false,
"VideoTurboTwoPass": false,
"x264Option": "",
"x264UseAdvancedOptions": false
}
],
"Folder": true,
"PresetName": "CLI Defaults",
"Type": 0
}
]

1 change: 1 addition & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ int main( int argc, char ** argv )

hb_global_init();
hb_presets_builtin_update();
hb_presets_cli_default_init();

/* Init libhb */
h = hb_init(4); // Show all logging until debug level is parsed
Expand Down

0 comments on commit 9905eb7

Please sign in to comment.