mirror of
https://github.com/mpv-player/mpv
synced 2024-12-17 12:25:03 +00:00
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
accuracey may be totally fake for some demuxers (mpg), but accurate for others.. (avi) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16347 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
43844d090c
commit
d620029e4b
@ -422,7 +422,7 @@ static int demux_asf_control(demuxer_t *demuxer,int cmd, void *arg){
|
||||
*/
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
*((unsigned long *)arg)=(unsigned long)(asf_movielength);
|
||||
*((double *)arg)=(double)(asf_movielength);
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -543,7 +543,7 @@ static int demux_audio_control(demuxer_t *demuxer,int cmd, void *arg){
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if (audio_length<=0) return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg)=(unsigned long)audio_length;
|
||||
*((double *)arg)=(double)audio_length;
|
||||
return DEMUXER_CTRL_GUESS;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -850,7 +850,7 @@ static int demux_avi_control(demuxer_t *demuxer,int cmd, void *arg){
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if (!priv->numberofframes) return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg)=priv->numberofframes/sh_video->fps;
|
||||
*((double *)arg)=(double)priv->numberofframes/sh_video->fps;
|
||||
if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
|
@ -343,7 +343,7 @@ static int demux_avs_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
{
|
||||
if (!AVS->video_info->num_frames) return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg) = AVS->video_info->num_frames / sh_video->fps;
|
||||
*((double *)arg) = (double)AVS->video_info->num_frames / sh_video->fps;
|
||||
return DEMUXER_CTRL_OK;
|
||||
}
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -402,7 +402,7 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
if (priv->avfc->duration == 0)
|
||||
return DEMUXER_CTRL_DONTKNOW;
|
||||
|
||||
*((unsigned long *)arg) = priv->avfc->duration / AV_TIME_BASE;
|
||||
*((double *)arg) = (double)priv->avfc->duration / AV_TIME_BASE;
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -3280,7 +3280,7 @@ demux_mkv_control (demuxer_t *demuxer, int cmd, void *arg)
|
||||
if (mkv_d->duration == 0)
|
||||
return DEMUXER_CTRL_DONTKNOW;
|
||||
|
||||
*((unsigned long *)arg) = (unsigned long)mkv_d->duration;
|
||||
*((double *)arg) = (double)mkv_d->duration;
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -2016,7 +2016,7 @@ static int demux_mov_control(demuxer_t *demuxer, int cmd, void *arg){
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if (!track->timescale)
|
||||
return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg) = track->length / track->timescale;
|
||||
*((double *)arg) = (double)track->length / track->timescale;
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -751,7 +751,7 @@ int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if (mpg_d && mpg_d->has_valid_timestamps) {
|
||||
*((unsigned long *)arg)=(long)mpg_d->final_pts;
|
||||
*((double *)arg)=(double)mpg_d->final_pts;
|
||||
return DEMUXER_CTRL_GUESS;
|
||||
}
|
||||
return DEMUXER_CTRL_DONTKNOW;
|
||||
|
@ -1605,7 +1605,7 @@ static int demux_ogg_control(demuxer_t *demuxer,int cmd, void *arg){
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if (ogg_d->final_granulepos<=0) return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg)=ogg_d->final_granulepos / rate;
|
||||
*((double *)arg)=(double)ogg_d->final_granulepos / rate;
|
||||
return DEMUXER_CTRL_GUESS;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -234,7 +234,7 @@ static int demux_rawdv_control(demuxer_t *demuxer,int cmd, void *arg) {
|
||||
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
*((unsigned long *)arg)=frames->frame_number / sh_video->fps;
|
||||
*((double *)arg)=(double)frames->frame_number / sh_video->fps;
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -1855,7 +1855,7 @@ static int demux_real_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
if (priv->duration == 0)
|
||||
return DEMUXER_CTRL_DONTKNOW;
|
||||
|
||||
*((unsigned long *)arg) = priv->duration;
|
||||
*((double *)arg) = (double)priv->duration;
|
||||
return DEMUXER_CTRL_OK;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -1350,8 +1350,8 @@ int demux_ty_control( demuxer_t *demuxer,int cmd, void *arg )
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if(!sh_video->i_bps) // unspecified or VBR
|
||||
return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg)=
|
||||
(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
|
||||
*((double *)arg)=
|
||||
((double)demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
|
||||
return DEMUXER_CTRL_GUESS;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -341,7 +341,7 @@ static int demux_xmms_control(demuxer_t *demuxer,int cmd, void *arg){
|
||||
switch(cmd) {
|
||||
case DEMUXER_CTRL_GET_TIME_LENGTH:
|
||||
if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW;
|
||||
*((unsigned long *)arg)=(unsigned long)xmms_length/1000;
|
||||
*((double *)arg)=(double)xmms_length/1000;
|
||||
return DEMUXER_CTRL_GUESS;
|
||||
|
||||
case DEMUXER_CTRL_GET_PERCENT_POS:
|
||||
|
@ -918,13 +918,13 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
|
||||
|
||||
|
||||
|
||||
unsigned long demuxer_get_time_length(demuxer_t *demuxer){
|
||||
unsigned long get_time_ans;
|
||||
double demuxer_get_time_length(demuxer_t *demuxer){
|
||||
double get_time_ans;
|
||||
sh_video_t *sh_video = demuxer->video->sh;
|
||||
// <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW
|
||||
if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH,(void *)&get_time_ans)<=0) {
|
||||
if (sh_video && sh_video->i_bps)
|
||||
get_time_ans = (demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
|
||||
get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
|
||||
else
|
||||
get_time_ans=0;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ char *demux_ogg_sub_lang(demuxer_t *demuxer, int index);
|
||||
|
||||
#endif
|
||||
|
||||
extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
|
||||
extern double demuxer_get_time_length(demuxer_t *demuxer);
|
||||
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
|
||||
extern int demuxer_switch_audio(demuxer_t *demuxer, int index);
|
||||
|
||||
|
@ -2032,7 +2032,7 @@ if(identify) {
|
||||
mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_RATE=%d\n", sh_audio->samplerate);
|
||||
mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_NCH=%d\n", sh_audio->channels);
|
||||
}
|
||||
mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_LENGTH=%ld\n", demuxer_get_time_length(demuxer));
|
||||
mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_LENGTH=%.2lf\n", demuxer_get_time_length(demuxer));
|
||||
}
|
||||
|
||||
if(!sh_video) goto main; // audio-only
|
||||
@ -3615,7 +3615,7 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
|
||||
break;
|
||||
|
||||
case MP_CMD_GET_TIME_LENGTH : {
|
||||
mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_LENGTH=%ld\n", demuxer_get_time_length(demuxer));
|
||||
mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_LENGTH=%.2lf\n", demuxer_get_time_length(demuxer));
|
||||
} break;
|
||||
|
||||
case MP_CMD_GET_VO_FULLSCREEN : {
|
||||
|
Loading…
Reference in New Issue
Block a user