[MPlayer-dev-eng] [PATCH] reorganized demux_{asf,avi,mpg,xmms}_control
Arpi
arpi at thot.banki.hu
Mon Dec 23 01:14:04 CET 2002
Hi,
argh
WTF are you trying to do ????????
pleeeeeeeeeeeeease RTFA before sending more of such nonsenses
> Compiled and tested with asf, avi and mpg, all show total time and
> percentage correctly.
> Also, this will allow us to create demux_control functions for other
> formats (mov, mp3, ogg, ...) more easily.
>
> As a side note, mpeg total time seems a little strange (with or without
> this patch). I tried a file which is 13379840 bytes, and MPlayer says it's
> '2304,0 kbps (288,0 kbyte/s)' -- that must be in the header, right? So I
> guess the header has something wrong though, because DEMUXER_
> CTRL_GET_TIME_LENGTH gives 46 seconds, while 13379840/1024/288=45,37 secs,
> and the OSD says it's 53 secs. :-?? What can we do about this? Nothing?
>
>
> Index: libmpdemux/demuxer.h
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
> retrieving revision 1.52
> diff -u -r1.52 demuxer.h
> --- libmpdemux/demuxer.h 22 Dec 2002 21:01:01 -0000 1.52
> +++ libmpdemux/demuxer.h 22 Dec 2002 23:58:18 -0000
> @@ -245,7 +245,7 @@
> int demux_info_print(demuxer_t *demuxer);
> int demux_control(demuxer_t *demuxer, int cmd, void *arg);
>
> -#endif
> -
> extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
> extern int demuxer_get_percent_pos(demuxer_t *demuxer);
> +#endif
> +
> Index: libmpdemux/demuxer.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
> retrieving revision 1.126
> diff -u -r1.126 demuxer.c
> --- libmpdemux/demuxer.c 22 Dec 2002 21:01:01 -0000 1.126
> +++ libmpdemux/demuxer.c 22 Dec 2002 23:58:22 -0000
> @@ -16,6 +16,7 @@
> #include "stream.h"
> #include "demuxer.h"
> #include "stheader.h"
> +#include "aviheader.h"
> #include "mf.h"
>
> #include "../libvo/fastmemcpy.h"
> @@ -1274,31 +1275,104 @@
> return NULL;
> }
>
> -extern int demux_mpg_control(demuxer_t *demuxer, int cmd, void *arg);
> -extern int demux_asf_control(demuxer_t *demuxer, int cmd, void *arg);
> -extern int demux_avi_control(demuxer_t *demuxer, int cmd, void *arg);
> -extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg);
> -
> -int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
> - switch(demuxer->type) {
> - case DEMUXER_TYPE_MPEG_ES:
> - case DEMUXER_TYPE_MPEG_PS:
> - return demux_mpg_control(demuxer,cmd,arg);
> - case DEMUXER_TYPE_ASF:
> - return demux_asf_control(demuxer,cmd,arg);
> - case DEMUXER_TYPE_AVI:
> - case DEMUXER_TYPE_AVI_NI:
> - case DEMUXER_TYPE_AVI_NINI:
> - return demux_avi_control(demuxer,cmd,arg);
> +int demux_control(demuxer_t *demuxer,int cmd, void *arg){
> + int asf_movielength=0;
> +/* demux_stream_t *d_audio=demuxer->audio;
> + sh_audio_t *sh_audio=d_audio->sh; */
> + demux_stream_t *d_video=demuxer->video;
> + sh_video_t *sh_video=d_video->sh;
> + avi_priv_t *priv=demuxer->priv;
> #ifdef HAVE_XMMS
> - case DEMUXER_TYPE_XMMS:
> - return demux_xmms_control(demuxer,cmd,arg);
> + xmms_priv_t *xpriv=demuxer->priv;
> #endif
> - default:
> - return DEMUXER_CTRL_NOTIMPL;
> + switch(cmd) {
> +
> + case DEMUXER_CTRL_GET_TIME_LENGTH:
> + switch(demuxer->type) {
> + case DEMUXER_TYPE_ASF:
> + *((unsigned long *)arg)=(unsigned long)(asf_movielength);
> + break;
> +
> + case DEMUXER_TYPE_AVI:
> + case DEMUXER_TYPE_AVI_NI:
> + case DEMUXER_TYPE_AVI_NINI:
> + if (!priv->numberofframes) {
> + return DEMUXER_CTRL_DONTKNOW;
> + }
> + *((unsigned long *)arg)=priv->numberoffr
> ames/sh_video->fps;
> + if (sh_video->video.dwLength<=1) {
> + return DEMUXER_CTRL_GUESS;
> + }
> + return DEMUXER_CTRL_OK;
> + break;
> +
> + case DEMUXER_TYPE_MPEG_ES:
> + case DEMUXER_TYPE_MPEG_PS:
> + if(!sh_video->i_bps) { // unspecified or VBR
> + return DEMUXER_CTRL_DONTKNOW;
> + }
> + *((unsigned long *)arg)=(demuxer->movi_e
> nd-demuxer->movi_start)/sh_video->i_bps;
> + return DEMUXER_CTRL_GUESS;
> + break;
> +
> +#ifdef HAVE_XMMS
> + case DEMUXER_TYPE_XMMS:
> + if (xmms_length<=0) {
> + return DEMUXER_CTRL_DONTKNOW;
> + }
> + *((unsigned long *)arg)=(unsigned long)xmms_length/1000;
> + return DEMUXER_CTRL_GUESS;
> + break;
> +#endif
> +
> + default:
> + break;
> + }
> +
> + case DEMUXER_CTRL_GET_PERCENT_POS:
> + if (demuxer->movi_end==demuxer->movi_start) {
> + return DEMUXER_CTRL_DONTKNOW;
> + }
> + switch(demuxer->type) {
> + case DEMUXER_TYPE_ASF:
> + *((int *)arg)=(int)((demuxer->filepos-de
> muxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100));
> + return DEMUXER_CTRL_OK;
> + break;
> +
> + case DEMUXER_TYPE_AVI:
> + case DEMUXER_TYPE_AVI_NI:
> + case DEMUXER_TYPE_AVI_NINI:
> + if (!priv->numberofframes) {
> + *((int *)arg)=(int)((demuxer->filepo
> s-demuxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100));
> + return DEMUXER_CTRL_OK;
> + }
> + *((int *)arg)=(int)(priv->video_pack_no*
> 100/priv->numberofframes);
> + if (sh_video->video.dwLength<=1) {
> + return DEMUXER_CTRL_GUESS;
> + }
> + return DEMUXER_CTRL_OK;
> + break;
> +
> + case DEMUXER_TYPE_MPEG_ES:
> + case DEMUXER_TYPE_MPEG_PS:
> + *((int *)arg)=(int)((demuxer->filepos-de
> muxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100));
> + return DEMUXER_CTRL_OK;
> + break;
> +
> +#ifdef HAVE_XMMS
> + case DEMUXER_TYPE_XMMS:
> + if (xmms_length<=0) {
> + return DEMUXER_CTRL_DONTKNOW;
> + }
> + *((int *)arg)=(int)( xpriv->spos / (floa
> t)(sh_audio->wf->nAvgBytesPerSec) / xmms_length );
> + return DEMUXER_CTRL_OK;
> + break;
> +#endif
> + }
> + default:
> + return DEMUXER_CTRL_NOTIMPL;
> }
> }
> -
>
>
> unsigned long demuxer_get_time_length(demuxer_t *demuxer){
> Index: libmpdemux/demux_asf.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpdemux/demux_asf.c,v
> retrieving revision 1.26
> diff -u -r1.26 demux_asf.c
> --- libmpdemux/demux_asf.c 23 Nov 2002 10:58:08 -0000 1.26
> +++ libmpdemux/demux_asf.c 22 Dec 2002 23:58:23 -0000
> @@ -12,7 +12,6 @@
> #include "asf.h"
> #include "demuxer.h"
>
> -
> /*
> * Load 16/32-bit values in little endian byte order
> * from an unaligned address
> @@ -396,25 +395,3 @@
>
> }
>
> -int demux_asf_control(demuxer_t *demuxer,int cmd, void *arg){
> -/* demux_stream_t *d_audio=demuxer->audio;
> - demux_stream_t *d_video=demuxer->video;
> - sh_audio_t *sh_audio=d_audio->sh;
> - sh_video_t *sh_video=d_video->sh;
> -*/
> - switch(cmd) {
> - case DEMUXER_CTRL_GET_TIME_LENGTH:
> - *((unsigned long *)arg)=(unsigned long)(asf_movielength);
> - return DEMUXER_CTRL_OK;
> -
> - case DEMUXER_CTRL_GET_PERCENT_POS:
> - if (demuxer->movi_end==demuxer->movi_start) {
> - return DEMUXER_CTRL_DONTKNOW;
> - }
> - *((int *)arg)=(int)((demuxer->filepos-demuxer->movi
> _start)/((demuxer->movi_end-demuxer->movi_start)/100));
> - return DEMUXER_CTRL_OK;
> -
> - default:
> - return DEMUXER_CTRL_NOTIMPL;
> - }
> -}
> Index: libmpdemux/demux_avi.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
> retrieving revision 1.53
> diff -u -r1.53 demux_avi.c
> --- libmpdemux/demux_avi.c 21 Dec 2002 22:11:48 -0000 1.53
> +++ libmpdemux/demux_avi.c 22 Dec 2002 23:58:25 -0000
> @@ -823,34 +823,3 @@
> free(priv);
> }
>
> -
> -int demux_avi_control(demuxer_t *demuxer,int cmd, void *arg){
> - avi_priv_t *priv=demuxer->priv;
> -/* demux_stream_t *d_audio=demuxer->audio;*/
> - demux_stream_t *d_video=demuxer->video;
> -/* sh_audio_t *sh_audio=d_audio->sh;*/
> - sh_video_t *sh_video=d_video->sh;
> -
> -
> -
> - switch(cmd) {
> - case DEMUXER_CTRL_GET_TIME_LENGTH:
> - if (!priv->numberofframes) return DEMUXER_CTRL_DONTKNOW;
> - *((unsigned long *)arg)=priv->numberofframes/sh_video->fps;
> - if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;
> - return DEMUXER_CTRL_OK;
> -
> - case DEMUXER_CTRL_GET_PERCENT_POS:
> - if (!priv->numberofframes) {
> - if (demuxer->movi_end==demuxer->movi_start) return DEMUXER_CTRL_DONTKNOW;
> - *((int *)arg)=(int)((demuxer->filepos-demuxer->movi_start)
> /((demuxer->movi_end-demuxer->movi_start)/100));
> - return DEMUXER_CTRL_OK;
> - }
> - *((int *)arg)=(int)(priv->video_pack_no*100/priv->numberofframes);
> - if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;
> - return DEMUXER_CTRL_OK;
> -
> - default:
> - return DEMUXER_CTRL_NOTIMPL;
> - }
> -}
> Index: libmpdemux/demux_mpg.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
> retrieving revision 1.46
> diff -u -r1.46 demux_mpg.c
> --- libmpdemux/demux_mpg.c 23 Nov 2002 10:58:08 -0000 1.46
> +++ libmpdemux/demux_mpg.c 22 Dec 2002 23:58:26 -0000
> @@ -405,26 +405,3 @@
> }
> }
>
> -int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
> -/* demux_stream_t *d_audio=demuxer->audio;*/
> - demux_stream_t *d_video=demuxer->video;
> -/* sh_audio_t *sh_audio=d_audio->sh;*/
> - sh_video_t *sh_video=d_video->sh;
> -
> - switch(cmd) {
> - 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->mov
> i_start)/sh_video->i_bps;
> - return DEMUXER_CTRL_GUESS;
> -
> - case DEMUXER_CTRL_GET_PERCENT_POS:
> - if (demuxer->movi_end==demuxer->movi_start)
> - return DEMUXER_CTRL_DONTKNOW;
> - *((int *)arg)=(int)((demuxer->filepos-demuxer->movi
> _start)/((demuxer->movi_end-demuxer->movi_start)/100));
> - return DEMUXER_CTRL_OK;
> -
> - default:
> - return DEMUXER_CTRL_NOTIMPL;
> - }
> -}
> Index: libmpdemux/demux_xmms.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libmpdemux/demux_xmms.c,v
> retrieving revision 1.1
> diff -u -r1.1 demux_xmms.c
> --- libmpdemux/demux_xmms.c 22 Dec 2002 21:01:01 -0000 1.1
> +++ libmpdemux/demux_xmms.c 22 Dec 2002 23:58:26 -0000
> @@ -313,24 +313,3 @@
> return 1;
> }
>
> -int demux_xmms_control(demuxer_t *demuxer,int cmd, void *arg){
> - demux_stream_t *d_video=demuxer->video;
> - sh_audio_t *sh_audio=demuxer->audio->sh;
> - xmms_priv_t *priv=demuxer->priv;
> -
> - switch(cmd) {
> - case DEMUXER_CTRL_GET_TIME_LENGTH:
> - if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW;
> - *((unsigned long *)arg)=(unsigned long)xmms_length/1000;
> - return DEMUXER_CTRL_GUESS;
> -
> - case DEMUXER_CTRL_GET_PERCENT_POS:
> - if (xmms_length<=0)
> - return DEMUXER_CTRL_DONTKNOW;
> - *((int *)arg)=(int)( priv->spos / (float)(sh_audio-
> >wf->nAvgBytesPerSec) / xmms_length );
> - return DEMUXER_CTRL_OK;
> -
> - default:
> - return DEMUXER_CTRL_NOTIMPL;
> - }
> -}
>
>
A'rpi / Astral & ESP-team
--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu
More information about the MPlayer-dev-eng
mailing list