⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x264_gtk.c.svn-base

📁 一個影像串流的壓縮方式H264加密方式
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <errno.h>#include <math.h>#if defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __DragonFly__#  include <inttypes.h>#else#  include <stdint.h>#endif#ifdef _WIN32#  include <unistd.h>  /* for mkdir */#endif#include <x264.h>#include <gtk/gtk.h>#include "x264_gtk.h"#include "x264_gtk_private.h"#include "x264_gtk_enum.h"#include "x264_gtk_bitrate.h"#include "x264_gtk_rc.h"#include "x264_gtk_mb.h"#include "x264_gtk_more.h"#define CHECK_FLAG(a,flag) ((a) & (flag)) == (flag)#define round(a) ( ((a)<0.0) ? (gint)(floor((a) - 0.5)) : (gint)(floor((a) + 0.5)) )/* Callbacks */static void _dialog_run (GtkDialog       *dialog,                         gint             response,                         X264_Gui_Config *gconfig,                         X264_Gtk        *x264_gtk);/* x264 config management */static void _default_load (GtkButton *button, gpointer user_data);static void _current_get (X264_Gui_Config *gconfig, X264_Gtk *x264_gtk);static void _current_set (X264_Gui_Config *gconfig, X264_Gtk *x264_gtk);static void _default_set (X264_Gtk *x264_gtk);/* Result must be freed */x264_param_t *x264_gtk_param_get (X264_Gtk *x264_gtk){  x264_param_t *param;  if (!x264_gtk)    return NULL;  param = (x264_param_t *)g_malloc (sizeof (x264_param_t));  if (!param)    return NULL;  x264_param_default (param);  /* bitrate */  if (x264_gtk->pass == X264_PASS_SINGLE_BITRATE)    param->rc.i_bitrate  = x264_gtk->average_bitrate;  else    param->rc.i_bitrate = x264_gtk->target_bitrate;  param->rc.i_qp_constant = x264_gtk->quantizer;  /* FIXME: what to do about psz_stat_out ? */  /* rate control */  param->rc.f_ip_factor = 1.0 + (double)x264_gtk->keyframe_boost / 100.0;  param->rc.f_pb_factor = 1.0 + (double)x264_gtk->bframes_reduction / 100.0;  param->rc.f_qcompress = (double)x264_gtk->bitrate_variability / 100.0;  param->rc.i_qp_min = x264_gtk->min_qp;  param->rc.i_qp_max = x264_gtk->max_qp;  param->rc.i_qp_step = x264_gtk->max_qp_step;  param->i_scenecut_threshold = x264_gtk->scene_cut_threshold;  param->i_keyint_min = x264_gtk->min_idr_frame_interval;  param->i_keyint_max = x264_gtk->max_idr_frame_interval;  /* mb */  param->analyse.b_transform_8x8 = x264_gtk->transform_8x8;  param->analyse.inter = 0;  if (x264_gtk->pframe_search_8)    param->analyse.inter |= X264_ANALYSE_PSUB16x16;  if (x264_gtk->bframe_search_8)    param->analyse.inter |= X264_ANALYSE_BSUB16x16;  if (x264_gtk->pframe_search_4)    param->analyse.inter |= X264_ANALYSE_PSUB8x8;  if (x264_gtk->inter_search_8)    param->analyse.inter |= X264_ANALYSE_I8x8;  if (x264_gtk->inter_search_4)    param->analyse.inter |= X264_ANALYSE_I4x4;  param->i_bframe = x264_gtk->use_as_reference;  param->analyse.b_bidir_me = x264_gtk->bidir_me;  param->b_bframe_adaptive = x264_gtk->adaptive;  if ((x264_gtk->use_as_reference > 1) && x264_gtk->weighted_biprediction)    param->analyse.b_weighted_bipred = 1;  else    param->analyse.b_weighted_bipred = 0;  /* not used: */  /* x264_gtk->max_consecutive; */  param->i_bframe_bias = x264_gtk->bias;  param->analyse.i_direct_mv_pred = x264_gtk->direct_mode;  /* more */  param->analyse.i_subpel_refine = x264_gtk->partition_decision + 1;  param->analyse.b_bframe_rdo = x264_gtk->bframe_rdo;  param->analyse.i_me_method = x264_gtk->me_method;  param->analyse.i_me_range = x264_gtk->range;  param->analyse.b_chroma_me = x264_gtk->chroma_me;  param->analyse.i_trellis = x264_gtk->trellis;  param->analyse.i_noise_reduction = x264_gtk->noise_reduction;  param->i_frame_reference = x264_gtk->max_ref_frames;  param->analyse.b_mixed_references = x264_gtk->mixed_refs;  param->vui.i_sar_width = x264_gtk->sample_ar_x;  param->vui.i_sar_height = x264_gtk->sample_ar_y;  param->i_threads = x264_gtk->threads;  param->b_cabac = x264_gtk->cabac;  param->b_deblocking_filter = x264_gtk->deblocking_filter;  param->i_deblocking_filter_alphac0 = x264_gtk->strength;  param->i_deblocking_filter_beta = x264_gtk->threshold;  param->i_log_level = x264_gtk->debug_method - 1;  return param;}/* Result must be freed */X264_Gtk *x264_gtk_load (void){  X264_Gtk     *x264_gtk;  GIOChannel   *file;  GError       *error = NULL;  gchar        *filename;  x264_gtk = (X264_Gtk *)g_malloc0 (sizeof (X264_Gtk));  if (!x264_gtk)    return NULL;  filename = g_build_filename (g_get_home_dir (),                               ".x264",                               "/x264.cfg",                               NULL);  file = g_io_channel_new_file (filename, "r", &error);  if (error)    {      g_print ("x264.cfg: %s\n", error->message);      g_print ("Loading default configuration\n");      _default_set (x264_gtk);    }  else    {      GIOStatus status;      gchar    *data = NULL;      gsize     length;      g_print ("Loading configuration from %s\n", filename);      g_io_channel_set_encoding (file, NULL, NULL);      status = g_io_channel_read_to_end (file, &data, &length, &error);      if ((status == G_IO_STATUS_NORMAL) &&          (length == sizeof (X264_Gtk)))        {          memcpy (x264_gtk, data, length);        }      g_io_channel_shutdown (file, TRUE, NULL);      g_io_channel_unref (file);    }  g_free (filename);  return x264_gtk;}GtkWidget *x264_gtk_window_create (GtkWidget *parent){  GtkWidget       *win_x264_gtk;  GtkWidget       *notebook;  GtkWidget       *page;  GtkWidget       *button;  GtkWidget       *label;  X264_Gui_Config *gconfig;  X264_Gtk        *x264_gtk;  gint             result;  GtkDialogFlags   flags = 0;  gconfig = (X264_Gui_Config *)g_malloc (sizeof (X264_Gui_Config));  if (!gconfig)    return NULL;  x264_gtk = x264_gtk_load ();  if (parent)    flags = GTK_DIALOG_MODAL |GTK_DIALOG_DESTROY_WITH_PARENT;  win_x264_gtk = gtk_dialog_new_with_buttons ("X264 Configuration",                                              GTK_WINDOW (parent),                                              flags,                                              NULL);  button = gtk_button_new_with_label ("Default");  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (win_x264_gtk)->action_area), button, FALSE, TRUE, 6);  g_signal_connect (G_OBJECT (button),                    "clicked",                    G_CALLBACK (_default_load),                    gconfig);  gtk_widget_show (button);  gtk_dialog_add_buttons (GTK_DIALOG (win_x264_gtk),                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,                          GTK_STOCK_OK, GTK_RESPONSE_OK,                          NULL);  g_object_set_data (G_OBJECT (win_x264_gtk), "x264-gui-config", gconfig);  g_object_set_data (G_OBJECT (win_x264_gtk), "x264-config", x264_gtk);  gtk_window_set_resizable (GTK_WINDOW (win_x264_gtk), FALSE);  notebook = gtk_notebook_new ();  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (win_x264_gtk)->vbox), notebook);  gtk_widget_show (notebook);  label = gtk_label_new ("Bitrate");  gtk_widget_show (label);  page = _bitrate_page (gconfig);  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);  gtk_widget_show (page);  label = gtk_label_new ("Rate Control");  gtk_widget_show (label);  page = _rate_control_page (gconfig);  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);  gtk_widget_show (page);  label = gtk_label_new ("MB & Frames");  gtk_widget_show (label);  page = _mb_page (gconfig);  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);  gtk_widget_show (page);  label = gtk_label_new ("More...");  gtk_widget_show (label);  page = _more_page (gconfig);  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);  gtk_widget_show (page);  _current_set (gconfig, x264_gtk);  result = gtk_dialog_run (GTK_DIALOG (win_x264_gtk));  _dialog_run (GTK_DIALOG (win_x264_gtk), result, gconfig, x264_gtk);  return win_x264_gtk;}voidx264_gtk_shutdown (GtkWidget *dialog){  X264_Gui_Config *gconfig;  gconfig = g_object_get_data (G_OBJECT (dialog), "x264-gui-config");  gtk_widget_destroy (dialog);  if (gconfig)    g_free (gconfig);}/* Notebook pages *//* Callbacks */static void_dialog_run (GtkDialog       *dialog __UNUSED__,             gint             response,             X264_Gui_Config *gconfig,             X264_Gtk        *x264_gtk){  if (response == GTK_RESPONSE_OK)    {      GIOChannel *file;      gchar      *filename;      gchar      *dir;      gsize       length;      gint        res;#ifndef _WIN32      mode_t      mode;

⌨️ 快捷键说明

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