?? av_play.c
字號:
/*------------------------------------------------------------------------ Function:av_play_pause Description: This function will pause the playing section.------------------------------------------------------------------------*/int av_play_pause(){#if 0 /* conflicts with "wait_pause" mechanism in play.c */ 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 */ av_timeout = glbTimer + HALF_SECOND; video_state = VIDEO_WAIT_TIMEOUT; return; }#else reset_video_normal_mode(vcx_playaudio_only);#endif if (data_type == AUDIO_DATA_TYPE) { video_state = AUDIO_PAUSE;#ifdef ANTI_SHOCK previous_sector = buffered_currCDtime();#endif TDM_force_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 { /* stop the TDM */ if (XPORT_active) { /* Stop TDM/DMA and save the last location */ turn_off_data(); }#if( defined(MP3) || defined(WMA_DEC) ) if ((STREAM_type == MP3_ID)#ifdef WMA_DEC || (STREAM_type == WMA_ID)#endif ) { if( !av_in_trick_mode ) { av_in_trick_mode = 1; previous_sector = MP3_currCDtime(); } currCDtime = stopCDtime = previous_sector; /* for real-time */ } else#endif /* MP3 || WMA */ { previous_sector = stopCDtime; vcx_pause = 1; /* only for video (mpeg1 stream) */ } #if (defined(GAMMA) || defined(FLESHTONE)) if((picture_type == 0xe0) #ifdef MZOOM && !vcx_mzoom#endif && !STREAM_type) { Gamma_Correction_main(); }#endif video_state = VIDEO_PAUSE; 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. * * NOTE: * - we are resetting PCM for non-video pause. * - no system_audio_partial_reset() for VCD anti-shock.. * resetting ABV will "unsync" AV-sync. */ dsa_pause();#ifdef ANTI_SHOCK if (TDM_isCDDA || (vcx_bitstream_type != MPEG1_PS)) #endif { system_audio_partial_reset(!vcx_pause); } 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(){ if (video_state == VIDEO_SLOW_MOTION) { system_audio_partial_reset(0); /* Fix audio break. */ } 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_SLOW_MOTION: DISP_limit = 1; reset_video_normal_mode(0); /* finish up playSectors() here instead of background * to speed up slow->play transition. */ if (!XPORT_active) playSectors(previous_sector, vcx_user_video_stream, 0); break; case VIDEO_FF: case VIDEO_FR: clear_dec(); playSectors(previous_sector, vcx_user_video_stream, 2324); break; case AUDIO_FF: case AUDIO_FR:#ifdef ANTI_SHOCK PLAY_set_2x_speed = 1; /* fill ABV faster at 2X speed */#endif playCDDA(cdda_track_start_time, previous_sector, endCDtime); break; case VIDEO_PAUSE: oh_my(0xd);#if( defined(MP3) || defined(WMA_DEC)) if ((STREAM_type == MP3_ID)#ifdef WMA_DEC || (STREAM_type == WMA_ID)#endif ) { clear_dec(); /* since in MP3 when we pause there is still a lot of data has not been processed, "previous_sector" has been adjusted back to resume play */#ifdef WMA_DEC if(STREAM_type == WMA_ID) wma_seek_size = (msf2sectors(previous_sector) - msf2sectors(play_item_begin_time))<<11;#endif playSectors(previous_sector, vcx_user_video_stream, 2324); } else#endif playSectors(stopCDtime, picture_type, 2324); break; case AUDIO_PAUSE:#ifdef ANTI_SHOCK PLAY_set_2x_speed = 1; /* fill ABV faster at 2X speed */ playCDDA(cdda_track_start_time, previous_sector, endCDtime);#else /* * 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();#endif /* ANTI_SHOCK */#ifdef CXDSERVO /* enable digital-out for CDDA play */ if (use_dig_out) CLEAR_SERVO_DIG_MUTE; #endif break; case VIDEO_STEP: playSectors(previous_sector, 0xe0, 2324); break; }#ifdef MP3 if (vcx_bitstream_type == MP3_PS) video_state = MP3_NORMAL; else#endif#ifdef WMA_DEC if (STREAM_type == WMA_ID) video_state = MP3_NORMAL; else#endif if (TDM_isCDDA) {#ifdef ANTI_SHOCK video_state = AUDIO_ESP;#else video_state = AUDIO_NORMAL;#endif ANTI_SHOCK } else#ifdef ABNORMAL_VCD if (abnormal_vcd) video_state = VIDEO_ABNORMAL; else#endif video_state = VIDEO_INIT_STATE; av_in_trick_mode = 0; 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){ reset_video_normal_mode(vcx_playaudio_only); 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; vcx_stepmode = 1; vcx_playvideo_only = 1; if (XPORT_active) vcx_step_advance = 1; else vcx_step_advance = 0; video_state = VIDEO_STEP; if (cd_pause) { dsa_pauserelease(); cd_pause = 0; } } else { if (vcx_step_advance == 0) { int space_left; vcx_step_advance = 1; /* To avoid VBV buffer overflow, we won't start copying data * * if there is enough data in buffer */ VBV_update_occupancy(space_left); space_left = VBV_size - space_left; if (space_left > 2000) { playSectors(previous_sector, 0xe0, 2324); } } } return (1);}#ifdef MULTI_EXT_FILEint av_play_continue(int start_mmssff, int end_mmssff){ /* set relative variables */ endCDtime = end_mmssff; end_of_play = 0; av_in_trick_mode = 0; #ifdef MP3 if (vcx_bitstream_type == MP3_PS) { video_state = MP3_NORMAL; }#endif /* MP3 */#ifdef WMA_DEC if (STREAM_type == WMA_ID) { video_state = MP3_NORMAL; wma_seek_size =( msf2sectors(start_mmssff) - msf2sectors(play_item_begin_time) )<<11; if ( wma_byterate ) wma_smpl_num = wma_seek_size/wma_byterate * sample_rate[wma_freq]; }#endif /*WMA_DEC*/#ifdef JPEG_DEC /* * For jpeg pictures, by the time we see endCDtime, we won't see EOR. * We'll force a flush to kick out all the data. */ if (is_jpeg == 1) { TDM_needs_flush = 1; video_state = JPEG_NORMAL; }#endif play_sector_state = PLAY_SECTOR_INIT; playSectors_step_by_step(start_mmssff, vcx_user_video_stream, 2324, 1); return (1);}#endif /* MULTI_EXT_FILE *//************************************************************************ Function: *************************************************************************/#if (defined WMA_DEC && !(defined WMA_DEMO))int AV_flush_audio(){ if (!(av_in_trick_mode||flush_thy_audio)) { flush_thy_audio = 2; return 1; } return 0;}#endif/*------------------------------------------------------------------------ Function: Parameters: Description:------------------------------------------------------------------------*/static int play_fast_init(int secs, int end_mmssff){ int cd_time; reset_video_normal_mode(1); /* clear other video/audio variables.*/ if (data_type == AUDIO_DATA_TYPE) {#ifdef FAST_MODE_CONTROL cd_time = ((servo_info & 0xffff) << 8); /* when FR across track boundary, previous time has to be set differently */ if (video_state == AUDIO_FR && !servo_info) previous_sector = adjCDtime(endCDtime, 0x0200, -1); else previous_sector = adjCDtime(cd_time, cdda_track_start_time, 1);#else#ifdef ANTI_SHOCK previous_sector = buffered_currCDtime();#else cd_time = ((servo_info & 0xffff) << 8); previous_sector = adjCDtime(cd_time, cdda_track_start_time, 1);#endif#endif } else { vcx_fast_forward = 1; /*set before turn_off_data() & clear_dec()*/ if (XPORT_active) { /* Stop TDM/DMA and save the last location */ turn_off_data(); }#if defined(MP3) || defined(WMA_DEC) if ( (STREAM_type == MP3_ID) #ifdef WMA_DEC || (STREAM_type == WMA_ID)#endif ){ if( !av_in_trick_mode ) { av_in_trick_mode = 1; previous_sector = MP3_currCDtime(); } vcx_playaudio_only = 1; /* audio mode */ } else#endif /* MP3 || WMA_DEC */ { /* mpeg1 stream */ previous_sector = stopCDtime; vcx_playvideo_only = 1; /* mute mode */ } clear_dec(); } fast_speed_time_limit = end_mmssff; vcx_fast_speed_done = 0;#ifdef MP3 if (STREAM_type == MP3_ID) { skip_mmssff = MP3_time2sectors(bcd2hex[secs]); } else#endif #ifdef WMA_DEC if (STREAM_type == WMA_ID) { skip_mmssff = (wma_byterate * (bcd2hex[secs]))>>11; skip_mmssff = logical2physical(skip_mmssff); } else#endif#ifdef ABNORMAL_VCD if (abnormal_vcd & TRACK_IS_ABVCD) { skip_mmssff = msf2sectors(secs<<8) * 600 / mpeg_mux_rate; skip_mmssff = logical2physical(skip_mmssff); } else#endif skip_mmssff = secs<<8; /* mm:ss:ff format */ play_speed_start();}/*------------------------------------------------------------------------ Function: av_play_fast_forward Parameters: secs: The jump time after an I frame is displayed. The format is seconds in BCD. end_mmssff: When the end_mmssff is played, the vcx_fast_speed_done variable will be set to 1. The called should check this variable and decide what to do. Description: This function will cause the decoder to a fast forward mode.------------------------------------------------------------------------*/int av_play_fast_forward(int secs, int end_mmssff){ video_state = (data_type == VIDEO_DATA_TYPE) ? VIDEO_FF : AUDIO_FF; play_fast_init(secs, end_mmssff); }/*------------------------------------------------------------------------ Function: Parameters: secs: The jump time after an I frame is displayed. The format is seconds in BCD. end_mmssff: When the end_mmssff is played, the vcx_fast_speed_done variable will be set to 1. The called should check this variable and decide what to do. Description: This function will cause the decoder to a fast rewind mode.------------------------------------------------------------------------*/int av_play_fast_rewind(int secs, int end_mmssff){ video_state = (data_type == VIDEO_DATA_TYPE) ? VIDEO_FR : AUDIO_FR;#ifdef FAST_MODE_CONTROL /* FR across track boundary, play_start is the begin time of the current track */ play_start_time = end_mmssff; #endif play_fast_init(secs, end_mmssff);}/*------------------------------------------------------------------------ Function: Parameters: Description:------------------------------------------------------------------------*/#ifdef MP3static int stop = 0;#endifvoid video_state_machine(){ int space_left, aspace_left; int video_buffer_fullness; int audio_full = 0; int video_full = 0;#ifdef MP3 int full = 0; int space_byte_left;#endif#ifdef WMA_CERT extern int MLP_dump;#endif switch (video_state) {#if defined(ABNORMAL_VCD) || defined(ANTI_SHOCK) case VIDEO_ABNORMAL: if (TDM_expect_stop) { if (XPORT_active) return; TDM_expect_stop = 0; previous_sector = stopCDtime; play_sector_state = 0; return; } VBV_update_space(space_left); ABV_update_space(aspace_left); audio_full = (aspace_left < 4*VBV_write); video_full = (space_left < 8*VBV_write); if (vcx_playvideo_only) full = video_full; else if (vcx_playaudio_only) full = audio_full; else full = (video_full || audio_full); if (XPORT_active) { /* TDM is running */ if (full) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -