Opened 17 years ago

Closed 17 years ago

#734 closed defect (fixed)

demuxer->movi_end goes to far with riff/wav/pcm files

Reported by: ndesir@… Owned by: r_togni@…
Priority: normal Component: demuxer
Version: 1.0rc1 Severity: normal
Keywords: Cc: ndesir@…
Blocked By: Blocking:
Reproduced by developer: no Analyzed by developer: no

Description

Seen on Linux and Win32 on several .wav files.

Mplayer continues to read audio data until the end of the file.
demuxer->movi_end gets to the end of the file.

and since I have more chunks after the data chunk,
the sound finishes with some glitches.

# cat garbage >> my-file.wav
# mplayer my-file.wav

I could solve the problem this way:

--- MPlayer-1.0rc1-ori/libmpdemux/demux_audio.c Thu Feb 1 06:25:09 2007
+++ MPlayer-1.0rc1/libmpdemux/demux_audio.c Thu Feb 1 17:08:47 2007
@@ -454,7 +454,7 @@

stream_skip(demuxer->stream, chunk_size);

} while (chunk_type != mmioFOURCC('d', 'a', 't', 'a'));
demuxer->movi_start = stream_tell(s);

  • demuxer->movi_end = s->end_pos;

+ demuxer->movi_end = demuxer->movi_start + chunk_size - 1;

printf("wav: %X .. %X\n",(int)demuxer->movi_start,(int)demuxer->movi_end);

Check if it contains dts audio
if((w->wFormatTag == 0x01) && (w->nChannels == 2) && (w->nSamplesPerSec == 44100)) {

But I didn't go deeper in the code (trying to understand how s->end_pos was set for example)

PS: I've made a checkout to see if something was done in the mean time, but it doesn't seem

Change History (3)

comment:1 by ndesir@…, 17 years ago

Cc: ndesir@… added

Sorry my patch didn't solved the problem, at least the total time is displayed correctly, but mplayer still continues to the end,

I am going to investigate a little more

comment:2 by ndesir@…, 17 years ago

I finally set s->end_pos in demux_audio.c and added a test directly in stream_file.c so that it behaves like reaching eof when it has read all the bytes of the data chunk.
I don't know if it's the correct place but since I wanted MPLayer to correctly handle the files I have to convert to linear, it works for me ;)
I also don't know if s->end_pos is set correctly in the all other file cases, at least for MP3, it is.

diff -ur MPlayer-1.0rc1-ori/libmpdemux/demux_audio.c MPlayer-1.0rc1/libmpdemux/demux_audio.c
--- MPlayer-1.0rc1-ori/libmpdemux/demux_audio.c Mon Oct 23 00:32:31 2006
+++ MPlayer-1.0rc1/libmpdemux/demux_audio.c Thu Feb 1 18:25:59 2007
@@ -454,7 +454,8 @@

stream_skip(demuxer->stream, chunk_size);

} while (chunk_type != mmioFOURCC('d', 'a', 't', 'a'));
demuxer->movi_start = stream_tell(s);

  • demuxer->movi_end = s->end_pos;

+ demuxer->movi_end = demuxer->movi_start + chunk_size - 1;
+ s->end_pos = demuxer->movi_end;

printf("wav: %X .. %X\n",(int)demuxer->movi_start,(int)demuxer->movi_end);

Check if it contains dts audio
if((w->wFormatTag == 0x01) && (w->nChannels == 2) && (w->nSamplesPerSec == 44100)) {

diff -ur MPlayer-1.0rc1-ori/stream/stream_file.c MPlayer-1.0rc1/stream/stream_file.c
--- MPlayer-1.0rc1-ori/stream/stream_file.c Mon Oct 23 00:32:25 2006
+++ MPlayer-1.0rc1/stream/stream_file.c Fri Feb 2 13:57:00 2007
@@ -35,7 +35,12 @@

};

static int fill_buffer(stream_t *s, char* buffer, int max_len){

  • int r = read(s->fd,buffer,max_len);

+ int r;
+ if(s->pos + max_len > s->end_pos + 1)
+ max_len = s->end_pos - s->pos + 1;
+ if(max_len <= 0)
+ return -1;
+ r = read(s->fd,buffer,max_len);

return (r <= 0) ? -1 : r;

}

comment:3 by reimar, 17 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.