summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-10-25 15:16:18 +0000
committerjstebbins <[email protected]>2011-10-25 15:16:18 +0000
commit9a6291134de9c5441e6871797b0cce53716e7365 (patch)
tree25ae1f44642f133d8758ad3838a64bcd39c29eeb
parent8507d9f1ba9a2ab6a423b6a47d2e3df4fb04a737 (diff)
Find font attachments by file name extension
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
-rw-r--r--libhb/stream.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libhb/stream.c b/libhb/stream.c
index 4d24be86d..953983d9d 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -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;