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

📄 av_play.c

📁 一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright 1996, ESS Technology, Inc.					*/
/* SCCSID @(#)av_play.c	1.97 11/13/98 */

/*
 * $Log$
 */

#include <stdlib.h>
#include <ctype.h>
#include "av_play.h"
#include "const.h"
#include "buffer.h"
#include "constvar.h"
#include "dsa.h"
#include "display.h"
#include "mpeg1vid.h"
#include "tdm.h"
#include "timedef.h"
#include "vcxi.h"
#include "util.h"
#include "xport.h"
#ifdef CUST3
#include "vcd.h"
#include "custdsa.h"
#endif
#include "sysinfo.h"
#include "debug.h"
#ifdef ECHO
#include "echo.h"
#endif
#ifdef CUST71
#include "play.h"
#include "fsosd.h"
#endif

#include "play.h"


#define PRINTF(x)

/*------------------------------------------------------------------------
  External Variables
------------------------------------------------------------------------*/
extern int play_sector_state;

/*------------------------------------------------------------------------
  Function Prototypes
------------------------------------------------------------------------*/
static int play_speed_start();

/*------------------------------------------------------------------------
  Definitions
------------------------------------------------------------------------*/
#define VIDEO_INIT_STATE		0
#define	VIDEO_SLOW_MOTION		1
#define VIDEO_FF			2
#define VIDEO_FR			3
#define VIDEO_PAUSE			4
#define AUDIO_FF			5
#define AUDIO_FR			6
#define AUDIO_NORMAL			7
#define AUDIO_PAUSE			8
#define VIDEO_NORMAL			9
#define VIDEO_STILL			10
#define VIDEO_DO_STILL			11
#define VIDEO_STEP			12
#define VIDEO_WAIT_TIMEOUT		13
/* add for ZOOM, no B frame can be zoomed, so, pause must be 
   actived at I or P frame */

#define VIDEO_DATA_TYPE			0
#define AUDIO_DATA_TYPE			1

#define TurnOffTDM system_reset

/*------------------------------------------------------------------------
  Local functions
------------------------------------------------------------------------*/
static int start_play_still();

/*------------------------------------------------------------------------
  Global Variables
------------------------------------------------------------------------*/
int	   vcx_fast_speed_done;

static int previous_sector;	/* stored the cd sector that will be used
				   to start later.			*/
#ifdef CUST71
static int ff_time_limit=0;
#endif
static int skip_mmssff;     /* The skip time for FF/FR      */
static int fast_speed_time_limit; /* the end time of FF/FR mode.	*/
static int timeout_begin_time;
static int play_start_time;
static int play_end_time;
static int still_type;		/* e1 or e2 */
static char data_type=0;		/* VIDEO or AUDIO */
int video_state;	        /* state of av play state machine.	*/
int cd_pause;		 /* 1 -> in pause mode.			*/
static char slow_resume=0;
static unsigned int	cdda_track_start_time;

/*------------------------------------------------------------------------
  Function:
  Description: In some cases, ther servo will stop and we do not notice.
               We have to avoid program hangs in the while loop.
------------------------------------------------------------------------*/
void turn_off_data()
{
    int time_out;

    TDM_off = 1;
    
    time_out = glbTimer + TWO_SECOND;

    while (XPORT_active) {
	if (glbTimer >= time_out) {
	    /* force XPORT_active to 0 to get out the loop. */
	    TDM_stop(1);	/* save stopCDtime */
	}
#ifdef ECHO
	MIC_service();
#endif
    }

    TDM_off = 0;	/* In case XPORT is not active */
}

/*------------------------------------------------------------------------
  Function: av_play_cdda_audio

  Parameters:
      start_mmssff : 
          the start time in BCD's minute, second and frame format.
      end_mmssff:
          the end time in BCD's minute, second and frame format.

  Description:
      This function will play a section of audio CD from start_mmssff
      to end_mmssff. When this section is finish, the end_of_play
      variable will be set to 1.
------------------------------------------------------------------------*/
int av_play_cdda_audio(int track_mmssff, int start_mmssff, int end_mmssff)
{
    reset_video_normal_mode(0);
    system_reset();
    system_start();

/*
  if (cd_pause) {
      dsa_pauserelease();
      cd_pause = 0;
    }
*/		
    cdda_track_start_time = track_mmssff;
    endCDtime = end_mmssff;

   if((play_state == PLAY_FR_STATE) || (play_state == PLAY_FF_STATE))
       vcx_playvideo_only = 1;
   else
       vcx_playvideo_only = 0;


    playCDDA(track_mmssff, start_mmssff, end_mmssff);

/* Victor: just add a end_of_play reset here to be safe and in sync with other
   operation like play_motion and etc. This should be redundente because play.c
   will reset end_of_play when each playitem is played. And I already reset it 
   in dsa.c when end_of_play is set by TDM.c when we read PSD sectors. But I 
   still got a false end_of_play set by somebody once ?! */
    end_of_play = 0;

#if (CUST3 || CUST4)
    play_start_time = start_mmssff;
#else
    {
	extern int goto_time;
	if (!goto_time)
	play_start_time = start_mmssff;
	goto_time = 0;
    }
#endif

    data_type = AUDIO_DATA_TYPE;

    video_state = AUDIO_NORMAL;
}

/*------------------------------------------------------------------------
  Function: av_play_motion_video

  Parameters:
      start_mmssff : 
          the start time in BCD's minute, second and frame format.
      end_mmssff:
          the end time in BCD's minute, second and frame format.

  Description:
      This function will play a section of motion video from start_mmssff
      to end_mmssff. When this section is finish, the end_of_play
      variable will be set to 1.
------------------------------------------------------------------------*/
int av_play_motion_video(int start_mmssff, int end_mmssff)
{
    /* set relative variables */
    endCDtime = end_mmssff;
    end_of_play = 0;
    
    /* clear buffers and reset some variables */
    reset_video_normal_mode(1);
    clear_dec();

    data_type = VIDEO_DATA_TYPE;
    video_state = VIDEO_NORMAL;

    return (playSectors(start_mmssff, 0xe0, 2324));
}

#if (CUST3 && !CUST71)
/*------------------------------------------------------------------------
  Function: av_play_motion_track

  Parameters:
	track : which track we want to play

  Description:
      This function will play a track
------------------------------------------------------------------------*/
int av_play_motion_track(int track)
{
    endCDtime = adjCDtime(CDinfo.leadout, AHEAD_TIME, -1);
    end_of_play = 0;

    /* clear buffers and reset some variables */
    reset_video_normal_mode(1);
    clear_dec();

    data_type = VIDEO_DATA_TYPE;
    video_state = VIDEO_NORMAL;
    playMotionVideoTrack(track);

    return (1);
}
#endif

/*------------------------------------------------------------------------
  Function: av_play_still

  Parameters:
      start_mmssff : 
          the start time in BCD's minute, second and frame format.
      end_mmssff:
          the end time in BCD's minute, second and frame format.
      type : value should be "0xe1" or "0xe2".
  Description:
      This function will play a section of still video from start_mmssff
      to end_mmssff. When this section is finish, the end_of_play
      variable will be set to 1.
------------------------------------------------------------------------*/
int av_play_still(int start_mmssff, int end_mmssff, int type)
{
    /* store variables used later */
    play_start_time = start_mmssff;
    play_end_time = end_mmssff;
    still_type = type;
    end_of_play = 0;

    /* clear buffers */
    reset_video_normal_mode(1);

    /* clear buffers */
    clear_dec();

    TDM_item_edc = 0;	/* Clear EDC count so we'll detect any error */
    start_play_still();
    return (1);
}

static int start_play_still()
{
    endCDtime = play_end_time & x00ffff00;
    end_of_play = 0;

    data_type = VIDEO_DATA_TYPE;
    video_state = VIDEO_NORMAL;

    /* reset decoder to reset mode */
    return (playSectors(play_start_time & x00ffff00, still_type, 2324));
}

/*------------------------------------------------------------------------
  Function:av_play_pause 

  Description:
      This function will pause the playing section.
------------------------------------------------------------------------*/
int set_pause;
int av_play_pause()
{

    if (video_state == VIDEO_SLOW_MOTION) {
	av_play_resume();
	set_pause = 1;
	return;
    } else if ((video_state == VIDEO_FF) || (video_state == VIDEO_FR)) {
	av_play_resume();
	set_pause = 1;
    	vcx_playvideo_only = 1; /* Mute the audio until pause */
	timeout_begin_time = glbTimer;
	video_state = VIDEO_WAIT_TIMEOUT;
	return;
    }

    if (data_type == AUDIO_DATA_TYPE) {
	video_state = AUDIO_PAUSE;
	TDM_stop(1);	/* Simply turn off XPORT to stop more data coming */
	/* Kill TDM so when we restart, left/right will not swap	*/
	mvd[tdmctl0] = 0x400;
	mvd[tdmrcvslots0] = 0;
    } else {

#ifndef DVD_VCD
	/* stop the TDM */	    
	if (XPORT_active) {
	    /* Stop TDM/DMA and save the last location */
	    turn_off_data();
	}
	previous_sector = stopCDtime;
#endif
	video_state = VIDEO_PAUSE;
	vcx_pause = 1;
	oh_my(0xe);
    }

    /*
     * For audio CD, we need to pause it first before calling
     * system_audio_partial_reset. Therefore, calling dsa_pause is
     * essential for CDDA. It doesn't hurt to call dsa_pause for
     * video CD (and may even be essential for some targets.
     */
    dsa_pause();
    system_audio_partial_reset(0);

    cd_pause = 1;

    return (1);
}

/*------------------------------------------------------------------------
  Function: av_play_resume

  Description:
      This function will take the player from trick mode to normal
      mode.

      trick mode includes FF/FR, slow motion, step and pause.
------------------------------------------------------------------------*/
int av_play_resume()
{
#ifdef CUST71
    SET_MUTEOFF;
#endif
    if (video_state == VIDEO_SLOW_MOTION) {
	system_audio_partial_reset(0);	/* Fix audio break. */
	slow_resume = 1;
	set_pause = 0;
	return 1;
    } else if (video_state == VIDEO_PAUSE || video_state == VIDEO_STEP)
	reset_video_normal_mode(0);
    else
	reset_video_normal_mode(1);

    switch (video_state) {
    case VIDEO_FF:
    case VIDEO_FR:
	clear_dec();
	playSectors(previous_sector, vcx_user_video_stream, 2324);
	break;
    case AUDIO_FF:
    case AUDIO_FR:
	playCDDA(cdda_track_start_time, previous_sector, endCDtime);
	break;
    case VIDEO_PAUSE:
    	oh_my(0xd);
	playSectors(stopCDtime, picture_type, 2324);
	break;
    case AUDIO_PAUSE:
	/* 
	 * Don't use 
	 * playCDDA(cdda_track_start_time, previous_sector, endCDtime);
	 * Due to DSA in-precision, we may stuck at the same place
	 * continuously if we just pause/release.
	 */
	XPORT_restart_at(XPORT_OFFSET_PLAY_CDDA, 1);
	TDM_turn_on();
	break;
    case VIDEO_STEP:
#ifdef CUST71
	system_audio_partial_reset(1);	/* Fix audio break. */
#endif
	playSectors(previous_sector, 0xe0, 2324);
	break;
    default:
	set_pause = 0;
    }

    video_state = VIDEO_INIT_STATE;

    return (1);
}

/*------------------------------------------------------------------------
  Function: av_play_slow_motion

  Parameters:
      field_length : The number of field time that a picture should be
                     display. For a normal speed NTSC picture, the
		     field_length is 2. If we want to make the slow
		     motion to 1/2 speed of normal speed, we need to
		     set field_length value to 4.

  Description:
      Plays slow motion.
------------------------------------------------------------------------*/
int av_play_slow_motion(int field_length)
{
    slow_resume = 0;
    reset_video_normal_mode(0);

    vcx_pause = 0;
    vcx_slow_motion = field_length;
    vcx_playvideo_only = 1;

    if (video_state == VIDEO_PAUSE) {
	playSectors(previous_sector, 0xe0, 2324);
    }

    video_state = VIDEO_SLOW_MOTION;
}

/*------------------------------------------------------------------------
  Function:av_play_step
  Description:
      When this function is called, the player will display a new 
      decoded picture.
------------------------------------------------------------------------*/
int av_play_step()
{
    if (video_state != VIDEO_STEP) {
	vcx_pause = 0;
	vcx_slow_motion = vcx_fast_forward = 0;

⌨️ 快捷键说明

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