[FFmpeg-devel] [BUG, PATCH] Revert broken use of ff_put_string() in vorbis_enc.c

Philipp Matthias Hahn pmhahn
Sat Nov 28 18:52:19 CET 2009


Revert commit 20095: Don't use ff_put_string in vorbis encoder.

ff_put_string() is declared in bistream.c, which uses put_bits() without
BITSTREAM_WRITER_LE being defined.
vorbis_enc.c on the other hand #defines BITSTREAM_WRITER_LE and thus must not
use this function.

Broken files contain the string "vorsib" instead of "vorbis".

--- libavcodec/vorbis_enc.c	(Revision 20639)
+++ libavcodec/vorbis_enc.c	(Arbeitskopie)
@@ -530,7 +530,14 @@
     // identification header
     init_put_bits(&pb, p, buffer_len);
     put_bits(&pb, 8, 1); //magic
-    ff_put_string(&pb, "vorbis", 0);
+    /*
+     * Do not use
+     * bitsream.c:void ff_put_string(PutBitContext * pbc, const char *s, int terminate_string)
+     * because it is Big-Endian which is incompatible with
+     * vorbis_enc.c:#define BITSTREAM_WRITER_LE
+     */
+    for (i = 0; "vorbis"[i]; i++)
+        put_bits(&pb, 8, "vorbis"[i]);
     put_bits32(&pb, 0); // version
     put_bits(&pb,  8, venc->channels);
     put_bits32(&pb, venc->sample_rate);
@@ -549,7 +556,8 @@
     // comment header
     init_put_bits(&pb, p, buffer_len);
     put_bits(&pb, 8, 3); //magic
-    ff_put_string(&pb, "vorbis", 0);
+    for (i = 0; "vorbis"[i]; i++)
+        put_bits(&pb, 8, "vorbis"[i]);
     put_bits32(&pb, 0); // vendor length TODO
     put_bits32(&pb, 0); // amount of comments
     put_bits(&pb,  1, 1); // framing
@@ -562,7 +570,8 @@
     // setup header
     init_put_bits(&pb, p, buffer_len);
     put_bits(&pb, 8, 5); //magic
-    ff_put_string(&pb, "vorbis", 0);
+    for (i = 0; "vorbis"[i]; i++)
+        put_bits(&pb, 8, "vorbis"[i]);
 
     // codebooks
     put_bits(&pb, 8, venc->ncodebooks - 1);

BYtE
Philipp

PS: I'm not subscribed, please cc: me on replies.
-- 
  / /  (_)__  __ ____  __ Philipp Hahn
 / /__/ / _ \/ // /\ \/ /
/____/_/_//_/\_,_/ /_/\_\ pmhahn at titan.lahn.de



More information about the ffmpeg-devel mailing list