[xiph-commits] r16107 - trunk/ffmpeg2theora/src

oggk at svn.xiph.org oggk at svn.xiph.org
Sat Jun 13 12:04:36 PDT 2009


Author: oggk
Date: 2009-06-13 12:04:36 -0700 (Sat, 13 Jun 2009)
New Revision: 16107

Modified:
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
extract tx3g text from the packet, as it is not raw text



Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-06-13 19:01:48 UTC (rev 16106)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-06-13 19:04:36 UTC (rev 16107)
@@ -312,6 +312,7 @@
   switch (enc->codec_id) {
     case CODEC_ID_TEXT:
     case CODEC_ID_SSA:
+    case CODEC_ID_MOV_TEXT:
       return 1;
     default:
       return 0;
@@ -1263,7 +1264,7 @@
               AVStream *stream=this->context->streams[pkt.stream_index];
               AVCodecContext *enc = stream->codec;
               if (enc) {
-                if (enc->codec_id == CODEC_ID_TEXT || enc->codec_id == CODEC_ID_SSA) {
+                if (enc->codec_id == CODEC_ID_TEXT || enc->codec_id == CODEC_ID_SSA || enc->codec_id==CODEC_ID_MOV_TEXT) {
                   char *allocated_utf8 = NULL;
                   const char *utf8 = pkt.data;
                   size_t utf8len = pkt.size;
@@ -1301,6 +1302,22 @@
                       utf8len = 0;
                     }
                   }
+                  else if (enc->codec_id == CODEC_ID_MOV_TEXT) {
+                    if (utf8len >= 2) {
+                      const unsigned char *data = (const unsigned char*)pkt.data;
+                      unsigned int text_len = (data[0] << 8) | data[1];
+                      utf8 += 2;
+                      utf8len -= 2;
+                      if (text_len < utf8len) {
+                        utf8len = text_len;
+                      }
+                      if (utf8len == 0) utf8 = NULL;
+                    }
+                    else {
+                      utf8 = NULL;
+                      utf8len = 0;
+                    }
+                  }
                   if (t < 0 && t + duration > 0) {
                     duration += t;
                     t = 0;



More information about the commits mailing list