📄 pthread_dec.c
字号:
start_line_number_sf = 265; end_line_number_sf = 268; transition_position_sf = 855; } else { ef_voffset = 335; of_voffset = 22; hsync_start_position = 44; hsync_end_position = 182; hsync_to_hvalid_end_cycle = 1440; start_line_number_ff = 1; end_line_number_ff = 11; transition_position_ff = 140; start_line_number_sf = 313; end_line_number_sf = 324; transition_position_sf = 855; } /* ef_voffset : vertical offset for even field, default is 284 * of_voffset : vertical offset for odd field, default is 21 */ dec_vertical_offset_mode(ef_voffset, of_voffset); /* hsync_start_position : horizontal sync start position * default is 28 * hsync_end_position : horizontal sync end position * default is 159 * hsync_to_hvalid_end_cycle : hsync to hvalid end cycle * default is 1440 */ horizontal_sync_control(hsync_start_position, hsync_end_position, hsync_to_hvalid_end_cycle); /* start_line_number_ff : vertical sync start line number of the first field * default is 3 * end_line_number_ff : vertical sync end line number of the first field * default is 7 * transition_position_ff : vertical sync transition position of the first field, * this value means the offset cycles from the end of * horizontal valid to the vercical sync transition position * default is 90 * start_line_number_sf : vertical sync start line number of the second field * default is 265 * end_line_number_sf : vertical sync end line number of the second field * default is 268 * transition_position_sf : vertical sync transition position of the second field * default is 855 */ vertical_sync_control(start_line_number_ff, end_line_number_ff, transition_position_ff, start_line_number_sf, end_line_number_sf, transition_position_sf); /* mode : '0' disable, '1' enable, default is '0' */ deinterlace_mode(0);// pentamicro 2006.01.11 for(ii=0; ii < MAX_CH_NUM; ii++) decode_standard(ii, gp_setup_param->enc_attr.encoding_type); return SUCCESS;}RETURN dec_play(DEC_OBJECT *pdo) { FILE_INFO ret; RETURN rret; pdo->psd = &gp_state_thread->state_dec; pdo->pdp = &gp_setup_param->dec; /* for real time play at event playback */ if (pdo->flag_first && pdo->global_count > 1) { decode_mode(trick_mode(TME_REAL, TM_PLAY, TD_FORWARD, 0)); pdo->play_mode = trick_mode(TME_REAL, TM_PLAY, TD_FORWARD, 0); pdo->flag_first = 0; pdo->global_count = 0; } /* 1st. set play mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_PLAY, TD_FORWARD, 0); pdo->psd->play_change = 0; } /* 2nd. get picture information and check file end */ ret = arrange_picture_inform(pdo); if (ret == F_END) { /* select next file */ if (pdo->pdp->play_conti) { rret = select_next_file(pdo); if (rret == FAILURE) { m_ERROR("pthread_dec.c:error In function 'select_next_file'\n"); return FAILURE; } else if (rret == ENDING) { m_DEBUG("pthread_dec.c:debug In function 'select_next_file'\n"); return ENDING; } else if (rret == SUCCESS) { return SUCCESS; } } else { return ENDING; } } /* 3rd. decision for feeding to at2041 */ if (decoding_stream_filter(pdo) == TRUE) { /* 4th. feeding data to decoder */ if (feed_data_to_decoder(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'feed_data_to_decoder'\n"); return FAILURE; } } else { /* 5th. move file pointer to next picture */ fseek(pdo->p_fd_ps, pdo->dip.cur_size, SEEK_CUR); } /* 6th. get picture inform */ if (get_picture_inform(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'get_picture_inform'\n"); return FAILURE; } return SUCCESS;} void dec_stop(DEC_OBJECT *pdo){ /* 1st. stop decoding */ video_decoder_stop(); if (gp_state_thread->state_dec.state == BUSY) { /* 2nd. close play file */ fclose(pdo->p_fd_ps); }}RETURN dec_ff(DEC_OBJECT *pdo) { FILE_INFO ret; RETURN rret; pdo->psd = &gp_state_thread->state_dec; pdo->pdp = &gp_setup_param->dec; /* 1st. set fast forward mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_FAST, TD_FORWARD, pdo->psd->play_step); pdo->psd->play_change = 0; } /* 2nd. get picture information and check file end */ ret = arrange_picture_inform(pdo); if (ret == F_END) { /* select next file */ if (pdo->pdp->play_conti) { rret = select_next_file(pdo); if (rret == FAILURE) { m_ERROR("pthread_dec.c:error In function 'select_next_file'\n"); return FAILURE; } else if (rret == ENDING) { m_DEBUG("pthread_dec.c:debug In function 'select_next_file'\n"); return ENDING; } else if (rret == SUCCESS) { return SUCCESS; } } else { return ENDING; } } /* 3rd. decision for feeding to at2041 */ if (fast_forward_stream_filter(pdo) == TRUE) { /* 4th. feeding data to decoder */ if (feed_data_to_decoder(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'feed_data_to_decoder'\n"); return FAILURE; } } else { /* 5th. move file pointer to next picture */ fseek(pdo->p_fd_ps, pdo->dip.cur_size, SEEK_CUR); } /* 6th. get picture inform */ if (get_picture_inform(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'get_picture_inform'\n"); return FAILURE; } return SUCCESS;}RETURN dec_slow(DEC_OBJECT *pdo) { FILE_INFO ret; RETURN rret; pdo->psd = &gp_state_thread->state_dec; pdo->pdp = &gp_setup_param->dec; /* 1st. set fast forward mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_SLOW, TD_FORWARD, pdo->psd->play_step); pdo->psd->play_change = 0; } /* 2nd. get picture information and check file end */ ret = arrange_picture_inform(pdo); if (ret == F_END) { /* select next file */ if (pdo->pdp->play_conti) { rret = select_next_file(pdo); if (rret == FAILURE) { m_ERROR("pthread_dec.c:error In function 'select_next_file'\n"); return FAILURE; } else if (rret == ENDING) { m_DEBUG("pthread_dec.c:debug In function 'select_next_file'\n"); return ENDING; } else if (rret == SUCCESS) { return SUCCESS; } } else { return ENDING; } } /* 3rd. decision for feeding to at2041 */ if (decoding_stream_filter(pdo) == TRUE) { /* 4th. feeding data to decoder */ if (feed_data_to_decoder(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'feed_data_to_decoder'\n"); return FAILURE; } } else { /* 5th. move file pointer to next picture */ fseek(pdo->p_fd_ps, pdo->dip.cur_size, SEEK_CUR); } /* 6th. get picture inform */ if (get_picture_inform(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'get_picture_inform'\n"); return FAILURE; } return SUCCESS;}RETURN dec_rew(DEC_OBJECT *pdo) { FILE_INFO ret; RETURN rret; pdo->psd = &gp_state_thread->state_dec; /* 1st. set fast forward mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_FAST, TD_BACKWARD, pdo->psd->play_step); pdo->psd->play_change = 0; } /* 2nd. get picture information and check file end */ ret = arrange_backward_picture_inform(pdo); if (ret == F_END) { /* select next file */ if (pdo->pdp->play_conti) { rret = select_previous_file(pdo); if (rret == FAILURE) { m_ERROR("pthread_dec.c:error In function 'select_previous_file'\n"); return FAILURE; } else if (rret == ENDING) { m_DEBUG("pthread_dec.c:debug In function 'select_previous_file'\n"); return ENDING; } else if (rret == SUCCESS) { return SUCCESS; } } else { return ENDING; } } /* 3rd. decision for feeding to at2041 */ if (fast_backward_stream_filter(pdo) == TRUE) { /* 4th. feeding data to decoder */ if (feed_data_to_decoder(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'feed_data_to_decoder'\n"); return FAILURE; } /* 5th. move file pointer to previous picture */ fseek(pdo->p_fd_ps, ~ (pdo->dip.prev_size + pdo->dip.cur_size) + 1, SEEK_CUR); } else { /* 5th. move file pointer to previous picture */ fseek(pdo->p_fd_ps, ~ pdo->dip.prev_size + 1, SEEK_CUR); } /* 6th. get picture inform */ if (get_picture_inform(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'get_picture_inform'\n"); return FAILURE; } return SUCCESS;}RETURN dec_step_forward(DEC_OBJECT *pdo) { FILE_INFO ret; RETURN rret; pdo->psd = &gp_state_thread->state_dec; pdo->pdp = &gp_setup_param->dec; /* 1st. set play mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_STEP, TD_FORWARD, 1); pdo->psd->play_change = 0; } /* 2nd. get picture information and check file end */ ret = arrange_picture_inform(pdo); if (ret == F_END) { /* select next file */ if (pdo->pdp->play_conti) { rret = select_next_file(pdo); if (rret == FAILURE) { m_ERROR("pthread_dec.c:error In function 'select_next_file'\n"); return FAILURE; } else if (rret == ENDING) { m_DEBUG("pthread_dec.c:debug In function 'select_next_file'\n"); return ENDING; } else if (rret == SUCCESS) { return SUCCESS; } } else { return ENDING; } } /* 3rd. decision for feeding to at2041 */ if (decoding_stream_filter(pdo) == TRUE) { /* 4th. feeding data to decoder */ if (feed_data_to_decoder(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'feed_data_to_decoder'\n"); return FAILURE; } } else { /* 4th. move file pointer to next picture */ fseek(pdo->p_fd_ps, pdo->dip.cur_size, SEEK_CUR); } /* 5th. get picture inform */ if (get_picture_inform(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'get_picture_inform'\n"); return FAILURE; } return SUCCESS;} RETURN dec_step_backward(DEC_OBJECT *pdo) { UNS16 exit_step_backward; FILE_INFO ret; RETURN rret; pdo->psd = &gp_state_thread->state_dec; /* 1st. set fast forward mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_STEP, TD_BACKWARD, pdo->psd->play_step); pdo->psd->play_change = 0; } exit_step_backward = 0; do { /* 2nd. get picture information and check file end */ ret = arrange_backward_picture_inform(pdo); if (ret == F_END) { /* select next file */ if (pdo->pdp->play_conti) { rret = select_previous_file(pdo); if (rret == FAILURE) { m_ERROR("pthread_dec.c:error In function 'select_previous_file'\n"); return FAILURE; } else if (rret == ENDING) { m_DEBUG("pthread_dec.c:debug In function 'select_previous_file'\n"); return ENDING; } else if (rret == SUCCESS) { return SUCCESS; } } else { return ENDING; } } /* 3rd. decision for feeding to at2041 */ if (fast_backward_stream_filter(pdo) == TRUE) { /* 4th. feeding data to decoder */ if (feed_data_to_decoder(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'feed_data_to_decoder'\n"); return FAILURE; } /* 5th. move file pointer to previous picture */ fseek(pdo->p_fd_ps, ~ (pdo->dip.prev_size + pdo->dip.cur_size) + 1, SEEK_CUR); exit_step_backward = 1; } else { /* 5th. move file pointer to previous picture */ fseek(pdo->p_fd_ps, ~ pdo->dip.prev_size + 1, SEEK_CUR); } /* 6th. get picture inform */ if (get_picture_inform(pdo) == FAILURE) { m_ERROR("pthread_dec.c:error In function 'get_picture_inform'\n"); return FAILURE; } } while (!exit_step_backward); return SUCCESS;}RETURN dec_pause(DEC_OBJECT *pdo) { pdo->psd = &gp_state_thread->state_dec; /* 1st. set play mode */ if (pdo->psd->play_change) { pdo->play_mode = trick_mode(TME_REAL, TM_PAUSE, TD_FORWARD, 0); pdo->psd->play_change = 0; } return SUCCESS;} FILE_INFO arrange_picture_inform(DEC_OBJECT *pdo){ UNS32 size_temp; /* 1st. get picture information for decoding */ size_temp= pdo->tpp.prev_pes_packet_length; pdo->dip.prev_size = ((size_temp >> 1) & 0x3ff800) + (size_temp & 0x7ff); if (pdo->dip.prev_size > DEC_MAX_BUF_SIZE) { printf("!!! PREV => [%d][%d]\n", pdo->dip.prev_size, pdo->tpp.prev_pes_packet_length); fflush(stdout); } size_temp = (pdo->tpp.cur_pes_packet_length >> 8); pdo->dip.cur_size = ((size_temp >> 1) & 0x3ff800) + (size_temp & 0x7ff); if (pdo->dip.cur_size > DEC_MAX_BUF_SIZE) { printf("!!! CUR => [%d][%d]\n", pdo->dip.cur_size, pdo->tpp.cur_pes_packet_length); fflush(stdout); } if ( ((pdo->tpp.start_code & 0x000000f0)) == 0xE0) { pdo->dip.data_type = DT_VIDEO; } else if ( ((pdo->tpp.start_code & 0x000000f0)) == 0xC0) { pdo->dip.data_type = DT_AUDIO; } pdo->dip.type = (pdo->tpp.cur_pes_packet_length & 0x00000003); if (pdo->tpp.cur_pes_packet_length & 0x00000080) { pdo->dip.conti = 1; } else { pdo->dip.conti = 0; } if (pdo->tpp.cur_pes_packet_length & 0x00000008 ) { pdo->dip.motion = 1; } else { pdo->dip.motion = 0; } if (pdo->tpp.cur_pes_packet_length & 0x00000004 ) { pdo->dip.motion_start = 1; } else { pdo->dip.motion_start = 0; } if (pdo->tpp.cur_pes_packet_length & 0x00000040) { pdo->dip.sensor = 1; } else { pdo->dip.sensor = 0; } if (pdo->tpp.cur_pes_packet_length & 0x00000020) { pdo->dip.sensor_start = 1; } else { pdo->dip.sensor_start = 0; } /* 2nd. check file stream ending */ if (pdo->end_fp <= ftell(pdo->p_fd_ps) + pdo->dip.cur_size) { return F_END; } return F_CONTI;}FILE_INFO arrange_backward_picture_inform(DEC_OBJECT *pdo){ UNS32 size_temp; /* 1st. get picture information for decoding */ size_temp = (pdo->tpp.prev_pes_packet_length); pdo->dip.prev_size = ((size_temp >> 1) & 0x3ff800) + (size_temp & 0x7ff); if (pdo->dip.prev_size > DEC_MAX_BUF_SIZE) { printf("!!! PREV => [0x%d][0x%d]\n", pdo->dip.prev_size, pdo->tpp.prev_pes_packet_length); fflush(stdout); } size_temp = (pdo->tpp.cur_pes_packet_length >> 8); pdo->dip.cur_size = ((size_temp >> 1) & 0x3ff800) + (size_temp & 0x7ff);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -