lqt_x264.c

来自「这个库实现了录象功能」· C语言 代码 · 共 529 行 · 第 1/2 页

C
529
字号
/******************************************************************************* 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-2007 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_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"),    },    {      .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")    },    {      .name =        "x264_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 = "Constant quality" },      .stringlist_options = (char*[]){ TRS("Constant quality"),                                       TRS("Average bitrate"),                                       TRS("CRF based VBR"),                                       (char*)0 },      .help_string = TRS("Ratecontrol method:\n"                     "Constant quality: Specify a quantizer parameter below\n"                     "Average bitrate: Specify a bitrate below\n"                     "CRF based VBR: Specify a rate factor 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)")    },#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 = 26.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 = 26 },      .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_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.")    },    {      .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 },    },    {      .name =        "x264_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 },

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?