-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathXLDFdkAacOutput.m
More file actions
200 lines (184 loc) · 6.57 KB
/
XLDFdkAacOutput.m
File metadata and controls
200 lines (184 loc) · 6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//
// XLDFdkAacOutput.m
// XLDFdkAacOutput
//
// Created by tmkk on 12/07/20.
// Copyright 2012 tmkk. All rights reserved.
//
#import "XLDFdkAacOutput.h"
#import "XLDFdkAacOutputTask.h"
@implementation XLDFdkAacOutput
+ (NSString *)pluginName
{
return @"MPEG-4 AAC (FDK)";
}
+ (BOOL)canLoadThisBundle
{
return YES;
}
- (id)init
{
[super init];
[NSBundle loadNibNamed:@"XLDFdkAacOutput" owner:self];
[self modeChanged:nil];
return self;
}
- (NSView *)prefPane
{
return o_prefPane;
}
- (void)savePrefs
{
NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];
[pref setInteger:[o_encoderMode indexOfSelectedItem] forKey:@"XLDFdkAacOutput_Mode"];
[pref setInteger:[o_bitrate intValue] forKey:@"XLDFdkAacOutput_Bitrate"];
[pref setInteger:[o_vbrQuality intValue] forKey:@"XLDFdkAacOutput_VBRQuality"];
[pref setInteger:[[o_complexity selectedCell] tag] forKey:@"XLDFdkAacOutput_Complexity"];
[pref setInteger:[o_manualLPF state] forKey:@"XLDFdkAacOutput_ManualLPF"];
[pref setInteger:[o_LPFFreq intValue] forKey:@"XLDFdkAacOutput_LPFFreq"];
[pref synchronize];
}
- (void)loadPrefs
{
NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];
[self loadConfigurations:pref];
}
- (id)createTaskForOutput
{
return [[XLDFdkAacOutputTask alloc] initWithConfigurations:[self configurations]];
}
- (id)createTaskForOutputWithConfigurations:(NSDictionary *)cfg
{
return [[XLDFdkAacOutputTask alloc] initWithConfigurations:cfg];
}
- (unsigned int)LPFFreq
{
if([o_manualLPF state] == NSOffState) return 0;
return [o_LPFFreq intValue];
}
- (NSMutableDictionary *)configurations
{
NSMutableDictionary *cfg = [[NSMutableDictionary alloc] init];
/* for GUI */
[cfg setObject:[NSNumber numberWithInt:[o_encoderMode indexOfSelectedItem]] forKey:@"XLDFdkAacOutput_Mode"];
[cfg setObject:[NSNumber numberWithInt:[o_bitrate intValue]] forKey:@"XLDFdkAacOutput_Bitrate"];
[cfg setObject:[NSNumber numberWithInt:[o_vbrQuality intValue]] forKey:@"XLDFdkAacOutput_VBRQuality"];
[cfg setObject:[NSNumber numberWithInt:[[o_complexity selectedCell] tag]] forKey:@"XLDFdkAacOutput_Complexity"];
[cfg setObject:[NSNumber numberWithInt:[o_manualLPF state]] forKey:@"XLDFdkAacOutput_ManualLPF"];
[cfg setObject:[NSNumber numberWithInt:[o_LPFFreq intValue]] forKey:@"XLDFdkAacOutput_LPFFreq"];
/* for task */
[cfg setObject:[NSNumber numberWithUnsignedInt:[o_encoderMode indexOfSelectedItem]] forKey:@"Mode"];
[cfg setObject:[NSNumber numberWithUnsignedInt:[o_bitrate intValue]*1000] forKey:@"Bitrate"];
[cfg setObject:[NSNumber numberWithUnsignedInt:[o_vbrQuality intValue]] forKey:@"VBRQuality"];
[cfg setObject:[NSNumber numberWithUnsignedInt:[[o_complexity selectedCell] tag]] forKey:@"Complexity"];
[cfg setObject:[NSNumber numberWithUnsignedInt:[self LPFFreq]] forKey:@"LPFFreq"];
/* desc */
if([o_encoderMode indexOfSelectedItem] == 0) {
if([[o_complexity selectedCell] tag] == 0)
[cfg setObject:[NSString stringWithFormat:@"CBR %dkbps",[o_bitrate intValue]] forKey:@"ShortDesc"];
else if([[o_complexity selectedCell] tag] == 1)
[cfg setObject:[NSString stringWithFormat:@"HE-AAC, CBR %dkbps",[o_bitrate intValue]] forKey:@"ShortDesc"];
else
[cfg setObject:[NSString stringWithFormat:@"HE-AAC v2, CBR %dkbps",[o_bitrate intValue]] forKey:@"ShortDesc"];
}
else if([o_encoderMode indexOfSelectedItem] == 1) {
if([o_vbrQuality intValue] < 2)
[cfg setObject:[NSString stringWithFormat:@"HE-AAC v2, VBR quality %d",[o_vbrQuality intValue]] forKey:@"ShortDesc"];
else if([o_vbrQuality intValue] < 6)
[cfg setObject:[NSString stringWithFormat:@"HE-AAC, VBR quality %d",[o_vbrQuality intValue]] forKey:@"ShortDesc"];
else
[cfg setObject:[NSString stringWithFormat:@"VBR quality %d",[o_vbrQuality intValue]] forKey:@"ShortDesc"];
}
return [cfg autorelease];
}
- (IBAction)modeChanged:(id)sender
{
if([o_encoderMode indexOfSelectedItem] == 0) {
[o_bitrate setEnabled:YES];
[o_complexity setEnabled:YES];
[o_text1 setTextColor:[NSColor controlTextColor]];
[o_text2 setTextColor:[NSColor controlTextColor]];
[o_text5 setTextColor:[NSColor controlTextColor]];
[o_vbrQuality setEnabled:NO];
[o_summary setTextColor:[NSColor disabledControlTextColor]];
[o_text3 setTextColor:[NSColor disabledControlTextColor]];
[o_text4 setTextColor:[NSColor disabledControlTextColor]];
}
else if([o_encoderMode indexOfSelectedItem] == 1) {
[o_bitrate setEnabled:NO];
[o_complexity setEnabled:NO];
[o_text1 setTextColor:[NSColor disabledControlTextColor]];
[o_text2 setTextColor:[NSColor disabledControlTextColor]];
[o_text5 setTextColor:[NSColor disabledControlTextColor]];
[o_vbrQuality setEnabled:YES];
[o_summary setTextColor:[NSColor controlTextColor]];
[o_text3 setTextColor:[NSColor controlTextColor]];
[o_text4 setTextColor:[NSColor controlTextColor]];
}
switch ([o_vbrQuality intValue]) {
case 0:
[o_summary setStringValue:@"Quality 0: HE-AAC v2, ~35kbps"];
break;
case 1:
[o_summary setStringValue:@"Quality 1: HE-AAC v2, ~45kbps"];
break;
case 2:
[o_summary setStringValue:@"Quality 2: HE-AAC, ~50kbps"];
break;
case 3:
[o_summary setStringValue:@"Quality 3: HE-AAC, ~75kbps"];
break;
case 4:
[o_summary setStringValue:@"Quality 4: HE-AAC, ~85kbps"];
break;
case 5:
[o_summary setStringValue:@"Quality 5: HE-AAC, ~100kbps"];
break;
case 6:
[o_summary setStringValue:@"Quality 6: LC-AAC, ~110kbps"];
break;
case 7:
[o_summary setStringValue:@"Quality 7: LC-AAC, ~130kbps"];
break;
case 8:
[o_summary setStringValue:@"Quality 8: LC-AAC, ~150kbps"];
break;
case 9:
[o_summary setStringValue:@"Quality 9: LC-AAC, ~250kbps"];
break;
default:
break;
}
if([o_manualLPF state] == NSOnState) {
[o_LPFFreq setEnabled:YES];
[o_text6 setTextColor:[NSColor controlTextColor]];
}
else {
[o_LPFFreq setEnabled:NO];
[o_text6 setTextColor:[NSColor disabledControlTextColor]];
}
}
- (void)loadConfigurations:(id)cfg
{
id obj;
if(obj=[cfg objectForKey:@"XLDFdkAacOutput_Bitrate"]) {
[o_bitrate setIntValue:[obj intValue]];
}
if(obj=[cfg objectForKey:@"XLDFdkAacOutput_Mode"]) {
if([obj intValue] < [o_encoderMode numberOfItems]) [o_encoderMode selectItemAtIndex:[obj intValue]];
}
if(obj=[cfg objectForKey:@"XLDFdkAacOutput_VBRQuality"]) {
[o_vbrQuality setIntValue:[obj intValue]];
}
if(obj=[cfg objectForKey:@"XLDFdkAacOutput_Complexity"]) {
[o_complexity selectCellWithTag:[obj intValue]];
}
if(obj=[cfg objectForKey:@"XLDFdkAacOutput_ManualLPF"]) {
[o_manualLPF setState:[obj intValue]];
}
if(obj=[cfg objectForKey:@"XLDFdkAacOutput_LPFFreq"]) {
[o_LPFFreq setIntValue:[obj intValue]];
}
[self modeChanged:self];
}
@end