[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[283] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-02 15:05:34
|
Revision: 283 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=283&view=rev Author: nickols_k Date: 2012-11-02 15:05:24 +0000 (Fri, 02 Nov 2012) Log Message: ----------- prepare next step of XP-CORE development Modified Paths: -------------- mplayerxp/libao2/ao_wav.c mplayerxp/libmpcodecs/dec_audio.c mplayerxp/mplayer.c mplayerxp/xmp_core.c mplayerxp/xmp_core.h Modified: mplayerxp/libao2/ao_wav.c =================================================================== --- mplayerxp/libao2/ao_wav.c 2012-11-02 13:52:14 UTC (rev 282) +++ mplayerxp/libao2/ao_wav.c 2012-11-02 15:05:24 UTC (rev 283) @@ -222,7 +222,7 @@ extern vo_data_t* vo_data; static unsigned get_space(ao_data_t* ao){ priv_t* priv=ao->priv; - float pts=dae_played_fra(xp_core->video).v_pts; + float pts=dae_played_frame(xp_core->video).v_pts; if(pts) return ao->pts < pts + priv->fast * 30000 ? ao->outburst : 0; return ao->outburst; Modified: mplayerxp/libmpcodecs/dec_audio.c =================================================================== --- mplayerxp/libmpcodecs/dec_audio.c 2012-11-02 13:52:14 UTC (rev 282) +++ mplayerxp/libmpcodecs/dec_audio.c 2012-11-02 15:05:24 UTC (rev 283) @@ -174,8 +174,7 @@ afs->output.rate = *out_samplerate ? *out_samplerate : afs->input.rate; afs->output.nch = *out_channels ? *out_channels : afs->input.nch; if(*out_format) afs->output.format = af_format_decode(*out_format,&afs->output.bps); - else - { + else { afs->output.format = afs->input.format; afs->output.bps = out_bps ? out_bps : afs->input.bps; } @@ -223,7 +222,7 @@ afs->output.nch = out_channels ? out_channels : afs->input.nch; afs->output.format = af_format_decode(out_format ? out_format : afs->input.format,&afs->output.bps); - // filter config: + // filter config: memcpy(&afs->cfg,&af_cfg,sizeof(af_cfg_t)); MSG_V("Building audio filter chain for %dHz/%dch/%dbit (%s) -> %dHz/%dch/%dbit (%s)...\n", Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2012-11-02 13:52:14 UTC (rev 282) +++ mplayerxp/mplayer.c 2012-11-02 15:05:24 UTC (rev 283) @@ -729,7 +729,7 @@ if(sh_audio) while(get_len_audio_buffer()) usleep(0); if(sh_video) { for(;;) { - if(dae_played_fra(xp_core->video).eof) break; + if(dae_played_eof(xp_core->video)) break; usleep(0); } } @@ -1175,7 +1175,7 @@ fflush(stdout); } -static void vplayer_check_chapter_change(frame_attr_t* shva_prev,float v_pts) +static void vplayer_check_chapter_change(xmp_frame_t* shva_prev,float v_pts) { priv_t*priv=mp_data->priv; sh_audio_t* sh_audio=priv->demuxer->audio->sh; @@ -1202,7 +1202,7 @@ } } -static float vplayer_compute_sleep_time(frame_attr_t* shva_prev,float screen_pts) +static float vplayer_compute_sleep_time(xmp_frame_t* shva_prev,float screen_pts) { priv_t*priv=mp_data->priv; sh_audio_t* sh_audio=priv->demuxer->audio->sh; @@ -1280,14 +1280,14 @@ int can_blit=0; int delay_corrected=1; int final_frame=0; - frame_attr_t shva_prev,shva; + xmp_frame_t shva_prev,shva; - shva_prev=dae_played_fra(xp_core->video); - final_frame = shva_prev.eof; + shva_prev=dae_played_frame(xp_core->video); + final_frame = dae_played_eof(xp_core->video); if(xp_core->video->eof && final_frame) return 1; can_blit=dae_try_inc_played(xp_core->video); /* <-- TRY SWITCH TO NEXT FRAME */ - shva=dae_next_played_fra(xp_core->video); + shva=dae_next_played_frame(xp_core->video); v_pts = shva.v_pts; /*------------------------ frame decoded. --------------------*/ /* blit frame */ @@ -1309,7 +1309,7 @@ #ifdef USE_OSD MSG_D("dec_ahead_main: draw_osd to %u\n",player_idx); MP_UNIT("draw_osd"); - update_osd(shva.stream_pts); + update_osd(shva.v_pts); vo_draw_osd(vo_data,dae_next_played(xp_core->video)); #endif } @@ -2168,7 +2168,7 @@ i_abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0; if(i_abs) { seek->flags = DEMUX_SEEK_SET|DEMUX_SEEK_PERCENTS; - if(sh_video) priv->osd_function= (v > dae_played_fra(xp_core->video).v_pts) ? OSD_FFW : OSD_REW; + if(sh_video) priv->osd_function= (v > dae_played_frame(xp_core->video).v_pts) ? OSD_FFW : OSD_REW; seek->secs = v/100.; } else { @@ -2834,8 +2834,8 @@ xmp_halt_threads(0); if(seek_args.secs && sh_video) { - frame_attr_t shvap = dae_played_fra(xp_core->video); - frame_attr_t shvad = xp_core->video->fra[dae_prev_decoded(xp_core->video)]; + xmp_frame_t shvap = dae_played_frame(xp_core->video); + xmp_frame_t shvad = dae_prev_decoded_frame(xp_core->video); seek_args.secs -= (xp_core->bad_pts?shvad.v_pts:d_video->pts)-shvap.v_pts; } Modified: mplayerxp/xmp_core.c =================================================================== --- mplayerxp/xmp_core.c 2012-11-02 13:52:14 UTC (rev 282) +++ mplayerxp/xmp_core.c 2012-11-02 15:05:24 UTC (rev 283) @@ -90,12 +90,12 @@ void dae_init(dec_ahead_engine_t* it,unsigned nframes,any_t* sh) { it->nframes=nframes; - it->fra = mp_malloc(sizeof(frame_attr_t)*nframes); + it->frame = mp_malloc(sizeof(xmp_frame_t)*nframes); it->sh=sh; dae_reset(it); } -void dae_uninit(dec_ahead_engine_t* it) { mp_free(it->fra); it->fra=0; } +void dae_uninit(dec_ahead_engine_t* it) { mp_free(it->frame); it->frame=NULL; } /* returns 1 - on success 0 - if busy */ int dae_try_inc_played(dec_ahead_engine_t* it) { @@ -114,6 +114,7 @@ unsigned new_idx; new_idx=(it->player_idx+1)%it->nframes; if(new_idx==it->decoder_idx) return 0; + if(it->free_priv) (*it->free_priv)(it,it->frame[it->player_idx].priv); it->player_idx=new_idx; return 1; } @@ -124,6 +125,7 @@ new_idx=(it->decoder_idx+1)%it->nframes; if(new_idx==it->player_idx) return 0; it->decoder_idx=new_idx; + if(it->new_priv) it->frame[it->player_idx].priv=(*it->new_priv)(it); it->num_decoded_frames++; return 1; } @@ -147,31 +149,46 @@ } } -frame_attr_t dae_played_fra(const dec_ahead_engine_t* it) { +xmp_frame_t dae_played_frame(const dec_ahead_engine_t* it) { unsigned idx=it->player_idx; - return it->fra[idx]; + return it->frame[idx]; } -frame_attr_t dae_decoded_fra(const dec_ahead_engine_t* it) { +xmp_frame_t dae_decoded_frame(const dec_ahead_engine_t* it) { unsigned idx=it->decoder_idx; - return it->fra[idx]; + return it->frame[idx]; } -frame_attr_t dae_next_played_fra(const dec_ahead_engine_t* it) { +xmp_frame_t dae_next_played_frame(const dec_ahead_engine_t* it) { unsigned idx=dae_next_played(it); - return it->fra[idx]; + return it->frame[idx]; } -frame_attr_t dae_next_decoded_fra(const dec_ahead_engine_t* it) { +xmp_frame_t dae_next_decoded_frame(const dec_ahead_engine_t* it) { unsigned idx=dae_next_decoded(it); - return it->fra[idx]; + return it->frame[idx]; } -frame_attr_t dae_prev_played_fra(const dec_ahead_engine_t* it) { +xmp_frame_t dae_prev_played_frame(const dec_ahead_engine_t* it) { unsigned idx=dae_prev_played(it); - return it->fra[idx]; + return it->frame[idx]; } -frame_attr_t dae_prev_decoded_fra(const dec_ahead_engine_t* it) { +xmp_frame_t dae_prev_decoded_frame(const dec_ahead_engine_t* it) { unsigned idx=dae_prev_decoded(it); - return it->fra[idx]; + return it->frame[idx]; } +int dae_played_eof(const dec_ahead_engine_t* it) { + unsigned idx=it->player_idx; + return (it->frame[idx].v_pts==HUGE_VALF)?1:0; +} + +int dae_decoded_eof(const dec_ahead_engine_t* it) { + unsigned idx=it->decoder_idx; + return (it->frame[idx].v_pts==HUGE_VALF)?1:0; +} + +void dae_decoded_mark_eof(dec_ahead_engine_t* it) { + unsigned idx=it->decoder_idx; + it->frame[idx].v_pts=HUGE_VALF; +} + pthread_mutex_t audio_play_mutex=PTHREAD_MUTEX_INITIALIZER; pthread_cond_t audio_play_cond=PTHREAD_COND_INITIALIZER; @@ -260,7 +277,7 @@ static unsigned compute_frame_dropping(sh_video_t* sh_video,float v_pts,float drop_barrier) { unsigned rc=0; - float screen_pts=dae_played_fra(xp_core->video).v_pts-(mp_conf.av_sync_pts?0:xp_core->initial_apts); + float screen_pts=dae_played_frame(xp_core->video).v_pts-(mp_conf.av_sync_pts?0:xp_core->initial_apts); static float prev_delta=64; float delta,max_frame_delay;/* delay for decoding of top slow frame */ max_frame_delay = mp_data->bench->max_video+mp_data->bench->max_vout; @@ -308,7 +325,7 @@ idx1 = dae_curr_vdecoded(xp_core); idx2 = dae_prev_vdecoded(xp_core); - frame_attr_t* fra=xp_core->video->fra; + xmp_frame_t* fra=xp_core->video->frame; while( dae_curr_vplayed(xp_core) != idx2 && fra[idx2].v_pts > fra[idx1].v_pts && fra[idx2].v_pts < fra[idx1].v_pts+1.0 ) { @@ -317,8 +334,6 @@ fra[idx1].v_pts = fra[idx2].v_pts; fra[idx2].v_pts = tmp; - fra[idx1].stream_pts = fra[idx1].v_pts; - fra[idx2].stream_pts = fra[idx2].v_pts; fra[idx2].duration = fra[idx1].v_pts - fra[idx2].v_pts; idx3=(idx2-1)%xp_core->num_v_buffs; @@ -390,7 +405,7 @@ /*-------------------- Decode a frame: -----------------------*/ in_size=video_read_frame_r(sh_video,&duration,&v_pts,&start,sh_video->fps); if(in_size<0) { - xp_core->video->fra[xp_core->video->decoder_idx].eof=1; + dae_decoded_mark_eof(xp_core->video); priv->dae->eof=1; break; } @@ -447,15 +462,14 @@ if(blit_frame) { unsigned idx=dae_curr_vdecoded(xp_core); if(xp_core->bad_pts) - xp_core->video->fra[idx].v_pts=mpeg_timer; + xp_core->video->frame[idx].v_pts=mpeg_timer; else - xp_core->video->fra[idx].v_pts = v_pts; - xp_core->video->fra[idx].stream_pts = v_pts; - xp_core->video->fra[idx].duration=duration; - xp_core->video->fra[idx].eof=0; + xp_core->video->frame[idx].v_pts = v_pts; + xp_core->video->frame[idx].duration=duration; + dae_decoded_clear_eof(xp_core->video); if(!xp_core->bad_pts) { int _idx = dae_prev_vdecoded(xp_core); - xp_core->video->fra[_idx].duration=v_pts-xp_core->video->fra[_idx].v_pts; + xp_core->video->frame[_idx].duration=v_pts-xp_core->video->frame[_idx].v_pts; } if(mp_conf.frame_reorder) reorder_pts_in_mpeg(); } /* if (blit_frame) */ @@ -892,7 +906,7 @@ mp_msg_flush(); xp_core->video->eof = 1; - xp_core->video->fra[dae_curr_vdecoded(xp_core)].eof=1; + dae_decoded_mark_eof(xp_core->video); /* Unlock all mutex ( man page says it may deadlock, but what is worse deadlock here or later? ) Modified: mplayerxp/xmp_core.h =================================================================== --- mplayerxp/xmp_core.h 2012-11-02 13:52:14 UTC (rev 282) +++ mplayerxp/xmp_core.h 2012-11-02 15:05:24 UTC (rev 283) @@ -19,21 +19,29 @@ enum xp_modes { XP_NA=0, XP_Video, XP_VideoAudio, XP_VAPlay, XP_VAFull }; -typedef struct frame_attr_s +typedef struct xmp_frame_s { - int eof; /* indicates last frame in stream */ + float v_pts; /* presentation time-stamp from input stream + __huge_valf indicates EOF */ float duration; /* frame duration */ - float v_pts; /* presentation time-stamp from input stream */ - float stream_pts; /* real stream's PTS mainly for OSD */ -}frame_attr_t; + any_t* priv; +}xmp_frame_t; +struct dec_ahead_engine_s; + +typedef any_t* (*func_new_frame_priv_t)(struct dec_ahead_engine_s*); +typedef void (*func_free_frame_priv_t)(struct dec_ahead_engine_s*,any_t*); + typedef struct dec_ahead_engine_s { volatile unsigned player_idx; /* index of frame which is currently played */ volatile unsigned decoder_idx; /* index of frame which is currently decoded */ unsigned nframes; /* number of frames in buffer */ - frame_attr_t* fra; /* frame related attributes */ + xmp_frame_t* frame; /* frame related attributes */ any_t* sh; /* corresponded sh_audio_t or sh_video_t */ int eof; /* EOF for stream */ + /* methods */ + func_new_frame_priv_t new_priv; + func_free_frame_priv_t free_priv; /* for statistics */ unsigned num_slow_frames;/* number of frames which were delayed due slow computer */ long long int num_played_frames; @@ -129,13 +137,18 @@ static inline unsigned dae_next_vplayed(const xp_core_t* xpc) { return dae_next_played(xpc->video); } static inline unsigned dae_next_vdecoded(const xp_core_t* xpc) { return dae_next_decoded(xpc->video); } -extern frame_attr_t dae_played_fra(const dec_ahead_engine_t* it); -extern frame_attr_t dae_decoded_fra(const dec_ahead_engine_t* it); -extern frame_attr_t dae_next_played_fra(const dec_ahead_engine_t* it); -extern frame_attr_t dae_next_decoded_fra(const dec_ahead_engine_t* it); -extern frame_attr_t dae_prev_played_fra(const dec_ahead_engine_t* it); -extern frame_attr_t dae_prev_decoded_fra(const dec_ahead_engine_t* it); +extern xmp_frame_t dae_played_frame(const dec_ahead_engine_t* it); +extern xmp_frame_t dae_decoded_frame(const dec_ahead_engine_t* it); +extern xmp_frame_t dae_next_played_frame(const dec_ahead_engine_t* it); +extern xmp_frame_t dae_next_decoded_frame(const dec_ahead_engine_t* it); +extern xmp_frame_t dae_prev_played_frame(const dec_ahead_engine_t* it); +extern xmp_frame_t dae_prev_decoded_frame(const dec_ahead_engine_t* it); +extern int dae_played_eof(const dec_ahead_engine_t* it); +extern int dae_decoded_eof(const dec_ahead_engine_t* it); +extern void dae_decoded_mark_eof(dec_ahead_engine_t* it); +extern inline void dae_decoded_clear_eof(dec_ahead_engine_t* it) { UNUSED(it); } + extern pthread_mutex_t audio_play_mutex; extern pthread_cond_t audio_play_cond; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |