[MPlayer-dev-eng] [PATCH] Latest CVS Theora update and about Tremor
Martin Drab
drab at kepler.fjfi.cvut.cz
Sat Aug 16 23:57:25 CEST 2003
Hi,
as I said earlier, I took a closer look at the whole
OGG/Theora/Vorbis/Tremor thing. What I saw was quite terrible. The
external libraries are quite badly written themselfs. Nevertheless there
seems to be interface of OGG/Vorbis, which can be used for Tremor as well
with just minimal differences. However this interface is not used in
MPlayer at all. Instead MPlayer uses some lower level interface to the
libraries and those seem to have changed dramatically in the past.
Actually I am quite mazed that this ever worked. There seems to be no easy
way to implement the new lower level Tremor interface in this. So I
suggest it would be best to rewrite the whole thing to match the proper
interface (it probably applies to Theora too and I think to whole OGG). I
shall do it, but it would probably take more time.
Meanwhile I'm sending this patch, which is more or less just the
Theora patch by David Kuehling with some minor changes and Tremor is left
as is, for now.
Martin Drab.
-------------- next part --------------
diff -Naur MPlayer-20030814.old/configure MPlayer-20030814/configure
--- MPlayer-20030814.old/configure 2003-08-13 18:29:00.000000000 +0200
+++ MPlayer-20030814/configure 2003-08-16 22:25:52.000000000 +0200
@@ -4154,16 +4154,53 @@
_def_tremor='#undef TREMOR'
_nocodecmodules="libvorbis $_nocodecmodules"
fi
-echores "$_vorbis"
+if test "$_vorbis" = yes -a "$_tremor" = yes ; then
+ echores "$_vorbis (Tremor)"
+else
+ echores "$_vorbis"
+fi
echocheck "OggTheora support"
if test "$_theora" = auto ; then
_theora=no
cat > $TMPC << EOF
#include <theora/theora.h>
-int main(void) { theora_version_number (); return 0; }
+#include <string.h>
+int main(void)
+{
+ /* theora is in flux, make sure that all interface routines and
+ * datatypes exist and work the way we expect it, so we don't break
+ * mplayer */
+ ogg_packet op;
+ theora_comment tc;
+ theora_info inf;
+ theora_state st;
+ yuv_buffer yuv;
+ int r;
+ double t;
+
+ theora_info_init (&inf);
+ theora_comment_init (&tc);
+
+ return 0;
+
+ /* we don't want to execute this kind of nonsense; just for making sure
+ * that compilation works... */
+ memset(&op, 0, sizeof(op));
+ r = theora_decode_header (&inf, &tc, &op);
+ r = theora_decode_init (&st, &inf);
+ t = theora_granule_time (&st, op.granulepos);
+ r = theora_decode_packetin (&st, &op);
+ r = theora_decode_YUVout (&st, &yuv);
+ theora_clear (&st);
+
+ return 0;
+}
EOF
cc_check -ltheora -logg -lm && _theora=yes
+ if test "$_theora" = no ; then
+ echo -n "(You should get the latest CVS of OggTheora if you want it working.) ... "
+ fi
fi
if test "$_theora" = yes ; then
_def_theora='#define HAVE_OGGTHEORA 1'
diff -Naur MPlayer-20030814.old/libmpcodecs/vd_theora.c MPlayer-20030814/libmpcodecs/vd_theora.c
--- MPlayer-20030814.old/libmpcodecs/vd_theora.c 2003-06-06 21:19:23.000000000 +0200
+++ MPlayer-20030814/libmpcodecs/vd_theora.c 2003-08-16 21:30:11.000000000 +0200
@@ -23,6 +23,8 @@
#include <theora/theora.h>
+#define THEORA_NUM_HEADER_PACKETS 3
+
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
return CONTROL_UNKNOWN;
@@ -30,6 +32,7 @@
typedef struct theora_struct_st {
theora_state st;
+ theora_comment cc;
theora_info inf;
} theora_struct_t;
@@ -41,7 +44,7 @@
int failed = 1;
int errorCode = 0;
ogg_packet op;
-// theora_comment tc;
+ int i;
/* check whether video output format is supported */
switch(sh->codec->outfmt[sh->outfmtidx])
@@ -60,35 +63,23 @@
sh->context = context;
if (!context)
break;
-
- /* read initial header */
- op.bytes = ds_get_packet (sh->ds,&op.packet);
- op.b_o_s = 1;
- if((errorCode = theora_decode_header (&context->inf, &op))) {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,
- "Broken Theora header; erroroCode=%i!\n", errorCode);
- break;
- }
-
- /* decode comment packet */
- op.bytes = ds_get_packet (sh->ds,&op.packet);
- op.b_o_s = 1;
-#if 0
- if((errorCode = theora_decode_comment (&tc, &op))) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,
- "Broken Theora comment; erroroCode=%i!\n", errorCode);
- break;
- }
-#endif
- /* decode tables packet */
- op.bytes = ds_get_packet (sh->ds,&op.packet);
- op.b_o_s = 1;
- if((errorCode = theora_decode_tables (&context->inf, &op))) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,
- "Broken Theora comment; erroroCode=%i!\n", errorCode);
- break;
+ theora_info_init(&context->inf);
+ theora_comment_init(&context->cc);
+
+ /* Read all header packets, pass them to theora_decode_header. */
+ for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++)
+ {
+ op.bytes = ds_get_packet (sh->ds, &op.packet);
+ op.b_o_s = 1;
+ if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) )
+ {
+ mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode);
+ break;
+ }
}
+ if (errorCode)
+ break;
/* now init codec */
errorCode = theora_decode_init (&context->st, &context->inf);
diff -Naur MPlayer-20030814.old/libmpdemux/demux_ogg.c MPlayer-20030814/libmpdemux/demux_ogg.c
--- MPlayer-20030814.old/libmpdemux/demux_ogg.c 2003-07-09 03:30:24.000000000 +0200
+++ MPlayer-20030814/libmpdemux/demux_ogg.c 2003-08-16 21:43:54.000000000 +0200
@@ -50,6 +50,7 @@
#ifdef HAVE_OGGTHEORA
typedef struct theora_struct_st {
theora_state st;
+ theora_comment cc;
theora_info inf;
} theora_struct_t;
#endif
@@ -633,7 +634,12 @@
} else if (pack.bytes >= 7 && !strncmp (&pack.packet[1], "theora", 6)) {
int errorCode = 0;
theora_info inf;
- errorCode = theora_decode_header (&inf, &pack);
+ theora_comment cc;
+
+ theora_info_init (&inf);
+ theora_comment_init (&cc);
+
+ errorCode = theora_decode_header (&inf, &cc, &pack);
if (errorCode)
mp_msg(MSGT_DEMUX,MSGL_ERR,"Theora header parsing failed: %i \n",
errorCode);
More information about the MPlayer-dev-eng
mailing list