changeset 34656:57d6486ffb58

Fix -aid/-vid selection with -demuxer ogg. The demuxer code conflicted with the generic code in new_sh_*, so remove everything except the -1 (default) handling.
author reimar
date Sun, 19 Feb 2012 16:07:35 +0000
parents 16f8330fc70b
children 812c3528724b
files libmpdemux/demux_ogg.c
diffstat 1 files changed, 10 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ogg.c	Sun Feb 19 15:58:25 2012 +0000
+++ b/libmpdemux/demux_ogg.c	Sun Feb 19 16:07:35 2012 +0000
@@ -513,6 +513,7 @@
         // We jump nothing for FLAC. Ain't this great? Packet contents have to be
         // handled differently for each and every stream type. The joy! The joy!
         if (!os->flac && (*pack->packet & PACKET_TYPE_HEADER) &&
+                ds->sh &&
                 (ds != d->audio || ((sh_audio_t*)ds->sh)->format != FOURCC_VORBIS || os->hdr_packets >= NUM_VORBIS_HDR_PACKETS ) &&
                 (ds != d->video || (((sh_video_t*)ds->sh)->format != FOURCC_THEORA)))
             return 0;
@@ -780,7 +781,6 @@
     stream_t *s;
     char *buf;
     int np, s_no, n_audio = 0, n_video = 0;
-    int audio_id = -1, video_id = -1, text_id = -1;
     ogg_sync_state *sync;
     ogg_page *page;
     ogg_packet pack;
@@ -1101,8 +1101,6 @@
                 ogg_d->subs[ogg_d->num_sub].samplerate = AV_RL64(&st->time_unit) / 10;
                 ogg_d->subs[ogg_d->num_sub].text       = 1;
                 ogg_d->subs[ogg_d->num_sub].id         = ogg_d->n_text;
-                if (demuxer->sub->id == ogg_d->n_text)
-                    text_id = ogg_d->num_sub;
                 new_sh_sub(demuxer, ogg_d->n_text, NULL);
                 ogg_d->n_text++;
                 ogg_d->text_ids = realloc_struct(ogg_d->text_ids, ogg_d->n_text, sizeof(*ogg_d->text_ids));
@@ -1125,28 +1123,24 @@
             if (sh_a) {
                 // If the audio stream is not defined we took the first one
                 if (demuxer->audio->id == -1) {
-                    demuxer->audio->id = n_audio - 1;
+                    demuxer->audio->id = ogg_d->num_sub;
+                    demuxer->audio->sh = sh_a;
                     //if (sh_a->wf) print_wave_header(sh_a->wf, MSGL_INFO);
                 }
                 /// Is it the stream we want
-                if (demuxer->audio->id == n_audio - 1) {
-                    demuxer->audio->sh = sh_a;
-                    sh_a->ds = demuxer->audio;
+                if (demuxer->audio->sh == sh_a) {
                     ds = demuxer->audio;
-                    audio_id = ogg_d->num_sub;
                 }
             }
             if (sh_v) {
                 /// Also for video
                 if (demuxer->video->id == -1) {
-                    demuxer->video->id = n_video - 1;
+                    demuxer->video->id = ogg_d->num_sub;
+                    demuxer->video->sh = sh_v;
                     //if (sh_v->bih) print_video_header(sh_v->bih, MSGL_INFO);
                 }
-                if (demuxer->video->id == n_video - 1) {
-                    demuxer->video->sh = sh_v;
-                    sh_v->ds = demuxer->video;
+                if (demuxer->video->sh == sh_v) {
                     ds = demuxer->video;
-                    video_id = ogg_d->num_sub;
                 }
             }
             /// Add the header packets if the stream isn't seekable
@@ -1165,24 +1159,12 @@
         goto err_out;
     }
 
-    if (!n_video || video_id < 0)
+    if (!demuxer->video->sh)
         demuxer->video->id = -2;
-    else
-        demuxer->video->id = video_id;
-    if (!n_audio || audio_id < 0)
+    if (!demuxer->audio->sh)
         demuxer->audio->id = -2;
-    else
-        demuxer->audio->id = audio_id;
-    /* Disable the subs only if there are no text streams at all.
-       Otherwise the stream to display might be chosen later when the comment
-       packet is encountered and the user used -slang instead of -sid. */
-    if (!ogg_d->n_text)
+    if (!demuxer->sub->sh)
         demuxer->sub->id = -2;
-    else if (text_id >= 0) {
-        demuxer->sub->id = text_id;
-        mp_msg(MSGT_DEMUX, MSGL_V,
-               "Ogg demuxer: Displaying subtitle stream id %d\n", text_id);
-    }
 
     ogg_d->final_granulepos   = 0;
     ogg_d->initial_granulepos = MP_NOPTS_VALUE;