]> granicus.if.org Git - handbrake/commitdiff
Find font attachments by file name extension
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 25 Oct 2011 15:16:18 +0000 (15:16 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 25 Oct 2011 15:16:18 +0000 (15:16 +0000)
Some font attachments don't have the correct mime type.  So check the
file name extension as well when looking for fonts.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4316 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/stream.c

index 4d24be86d98df5b403be920f57054deada17f392..953983d9d6a12f5207afcb061836b8b128daaf24 100644 (file)
@@ -5109,21 +5109,37 @@ static void add_ffmpeg_attachment( hb_title_t *title, hb_stream_t *stream, int i
     AVCodecContext *codec = st->codec;
 
     enum attachtype type;
+    const char *name = get_ffmpeg_metadata_value( st->metadata, "filename" );
     switch ( codec->codec_id )
     {
         case CODEC_ID_TTF:
+            // Libav sets codec ID based on mime type of the attachment
             type = FONT_TTF_ATTACH;
             break;
         default:
+        {
+            int len = strlen( name );
+            if( len >= 4 &&
+                ( !strcmp( name + len - 4, ".ttc" ) ||
+                  !strcmp( name + len - 4, ".TTC" ) ||
+                  !strcmp( name + len - 4, ".ttf" ) ||
+                  !strcmp( name + len - 4, ".TTF" ) ) )
+            {
+                // Some attachments don't have the right mime type.
+                // So also trigger on file name extension.
+                type = FONT_TTF_ATTACH;
+                break;
+            }
             // Ignore unrecognized attachment type
             return;
+        }
     }
 
     hb_attachment_t *attachment = calloc( 1, sizeof(*attachment) );
 
     // Copy the attachment name and data
     attachment->type = type;
-    attachment->name = strdup( get_ffmpeg_metadata_value( st->metadata, "filename" ) );
+    attachment->name = strdup( name );
     attachment->data = malloc( codec->extradata_size );
     memcpy( attachment->data, codec->extradata, codec->extradata_size );
     attachment->size = codec->extradata_size;