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

📄 yuvscaler.c

📁 Motion JPEG编解码器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	    {	      output = 1;	      interlaced = Y4M_ILACE_NONE;	      display_width = 352;	      if (norm == 0)		{		  mjpeg_info		    ("LOVCDSTILL output format requested in PAL/SECAM norm");		  display_height = 288;		}	      else if (norm == 1)		{		  mjpeg_info ("LOVCDSTILL output format requested in NTSC norm");		  display_height = 240;		}	      else		mjpeg_error_exit1		  ("No norm specified, cannot determine LOVCDSTILL output size. Please use the -n option!");	    }	  if (strcmp (optarg, MONO_KEYWORD) == 0)	    {	      output = 1;	      mono = 1;	    }	  if (output == 0)	    mjpeg_error_exit1 ("Uncorrect output keyword: %s", optarg);	  break;	  // **************            	  // MODE KEYOWRD	  // *************	case 'M':	  mode = 0;	   	   if (strcmp (optarg, WIDE2STD_KEYWORD) == 0)	    {	      wide = 1;	      mode = 1;	    }	   // developper's Testing purpose only	   if (strcmp (optarg, NOMMX) == 0)	    {#ifdef HAVE_ASM_MMX	       	      mmx = 0;#endif	       	      mode = 1;	    }	  if (strcmp (optarg, RESAMPLE) == 0)	    {	      mode = 1;	      algorithm = 0;	    }	  if (strcmp (optarg, BICUBIC) == 0)	    {	      mode = 1;	      algorithm = 1;	    }	  if (strcmp (optarg, NO_HEADER) == 0)	    {	      mode = 1;	      no_header = 1;	    }	  if (strncmp (optarg, RATIO_KEYWORD, 6) == 0)	    {	      if (sscanf (optarg, "RATIO_%u_%u_%u_%u", &ui1, &ui2, &ui3, &ui4)		  == 4)		{		  // A coherence check will be done when the useful input sizes are known		  ratio = 1;		  mode = 1;		  input_width_slice = ui1;		  output_width_slice = ui2;		  input_height_slice = ui3;		  output_height_slice = ui4;		}	      if (ratio == 0)		mjpeg_error_exit1 ("Unconsistent RATIO keyword: %s", optarg);	    }	  if (strcmp (optarg, FAST_WIDE2VCD) == 0)	    {	      wide = 1;	      mode = 1;	      ratio = 1;	      input_width_slice = 2;	      output_width_slice = 1;	      input_height_slice = 2;	      output_height_slice = 1;	      vcd = 1;	      svcd = 0;		// if user gives VCD and SVCD keyword, take last one only into account	      display_width = 352;	      if (norm == 0)		{		  mjpeg_info		    ("VCD output format requested in PAL/SECAM norm");		  display_height = 288;		}	      else if (norm == 1)		{		  mjpeg_info ("VCD output format requested in NTSC norm");		  display_height = 240;		}	      else		mjpeg_error_exit1		  ("No norm specified, cannot determine VCD output size. Please use the -n option!");	    }	  if (strcmp (optarg, WIDE2VCD) == 0)	    {	      wide = 1;	      mode = 1;	      vcd = 1;	      svcd = 0;		// if user gives VCD and SVCD keyword, take last one only into account	      display_width = 352;	      if (norm == 0)		{		  mjpeg_info		    ("VCD output format requested in PAL/SECAM norm");		  display_height = 288;		}	      else if (norm == 1)		{		  mjpeg_info ("VCD output format requested in NTSC norm");		  display_height = 240;		}	      else		mjpeg_error_exit1		  ("No norm specified, cannot determine VCD output size. Please use the -n option!");	    }	  if (strcmp (optarg, FASTVCD) == 0)	    {	      mode = 1;	      vcd = 1;	      svcd = 0;		// if user gives VCD and SVCD keyword, take last one only into account	      ratio = 1;	      input_width_slice = 2;	      output_width_slice = 1;	      input_height_slice = 2;	      output_height_slice = 1;	      display_width = 352;	      if (norm == 0)		{		  mjpeg_info		    ("VCD output format requested in PAL/SECAM norm");		  display_height = 288;		}	      else if (norm == 1)		{		  mjpeg_info ("VCD output format requested in NTSC norm");		  display_height = 240;		}	      else		mjpeg_error_exit1		  ("No norm specified, cannot determine VCD output size. Please use the -n option!");	    }	  if (mode == 0)	    mjpeg_error_exit1 ("Uncorrect mode keyword: %s", optarg);	  break;	  // **************            	  // INPUT KEYOWRD	  // *************	case 'I':	  input = 0;	  if (strncmp (optarg, USE_KEYWORD, 4) == 0)	    {	      input = 1;	      if (sscanf (optarg, "USE_%ux%u+%u+%u", &ui1, &ui2, &ui3, &ui4)		  == 4)		{		  // Coherence check: 		  // every values must be multiple of 2		  // and if input is interlaced, height offsets must be multiple of 4		  // since U and V have half Y resolution and are interlaced		  // and the required zone must be inside the input size		  if ((ui1 % 2 == 0) && (ui2 % 2 == 0) && (ui3 % 2 == 0)		      && (ui4 % 2 == 0) && (ui1 + ui3 <= input_width)		      && (ui2 + ui4 <= input_height))		    {		      input_useful_width = ui1;		      input_useful_height = ui2;		      input_discard_col_left = ui3;		      input_discard_line_above = ui4;		      input_discard_col_right =			input_width - input_useful_width -			input_discard_col_left;		      input_discard_line_under =			input_height - input_useful_height -			input_discard_line_above;		      input_useful = 1;		    }		  else		    mjpeg_error_exit1		      ("Unconsistent USE keyword: %s, offsets/sizes not multiple of 2 or offset+size>input size",		       optarg);		  if (interlaced != Y4M_ILACE_NONE)		    {		      if ((input_useful_height % 4 != 0)			  || (input_discard_line_above % 4 != 0))			mjpeg_error_exit1			  ("Unconsistent USE keyword: %s, height offset or size not multiple of 4 but input is interlaced!!",			   optarg);		    }		}	       else		 mjpeg_error_exit1		 ("Uncorrect USE input flag argument: %s", optarg);	    }	  if (strncmp (optarg, ACTIVE, 6) == 0)	    {	      input = 1;	      if (sscanf		  (optarg, "ACTIVE_%ux%u+%u+%u", &ui1, &ui2, &ui3, &ui4) == 4)		{		  // Coherence check : offsets must be multiple of 2 since U and V have half Y resolution 		  // if interlaced, height must be multiple of 4		  // and the required zone must be inside the input size		  if ((ui1 % 2 == 0) && (ui2 % 2 == 0) && (ui3 % 2 == 0)		      && (ui4 % 2 == 0) && (ui1 + ui3 <= input_width)		      && (ui2 + ui4 <= input_height))		    {		      input_active_width = ui1;		      input_active_height = ui2;		      input_black_col_left = ui3;		      input_black_line_above = ui4;		      input_black_col_right =			input_width - input_active_width -			input_black_col_left;		      input_black_line_under =			input_height - input_active_height -			input_black_line_above;		      input_black = 1;		    }		  else		    mjpeg_error_exit1		      ("Unconsistent ACTIVE keyword: %s, offsets/sizes not multiple of 2 or offset+size>input size",		       optarg);		  if (interlaced != Y4M_ILACE_NONE)		    {		      if ((input_active_height % 4 != 0)			  || (input_black_line_above % 4 != 0))			mjpeg_error_exit1			  ("Unconsistent ACTIVE keyword: %s, height offset or size not multiple of 4 but input is interlaced!!",			   optarg);		    }		}	      else		mjpeg_error_exit1		  ("Uncorrect ACTIVE input flag argument: %s", optarg);	    }	  if (input == 0)	    mjpeg_error_exit1 ("Uncorrect input keyword: %s", optarg);	  break;	default:	   break;	}    }// Interlacing warnings  if (vcd == 1)    {       if ((interlaced == Y4M_ILACE_TOP_FIRST)	   || (interlaced == Y4M_ILACE_BOTTOM_FIRST))	 mjpeg_warn	 ("Interlaced input frames will be downscaled to non-interlaced VCD frames\nIf quality is an issue, please consider deinterlacing input frames with yuvdeinterlace");       interlaced = Y4M_ILACE_NONE;    }  // Size Keyword final coherence check  if ((interlaced != Y4M_ILACE_NONE) && (size_keyword == 1))    {      if (display_height % 4 != 0)	mjpeg_error_exit1	  ("Unconsistent SIZE keyword, Height is not multiple of 4 but output interlaced!!");    }  // Unspecified input variables specification  if (input_useful_width == 0)    input_useful_width = input_width;  if (input_useful_height == 0)    input_useful_height = input_height;  // Ratio coherence check against input_useful size  if (ratio == 1)    {      if ((input_useful_width % input_width_slice == 0)	  && (input_useful_height % input_height_slice == 0))	{	  output_active_width =	    (input_useful_width / input_width_slice) * output_width_slice;	  output_active_height =	    (input_useful_height / input_height_slice) * output_height_slice;	}      else	mjpeg_error_exit1	  ("Specified input ratios (%u and %u) does not divide input useful size (%u and %u)!",	   input_width_slice, input_height_slice, input_useful_width,	   input_useful_height);    }  // if USE and ACTIVE keywords were used, redefined input ACTIVE size relative to USEFUL zone  if ((input_black == 1) && (input_useful == 1))    {      input_black_line_above =	input_black_line_above >	input_discard_line_above ? input_black_line_above -	input_discard_line_above : 0;      input_black_line_under =	input_black_line_under >	input_discard_line_under ? input_black_line_under -	input_discard_line_under : 0;      input_black_col_left =	input_black_col_left >	input_discard_col_left ? input_black_col_left -	input_discard_col_left : 0;      input_black_col_right =	input_black_col_right >	input_discard_col_right ? input_black_col_right -	input_discard_col_right : 0;      input_active_width =	input_useful_width - input_black_col_left - input_black_col_right;      input_active_height =	input_useful_height - input_black_line_above - input_black_line_under;      if ((input_active_width == input_useful_width)	  && (input_active_height == input_useful_height))	input_black = 0;	// black zone is not enterely inside useful zone    }  // Unspecified output variables specification  if (output_active_width == 0)    output_active_width = display_width;  if (output_active_height == 0)    output_active_height = display_height;//  if (display_width == 0)//    display_width = output_active_width;//  if (display_height == 0)//    display_height = output_active_height;  if (wide == 1)    output_active_height = (output_active_height * 3) / 4;  // Common pitfall! it is 3/4 not 9/16!  // Indeed, Standard ratio is 4:3, so 16:9 has an height that is 3/4 smaller than the display_height  // At this point, input size, input_useful size, output_active size and display size are specified  // Time for the final coherence check and black and skip initialisations  // Final check  output_width =    output_active_width > display_width ? output_active_width : display_width;

⌨️ 快捷键说明

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