File: lqt_x264.c

package info (click to toggle)
libquicktime 2%3A1.2.4-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 5,848 kB
  • sloc: ansic: 55,288; sh: 10,976; makefile: 456; sed: 16
file content (738 lines) | stat: -rw-r--r-- 26,545 bytes parent folder | download | duplicates (8)
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
/*******************************************************************************
 lqt_x264.c

 libquicktime - A library for reading and writing quicktime/avi/mp4 files.
 http://libquicktime.sourceforge.net

 Copyright (C) 2002 Heroine Virtual Ltd.
 Copyright (C) 2002-2011 Members of the libquicktime project.

 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
 Software Foundation; either version 2.1 of the License, or (at your option)
 any later version.

 This library 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 Lesser General Public License for more
 details.

 You should have received a copy of the GNU Lesser General Public License along
 with this library; if not, write to the Free Software Foundation, Inc., 51
 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/ 

#include "lqt_private.h"
#include <quicktime/lqt_codecapi.h>
#include <x264.h> // X264_BUILD value
#include "qtx264.h"

static char * fourccs_x264[]  = { "avc1", (char*)0 };

static lqt_parameter_info_static_t encode_parameters_x264[] =
  {
    {
      .name =        "x264_sec_frame_type",
      .real_name =   TRS("Frame-type options"),
      .type =        LQT_PARAMETER_SECTION
    },
    {
      .name =        "x264_i_keyint_max",
      .real_name =   TRS("Maximum GOP size"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 250 },
    },
    {
      .name =        "x264_i_keyint_min",
      .real_name =   TRS("Minimum GOP size"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 25 },
    },
    {
      .name =        "x264_i_scenecut_threshold",
      .real_name =   TRS("Scenecut threshold"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 40 },
      .help_string = TRS("How aggressively to insert extra I-frames")
    },
    {
      .name =        "x264_i_bframe",
      .real_name =   TRS("B-Frames"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 16 },
      .help_string = TRS("Number of B-frames between I and P"),
    },
#if X264_BUILD < 63
    {
      .name =        "x264_b_bframe_adaptive",
      .real_name =   TRS("Adaptive B-frame decision"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
#else
    {
    .name =        "x264_i_bframe_adaptive",
    .real_name =   TRS("Adaptive B-frame decision"),
    .type =        LQT_PARAMETER_STRINGLIST,
    .val_default = { .val_string = "Fast" },
    .stringlist_options = (char*[]){ TRS("None"),
                                     TRS("Fast"),
                                     TRS("Trellis"),
                                     (char*)0 },
    },
#endif
    {
      .name =        "x264_i_bframe_bias",
      .real_name =   TRS("B-frame bias"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int =  -90 },
      .val_max =     { .val_int = 100 },
      .help_string = TRS("Influences how often B-frames are used"),
    },
#if X264_BUILD >= 88
    {
      .name =        "x264_i_bframe_pyramid",
      .real_name =   TRS("B-frame pyramid"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "Normal" },
      .stringlist_options = (char*[]){ TRS("None"),
                                       TRS("Strict"),
                                       TRS("Normal"),
                                       (char*)0 },
      .help_string = TRS("Keep some B-frames as references")
    },
#elif X264_BUILD >= 78
    {
      .name =        "x264_i_bframe_pyramid",
      .real_name =   TRS("B-frame pyramid"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 2 },
      .help_string = TRS("Keep some B-frames as references")
    },
#else
    {
      .name =        "x264_b_bframe_pyramid",
      .real_name =   TRS("B-frame pyramid"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .help_string = TRS("Keep some B-frames as references")
    },
#endif
    {
      .name =        "x264_sec_ratecontrol",
      .real_name =   TRS("Ratecontrol"),
      .type =        LQT_PARAMETER_SECTION
    },
    {
      .name =        "x264_i_rc_method",
      .real_name =   TRS("Ratecontrol method"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "CRF based VBR" },
      .stringlist_options = (char*[]){ TRS("Constant quality"),
                                       TRS("CRF based VBR"),
                                       TRS("Average bitrate"),
                                       (char*)0 },
      .help_string = TRS("Ratecontrol method:\n"
                     "Constant quality: Specify a quantizer parameter below\n"
                     "CRF based VBR: Specify a rate factor below\n"
                     "Average bitrate: Specify a bitrate below\n"
                         "Selecting 2-pass encoding will force Average bitrate."),
    },
    {
      .name =        "x264_i_bitrate",
      .real_name =   TRS("Bitrate"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .help_string = TRS("Bitrate in kbit/s. 0 means VBR (recommended)")
    },
    {
      .name =        "x264_f_rate_tolerance",
      .real_name =   TRS("Bitrate tolerance"),
      .type =        LQT_PARAMETER_FLOAT,
      .val_default = { .val_float = 1.0 },
      .val_min =     { .val_float = 0.0 },
      .val_max =     { .val_float = 100.0 },
      .num_digits =  1,
      .help_string = TRS("Allowed variance of average bitrate")
    },
    {
      .name =        "x264_i_vbv_max_bitrate",
      .real_name =   TRS("Maximum local bitrate"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .help_string = TRS("Sets a maximum local bitrate in kbits/s.")
    },
    {
      .name =        "x264_i_vbv_buffer_size",
      .real_name =   TRS("VBV Buffer size"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .help_string = TRS("Averaging period for the maximum local bitrate. "
                         "Measured in kbits.")
    },
    {
      .name =        "x264_f_vbv_buffer_init",
      .real_name =   TRS("Initial VBV buffer occupancy"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_default = { .val_float = 0.9 },
      .val_min =     { .val_float = 0.0 },
      .val_max =     { .val_float = 1.0 },
      .help_string = TRS("Sets the initial VBV buffer occupancy as a fraction of "
                         "the buffer size.")
    },
#if X264_BUILD >= 69
    {
      .name =        "x264_b_psy",
      .real_name =   TRS("Psy optimizations"),
      .type =        LQT_PARAMETER_INT,
      .val_min     = { .val_int = 0 },
      .val_max     = { .val_int = 1 },
      .val_default = { .val_int = 1 },
      .help_string = TRS("Psychovisual optimization"),
    },
#endif
    
#if X264_BUILD >= 63
    {
      .name =        "x264_f_psy_rd",
      .real_name =   TRS("Psy RD strength"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_min     = { .val_float = 0.0 },
      .val_max     = { .val_float = 10.0 },
      .val_default = { .val_float = 1.0 },
      .help_string = TRS("Strength of psychovisual optimization: RD (requires Partition decision >= 6)"),
    },
    {
      .name =        "x264_f_psy_trellis",
      .real_name =   TRS("Psy trellis strength"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_min     = { .val_float = 0.0 },
      .val_max     = { .val_float = 10.0 },
      .val_default = { .val_float = 0.0 },
      .help_string = TRS("Strength of psychovisual optimization (requires trellis)"),
    },
#endif
#if X264_BUILD >= 69
    {
      .name =        "x264_b_mb_tree",
      .real_name =   TRS("Macroblock-tree ratecontrol"),
      .type =        LQT_PARAMETER_INT,
      .val_min     = { .val_int = 0 },
      .val_max     = { .val_int = 1 },
      .val_default = { .val_int = 1 },
    },
    {
      .name =        "x264_i_lookahead",
      .real_name =   TRS("Lookahead"),
      .type =        LQT_PARAMETER_INT,
      .val_min     = { .val_int = 0 },
      .val_max     = { .val_int = 250 },
      .val_default = { .val_int = 40 },
      .help_string = TRS("Number of frames for frametype lookahead"),
    },
#endif
    {
      .name =        "x264_sec_quantizer",
      .real_name =   TRS("Quantizer"),
      .type =        LQT_PARAMETER_SECTION
    },
#if X264_BUILD < 54
    {
      .name =        "x264_i_rf_constant",
      .real_name =   TRS("Nominal Quantizer parameter"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 26 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 51 },
      .help_string = TRS("This selects the nominal quantizer to use (1 to 51). "
                     "Lower values result in better fidelity, but higher "
                         "bitrates. 26 is a good default value. 0 means lossless.")
    },
#else
    {
      .name =        "x264_f_rf_constant",
      .real_name =   TRS("Nominal Quantizer parameter"),
      .type =        LQT_PARAMETER_FLOAT,
      .val_default = { .val_float = 23.0 },
      .val_min =     { .val_float = 0.0 },
      .val_max =     { .val_float = 51.0 },
      .help_string = TRS("This selects the nominal quantizer to use (1 to 51). "
                     "Lower values result in better fidelity, but higher "
                         "bitrates. 26 is a good default value. 0 means lossless.")
    },
#endif
    {
      .name =        "x264_i_qp_constant",
      .real_name =   TRS("Quantizer parameter"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 23 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 51 },
      .help_string = TRS("This selects the quantizer to use (1 to 51). Lower "
                     "values result in better fidelity, but higher bitrates. "
                         "26 is a good default value. 0 means lossless.")
    },
    {
      .name =        "x264_i_qp_min",
      .real_name =   TRS("Minimum quantizer parameter"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 10 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 51 },
      .help_string = TRS("Minimum quantizer parameter")
    },
    {
      .name =        "x264_i_qp_max",
      .real_name =   TRS("Maximum quantizer parameter"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 51 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 51 },
      .help_string = TRS("Maximum quantizer parameter")
    },
    {
      .name =        "x264_i_qp_step",
      .real_name =   TRS("Maximum QP step"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 4 },
      .val_min =     { .val_int = 1 },
      .val_max =     { .val_int = 50 },
      .help_string = TRS("Maximum quantizer step")
    },
    {
      .name =        "x264_f_ip_factor",
      .real_name =   TRS("QP factor between I and P"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_default = { .val_float = 1.40 },
    },
    {
      .name =        "x264_f_pb_factor",
      .real_name =   TRS("QP factor between P and B"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_default = { .val_float = 1.30 },
    },
#if X264_BUILD >= 62
    {
      .name =        "x264_i_aq_mode",
      .real_name =   TRS("Adaptive quantization"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "Variance AQ (complexity mask)" },
      .stringlist_options = (char*[]){ TRS("None"),
                                       TRS("Variance AQ (complexity mask)"),
#if X264_BUILD >= 69
                                       TRS("Autovariance AQ (experimental)"),
#endif
                                       (char*)0 },
    },
    {
      .name =        "x264_f_aq_strength",
      .real_name =   TRS("AQ strength"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_min     = { .val_float = 0.5 },
      .val_max     = { .val_float = 1.5 },
      .val_default = { .val_float = 1.0 },
      .help_string = TRS("Adaptive quantization strength:\n"
                         "Reduces blocking and blurring in flat and\n"
                         "textured areas"),
    },
#endif

#if X264_BUILD >= 88
    {
      .name =        "x264_f_qcompress",
      .real_name =   TRS("QP curve compression"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_min     = { .val_float = 0.0 },
      .val_max     = { .val_float = 1.0 },
      .val_default = { .val_float = 0.6 },
      .help_string = TRS("Only for 2-pass encoding"),
    },
    {
      .name =        "x264_f_qblur",
      .real_name =   TRS("QP Reduce fluctuations in QP (after curve compression)"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_default = { .val_float = 0.5 },
      .help_string = TRS("Only for 2-pass encoding"),
    },
    {
      .name =        "x264_f_complexity_blur",
      .real_name =   TRS("Temporally blur complexity"),
      .type =        LQT_PARAMETER_FLOAT,
      .num_digits =  2,
      .val_default = { .val_float = 20 },
      .help_string = TRS("Only for 2-pass encoding"),
    },
    {
      .name =        "x264_i_chroma_qp_offset",
      .real_name =   TRS("QP difference between chroma and luma"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
    },
    {
      .name =        "x264_i_luma_deadzone_0",
      .real_name =   TRS("Inter luma quantization deadzone"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 21 },
    },
    {
      .name =        "x264_i_luma_deadzone_1",
      .real_name =   TRS("Intra luma quantization deadzone"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 11 },
    },
#endif

    {
      .name =        "x264_sec_partitions",
      .real_name =   TRS("Partitions"),
      .type =        LQT_PARAMETER_SECTION,
    },
    {
      .name =        "x264_analyse_8x8_transform",
      .real_name =   TRS("8x8 transform"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
    {
      .name =        "x264_analyse_psub16x16",
      .real_name =   TRS("8x16, 16x8 and 8x8 P-frame search"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
    {
      .name =        "x264_analyse_bsub16x16",
      .real_name =   TRS("8x16, 16x8 and 8x8 B-frame search"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
    {
      .name =        "x264_analyse_psub8x8",
      .real_name =   TRS("4x8, 8x4 and 4x4 P-frame search"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
    {
      .name =        "x264_analyse_i8x8",
      .real_name =   TRS("8x8 Intra search"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .help_string = TRS("8x8 Intra search requires 8x8 transform"),
    },
    {
      .name =        "x264_analyse_i4x4",
      .real_name =   TRS("4x4 Intra search"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
    {
      .name =        "x264_sec_me",
      .real_name =   TRS("Motion estimation"),
      .type =        LQT_PARAMETER_SECTION,
    },
    {
      .name =        "x264_i_me_method",
      .real_name =   TRS("Method"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "Hexagonal search" },
      .stringlist_options = (char*[]){ TRS("Diamond search"),
                                       TRS("Hexagonal search"),
                                       TRS("Uneven Multi-Hexagon"),
                                       TRS("Exhaustive search"),
#if X264_BUILD > 57
                                       TRS("Hadamard exhaustive search (slow)"),
#endif

                                       (char*)0 },
      .help_string = TRS("Motion estimation method\n"
                     "Diamond search: fastest\n"
                     "Hexagonal search: default setting\n"
                     "Uneven Multi-Hexagon: better but slower\n"
                         "Exhaustive search: extremely slow, primarily for testing")
    },
    {
      .name =        "x264_i_subpel_refine",
      .real_name =   TRS("Partition decision"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 1 },
#if X264_BUILD < 65
      .val_max =     { .val_int = 7 },
#else
      .val_max =     { .val_int = 9 },
#endif
#if X264_BUILD < 88
      .val_default = { .val_int = 5 },
#else
      .val_default = { .val_int = 7 },
#endif
      .help_string = TRS("Subpixel motion estimation and partition decision "
#if X264_BUILD < 65
                         "quality: 1=fast, 7=best.")
#else
                         "quality: 1=fast, 9=best.")
#endif
    },
#if X264_BUILD < 65
    {
      .name =        "x264_b_bframe_rdo",
      .real_name =   TRS("RD based mode decision for B-frames"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .val_default = { .val_int = 0 },
      .help_string = TRS("RD based mode decision for B-frames. Requires partition "
                         "decision 6.")
    },
#endif
    {
      .name =        "x264_i_me_range",
      .real_name =   TRS("Search range"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 16 },
      .help_string = TRS("Maximum distance to search for motion estimation, "
                     "measured from predicted position(s). Default of 16 is "
                     "good for most footage, high motion sequences may benefit "
                         "from settings between 24-32.")
    },
    {
      .name =        "x264_i_frame_reference",
      .real_name =   TRS("Max Ref. frames"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 1 },
      .val_max =     { .val_int = 16 },
      .val_default = { .val_int = 1 },
      .help_string = TRS("This is effective in Anime, but seems to make little "
                     "difference in live-action source material. Some decoders "
                         "are unable to deal with large frameref values.")
    },
    {
      .name =        "x264_b_chroma_me",
      .real_name =   TRS("Chroma motion estimation"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .val_default = { .val_int = 1 },
    },
    {
      .name =        "x264_b_mixed_references",
      .real_name =   TRS("Mixed references"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .val_default = { .val_int = 1 },
      .help_string = TRS("Allow each MB partition in P-frames to have it's own "
                         "reference number")
    },
#if X264_BUILD < 65
    {
      .name =        "x264_b_bidir_me",
      .real_name =   TRS("Bidirectional ME"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .val_default = { .val_int = 0 },
      .help_string = TRS("Jointly optimize both MVs in B-frames")
    },
#endif
    {
      .name =        "x264_b_weighted_bipred",
      .real_name =   TRS("Weighted biprediction"),
      .type =        LQT_PARAMETER_INT,
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .val_default = { .val_int = 0 },
      .help_string = TRS("Implicit weighting for B-frames")
    },
#if X264_BUILD >= 88
    {
      .name =        "x264_i_weighted_pred",
      .real_name =   TRS("Weighted prediction for P-frames"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "Smart analysis" },
      .stringlist_options = (char*[]){ TRS("Disabled"),
                                       TRS("Blind offset"),
                                       TRS("Smart analysis"),
                                       (char*)0 },
    },
#endif
    {
      .name =        "x264_i_direct_mv_pred",
      .real_name =   TRS("Direct MV prediction mode"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "Spatial" },
      .stringlist_options = (char*[]){ TRS("None"),
                                       TRS("Spatial"),
                                       TRS("Temporal"),
                                       TRS("Auto"),
                                       (char*)0 },
    },
    {
      .name =        "x264_sec_misc",
      .real_name =   TRS("Misc"),
      .type =        LQT_PARAMETER_SECTION,
    },
    {
      .name =        "x264_b_deblocking_filter",
      .real_name =   TRS("Deblocking filter"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .help_string = TRS("Use deblocking loop filter (increases quality).")
    },
    {
      .name =        "x264_i_deblocking_filter_alphac0",
      .real_name =   TRS("Deblocking filter strength"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = -6 },
      .val_max =     { .val_int = 6 },
      .help_string = TRS("Loop filter AlphaC0 parameter")
    },
    {
      .name =        "x264_i_deblocking_filter_beta",
      .real_name =   TRS("Deblocking filter threshold"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = -6 },
      .val_max =     { .val_int = 6 },
      .help_string = TRS("Loop filter Beta parameter")
    },
    {
      .name =        "x264_b_cabac",
      .real_name =   TRS("Enable CABAC"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
      .help_string = TRS("Enable CABAC (Context-Adaptive Binary Arithmetic "
                     "Coding). Slightly slows down encoding and decoding, but "
                         "should save 10-15% bitrate.")
    },
    {
      .name =        "x264_i_trellis",
      .real_name =   TRS("Trellis RD quantization"),
      .type =        LQT_PARAMETER_STRINGLIST,
      .val_default = { .val_string = "Enabled (final)" },
      .stringlist_options = (char*[]){ TRS("Disabled"),
                                       TRS("Enabled (final)"),
                                       TRS("Enabled (always)"),
                                       (char*)0 },
      .help_string = TRS("Trellis RD quantization. Requires CABAC. Can be enabled "
                     "either for the final encode of a MB or for all mode "
                         "desisions")
    },
    {
      .name =        "x264_i_noise_reduction",
      .real_name =   TRS("Noise reduction"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 0 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1<<16 } 
    },
#if X264_BUILD >= 28
    {
      .name =        "x264_i_threads",
      .real_name =   TRS("Threads"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      // .val_min =     { .val_int =  },
      // .val_max =     { .val_int = 256 },
      .help_string = TRS("Number of threads")
    },
#endif
#if X264_BUILD >= 88
    {
      .name =        "x264_b_fast_pskip",
      .real_name =   TRS("early SKIP detection on P-frames"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
    {
      .name =        "x264_b_dct_decimate",
      .real_name =   TRS("Transform coefficient thresholding on P-frames"),
      .type =        LQT_PARAMETER_INT,
      .val_default = { .val_int = 1 },
      .val_min =     { .val_int = 0 },
      .val_max =     { .val_int = 1 },
    },
#endif
    { /* End of parameters */ }
  };

static lqt_codec_info_static_t codec_info_x264 =
  {
    .name =                "x264",
    .long_name =           TRS("H.264 (MPEG4 AVC) encoder"),
    .description =         TRS("Based on the x264 library"),
    .fourccs =             fourccs_x264,
    .type =                LQT_CODEC_VIDEO,
    .direction =           LQT_DIRECTION_ENCODE,
    .encoding_parameters = encode_parameters_x264,
    .decoding_parameters = (lqt_parameter_info_static_t*)0,
    .compatibility_flags = LQT_FILE_QT_OLD |
                           LQT_FILE_QT |
                           LQT_FILE_MP4 |
                           LQT_FILE_AVI |
                           LQT_FILE_AVI_ODML,
    .compression_id      = LQT_COMPRESSION_H264,
  };

/* These are called from the plugin loader */

LQT_EXTERN int get_num_codecs() { return 1; }

LQT_EXTERN lqt_codec_info_static_t * get_codec_info(int index)
  {
  switch(index)
    {
    case 0:
      return &codec_info_x264;
    }
  return (lqt_codec_info_static_t*)0;
  }

/*
 *   Return the actual codec constructor
 */

LQT_EXTERN lqt_init_codec_func_t get_codec(int index)
  {
  switch(index)
    {
    case 0:
      return quicktime_init_codec_x264;
      break;
    }
  return (lqt_init_codec_func_t)0;
  }