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

📄 vpp.c

📁 C语言编写的监控中心终端程序。基于GPRS上传收发数据功能
💻 C
字号:
#include "config.h"
#include "regmap.h"
#include "global.h"
#include "avd.h"

#include "vpp.h"
#include "set.h"
#include "fs9660.h"

/*
** FUNCTION
** vpp_set_pic(int w, int h)
**
** DESCRIPTION
** setup picture display parameter according to following information
**
**  width of picture
**  height of picture
**  vpp_zoom
**  vpp_zoom_x
**  vpp_zoom_y
**
** REFERENCE
**  vpp_zoom    : 1:x1 2:x2 3:x4 4:x8
**  vpp_zoom_x  : starting display X
**  vpp_zoom_y  : starting display Y
**
*/

#define	TV_WIDTH		704
#define	TV_HEIGHT		((IsAVDDisplayNTSC()) ? 480 : 576)

/*
** VPP controls
*/
#define	FILTER_HEXP8		(RF_H_EXP_8_1)
#define	FILTER_HEXP4		(RF_H_EXP_4_1)
#define	FILTER_HEXP2		(RF_H_EXP_2_1)
#define	FILTER_HEXP3_2		(RF_H_EXP_3_2)
#define	FILTER_HEXP1		(RF_H_EXP_1_1)

enum
{
    ZOOM_X_x3_2		= -1,
    ZOOM_X_x1		= 1,
    ZOOM_X_x2		= 2,
    ZOOM_X_x4		= 4,
    ZOOM_X_x8		= 8,
};

enum
{
    ZOOM_Y_x1		= 1,
    ZOOM_Y_x2		= 2,
    ZOOM_Y_x4		= 4,
    ZOOM_Y_x8		= 8,
};

void vpp_set_pic(int width, int height)
{
    /*
     ** Decide expansion factor zoomX zoomY
     **
     ** if (vpp_zoom)
     **   use vpp_zoom to scale it
     ** else
     **   use decision rule to do it
     */
    zoomX = 1;
    zoomY = 1;

    if (vpp_zoom) {
	zoomX = zoomY = (vpp_zoom < 4) ? vpp_zoom : 4;
    }

    /*
     ** Decide display start (default: from TV pixel 0 line 0)
     */
    zoomX_start = 0;
    zoomY_start = 0;
    if (IsVPPKeepCentered()) {
	zoomX_start = (TV_WIDTH - width) >> 1;
	zoomY_start = (TV_HEIGHT - height) >> 1;
    }

    if (zoomX == ZOOM_X_x2)
	zoomX_start >>= 1;
    else if (zoomX == ZOOM_X_x4)
	zoomX_start >>= 2;
    else if (zoomX == ZOOM_X_x8)
	zoomX_start >>= 3;

    if (zoomY == ZOOM_Y_x2)
	zoomY_start >>= 1;
    else if (zoomY == ZOOM_Y_x4)
	zoomY_start >>= 2;
    else if (zoomY == ZOOM_Y_x8)
	zoomY_start >>= 3;

    /*
     ** decide display offset (default: from PIC pixel 0 line 0)
     */
    zoomX_pic_start = 0;
    zoomY_pic_start = 0;
    if (vpp_zoom) {
	zoomX_pic_start = 0;
	zoomY_pic_start = 0;
    }
    if (zoomX_pic_start < 0)
	zoomX_pic_start = 0;
    if (zoomX_pic_start >= width)
	zoomX_pic_start = width - 1;
    if (zoomY_pic_start < 0)
	zoomY_pic_start = 0;
    if (zoomY_pic_start >= height)
	zoomY_pic_start = height - 1;

    /*
     ** Decide display end (for a picture).
     ** We have to check if the VPP request if larger than the display
     */
    zoomX_size = width - zoomX_pic_start;
    zoomY_size = height - zoomY_pic_start;

    total = TV_WIDTH;
    if (zoomX == ZOOM_X_x2)
	total >>= 1;
    else if (zoomX == ZOOM_X_x4)
	total >>= 2;
    else if (zoomX == ZOOM_X_x8)
	total >>= 3;
    if (zoomX_size > total)
	zoomX_size = total;

    total = 576;
//  total = 288;
    if (zoomY == ZOOM_Y_x2)
	total >>= 1;
    else if (zoomY == ZOOM_Y_x4)
	total >>= 2;
    else if (zoomY == ZOOM_Y_x8)
	total >>= 3;
    if (zoomY_size > total)
	zoomY_size = total;

    if (height > 480)
	decode_type = DECODE_TYPE_PAL;
    else if (height > 288)
	decode_type = DECODE_TYPE_NTSC;
    else if (height > 240)
	decode_type = DECODE_TYPE_PAL;
    else
	decode_type = DECODE_TYPE_NTSC;

    if (width > 352) {
	switch (vpp_zoom) {
	case 0:
//	    v_filter_mode  = VINT_1_000;
//	    if ((width == 704) & (IsAVDDisplayPAL()))
//		v_filter_mode = VINT_1_200;
//	    break;
	case 1:
	    if (IsAVDDisplayPAL())
		v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				VINT_1_000 : VINT_1_200;
	    else
		v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				VINT_0_833 : VINT_1_000;
	    break;
	case 2:
	    v_filter_mode = VINT_2_000;
	    if ((width == 704) & (IsAVDDisplayPAL()))
		v_filter_mode = VINT_2_400;
//	    width = width / 2;
//	    height = height / 2;
	    break;
	case 3:
	    v_filter_mode = VINT_3_000;
	    if ((width == 704) & (IsAVDDisplayPAL()))
		v_filter_mode = VINT_3_600;
	    break;
	case 4:
	    v_filter_mode = VINT_4_000;
	    if ((width == 704) & (IsAVDDisplayPAL()))
		v_filter_mode = VINT_4_800;
//	    width = width / 4;
//	    height = height / 4;
	    break;
	default:
	    v_filter_mode = VINT_1_000;
	    if ((width == 704) & (IsAVDDisplayPAL()))
		v_filter_mode = VINT_1_200;
	    break;
	}

	switch (vpp_zoom) {
	case 0:
	    if ((cd_type_loaded == CDSVCD) && (width == 480))
		h_filter_mode = HEXP_1_500;
	    else
		h_filter_mode = HEXP_1_000;
	    break;
	case 1:
	    if ((cd_type_loaded == CDSVCD) && (width == 480))
		h_filter_mode = HEXP_1_500;
	    else
		h_filter_mode = HEXP_1_000;
	    break;
	case 2:
	    if ((cd_type_loaded == CDSVCD) && (width == 480))
		h_filter_mode = HEXP_3_000;
	    else
		h_filter_mode = CIF_ENABLE;
//	    width = width / 2;
//	    height = height / 2;
	    break;
	case 3:
	    if ((cd_type_loaded == CDSVCD) && (width == 480))
		h_filter_mode = HEXP_4_500;
	    else
		h_filter_mode = HEXP_3_000;
//	    width = width / 2;
//	    height = height / 2;
	    break;
	case 4:
	    if ((cd_type_loaded == CDSVCD) && (width == 480))
		h_filter_mode = HEXP_6_000;
	    else
		h_filter_mode = HEXP_2_000 + CIF_ENABLE;
//	    width = width / 4;
//	    height = height / 4;
	    break;
	default:
	    if ((cd_type_loaded == CDSVCD) && (width == 480))
		h_filter_mode = HEXP_1_500;
	    else
		h_filter_mode = HEXP_1_000;
	    break;
	}
    }
    else {		// VCD OKO
	if (cd_type_loaded == CDSVCD) {		// bondy 2002/3/18
	    switch (vpp_zoom) {
	    case 0:
	    case 1:
		if (height < 480) {
//		    for SVCD show logo
		    if (IsAVDDisplayPAL())
			v_filter_mode = VINT_2_000;
		    else
			v_filter_mode = VINT_1_667;
		}
		else {
		    if (IsAVDDisplayPAL())
			v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
					VINT_1_000 : VINT_1_200;
		    else
			v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
					VINT_1_000 : VINT_1_000;
		}
		h_filter_mode = CIF_ENABLE;
		break;
	    case 2:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_2_000 : VINT_2_400;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_2_000 : VINT_2_000;
		h_filter_mode = HEXP_2_000 + CIF_ENABLE;
		break;
	    case 3:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_3_000 : VINT_3_600;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_3_000 : VINT_3_000;
		h_filter_mode = HEXP_3_000 + CIF_ENABLE;
		break;
	    case 4:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_4_000 : VINT_4_800;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_4_000 : VINT_4_000;
		h_filter_mode = HEXP_4_000 + CIF_ENABLE;
		break;
	    default:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_1_000 : VINT_1_200;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_1_000 : VINT_1_000;
		h_filter_mode = CIF_ENABLE;
		break;
	    }
	}
	else {
	    switch (vpp_zoom) {
	    case 0:
	    case 1:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_2_000 : VINT_2_400;
		else {
		    if (cd_type_loaded != CDROM)
			v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
					VINT_1_667 : VINT_2_000;
		    else
			v_filter_mode = VINT_1_667;
		}
		h_filter_mode = CIF_ENABLE;
		break;
	    case 2:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_4_000 : VINT_4_800;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_3_333 : VINT_4_000;
		h_filter_mode = HEXP_2_000 + CIF_ENABLE;
		break;
	    case 3:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_6_000 : VINT_7_200;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_5_000 : VINT_6_000;
		h_filter_mode = HEXP_3_000 + CIF_ENABLE;
		break;
	    case 4:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_8_000 : VINT_9_600;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_6_666 : VINT_8_000;
		h_filter_mode = HEXP_4_000 + CIF_ENABLE;
		break;
	    default:
		if (IsAVDDisplayPAL())
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_2_000 : VINT_2_400;
		else
		    v_filter_mode = (decode_type == DECODE_TYPE_PAL) ?
				    VINT_1_667 : VINT_2_000;
		h_filter_mode = CIF_ENABLE;
		break;
	    }
	}
    }

    if (show_logo) {
	if (IsAVDDisplayPAL()) {
	    v_filter_mode = VINT_2_000;
	}
	else {
	    v_filter_mode = VINT_1_667;
	}
    }

    dis_width = width;
    dis_height = height;

    regs0->dis_tv_std = IsAVDDisplayPAL() ? 1 : 0;
//  regs0->dis_tv_out = 1 << 3; 	// RF_VOUT_SWAP_LC;
//  for emualtion (IsAVDDisplayPAL()) ?  RF_VOUT_SWAP_LC : 0;
}

⌨️ 快捷键说明

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