1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-20 22:40:52 +00:00

cosmetics: indentation, whitespace changes

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27087 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
diego 2008-06-16 12:11:14 +00:00
parent 005cf981d4
commit ed59b9030e

View File

@ -160,27 +160,27 @@ void free_demuxer_stream(demux_stream_t *ds)
demux_stream_t *new_demuxer_stream(struct demuxer_st *demuxer, int id)
{
demux_stream_t *ds = malloc(sizeof(demux_stream_t));
ds->buffer_pos=ds->buffer_size=0;
ds->buffer=NULL;
ds->pts=0;
ds->pts_bytes=0;
ds->eof=0;
ds->pos=0;
ds->dpos=0;
ds->pack_no=0;
ds->buffer_pos = ds->buffer_size = 0;
ds->buffer = NULL;
ds->pts = 0;
ds->pts_bytes = 0;
ds->eof = 0;
ds->pos = 0;
ds->dpos = 0;
ds->pack_no = 0;
ds->packs=0;
ds->bytes=0;
ds->first=ds->last=ds->current=NULL;
ds->id=id;
ds->demuxer=demuxer;
ds->packs = 0;
ds->bytes = 0;
ds->first = ds->last = ds->current = NULL;
ds->id = id;
ds->demuxer = demuxer;
ds->asf_seq=-1;
ds->asf_packet=NULL;
ds->asf_seq = -1;
ds->asf_packet = NULL;
ds->ss_mul=ds->ss_div=0;
ds->ss_mul = ds->ss_div = 0;
ds->sh=NULL;
ds->sh = NULL;
return ds;
}
@ -206,27 +206,27 @@ static const demuxer_desc_t *get_demuxer_desc_from_type(int file_format)
demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
int s_id, char *filename)
{
demuxer_t *d=malloc(sizeof(demuxer_t));
memset(d,0,sizeof(demuxer_t));
d->stream=stream;
demuxer_t *d = malloc(sizeof(demuxer_t));
memset(d, 0, sizeof(demuxer_t));
d->stream = stream;
d->stream_pts = MP_NOPTS_VALUE;
d->reference_clock = MP_NOPTS_VALUE;
d->movi_start=stream->start_pos;
d->movi_end=stream->end_pos;
d->seekable=1;
d->synced=0;
d->filepos=0;
d->audio=new_demuxer_stream(d,a_id);
d->video=new_demuxer_stream(d,v_id);
d->sub=new_demuxer_stream(d,s_id);
d->type=type;
d->movi_start = stream->start_pos;
d->movi_end = stream->end_pos;
d->seekable = 1;
d->synced = 0;
d->filepos = 0;
d->audio = new_demuxer_stream(d, a_id);
d->video = new_demuxer_stream(d, v_id);
d->sub = new_demuxer_stream(d, s_id);
d->type = type;
if (type)
if (!(d->desc = get_demuxer_desc_from_type(type)))
mp_msg(MSGT_DEMUXER,MSGL_ERR,"BUG! Invalid demuxer type in new_demuxer(), big troubles ahead.");
mp_msg(MSGT_DEMUXER, MSGL_ERR, "BUG! Invalid demuxer type in new_demuxer(), big troubles ahead.");
if (filename) // Filename hack for avs_check_file
d->filename=strdup(filename);
d->filename = strdup(filename);
stream_reset(stream);
stream_seek(stream,stream->start_pos);
stream_seek(stream, stream->start_pos);
return d;
}
@ -235,7 +235,7 @@ extern int dvdsub_id;
sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
{
if (id > MAX_S_STREAMS - 1 || id < 0) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested sub stream id overflow (%d > %d)\n",
mp_msg(MSGT_DEMUXER, MSGL_WARN, "Requested sub stream id overflow (%d > %d)\n",
id, MAX_S_STREAMS);
return NULL;
}
@ -264,24 +264,24 @@ void free_sh_sub(sh_sub_t *sh)
sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
{
if (id > MAX_A_STREAMS-1 || id < 0) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n",
if (id > MAX_A_STREAMS - 1 || id < 0) {
mp_msg(MSGT_DEMUXER, MSGL_WARN, "Requested audio stream id overflow (%d > %d)\n",
id, MAX_A_STREAMS);
return NULL;
}
if (demuxer->a_streams[id])
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_AudioStreamRedefined,id);
mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_AudioStreamRedefined, id);
else {
sh_audio_t *sh = calloc(1, sizeof(sh_audio_t));
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundAudioStream,id);
mp_msg(MSGT_DEMUXER, MSGL_V, MSGTR_FoundAudioStream, id);
demuxer->a_streams[id] = sh;
sh->aid = aid;
sh->ds = demuxer->audio;
// set some defaults
sh->samplesize=2;
sh->sample_format=AF_FORMAT_S16_NE;
sh->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/
sh->pts=MP_NOPTS_VALUE;
sh->samplesize = 2;
sh->sample_format = AF_FORMAT_S16_NE;
sh->audio_out_minsize = 8192; /* default size, maybe not enough for Win32/ACM */
sh->pts = MP_NOPTS_VALUE;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid);
}
return demuxer->a_streams[id];
@ -291,7 +291,7 @@ void free_sh_audio(demuxer_t *demuxer, int id)
{
sh_audio_t *sh = demuxer->a_streams[id];
demuxer->a_streams[id] = NULL;
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing sh_audio at %p\n",sh);
mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_audio at %p\n", sh);
free(sh->wf);
free(sh->codecdata);
free(sh->lang);
@ -301,15 +301,15 @@ void free_sh_audio(demuxer_t *demuxer, int id)
sh_video_t *new_sh_video_vid(demuxer_t *demuxer, int id, int vid)
{
if (id > MAX_V_STREAMS - 1 || id < 0) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n",
mp_msg(MSGT_DEMUXER, MSGL_WARN, "Requested video stream id overflow (%d > %d)\n",
id, MAX_V_STREAMS);
return NULL;
}
if (demuxer->v_streams[id])
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id);
mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_VideoStreamRedefined, id);
else {
sh_video_t *sh = calloc(1, sizeof(sh_video_t));
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundVideoStream,id);
mp_msg(MSGT_DEMUXER, MSGL_V, MSGTR_FoundVideoStream, id);
demuxer->v_streams[id] = sh;
sh->vid = vid;
sh->ds = demuxer->video;
@ -320,7 +320,7 @@ sh_video_t *new_sh_video_vid(demuxer_t *demuxer, int id, int vid)
void free_sh_video(sh_video_t *sh)
{
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing sh_video at %p\n",sh);
mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_video at %p\n", sh);
free(sh->bih);
free(sh);
}
@ -328,7 +328,7 @@ void free_sh_video(sh_video_t *sh)
void free_demuxer(demuxer_t *demuxer)
{
int i;
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing demuxer at %p\n",demuxer);
mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing demuxer at %p\n", demuxer);
if (demuxer->desc->close)
demuxer->desc->close(demuxer);
// Very ugly hack to make it behave like old implementation
@ -348,7 +348,7 @@ void free_demuxer(demuxer_t *demuxer)
free_demuxer_stream(demuxer->audio);
free_demuxer_stream(demuxer->video);
free_demuxer_stream(demuxer->sub);
skip_streamfree:
skip_streamfree:
if (demuxer->info) {
for (i = 0; demuxer->info[i] != NULL; i++)
free(demuxer->info[i]);
@ -356,12 +356,12 @@ skip_streamfree:
}
free(demuxer->filename);
if (demuxer->chapters) {
for (i = 0; i<demuxer->num_chapters; i++)
for (i = 0; i < demuxer->num_chapters; i++)
free(demuxer->chapters[i].name);
free(demuxer->chapters);
}
if (demuxer->attachments) {
for (i = 0; i<demuxer->num_attachments; i++) {
for (i = 0; i < demuxer->num_attachments; i++) {
free(demuxer->attachments[i].name);
free(demuxer->attachments[i].type);
free(demuxer->attachments[i].data);
@ -376,31 +376,31 @@ void ds_add_packet(demux_stream_t *ds, demux_packet_t *dp)
{
// append packet to DS stream:
++ds->packs;
ds->bytes+=dp->len;
ds->bytes += dp->len;
if (ds->last) {
// next packet in stream
ds->last->next=dp;
ds->last=dp;
ds->last->next = dp;
ds->last = dp;
} else {
// first packet in stream
ds->first=ds->last=dp;
ds->first = ds->last = dp;
}
mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%u [packs: A=%d V=%d]\n",
(ds==ds->demuxer->audio)?"d_audio":"d_video",
dp->len,dp->pts,(unsigned int)dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs);
mp_dbg(MSGT_DEMUXER, MSGL_DBG2, "DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%u [packs: A=%d V=%d]\n",
(ds == ds->demuxer->audio) ? "d_audio" : "d_video",
dp->len, dp->pts, (unsigned int) dp->pos, ds->demuxer->audio->packs, ds->demuxer->video->packs);
}
void ds_read_packet(demux_stream_t *ds, stream_t *stream, int len,
double pts, off_t pos, int flags)
{
demux_packet_t* dp=new_demux_packet(len);
len = stream_read(stream,dp->buffer,len);
demux_packet_t *dp = new_demux_packet(len);
len = stream_read(stream, dp->buffer, len);
resize_demux_packet(dp, len);
dp->pts = pts;
dp->pos=pos;
dp->flags=flags;
dp->pos = pos;
dp->flags = flags;
// append packet to DS stream:
ds_add_packet(ds,dp);
ds_add_packet(ds, dp);
}
// return value:
@ -419,11 +419,11 @@ int demux_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
#define MAX_ACUMULATED_PACKETS 64
int ds_fill_buffer(demux_stream_t *ds)
{
demuxer_t *demux=ds->demuxer;
demuxer_t *demux = ds->demuxer;
if (ds->current)
free_demux_packet(ds->current);
ds->current=NULL;
if (mp_msg_test(MSGT_DEMUXER,MSGL_DBG3)) {
ds->current = NULL;
if (mp_msg_test(MSGT_DEMUXER, MSGL_DBG3)) {
if (ds == demux->audio)
mp_dbg(MSGT_DEMUXER, MSGL_DBG3, "ds_fill_buffer(d_audio) called\n");
else if (ds == demux->video)
@ -435,69 +435,69 @@ int ds_fill_buffer(demux_stream_t *ds)
}
while (1) {
if (ds->packs) {
demux_packet_t *p=ds->first;
demux_packet_t *p = ds->first;
#if 0
if (demux->reference_clock != MP_NOPTS_VALUE) {
if ((p->pts != MP_NOPTS_VALUE)
&& (p->pts > demux->reference_clock)
&& (ds->packs < MAX_ACUMULATED_PACKETS)) {
if (demux_fill_buffer(demux,ds))
if (demux_fill_buffer(demux, ds))
continue;
}
}
#endif
// copy useful data:
ds->buffer=p->buffer;
ds->buffer_pos=0;
ds->buffer_size=p->len;
ds->pos=p->pos;
ds->dpos+=p->len; // !!!
ds->buffer = p->buffer;
ds->buffer_pos = 0;
ds->buffer_size = p->len;
ds->pos = p->pos;
ds->dpos += p->len; // !!!
++ds->pack_no;
if (p->pts != MP_NOPTS_VALUE) {
ds->pts=p->pts;
ds->pts_bytes=0;
ds->pts = p->pts;
ds->pts_bytes = 0;
}
ds->pts_bytes+=p->len; // !!!
ds->pts_bytes += p->len; // !!!
if (p->stream_pts != MP_NOPTS_VALUE)
demux->stream_pts = p->stream_pts;
ds->flags=p->flags;
ds->flags = p->flags;
// unlink packet:
ds->bytes-=p->len;
ds->current=p;
ds->first=p->next;
ds->bytes -= p->len;
ds->current = p;
ds->first = p->next;
if (!ds->first)
ds->last = NULL;
--ds->packs;
return 1;
}
if (demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes);
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyAudioInBuffer, demux->audio->packs, demux->audio->bytes);
mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
break;
}
if (demux->video->packs >= MAX_PACKS || demux->video->bytes >= MAX_PACK_BYTES) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes);
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyVideoInBuffer, demux->video->packs, demux->video->bytes);
mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
break;
}
if (!demux_fill_buffer(demux,ds)) {
mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"ds_fill_buffer()->demux_fill_buffer() failed\n");
if (!demux_fill_buffer(demux, ds)) {
mp_dbg(MSGT_DEMUXER, MSGL_DBG2, "ds_fill_buffer()->demux_fill_buffer() failed\n");
break; // EOF
}
}
ds->buffer_pos=ds->buffer_size=0;
ds->buffer=NULL;
mp_msg(MSGT_DEMUXER,MSGL_V,"ds_fill_buffer: EOF reached (stream: %s) \n",ds==demux->audio?"audio":"video");
ds->eof=1;
ds->buffer_pos = ds->buffer_size = 0;
ds->buffer = NULL;
mp_msg(MSGT_DEMUXER, MSGL_V, "ds_fill_buffer: EOF reached (stream: %s) \n", ds == demux->audio ? "audio" : "video");
ds->eof = 1;
return 0;
}
int demux_read_data(demux_stream_t *ds, unsigned char *mem, int len)
{
int x;
int bytes=0;
while (len > 0) {
x=ds->buffer_size-ds->buffer_pos;
int x;
int bytes = 0;
while (len > 0) {
x = ds->buffer_size - ds->buffer_pos;
if (x == 0) {
if (!ds_fill_buffer(ds))
return bytes;
@ -510,8 +510,8 @@ while (len > 0) {
len -= x;
ds->buffer_pos += x;
}
}
return bytes;
}
return bytes;
}
/**
@ -553,26 +553,26 @@ int demux_pattern_3(demux_stream_t *ds, unsigned char *mem, int maxlen,
void ds_free_packs(demux_stream_t *ds)
{
demux_packet_t *dp=ds->first;
demux_packet_t *dp = ds->first;
while (dp) {
demux_packet_t *dn=dp->next;
demux_packet_t *dn = dp->next;
free_demux_packet(dp);
dp=dn;
dp = dn;
}
if (ds->asf_packet) {
// free unfinished .asf fragments:
free(ds->asf_packet->buffer);
free(ds->asf_packet);
ds->asf_packet=NULL;
ds->asf_packet = NULL;
}
ds->first=ds->last=NULL;
ds->packs=0; // !!!!!
ds->bytes=0;
ds->first = ds->last = NULL;
ds->packs = 0; // !!!!!
ds->bytes = 0;
if (ds->current)
free_demux_packet(ds->current);
ds->current=NULL;
ds->buffer=NULL;
ds->buffer_pos=ds->buffer_size;
ds->current = NULL;
ds->buffer = NULL;
ds->buffer_pos = ds->buffer_size;
ds->pts = 0;
ds->pts_bytes = 0;
}
@ -587,13 +587,13 @@ int ds_get_packet(demux_stream_t *ds, unsigned char **start)
return -1;
}
}
len=ds->buffer_size-ds->buffer_pos;
len = ds->buffer_size - ds->buffer_pos;
*start = &ds->buffer[ds->buffer_pos];
ds->buffer_pos+=len;
ds->buffer_pos += len;
return len;
}
int ds_get_packet_pts(demux_stream_t *ds,unsigned char **start, double *pts)
int ds_get_packet_pts(demux_stream_t *ds, unsigned char **start, double *pts)
{
int len;
*pts = MP_NOPTS_VALUE;
@ -607,25 +607,25 @@ int ds_get_packet_pts(demux_stream_t *ds,unsigned char **start, double *pts)
// Return pts unless this read starts from the middle of a packet
if (!ds->buffer_pos)
*pts = ds->current->pts;
len=ds->buffer_size-ds->buffer_pos;
len = ds->buffer_size - ds->buffer_pos;
*start = &ds->buffer[ds->buffer_pos];
ds->buffer_pos+=len;
ds->buffer_pos += len;
return len;
}
int ds_get_packet_sub(demux_stream_t *ds, unsigned char **start)
{
int len;
if(ds->buffer_pos >= ds->buffer_size){
if (ds->buffer_pos >= ds->buffer_size) {
*start = NULL;
if (!ds->packs)
return -1; // no sub
if (!ds_fill_buffer(ds))
return -1; // EOF
}
len=ds->buffer_size-ds->buffer_pos;
len = ds->buffer_size - ds->buffer_pos;
*start = &ds->buffer[ds->buffer_pos];
ds->buffer_pos+=len;
ds->buffer_pos += len;
return len;
}
@ -633,17 +633,17 @@ double ds_get_next_pts(demux_stream_t *ds)
{
demuxer_t *demux = ds->demuxer;
while (!ds->first) {
if(demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES){
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes);
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
if (demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES) {
mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyAudioInBuffer, demux->audio->packs, demux->audio->bytes);
mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
return MP_NOPTS_VALUE;
}
if(demux->video->packs >= MAX_PACKS || demux->video->bytes >= MAX_PACK_BYTES){
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes);
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
if (demux->video->packs >= MAX_PACKS || demux->video->bytes >= MAX_PACK_BYTES) {
mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyVideoInBuffer, demux->video->packs, demux->video->bytes);
mp_msg(MSGT_DEMUXER, MSGL_HINT, MSGTR_MaybeNI);
return MP_NOPTS_VALUE;
}
if(!demux_fill_buffer(demux,ds))
if (!demux_fill_buffer(demux, ds))
return MP_NOPTS_VALUE;
}
return ds->first->pts;
@ -703,15 +703,15 @@ int get_demuxer_type_from_name(char *demuxer_name, int *force)
if (*endptr) // Conversion failed
return -1;
if ((type_int > 0) && (type_int <= DEMUXER_TYPE_MAX))
return (int)type_int;
return (int) type_int;
return -1;
}
int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats)
int extension_parsing = 1; // 0=off 1=mixed (used only for unstable formats)
int correct_pts=0;
int user_correct_pts=-1;
int correct_pts = 0;
int user_correct_pts = -1;
/*
NOTE : Several demuxers may be opened at the same time so
@ -730,18 +730,18 @@ static demuxer_t *demux_open_stream(stream_t *stream, int file_format,
int force, int audio_id, int video_id,
int dvdsub_id, char *filename)
{
demuxer_t *demuxer=NULL;
demuxer_t *demuxer = NULL;
sh_video_t *sh_video=NULL;
sh_video_t *sh_video = NULL;
const demuxer_desc_t *demuxer_desc;
int fformat = 0;
int i;
const demuxer_desc_t *demuxer_desc;
int fformat = 0;
int i;
// If somebody requested a demuxer check it
if (file_format) {
// If somebody requested a demuxer check it
if (file_format) {
if ((demuxer_desc = get_demuxer_desc_from_type(file_format))) {
demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename);
demuxer = new_demuxer(stream, demuxer_desc->type, audio_id, video_id, dvdsub_id, filename);
if (demuxer_desc->check_file)
fformat = demuxer_desc->check_file(demuxer);
if (force || !demuxer_desc->check_file)
@ -767,12 +767,11 @@ if (file_format) {
free_demuxer(demuxer);
return NULL;
}
}
// Test demuxers with safe file checks
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
}
// Test demuxers with safe file checks
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
if (demuxer_desc->safe_check) {
demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename);
demuxer = new_demuxer(stream, demuxer_desc->type, audio_id, video_id, dvdsub_id, filename);
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
demuxer_t *demux2 = demuxer;
@ -787,7 +786,7 @@ for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
return demuxer; // handled in mplayer.c
// Format changed after check, recurse
free_demuxer(demuxer);
demuxer=demux_open_stream(stream, fformat, force,
demuxer = demux_open_stream(stream, fformat, force,
audio_id, video_id, dvdsub_id, filename);
if (demuxer)
return demuxer; // done!
@ -797,29 +796,28 @@ for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
free_demuxer(demuxer);
demuxer = NULL;
}
}
}
// If no forced demuxer perform file extension based detection
// Ok. We're over the stable detectable fileformats, the next ones are a bit
// fuzzy. So by default (extension_parsing==1) try extension-based detection
// first:
if (file_format == DEMUXER_TYPE_UNKNOWN && filename && extension_parsing == 1) {
file_format=demuxer_type_by_filename(filename);
// If no forced demuxer perform file extension based detection
// Ok. We're over the stable detectable fileformats, the next ones are a bit
// fuzzy. So by default (extension_parsing==1) try extension-based detection
// first:
if (file_format == DEMUXER_TYPE_UNKNOWN && filename && extension_parsing == 1) {
file_format = demuxer_type_by_filename(filename);
if (file_format != DEMUXER_TYPE_UNKNOWN) {
// we like recursion :)
demuxer=demux_open_stream(stream, file_format, force,
demuxer = demux_open_stream(stream, file_format, force,
audio_id, video_id, dvdsub_id, filename);
if (demuxer)
return demuxer; // done!
file_format=DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing...
mp_msg(MSGT_DEMUXER,MSGL_V,"demuxer: continue fuzzy content-based format guessing...\n");
file_format = DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing...
mp_msg(MSGT_DEMUXER, MSGL_V, "demuxer: continue fuzzy content-based format guessing...\n");
}
}
// Try detection for all other demuxers
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
}
// Try detection for all other demuxers
for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
if (!demuxer_desc->safe_check && demuxer_desc->check_file) {
demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename);
demuxer = new_demuxer(stream, demuxer_desc->type, audio_id, video_id, dvdsub_id, filename);
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
demuxer_t *demux2 = demuxer;
@ -834,7 +832,7 @@ for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
return demuxer; // handled in mplayer.c
// Format changed after check, recurse
free_demuxer(demuxer);
demuxer=demux_open_stream(stream, fformat, force,
demuxer = demux_open_stream(stream, fformat, force,
audio_id, video_id, dvdsub_id, filename);
if (demuxer)
return demuxer; // done!
@ -844,29 +842,29 @@ for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
free_demuxer(demuxer);
demuxer = NULL;
}
}
}
return NULL;
//====== File format recognized, set up these for compatibility: =========
dmx_open:
return NULL;
//====== File format recognized, set up these for compatibility: =========
dmx_open:
demuxer->file_format=file_format;
demuxer->file_format = file_format;
if ((sh_video = demuxer->video->sh) && sh_video->bih){
int biComp=le2me_32(sh_video->bih->biCompression);
mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO: [%.4s] %dx%d %dbpp %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
(char *)&biComp,
if ((sh_video = demuxer->video->sh) && sh_video->bih) {
int biComp = le2me_32(sh_video->bih->biCompression);
mp_msg(MSGT_DEMUX, MSGL_INFO, "VIDEO: [%.4s] %dx%d %dbpp %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
(char *) &biComp,
sh_video->bih->biWidth,
sh_video->bih->biHeight,
sh_video->bih->biBitCount,
sh_video->fps,
sh_video->i_bps*0.008f,
sh_video->i_bps/1024.0f );
}
sh_video->i_bps * 0.008f,
sh_video->i_bps / 1024.0f);
}
#ifdef USE_ASS
if (ass_enabled && ass_library) {
for (i = 0; i < MAX_S_STREAMS; ++i) {
sh_sub_t* sh = demuxer->s_streams[i];
sh_sub_t *sh = demuxer->s_streams[i];
if (sh && sh->type == 'a') {
sh->ass_track = ass_new_track(ass_library);
if (sh->ass_track && sh->extradata)
@ -876,7 +874,7 @@ int biComp=le2me_32(sh_video->bih->biCompression);
}
}
#endif
return demuxer;
return demuxer;
}
char *audio_stream = NULL;
@ -895,43 +893,43 @@ extern float stream_cache_seek_min_percent;
demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
int video_id, int dvdsub_id, char *filename)
{
stream_t *as = NULL,*ss = NULL;
demuxer_t *vd,*ad = NULL,*sd = NULL;
stream_t *as = NULL, *ss = NULL;
demuxer_t *vd, *ad = NULL, *sd = NULL;
demuxer_t *res;
int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ;
int afmt = DEMUXER_TYPE_UNKNOWN, sfmt = DEMUXER_TYPE_UNKNOWN;
int demuxer_type;
int audio_demuxer_type = 0, sub_demuxer_type = 0;
int demuxer_force = 0, audio_demuxer_force = 0, sub_demuxer_force = 0;
if ((demuxer_type = get_demuxer_type_from_name(demuxer_name, &demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,"-demuxer %s does not exist.\n",demuxer_name);
mp_msg(MSGT_DEMUXER, MSGL_ERR, "-demuxer %s does not exist.\n", demuxer_name);
}
if ((audio_demuxer_type = get_demuxer_type_from_name(audio_demuxer_name, &audio_demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,"-audio-demuxer %s does not exist.\n",audio_demuxer_name);
mp_msg(MSGT_DEMUXER, MSGL_ERR, "-audio-demuxer %s does not exist.\n", audio_demuxer_name);
}
if ((sub_demuxer_type = get_demuxer_type_from_name(sub_demuxer_name, &sub_demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,"-sub-demuxer %s does not exist.\n",sub_demuxer_name);
if ((sub_demuxer_type = get_demuxer_type_from_name(sub_demuxer_name,&sub_demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER, MSGL_ERR, "-sub-demuxer %s does not exist.\n", sub_demuxer_name);
}
if (audio_stream) {
as = open_stream(audio_stream,0,&afmt);
as = open_stream(audio_stream, 0, &afmt);
if (!as) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenAudioStream,audio_stream);
mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_CannotOpenAudioStream, audio_stream);
return NULL;
}
if (audio_stream_cache) {
if (!stream_enable_cache(as,audio_stream_cache * 1024,audio_stream_cache * 1024 * (stream_cache_min_percent / 100.0),
if (!stream_enable_cache(as, audio_stream_cache * 1024, audio_stream_cache * 1024 * (stream_cache_min_percent / 100.0),
audio_stream_cache * 1024 * (stream_cache_seek_min_percent / 100.0))) {
free_stream(as);
mp_msg(MSGT_DEMUXER,MSGL_ERR,"Can't enable audio stream cache\n");
mp_msg(MSGT_DEMUXER, MSGL_ERR, "Can't enable audio stream cache\n");
return NULL;
}
}
}
if (sub_stream) {
ss = open_stream(sub_stream,0,&sfmt);
ss = open_stream(sub_stream, 0, &sfmt);
if (!ss) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenSubtitlesStream,sub_stream);
mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_CannotOpenSubtitlesStream, sub_stream);
return NULL;
}
}
@ -950,26 +948,26 @@ demuxer_t *demux_open(stream_t *vs, int file_format, int audio_id,
ad = demux_open_stream(as, audio_demuxer_type ? audio_demuxer_type : afmt,
audio_demuxer_force, audio_id, -2, -2, audio_stream);
if (!ad) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream);
mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_OpeningAudioDemuxerFailed, audio_stream);
free_stream(as);
} else if (ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->format == 0x55) // MP3
hr_mp3_seek=1; // Enable high res seeking
} else if (ad->audio->sh && ((sh_audio_t *) ad->audio->sh)->format == 0x55) // MP3
hr_mp3_seek = 1; // Enable high res seeking
}
if (ss) {
sd = demux_open_stream(ss, sub_demuxer_type ? sub_demuxer_type : sfmt,
sub_demuxer_force, -2, -2, dvdsub_id, sub_stream);
if (!sd) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningSubtitlesDemuxerFailed,sub_stream);
mp_msg(MSGT_DEMUXER, MSGL_WARN, MSGTR_OpeningSubtitlesDemuxerFailed, sub_stream);
free_stream(ss);
}
}
if (ad && sd)
res = new_demuxers_demuxer(vd,ad,sd);
res = new_demuxers_demuxer(vd, ad, sd);
else if (ad)
res = new_demuxers_demuxer(vd,ad,vd);
res = new_demuxers_demuxer(vd, ad, vd);
else if (sd)
res = new_demuxers_demuxer(vd,vd,sd);
res = new_demuxers_demuxer(vd, vd, sd);
else
res = vd;
@ -990,32 +988,33 @@ void demux_flush(demuxer_t *demuxer)
int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay,
int flags)
{
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;
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;
double tmp = 0;
double pts;
if (!demuxer->seekable) {
if (!demuxer->seekable) {
if (demuxer->file_format == DEMUXER_TYPE_AVI)
mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekRawAVI);
mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_CantSeekRawAVI);
#ifdef USE_TV
else if (demuxer->file_format == DEMUXER_TYPE_TV)
mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_TVInputNotSeekable);
mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_TVInputNotSeekable);
#endif
else
mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekFile);
mp_msg(MSGT_SEEK, MSGL_WARN, MSGTR_CantSeekFile);
return 0;
}
}
demux_flush(demuxer);
// clear demux buffers:
if (sh_audio)
sh_audio->a_buffer_len=0;
sh_audio->a_buffer_len = 0;
demuxer->stream->eof = 0;
demuxer->video->eof=0;
demuxer->audio->eof=0;
demuxer->video->eof = 0;
demuxer->audio->eof = 0;
if (sh_video)
sh_video->timer = 0; // !!!!!!
@ -1040,14 +1039,14 @@ if (!demuxer->seekable) {
return 1;
}
dmx_seek:
if (demuxer->desc->seek)
demuxer->desc->seek(demuxer,rel_seek_secs,audio_delay,flags);
dmx_seek:
if (demuxer->desc->seek)
demuxer->desc->seek(demuxer, rel_seek_secs, audio_delay, flags);
if (sh_audio)
resync_audio_stream(sh_audio);
return 1;
return 1;
}
int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
@ -1060,16 +1059,16 @@ int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
if (!strcasecmp(opt, info[2 * n])) {
mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_DemuxerInfoChanged, opt,
param);
free(info[2*n+1]);
info[2*n+1] = strdup(param);
free(info[2 * n + 1]);
info[2 * n + 1] = strdup(param);
return 0;
}
}
info = demuxer->info = (char**)realloc(info,(2*(n+2))*sizeof(char*));
info[2*n] = strdup(opt);
info[2*n+1] = strdup(param);
memset(&info[2*(n+1)],0,2*sizeof(char*));
info = demuxer->info = (char **) realloc(info, (2 * (n + 2)) * sizeof(char *));
info[2 * n] = strdup(opt);
info[2 * n + 1] = strdup(param);
memset(&info[2 * (n + 1)], 0, 2 * sizeof(char *));
return 1;
}
@ -1082,11 +1081,11 @@ int demux_info_print(demuxer_t *demuxer)
if (!info)
return 0;
mp_msg(MSGT_DEMUX, MSGL_INFO,MSGTR_ClipInfo);
mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_ClipInfo);
for (n = 0; info[2 * n] != NULL; n++) {
mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n",info[2*n],info[2*n+1]);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_NAME%d=%s\n", n, info[2*n]);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_VALUE%d=%s\n", n, info[2*n+1]);
mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n", info[2 * n], info[2 * n + 1]);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_NAME%d=%s\n", n, info[2 * n]);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_VALUE%d=%s\n", n, info[2 * n + 1]);
}
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_N=%d\n", n);
@ -1098,9 +1097,9 @@ char *demux_info_get(demuxer_t *demuxer, const char *opt)
int i;
char **info = demuxer->info;
for(i = 0; info && info[2*i] != NULL; i++) {
for (i = 0; info && info[2 * i] != NULL; i++) {
if (!strcasecmp(opt, info[2 * i]))
return info[2*i+1];
return info[2 * i + 1];
}
return NULL;
@ -1110,7 +1109,7 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg)
{
if (demuxer->desc->control)
return demuxer->desc->control(demuxer,cmd,arg);
return demuxer->desc->control(demuxer, cmd, arg);
return DEMUXER_CTRL_NOTIMPL;
}
@ -1123,15 +1122,15 @@ double demuxer_get_time_length(demuxer_t *demuxer)
sh_video_t *sh_video = demuxer->video->sh;
sh_audio_t *sh_audio = demuxer->audio->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 (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH, (void *) &get_time_ans) <= 0) {
if (sh_video && sh_video->i_bps && sh_audio && sh_audio->i_bps)
get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/(sh_video->i_bps+sh_audio->i_bps);
get_time_ans = (double) (demuxer->movi_end - demuxer->movi_start) / (sh_video->i_bps + sh_audio->i_bps);
else if (sh_video && sh_video->i_bps)
get_time_ans = (double)(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 if (sh_audio && sh_audio->i_bps)
get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_audio->i_bps;
get_time_ans = (double) (demuxer->movi_end - demuxer->movi_start) / sh_audio->i_bps;
else
get_time_ans=0;
get_time_ans = 0;
}
return get_time_ans;
}
@ -1208,22 +1207,22 @@ int demuxer_add_attachment(demuxer_t *demuxer, const char *name,
memcpy(demuxer->attachments[demuxer->num_attachments].data, data, size);
demuxer->attachments[demuxer->num_attachments].data_size = size;
return demuxer->num_attachments ++;
return demuxer->num_attachments++;
}
int demuxer_add_chapter(demuxer_t *demuxer, const char *name, uint64_t start,
uint64_t end)
{
if (demuxer->chapters == NULL)
demuxer->chapters = malloc (32*sizeof(*demuxer->chapters));
demuxer->chapters = malloc(32 * sizeof(*demuxer->chapters));
else if (!(demuxer->num_chapters % 32))
demuxer->chapters = realloc (demuxer->chapters, (demuxer->num_chapters + 32) * sizeof(*demuxer->chapters));
demuxer->chapters = realloc(demuxer->chapters, (demuxer->num_chapters + 32) * sizeof(*demuxer->chapters));
demuxer->chapters[demuxer->num_chapters].start = start;
demuxer->chapters[demuxer->num_chapters].end = end;
demuxer->chapters[demuxer->num_chapters].name = strdup(name);
return demuxer->num_chapters ++;
return demuxer->num_chapters++;
}
/**
@ -1269,7 +1268,6 @@ int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode,
ds_fill_buffer(demuxer->audio);
resync_audio_stream(sh_audio);
}
//exit status may be ok, but main() doesn't have to seek itself (because e.g. dvds depend on sectors, not on pts)
*seek_pts = -1.0;
@ -1290,7 +1288,7 @@ int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode,
}
return ris != STREAM_UNSUPPORTED ? chapter : -1;
} else { //chapters structure is set in the demuxer
} else { // chapters structure is set in the demuxer
total = demuxer->num_chapters;
if (mode == 1) //absolute seeking
@ -1339,7 +1337,7 @@ int demuxer_get_current_chapter(demuxer_t *demuxer)
sh_video_t *sh_video = demuxer->video->sh;
sh_audio_t *sh_audio = demuxer->audio->sh;
uint64_t now;
now = (sh_video ? sh_video->pts : (sh_audio?sh_audio->pts:0))*1000+0.5;
now = (sh_video ? sh_video->pts : (sh_audio ? sh_audio->pts : 0)) * 1000 + 0.5;
for (chapter = demuxer->num_chapters - 1; chapter >= 0; --chapter) {
if (demuxer->chapters[chapter].start <= now)
break;
@ -1351,7 +1349,7 @@ int demuxer_get_current_chapter(demuxer_t *demuxer)
char *demuxer_chapter_name(demuxer_t *demuxer, int chapter)
{
if (demuxer->num_chapters && demuxer->chapters) {
if (chapter >=0 && chapter < demuxer->num_chapters &&
if (chapter >= 0 && chapter < demuxer->num_chapters &&
demuxer->chapters[chapter].name)
return strdup(demuxer->chapters[chapter].name);
}
@ -1402,7 +1400,7 @@ int demuxer_chapter_count(demuxer_t *demuxer)
int demuxer_angles_count(demuxer_t *demuxer)
{
int ris, angles=-1;
int ris, angles = -1;
ris = stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_ANGLES, &angles);
if (ris == STREAM_UNSUPPORTED)
@ -1412,7 +1410,7 @@ int demuxer_angles_count(demuxer_t *demuxer)
int demuxer_get_current_angle(demuxer_t *demuxer)
{
int ris, curr_angle=-1;
int ris, curr_angle = -1;
ris = stream_control(demuxer->stream, STREAM_CTRL_GET_ANGLE, &curr_angle);
if (ris == STREAM_UNSUPPORTED)
return -1;
@ -1422,7 +1420,7 @@ int demuxer_get_current_angle(demuxer_t *demuxer)
int demuxer_set_angle(demuxer_t *demuxer, int angle)
{
int ris, angles=-1;
int ris, angles = -1;
sh_video_t *sh_video = demuxer->video->sh;
sh_audio_t *sh_audio = demuxer->audio->sh;
@ -1508,4 +1506,3 @@ int demuxer_default_sub_track(demuxer_t *d)
}
return -1;
}