📄 yuvcorrect_tune.c
字号:
/* * yuvcorrect_tune.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 // November: RGB corrections available as well as image splitting// TODO:// S, D and Q keystrokes#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <math.h>#include <fcntl.h>#include <signal.h>#include "yuv4mpeg.h"#include "yuvcorrect.h"#define yuvcorrect_tune_VERSION "26-11-2002"// For pointer adress alignementextern const uint16_t ALIGNEMENT; // 16 bytes alignement for mmx registers in SIMD instructions for Pentiumextern const char *legal_opt_flags;const float gamma_increment=0.01;const char FULL[] = "FULL";const char HALF_LEFT[] = "HALF_LEFT";const char HALF_RIGHT[] = "HALF_RIGHT";const char QUARTER_LEFT[] = "QUARTER_LEFT";const char QUARTER_RIGHT[] = "QUARTER_RIGHT";const char TQUARTER_LEFT[] = "3QUARTER_LEFT";const char TQUARTER_RIGHT[] = "3QUARTER_RIGHT";const char TOP[] = "TOP";const char BOTTOM[] = "BOTTOM";const char RGBFIRST[] = "RGBFIRST";void yuvcorrect_tune_print_usage (void);void add_reference_part(frame_t *frame,uint8_t *final_ref,uint8_t type);void yuvcorrect_tune_handle_args (int argc, char *argv[], overall_t *overall, general_correction_t *gen_correct);// *************************************************************************************voidyuvcorrect_tune_print_usage (void){ fprintf (stderr, "usage: yuvcorrect_tune -I <filename> -F <Ref Frame> -M [mode_keyword] -Y [yuv_keyword] -R [RGB_keyword] [-v 0-2] [-h]\n" "yuvcorrect_tune is an interactive tool enabling you to interactively tune different\n" "corrections related to interlacing, luminance and color. <filename> defines the uncorrected\n" "reference yuv frames (in yuv4MPEG 4:2:0 format)\n" "Typical use is 'lav2yuv -f 1 <videofile> > frame ; cat fifo | yuvplay ; yuvcorrect_tune -I frame <keywords> > fifo' \n" "\n" "yuvcorrect_tune is keyword driven :\n" "\t -I <filename>\n" "\t -F <Ref Frame> (optional)\n" "\t -M for keyword concerning the correction MODE of yuvcorrect_tune\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" "\n" "\t Yuvcorrect_tune uses _only_ the first frame it reads from <filename> and all corrections defined on command\n" "\t line will then be applied to this frame to generate the image frame.\n" "\t It is to this image frame that color corrections will be applied, as defined by succesive keystrokes\n" "\t on the keyboard. By default, the resulting corrected frame is then outputted to stdout.\n" "\t But - using mode keywords - part of this corrected frame may be replaced by the corresponding part of a\n" "\t Ref frame (-F keyword) like colorbars, thus enabling to visually adjust correction to match the reference frame.\n" "\n" "Possible mode keyword are:\n" "\t FULL (default)\n" "\t HALF_LEFT The generated frame is now constituted of two different parts:\n" "\t the left half shows the final reference uncorrected while the right half shows it corrected\n" "\t HALF_RIGHT Same as HALF_LEFT except right and left are inversed\n" "\t QUARTER_LEFT Same as HALF_LEFT except the uncorrected part is only a quarter of the image\n" "\t QUARTER_RIGHT Same as HALF_RIGHT except the uncorrected part is only a quarter of the image\n" "\t 3QUARTER_LEFT The left three quarters of the image is uncorrected, the right quarter corrected\n" "\t 3QUARTER_RIGHT The right three quarters of the image is uncorrected, the left quarter corrected\n" "\t TOP the top half is uncorrected, the bottom half is corrected\n" "\t BOTTOM the bottom half is uncorrected, the top half is corrected\n" "\t RGBFIRST to have yuvcorrect_tune apply RGB corrections first, then YUV corrections\n" "\n" "Possible yuv keywords are:\n" "\t LUMINANCE_Gamma_InputYmin_InputYmax_OutputYmin_OutputYmax\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\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_tune 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" "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" "How to use the keyboard:\n" "Pressing Y, U, V, R, G, B or M will tell yuvcorrect_tune that all following keystrokes refer to corrections applied to\n" "Y values, UV values, UV values, R values, G values, B values, Mode of yuvcorrect_tune ; until ESCAPE is pressed\n" "To define corrections, use Capital letter to increase and minor letter to decrease\n" "Gamma values are changed by amount of 0.01, Ufactor and Vfactor by 0.05; UVrotation by amount of 1 degree; Integer values by 1\n" "To modify the 1st, 2nd, 3rd, 4th, 5th, 6th or 7th parameter, use respectively e/E, r/R, t/T, y/Y, u/U, i/I, o/O\n" "To modify yuvcorrect_tune mode, use keypad values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n" "For status, press S. To go back to default, press D. To quit, press Q.\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; optind = 1; while ((c = getopt (argc, argv, legal_opt_flags)) != -1) { switch (c) { case 'I': if ((overall->ImgFrame=open(optarg,O_RDONLY))==-1) mjpeg_error_exit1("Unable to open %s!!",optarg); break; case 'F': if ((overall->RefFrame=open(optarg,O_RDONLY))==-1) mjpeg_error_exit1("Unable to open %s!!",optarg); break; 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_tune_print_usage (); break; default: break; } } if ((optind != argc)||(overall->ImgFrame==-1)) yuvcorrect_tune_print_usage (); if (overall->RefFrame==-1) overall->RefFrame=overall->ImgFrame;}// *************************************************************************************// *************************************************************************************voidyuvcorrect_tune_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; // 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 + -