[MPlayer-cvslog] CVS: main/libmpdemux demux_mkv.c, 1.39, 1.40 demux_mpg.c, 1.56, 1.57 demuxer.c, 1.185, 1.186 demuxer.h, 1.75, 1.76
Reimar Döffinger CVS
syncmail at mplayerhq.hu
Thu Apr 28 16:43:22 CEST 2005
CVS change done by Reimar Döffinger CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv28662/libmpdemux
Modified Files:
demux_mkv.c demux_mpg.c demuxer.c demuxer.h
Log Message:
adds a parameter to the switch_audio command to directly select a track.
Patch by kiriuja mplayer-patches at en-directo net
Index: demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- demux_mkv.c 13 Apr 2005 22:33:19 -0000 1.39
+++ demux_mkv.c 28 Apr 2005 14:43:18 -0000 1.40
@@ -2118,16 +2118,17 @@
void demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, int flags);
-/** \brief Given a matroska track number, find the subtitle number that mplayer would ask for.
+/** \brief Given a matroska track number and type, find the id that mplayer would ask for.
* \param d The demuxer for which the subtitle id should be returned.
* \param num The matroska track number we are looking up.
+ * \param type The track type.
*/
-static int demux_mkv_sub_reverse_id(mkv_demuxer_t *d, int num)
+static int demux_mkv_reverse_id(mkv_demuxer_t *d, int num, int type)
{
int i, id;
for (i=0, id=0; i < d->num_tracks; i++)
- if (d->tracks[i] != NULL && d->tracks[i]->type == MATROSKA_TRACK_SUBTITLE) {
+ if (d->tracks[i] != NULL && d->tracks[i]->type == type) {
if (d->tracks[i]->tnum == num)
return id;
id++;
@@ -2351,7 +2352,7 @@
{
mp_msg (MSGT_DEMUX, MSGL_INFO,
"[mkv] Will display subtitle track %u\n", track->tnum);
- dvdsub_id = demux_mkv_sub_reverse_id(mkv_d, track->tnum);
+ dvdsub_id = demux_mkv_reverse_id(mkv_d, track->tnum, MATROSKA_TRACK_SUBTITLE);
demuxer->sub->id = track->tnum;
}
else
@@ -3344,12 +3345,13 @@
if (demuxer->audio && demuxer->audio->sh) {
int i;
demux_stream_t *d_audio = demuxer->audio;
- sh_audio_t *sh_audio = d_audio->sh;
int idx = d_audio->id - 1; // track ids are 1 based
int num = mkv_d->num_tracks;
mkv_track_t *otrack = mkv_d->tracks[idx];
- for (i = 1; i < num; i++) {
- mkv_track_t *track = mkv_d->tracks[(idx+i)%num];
+ mkv_track_t *track = 0;
+ if (*((int*)arg) < 0)
+ for (i = 1; i <= num; i++) {
+ track = mkv_d->tracks[(idx+i)%num];
if ((track->type == MATROSKA_TRACK_AUDIO) &&
!strcmp(track->codec_id, otrack->codec_id) &&
(track->a_channels == otrack->a_channels) &&
@@ -3358,12 +3360,21 @@
break;
}
}
- if (i < num) {
- d_audio->id = (idx+i)%num + 1;
+ else {
+ track = demux_mkv_find_track_by_num (mkv_d, *((int*)arg), MATROSKA_TRACK_AUDIO);
+ if (track == NULL ||
+ strcmp (track->codec_id, otrack->codec_id) ||
+ track->a_channels != otrack->a_channels ||
+ track->a_bps != otrack->a_bps ||
+ track->a_sfreq != otrack->a_sfreq)
+ track = otrack;
+ }
+ if (track != otrack) {
+ d_audio->id = track->tnum;
ds_free_packs(d_audio);
}
- *((int *)arg)=(int)d_audio->id;
}
+ *((int*)arg) = demux_mkv_reverse_id (mkv_d, demuxer->audio->id, MATROSKA_TRACK_AUDIO);
return DEMUXER_CTRL_OK;
default:
Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- demux_mpg.c 3 Apr 2005 14:08:26 -0000 1.56
+++ demux_mpg.c 28 Apr 2005 14:43:18 -0000 1.57
@@ -643,6 +643,8 @@
sh_audio_t *sh_audio = d_audio->sh;
sh_audio_t *sh_a;
int i;
+ if (*((int*)arg) < 0)
+ {
for (i = 0; i < mpg_d->num_a_streams; i++) {
if (d_audio->id == mpg_d->a_stream_ids[i]) break;
}
@@ -650,13 +652,22 @@
i = (i+1) % mpg_d->num_a_streams;
sh_a = (sh_audio_t*)demuxer->a_streams[mpg_d->a_stream_ids[i]];
} while (sh_a->format != sh_audio->format);
- if (d_audio->id != mpg_d->a_stream_ids[i]) {
+ }
+ else {
+ for (i = 0; i < mpg_d->num_a_streams; i++)
+ if (*((int*)arg) == mpg_d->a_stream_ids[i]) break;
+ if (i < mpg_d->num_a_streams)
+ sh_a = (sh_audio_t*)demuxer->a_streams[*((int*)arg)];
+ if (sh_a->format != sh_audio->format)
+ i = mpg_d->num_a_streams;
+ }
+ if (i < mpg_d->num_a_streams && d_audio->id != mpg_d->a_stream_ids[i]) {
d_audio->id = mpg_d->a_stream_ids[i];
d_audio->sh = sh_a;
ds_free_packs(d_audio);
}
- *((int *)arg)=(int)d_audio->id;
}
+ *((int*)arg) = demuxer->audio->id;
return DEMUXER_CTRL_OK;
default:
Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -r1.185 -r1.186
--- demuxer.c 3 Apr 2005 14:08:26 -0000 1.185
+++ demuxer.c 28 Apr 2005 14:43:19 -0000 1.186
@@ -1778,8 +1778,9 @@
return ans;
}
-int demuxer_switch_audio(demuxer_t *demuxer){
- int ans = 0;
- int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &ans);
- return ans;
+int demuxer_switch_audio(demuxer_t *demuxer, int index){
+ int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index);
+ if (res == DEMUXER_CTRL_NOTIMPL)
+ index = demuxer->audio->id;
+ return index;
}
Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- demuxer.h 3 Apr 2005 14:08:26 -0000 1.75
+++ demuxer.h 28 Apr 2005 14:43:19 -0000 1.76
@@ -287,6 +287,6 @@
extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
-extern int demuxer_switch_audio(demuxer_t *demuxer);
+extern int demuxer_switch_audio(demuxer_t *demuxer, int index);
extern int demuxer_type_by_filename(char* filename);
More information about the MPlayer-cvslog
mailing list