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

📄 yuvcorrect.c

📁 Motion JPEG编解码器源代码
💻 C
字号:
/*  *  yuvcorrect.c  *  Copyright (C) 2002 Xavier Biquard <xbiquard@free.fr>  *   *  This program is free software; you can redistribute it and/or modify  *  it under the terms of the GNU General Public License as published by  *  the Free Software Foundation; either version 2 of the License, or  *  (at your option) any later version.  *  *  This program 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 General Public License for more details.  *  *  You should have received a copy of the GNU General Public License  *  along with this program; if not, write to the Free Software  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */// September/October 2002: First version // TODO:// Slow down possibility at 1:2 => all preprocessing in a new utility called yuvcorrect#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <math.h>#include <signal.h>#include "yuv4mpeg.h"#include "yuvcorrect.h"extern const uint16_t OFFSET;extern const uint16_t ALIGNENEMENT;extern const char *legal_opt_flags;  const char PIPE[] = "PIPE";const char STAT[] = "STAT";const char FULL[] = "FULL";const char HALF[] = "HALF";const char TOP_FIRST[] = "INTERLACED_TOP_FIRST";const char BOT_FIRST[] = "INTERLACED_BOTTOM_FIRST";const char NOT_INTER[] = "NOT_INTERLACED";const char PROGRESSIVE[] = "PROGRESSIVE";const char LINESWITCH[] = "LINE_SWITCH";const char NO_HEADER[] = "NO_HEADER";const char TOP_FORWARD[] = "TOP_FORWARD";const char BOTT_FORWARD[] = "BOTT_FORWARD";const char RGBFIRST[] = "RGBFIRST";#define yuvcorrect_VERSION "16-11-2002"// Prototypes specific to yuvcorrectvoid yuvcorrect_print_usage (void);void yuvcorrect_print_information (general_correction_t * gen_correct,				   yuv_correction_t * yuv_correct,				   rgb_correction_t * rgb_correct);void yuvcorrect_handle_args (int argc, char *argv[], overall_t * overall,			     general_correction_t * gen_correct);// *************************************************************************************voidyuvcorrect_print_usage (void){  fprintf (stderr,	   "usage: yuvcorrect -M [mode_keyword] -T [general_keyword] -Y [yuv_keyword] -R [RGB_keyword]  [-v 0-2] [-h]\n"	   "yuvcorrect applies different corrections related to interlacing and color\n"	   "to yuv frames coming from stdin (in yuv4MPEG 4:2:0 format) to stdout.\n"	   "In contrast to yuvscaler, frame size is kept constant.\n"	   "\n"	   "yuvcorrect is keyword driven :\n"	   "\t -M for keyword concerning the correction MODE of yuvcorrect\n"	   "\t -T for keyword concerning spatial, temporal or header corrections to be applied\n"	   "\t -Y for keyword concerning color corrections in the yuv space\n"	   "\t -R for keyword concerning color corrections in the RGB space\n"	   "By default, yuvcorrect will not modify frames and simply act as a pass-through. Also, it will apply\n"	   "YUV corrections first and then RGB corrections\n"	   "\n" "Possible mode keyword are:\n"	   "\t STAT to have yuvcorrect print statistical information on your frames _before_ corrections\n"	   "\t RGBFIRST to have yuvcorrect apply RGB corrections first, then YUV corrections\n"	   "\n"	   "Possible general keyword are:\n"	   "\t If you suspect that your video capture was given a wrong interlacing type,\n"	   "\t and/or was spatially or temporarly missed up, please use and combine:\n"	   "\t INTERLACED_TOP_FIRST    to correct file header by specifying top_field_first as interlacing type\n"	   "\t INTERLACED_BOTTOM_FIRST to correct file header by specifying bottom_field_first as interlacing\n"	   "\t NOT_INTERLACED          to correct file header by specifying not-interlaced/progressive as interlacing type\n"	   "\t PROGRESSIVE             to correct file header by specifying not-interlaced/progressive as interlacing type\n"	   "\t NO_HEADER    to suppress stream header generation (apply different corrections to different part of an input file)\n"	   "\t LINE_SWITCH  to switch lines two by two\n"	   "\t BOTT_FORWARD to move the bottom field one frame forward\n"	   "\t TOP_FORWARD  to move the top    field one frame forward\n"	   "\n"	   "Possible yuv keywords are:\n"	   "\t LUMINANCE_Gamma_InputYmin_InputYmax_OutputYmin_OutputYmax or\n"	   "\t Y_Gamma_InputYmin_InputYmax_OutputYmin_OutputYmax\n"	   "\t    to correct the input frame luminance by clipping it inside range [InputYmin;InputYmax],\n"	   "\t    scale with power (1/Gamma), and expand/shrink/shift it to [OutputYmin;OutputYmax]\n"	   "\t CHROMINANCE_UVrotation_Ufactor_Urotcenter_Vfactor_Vrotcenter_UVmin_UVmax or\n"	   "\t UV_UVrotation_Ufactor_Urotcenter_Vfactor_Vrotcenter_UVmin_UVmax\n"	   "\t    to rotate rescaled UV chroma components Ufactor*(U-Urotcenter) and Vfactor*(V-Vrotcenter)\n"	   "\t    by (float) UVrotation degrees, recenter to the normalize (128,128) center,\n"	   "\t    and _clip_ the result to range [UVmin;UVmax]\n"	   "\t CONFORM to have yuvcorrect generate frames conform to the Rec.601 specification for Y'CbCr frames\n"	   "\t    that is LUMINANCE_1.0_16_235_16_235 and CHROMINANCE_0.0_1.0_128_1.0_128_16_240\n"	   "\n"	   "\t Possible RGB keywords are:\n"	   "\t R_Gamma_InputRmin_InputRmax_OutputRmin_OutputRmax\n"	   "\t G_Gamma_InputGmin_InputGmax_OutputGmin_OutputGmax\n"	   "\t B_Gamma_InputBmin_InputBmax_OutputBmin_OutputBmax\n"	   "\t    to correct the input frame RGB color by clipping it inside range [InputRGBmin;InputRGBmax],\n"	   "\t    scale with power (1/Gamma), and expand/shrink/shift it to [OutputRGBmin;OutputRGBmax]\n"	   "\n"	   "-v  Specifies the degree of verbosity: 0=quiet, 1=normal, 2=verbose/debug\n"	   "-h : print this lot!\n");  exit (1);}// *************************************************************************************// ***********************************************************************voidhandle_args_overall (int argc, char *argv[], overall_t * overall){  int c, verb;  while ((c = getopt (argc, argv, legal_opt_flags)) != -1)    {      switch (c)	{	case 'v':	  verb = atoi (optarg);	  if (verb < 0 || verb > 2)	    {	      mjpeg_info		("Verbose level must be 0, 1 or 2 ! => resuming to default 1");	    }	  else	    {	      overall->verbose = verb;	    }	  break;	case 'h':	  yuvcorrect_print_usage ();	  break;	default:	  break;	}    }  if (optind != argc)    yuvcorrect_print_usage ();}// *************************************************************************************// *************************************************************************************voidyuvcorrect_handle_args (int argc, char *argv[], overall_t * overall,	     general_correction_t * gen_correct){  // This function handles argument passing on the command line  int c;  int k_mode, k_general;  // Ne pas oublier de mettre la putain de ligne qui suit, sinon, plus d'argument 

⌨️ 快捷键说明

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