diff options
author | jstebbins <[email protected]> | 2013-01-03 22:58:47 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2013-01-03 22:58:47 +0000 |
commit | 1f5b59d8d279a143b098b3faa7c9495c35348db7 (patch) | |
tree | 54bf2e21c437d858691cb5b5c0f942401f799752 /gtk/src/presets.c | |
parent | 4f8b3c1507a169da1154cb7f1f2cabba9dd71ef5 (diff) |
LinGui: build preset import/export tables from hb_encoder_t tables
This makes tracking additions to libhb encoders completely transparent to
the LinGui. Changes or deletions still require special handling to ensure
backwards compatibility.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5140 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/presets.c')
-rw-r--r-- | gtk/src/presets.c | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 259953251..2f7e15104 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -2018,44 +2018,74 @@ typedef struct gchar *lin_val; } value_map_t; -static value_map_t vcodec_xlat[] = +static value_map_t vcodec_xlat_compat[] = { - {"MPEG-2 (FFmpeg)", "ffmpeg2"}, - {"MPEG-4 (FFmpeg)", "ffmpeg4"}, {"MPEG-4 (FFmpeg)", "ffmpeg"}, {"MPEG-4 (XviD)", "ffmpeg4"}, - {"H.264 (x264)", "x264"}, - {"VP3 (Theora)", "theora"}, {NULL,NULL} }; -static value_map_t acodec_xlat[] = +static value_map_t *vcodec_xlat; + +static value_map_t acodec_xlat_compat[] = { - {"AAC (ffmpeg)", "ffaac"}, - {"AAC (faac)", "faac"}, {"AAC (CoreAudio)", "faac"}, {"HE-AAC (CoreAudio)", "faac"}, - {"AC3 (ffmpeg)", "ffac3"}, {"AC3 (ffmpeg)", "ac3"}, - {"AC3", "ac3"}, // Backwards compatibility with mac ui - {"MP3 Passthru", "copy:mp3"}, + {"AC3", "ac3"}, {"MP3 Passthru", "mp3pass"}, - {"AAC Passthru", "copy:aac"}, {"AAC Passthru", "aacpass"}, - {"AC3 Passthru", "copy:ac3"}, {"AC3 Passthru", "ac3pass"}, - {"DTS Passthru", "copy:dts"}, {"DTS Passthru", "dtspass"}, - {"DTS-HD Passthru", "copy:dtshd"}, {"DTS-HD Passthru", "dtshdpass"}, - {"Auto Passthru", "copy"}, {"Auto Passthru", "auto"}, - {"MP3 (lame)", "lame"}, - {"FLAC (ffmpeg)", "ffflac"}, - {"Vorbis (vorbis)", "vorbis"}, {NULL,NULL} }; +static value_map_t *acodec_xlat; + +static value_map_t * create_encoder_xlat_tbl(value_map_t *compat, hb_encoder_t *enc, int size) +{ + value_map_t *out; + int cc, ii; + + for (cc = 0; compat[cc].mac_val != NULL; cc++); + + out = calloc(cc + size + 1, sizeof(value_map_t)); + + for (ii = 0; ii < size; ii++) + { + out[ii].mac_val = enc[ii].human_readable_name; + out[ii].lin_val = enc[ii].short_name; + } + + for (ii = 0; ii < cc; ii++) + out[ii+size] = compat[ii]; + + return out; +} + +static value_map_t * create_mix_xlat_tbl(value_map_t *compat, hb_mixdown_t * mix, int size) +{ + value_map_t *out; + int cc, ii; + + for (cc = 0; compat[cc].mac_val != NULL; cc++); + + out = calloc(cc + size + 1, sizeof(value_map_t)); + + for (ii = 0; ii < size; ii++) + { + out[ii].mac_val = mix[ii].human_readable_name; + out[ii].lin_val = mix[ii].short_name; + } + + for (ii = 0; ii < cc; ii++) + out[ii+size] = compat[ii]; + + return out; +} + value_map_t container_xlat[] = { {"MP4 file", "mp4"}, @@ -3273,23 +3303,10 @@ update_standard_presets(signal_user_data_t *ud) void ghb_presets_load(signal_user_data_t *ud) { - int ii, jj; - - // Create audio mixdown translation table - mix_xlat = malloc(sizeof(value_map_t) * - (hb_audio_mixdowns_count + - sizeof(mix_xlat_compat) / sizeof(value_map_t))); - for (ii = 0; ii < hb_audio_mixdowns_count; ii++) - { - mix_xlat[ii].mac_val = hb_audio_mixdowns[ii].human_readable_name; - mix_xlat[ii].lin_val = hb_audio_mixdowns[ii].short_name; - } - for (jj = 0; mix_xlat_compat[jj].mac_val != NULL; jj++, ii++) - { - mix_xlat[ii] = mix_xlat_compat[jj]; - } - mix_xlat[ii].mac_val = NULL; - mix_xlat[ii].lin_val = NULL; + // Create translation tables from libhb tables + mix_xlat = create_mix_xlat_tbl(mix_xlat_compat, hb_audio_mixdowns, hb_audio_mixdowns_count); + acodec_xlat = create_encoder_xlat_tbl(acodec_xlat_compat, hb_audio_encoders, hb_audio_encoders_count); + vcodec_xlat = create_encoder_xlat_tbl(vcodec_xlat_compat, hb_video_encoders, hb_video_encoders_count); presetsPlist = load_plist("presets"); if (presetsPlist == NULL) |