📄 av_play.c
字号:
#ifdef ANTI_SHOCK /* for VCD anti-shock, not abnormal muxrate tracks */ if(abnormal_vcd == ESP_FOR_VCD) { PLAY_set_2x_speed = 0; /* back to 1X when full */ }#endif /* ANTI_SHOCK */ play_sector_state = 0; stop = full; TDM_expect_stop = 1; /* Set RISC stat bit so XPORT will before at the next SYNC */ mvd[xport_input_mode] = XPORT_input_mode | 0x4; } } else { if ((currCDtime == endCDtime) || #ifdef ANTI_SHOCK XPORT_data_end || #endif end_of_play) { video_state = 0; } else { if (stop && full) return; playSectors_step_by_step(previous_sector,vcx_user_video_stream, 2324, 1); } } break; #endif#if (defined(MP3) || defined(JPEG_DEC) || defined(WMA_DEC) || defined(AVI_DEC)) case MP3_NORMAL: if ( (STREAM_type == MP3_ID) #ifdef WMA_DEC#ifdef WMA_CERT || ( (STREAM_type == WMA_ID)&&(!MLP_dump) )#else || (STREAM_type == WMA_ID)#endif WMA_CERT#endif#ifdef AVI_DEC || (STREAM_type == AVI_ID)#endif ) { if (TDM_expect_stop) { if (XPORT_active) return; TDM_expect_stop = 0; previous_sector = stopCDtime; play_sector_state = 0;#ifdef MP3CDG cdg_pause = 0;#endif return; } ABV_update_occupancy(space_left); space_left = ABV_size - space_left; if ((STREAM_type == MP3_ID) && (MPG_layer == 3)) { ABV_byte_update_occupancy(space_byte_left); space_byte_left = ABV_byte_size - space_byte_left; space_byte_left >>= 2; if (space_byte_left < space_left) space_left = space_byte_left; } { int tmp = (ABV_write << 4); #ifdef WMA_DEC if (STREAM_type == WMA_ID) tmp <<= 2;#endif#ifdef AVI_DEC if (is_jpeg == 2) tmp <<= 1;#endif audio_full = (space_left < tmp); } full = audio_full; if (XPORT_active) { /* TDM is running */ if (full) { play_sector_state = 0; stop = audio_full; TDM_expect_stop = 1;#if (defined WMA_DEC && defined WMA_CERT) MLP_dump = 1;#endif /* Set RISC state bit so XPORT will before at the nexe SYNC */ mvd[xport_input_mode] = XPORT_input_mode | 0x4; } } else { if (currCDtime == endCDtime || end_of_play) { video_state = VIDEO_INIT_STATE;#ifdef TRACE_MP3_AUDIOBREAK MP3_is_decoding = 0;#endif#if (defined WMA_DEC && defined WMA_CERT) MLP_dump = 1;#endif } else { if (!play_sector_state && stop && (space_left < MP3_VBR_gain)){#ifdef MP3CDG if (mcg_need_data) MCG_get_data();#endif return; }#ifdef SAM_SRV if(!mp3_playing) mp3_playing=1;#endif playSectors_step_by_step(previous_sector, vcx_user_video_stream, 2324, 1); } } } break; #endif#ifdef JPEG_DEC case JPEG_NORMAL: if (TDM_expect_stop) { if (XPORT_active) return; TDM_expect_stop = 0; previous_sector = stopCDtime; play_sector_state = 0; return; } VBV_update_occupancy(space_left); space_left = VBV_size - space_left; full = (space_left < 8 * VBV_write); if (XPORT_active) { /* TDM is running */ if (full) { play_sector_state = 0; stop = full; TDM_expect_stop = 1; /* Set RISC state bit so XPORT will before at the nexe SYNC */ mvd[xport_input_mode] = XPORT_input_mode | 0x4; } } else { /* TDM is stop */ if (currCDtime == endCDtime || end_of_play) { video_state = VIDEO_INIT_STATE; } else { if (!play_sector_state && stop && full) return; playSectors_step_by_step(previous_sector, vcx_user_video_stream, 2324, 1); } } break;#endif case VIDEO_SLOW_MOTION: VBV_update_occupancy(video_buffer_fullness); space_left = VBV_size - video_buffer_fullness; if (XPORT_active) { /* TDM is running */ /* "12*VBV_write" (3072DW) of VBV space can hold approximately.. * (1) 95ms at 1X <<< assume data enters at 1X * (2) 47ms at 2X * (3) 23ms at 4X * * Basically, the frequency that we get here to check * for "space_left" has to be more than 10Hz (1000/95) * to ensure that we can prevent VBV overflow. */ if (space_left < 12*VBV_write) { turn_off_data(); previous_sector = stopCDtime; play_sector_state = 0; /* Re-start immediately after we stopped. */ playSectors_step_by_step(previous_sector, 0xe0, 2324, 1); } } else { /* "24*VBV_write" (6144DW) of VBV data holds approximately.. * (1) 190ms at normal play * (2) 570ms at "slow 1" <<< slow worst case * (3) 950ms at "slow 2" * (4) 1.3sec at "slow 3" * * Basically, the servo needs to be able to get new data * within 570ms before we have VBV starving. */ if (video_buffer_fullness < 24*VBV_write) { playSectors_step_by_step(previous_sector, 0xe0, 2324, 1); } } break;#ifdef ANTI_SHOCK case AUDIO_ESP: /* PLAY_set_2x_speed */ if (TDM_expect_stop) { TDM_expect_stop = 0; previous_sector = stopCDtime; play_cdda_state = PLAY_CDDA_INIT; stop = 1; } ABV_update_space(space_left); if (stop) { if ((space_left > 30*ABV_write) || (play_cdda_state > PLAY_CDDA_INIT)) { (void) playCDDA_step_by_step(0, previous_sector, 0, 1); if (XPORT_active) stop = 0; } } else { if (XPORT_active) { audio_full = (space_left < (4*ABV_write)); if (audio_full) { av_cdda_match_stop(); } } else { if (XPORT_data_end || end_of_play) video_state = VIDEO_INIT_STATE; else { stop = 1; /* should not get here, but should handle it */ } } } break;#endif /* ANTI_SHOCK */ case AUDIO_FF: case AUDIO_FR: case VIDEO_FF: case VIDEO_FR: /* Don't hang on here waiting for vcx_pause_ack. (for bad disc) */ if (vcx_pause_ack || (glbTimer > av_timeout)) { vcx_pause_ack = 0; play_speed_start(); } break; case VIDEO_STILL: if (VID_frame_count>1) { if(is_slide_show^VID_frame_count) { /* save last pic start */ PLAY_set_item_start_time(adjCDtime(currCDtime, 0x40, 0)); } is_slide_show = VID_frame_count; } break; case VIDEO_STEP: if (vcx_step_advance == 0) { if (XPORT_active) { /* Stop TDM/DMA and save the last location */ turn_off_data(); } /* Record the CD location when DMA is turned off */ previous_sector = stopCDtime; } break; case VIDEO_WAIT_TIMEOUT: /* we wait for 0.5 second, so the vbv/avb will be in good state. */ if (glbTimer > av_timeout) video_state = VIDEO_INIT_STATE; break; default:#ifdef MP3CDG if (mcg_need_data) MCG_get_data();#endif break; }}static int play_speed_start(){ extern int play_item_begin_time; int rel_time, cd_time; vcx_interupt_FrameCount_pause = 0; cd_time = previous_sector; if ((video_state == VIDEO_FF) || (video_state == AUDIO_FF)) { cd_time = adjCDtime(cd_time, skip_mmssff, 1); /* need to check the end time */ if (cd_time >= fast_speed_time_limit) { cd_time = fast_speed_time_limit; vcx_fast_speed_done = 1; return(1); } } if ((video_state == VIDEO_FR) || (video_state == AUDIO_FR)) { cd_time = adjCDtime(cd_time, skip_mmssff, -1); /* need to check start time */ if (cd_time <= fast_speed_time_limit) { vcx_fast_speed_done = 1;#ifdef MP3 MPG_frames = 0;#endif#ifdef WMA_DEC if (STREAM_type == WMA_ID) wma_smpl_num = 0;#endif return (1); } } previous_sector = cd_time; /* store current time point */ /* relative track time(in frames) */ rel_time = msf2sectors(cd_time) - msf2sectors(play_item_begin_time);#ifdef MP3 if (STREAM_type == MP3_ID) { MPG_frames = ((int)rel_time * 2048) / (MP3_framesize); if (MPG_frames < 0) MPG_frames = 0; MP3_time_elapsed(); clear_dec(); /* jump only..during FF/FR may hang in huffman * if there's not enough data for "getbits". */ dsa_go(cd_time); av_timeout = glbTimer + HALF_SECOND*(1+(fast_frame_index>>1)); return (1); } #endif#ifdef WMA_DEC if (STREAM_type == WMA_ID) { int wma_time; wma_seek_size =(rel_time<<11); if ( wma_byterate ) { wma_time = wma_seek_size/wma_byterate;#ifdef WMA_DEMO if ( wma_time>60 ) { WMA_demo_end(); wma_time = 60; }#endif wma_smpl_num = wma_time * sample_rate[wma_freq]; } clear_dec(); /* jump only..during FF/FR may hang in huffman * if there's not enough data for "getbits". */ dsa_go(cd_time); av_timeout = glbTimer + HALF_SECOND*(1+(fast_frame_index>>1)); return (1); }#endif if (data_type == AUDIO_DATA_TYPE) {#ifdef ANTI_SHOCK AUD_n_samples = (588*rel_time); /* in dwords */#endif playCDDA(cdda_track_start_time, cd_time, endCDtime); av_timeout = glbTimer + HALF_SECOND; } else { /* mpeg video */ /* set the interrupt framecount */ /* stop decoder when "fast_frame" frame is displayed */ vcx_interupt_FrameCount = VID_frame_count + 1; vcx_interupt_FrameCount_pause = VC_PAUSE; clear_dec(); fuzzyPlaySector(cd_time, 2324); av_timeout = glbTimer + THREE_SECOND; } return (1);}/*------------------------------------------------------------------------ Function: Parameters: Description:------------------------------------------------------------------------*/void av_reset(){#ifdef DAE_SPATIAL if (DAE_mode > 0) { /* disable DAE effects processing.. * this affects 1) track changes and 2) stop & eject * * NOTE: we will restore DAE_mode in av_play_cdda_audio() * and av_play_motion_video(). */ DAE_mode_save = DAE_mode; DAE_mode = 0; }#endif reset_video_normal_mode(1); video_state= VIDEO_INIT_STATE;#if (defined CDG && !defined HOST_SLAVE) if (!repeat_a2b && (CDG_started || MP3CDG_started)) CDG_init(0);#endif#if defined(ABNORMAL_VCD) || defined(ANTI_SHOCK) if (abnormal_vcd) { abnormal_vcd &= ~TRACK_IS_ABVCD; PLAY_set_2x_speed = 0; mem_config_restore(0); }#endif}/*------------------------------------------------------------------------ Function:reset_video_normal_mode Parameters: Description: This function resets vcx_variables back to the state that normal play will be in a good start state.------------------------------------------------------------------------*/int reset_video_normal_mode(int reset){ /* set the audio to clean state. */ if (reset) {#ifdef MP3 if ((STREAM_type == MP3_ID )#ifdef XSEG4_ON_FLY && (vcx_xseg_loaded == XSEG4_CODE) /* MP3 is loaded */#endif ) { MP3_init(); } else#endif /* MP3 */ #ifdef WMA_DEC if (STREAM_type == WMA_ID) { WMA_init(); } else#endif#ifdef AVI_DEC if (STREAM_type != AVI_ID) #endif { AUD_init(); } } /* variables set in FF/FR state */ vcx_playvideo_only = 0; vcx_playaudio_only = 0; vcx_interupt_FrameCount_pause = 0; vcx_fast_forward = 0; vcx_pause = vcx_pause_ack = 0; vcx_fast_speed_done = 0; /* variable set in slow state */ vcx_slow_motion = 0; /* variable set in step state */ vcx_stepmode = 0; vcx_step_advance = 0; /* start decode for the first I frame */ if (reset) { VID_first_time_seek = 1; showingLogo = 0; } if (cd_pause) { dsa_pauserelease(); cd_pause = 0; }}/* clear decoder buffer */void clear_dec(void){ system_reset();#if defined(ABNORMAL_VCD) || defined(ANTI_SHOCK) if (CDinfo.type == CD_VCD) { mem_config_restore(abnormal_vcd); }#endif system_start();}/* Set AV_near_track_end_time for backup track end indicator */static void AV_near_track_end_init(uint length_msf){ if (length_msf < 0x2000) { /* less than 20 secs */ /* length_msf/2..process "seconds" ignore "frames" */ length_msf = (uint)hex2bcd[bcd2hex[length_msf>>8] >> 1]; /* secs */ length_msf <<= 8; /* SS -> SS:FF */ } else { /* length_msf - 10 secs */ length_msf = adjCDtime(length_msf, 0x1000, -1); } AV_near_track_end_time = (length_msf >> 8); /* MM:SS:FF -> MM:SS */ servo_track_changed = 0;}#ifdef ANTI_SHOCKvoid av_cdda_match_stop(void){ TDM_expect_stop = 1; TDM_force_stop(1);/* turn off XPORT */ /* stop filling ABV */ buscon_zap(xporta); ABV_filling = 0; ABV_wrptr_retreat(2); /* position to last copied data */ /* save data for match */ ABV_data_save[0] = *((unsigned int *)dram(ABV_wrptr++)); ABV_data_save[1] = *((unsigned int *)dram(ABV_wrptr++));}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -