[MPlayer-cvslog] r37304 - trunk/libmpdemux/demux_ogg.c

reimar subversion at mplayerhq.hu
Thu Oct 23 23:21:10 CEST 2014


Author: reimar
Date: Thu Oct 23 23:21:09 2014
New Revision: 37304

Log:
demux_ogg: Hacky, not-quite-correct support for Opus.

Not correct in the meaning that the FFmpeg decoder at least
complains about some invalid packets.
Have not noticed any real issues in short testing though.

Modified:
   trunk/libmpdemux/demux_ogg.c

Modified: trunk/libmpdemux/demux_ogg.c
==============================================================================
--- trunk/libmpdemux/demux_ogg.c	Wed Oct 22 21:40:55 2014	(r37303)
+++ trunk/libmpdemux/demux_ogg.c	Thu Oct 23 23:21:09 2014	(r37304)
@@ -37,6 +37,7 @@
 #include "demux_mov.h"
 #include "demux_ogg.h"
 
+#define FOURCC_OPUS   mmioFOURCC('o', 'p', 'u', 's')
 #define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's')
 #define FOURCC_SPEEX  mmioFOURCC('s', 'p', 'x', ' ')
 #define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o')
@@ -121,6 +122,7 @@ typedef struct ogg_stream {
     // Logical stream state
     ogg_stream_state stream;
     int hdr_packets;
+    int opus;
     int vorbis;
     int speex;
     int theora;
@@ -288,7 +290,7 @@ static unsigned char *demux_ogg_read_pac
             os->lastsize = blocksize;
             os->lastpos  = pack->granulepos;
         }
-    } else if (os->speex) {
+    } else if (os->speex || os->opus) {
         // whole packet (default)
 # ifdef CONFIG_OGGTHEORA
     } else if (os->theora) {
@@ -512,7 +514,7 @@ static int demux_ogg_add_packet(demux_st
         // (PACKET_TYPE_HEADER bit doesn't even exist for theora ?!)
         // 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) &&
+        if (!os->opus && !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)))
@@ -865,6 +867,15 @@ int demux_ogg_open(demuxer_t *demuxer)
             mp_msg(MSGT_DEMUX, MSGL_INFO,
                    "[Ogg] stream %d: audio (Vorbis), -aid %d\n",
                    ogg_d->num_sub, n_audio - 1);
+        } else if (pack.bytes >= 8 && !strncmp(pack.packet, "OpusHead", 8)) {
+            sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio, NULL);
+            sh_a->format = FOURCC_OPUS;
+            ogg_d->subs[ogg_d->num_sub].opus = 1;
+            ogg_d->subs[ogg_d->num_sub].id   = n_audio;
+            n_audio++;
+            mp_msg(MSGT_DEMUX, MSGL_INFO,
+                   "[Ogg] stream %d: audio (Opus), -aid %d\n",
+                   ogg_d->num_sub, n_audio - 1);
         } else if (pack.bytes >= 80 && !strncmp(pack.packet, "Speex", 5)) {
             sh_a = new_sh_audio_aid(demuxer, ogg_d->num_sub, n_audio, NULL);
             sh_a->wf         = calloc(1, sizeof(*sh_a->wf) + pack.bytes);
@@ -1549,7 +1560,7 @@ static void demux_ogg_seek(demuxer_t *de
                     break;
                 }
             }
-            if (!precision && (is_keyframe || os->vorbis || os->speex)) {
+            if (!precision && (is_keyframe || os->vorbis || os->speex || os->opus)) {
                 if (sub_clear_text(&ogg_sub, MP_NOPTS_VALUE)) {
                     vo_sub = &ogg_sub;
                     vo_osd_changed(OSDTYPE_SUBTITLE);


More information about the MPlayer-cvslog mailing list