[MPlayer-cvslog] CVS: main/libmpdemux demux_ogg.c, 1.70, 1.71 demux_mkv.c, 1.40, 1.41
Nico Sabbi CVS
syncmail at mplayerhq.hu
Thu May 12 19:36:01 CEST 2005
CVS change done by Nico Sabbi CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv24408/libmpdemux
Modified Files:
demux_ogg.c demux_mkv.c
Log Message:
vorbis extradata is now passed from demuxer to decoder in matroska's way
Index: demux_ogg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- demux_ogg.c 2 May 2005 07:59:12 -0000 1.70
+++ demux_ogg.c 12 May 2005 17:35:57 -0000 1.71
@@ -736,6 +736,86 @@
void demux_close_ogg(demuxer_t* demuxer);
+static inline unsigned int store_ughvlc(unsigned char *s, unsigned int v)
+{
+ unsigned int n = 0;
+
+ while(v >= 0xff)
+ {
+ *s++ = 0xff;
+ v -= 0xff;
+ n++;
+ }
+ *s = v;
+ n++;
+
+ return n;
+}
+
+static void fixup_vorbis_wf(sh_audio_t *sh)
+{
+ int i, k, offset;
+ ogg_packet op[3];
+ unsigned char *buf[3];
+ unsigned char *ptr;
+
+ for(i = 0; i < 3; i++) {
+ op[i].bytes = ds_get_packet(sh->ds, &(op[i].packet));
+ mp_msg(MSGT_DEMUX,MSGL_V, "fixup_vorbis_wf: i=%d, size=%d\n", i, op[i].bytes);
+ if(op[i].bytes < 0) {
+ mp_msg(MSGT_DEMUX,MSGL_ERR,"Ogg demuxer error!, fixup_vorbis_wf: bad packet n. %d\n", i);
+ return;
+ }
+ buf[i] = malloc(op[i].bytes);
+ if(!buf[i])
+ return;
+ memcpy(buf[i], op[i].packet, op[i].bytes);
+ }
+
+ sh->wf = (WAVEFORMATEX*)calloc(1, sizeof(WAVEFORMATEX) + op[0].bytes + op[1].bytes + op[2].bytes + 64);
+ ptr = (unsigned char*) (sh->wf+1);
+
+ ptr[0] = 2;
+ offset = 1;
+ offset += store_ughvlc(&ptr[offset], op[0].bytes);
+ mp_msg(MSGT_DEMUX,MSGL_V,"demux_ogg, offset after 1st len = %d\n", offset);
+ offset += store_ughvlc(&ptr[offset], op[1].bytes);
+ mp_msg(MSGT_DEMUX,MSGL_V,"demux_ogg, offset after 2nd len = %d\n", offset);
+ for(i = 0; i < 3; i++) {
+ mp_msg(MSGT_DEMUX,MSGL_V,"demux_ogg, i=%d\n", op[i].bytes, offset, i);
+ memcpy(&ptr[offset], buf[i], op[i].bytes);
+ offset += op[i].bytes;
+ }
+ sh->wf->cbSize = offset;
+ mp_msg(MSGT_DEMUX,MSGL_V, "demux_ogg, extradata size: %d\n", sh->wf->cbSize);
+ sh->wf = (WAVEFORMATEX*)realloc(sh->wf, sizeof(WAVEFORMATEX) + sh->wf->cbSize);
+
+ if(op[0].bytes >= 29) {
+ unsigned int br, nombr, minbr, maxbr;
+ ptr = buf[0];
+ sh->channels = ptr[11];
+ sh->samplerate = sh->wf->nSamplesPerSec = get_uint32(&ptr[12]);
+ maxbr = get_uint32(&ptr[16]); //max
+ nombr = get_uint32(&ptr[20]); //nominal
+ minbr = get_uint32(&ptr[24]); //minimum
+ br = maxbr / 8;
+ if(!br)
+ br = nombr / 8;
+ if(!br)
+ br = minbr / 8;
+ sh->wf->nAvgBytesPerSec = br;
+ sh->wf->wBitsPerSample = 16;
+ sh->samplesize = (sh->wf->wBitsPerSample+7)/8;
+
+ mp_msg(MSGT_DEMUX,MSGL_V,"demux_ogg, vorbis stream features are: channels: %d, srate: %d, bitrate: %d, max: %u, nominal: %u, min: %u\n",
+ sh->channels, sh->samplerate, sh->wf->nAvgBytesPerSec, maxbr, nombr, minbr);
+ }
+ free(buf[2]);
+ free(buf[1]);
+ free(buf[0]);
+}
+
+
/// Open an ogg physical stream
int demux_ogg_open(demuxer_t* demuxer) {
ogg_demuxer_t* ogg_d;
@@ -1107,6 +1187,9 @@
mp_msg(MSGT_DEMUX,MSGL_V,"Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n",n_audio,n_audio>1?"s":"",n_video,n_video>1?"s":"",ogg_d->n_text,ogg_d->n_text>1?"s":"");
+ if(sh_a->format == FOURCC_VORBIS)
+ fixup_vorbis_wf(sh_a);
+
return 1;
err_out:
Index: demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- demux_mkv.c 28 Apr 2005 14:43:18 -0000 1.40
+++ demux_mkv.c 12 May 2005 17:35:57 -0000 1.41
@@ -1781,48 +1781,8 @@
track->a_formattag = mmioFOURCC('M', 'P', '4', 'A');
else if (!strcmp(track->codec_id, MKV_A_VORBIS))
{
- unsigned char *c;
- uint32_t offset, length;
-
if (track->private_data == NULL)
return 1;
-
- c = (unsigned char *) track->private_data;
- if (*c != 2)
- {
- mp_msg (MSGT_DEMUX, MSGL_WARN, "[mkv] Vorbis track does not "
- "contain valid headers.\n");
- return 1;
- }
-
- offset = 1;
- for (i=0; i < 2; i++)
- {
- length = 0;
- while (c[offset] == (unsigned char) 0xFF
- && length < track->private_size)
- {
- length += 255;
- offset++;
- }
- if (offset >= (track->private_size - 1))
- {
- mp_msg (MSGT_DEMUX, MSGL_WARN, "[mkv] Vorbis track "
- "does not contain valid headers.\n");
- return 1;
- }
- length += c[offset];
- offset++;
- track->header_sizes[i] = length;
- }
-
- track->headers[0] = &c[offset];
- track->headers[1] = &c[offset + track->header_sizes[0]];
- track->headers[2] = &c[offset + track->header_sizes[0] +
- track->header_sizes[1]];
- track->header_sizes[2] = track->private_size - offset
- - track->header_sizes[0] - track->header_sizes[1];
-
track->a_formattag = mmioFOURCC('v', 'r', 'b', 's');
}
else if (!strcmp(track->codec_id, MKV_A_QDMC))
@@ -1954,14 +1914,9 @@
}
else if (track->a_formattag == mmioFOURCC('v', 'r', 'b', 's')) /* VORBIS */
{
- for (i=0; i < 3; i++)
- {
- dp = new_demux_packet (track->header_sizes[i]);
- memcpy (dp->buffer,track->headers[i],track->header_sizes[i]);
- dp->pts = 0;
- dp->flags = 0;
- ds_add_packet (demuxer->audio, dp);
- }
+ sh_a->wf->cbSize = track->private_size;
+ sh_a->wf = (WAVEFORMATEX*)realloc(sh_a->wf, sizeof(WAVEFORMATEX) + sh_a->wf->cbSize);
+ memcpy((unsigned char *) (sh_a->wf+1), track->private_data, sh_a->wf->cbSize);
}
else if (track->private_size >= sizeof(real_audio_v4_props_t)
&& !strncmp (track->codec_id, MKV_A_REALATRC, 7))
More information about the MPlayer-cvslog
mailing list