| 5898 | } |
| 5899 | |
| 5900 | static void add_ffmpeg_attachment( hb_title_t *title, hb_stream_t *stream, int id ) |
| 5901 | { |
| 5902 | AVStream *st = stream->ffmpeg_ic->streams[id]; |
| 5903 | AVCodecParameters *codecpar = st->codecpar; |
| 5904 | |
| 5905 | enum attachtype type; |
| 5906 | const char *name = get_ffmpeg_metadata_value( st->metadata, "filename" ); |
| 5907 | switch ( codecpar->codec_id ) |
| 5908 | { |
| 5909 | case AV_CODEC_ID_TTF: |
| 5910 | // FFmpeg sets codec ID based on mime type of the attachment |
| 5911 | type = FONT_TTF_ATTACH; |
| 5912 | break; |
| 5913 | default: |
| 5914 | { |
| 5915 | int len = name ? strlen( name ) : 0; |
| 5916 | if( len >= 4 ) |
| 5917 | { |
| 5918 | // Some attachments don't have the right mime type. |
| 5919 | // So also trigger on file name extension. |
| 5920 | if( !strcasecmp( name + len - 4, ".ttc" ) || |
| 5921 | !strcasecmp( name + len - 4, ".ttf" ) ) |
| 5922 | { |
| 5923 | type = FONT_TTF_ATTACH; |
| 5924 | break; |
| 5925 | } |
| 5926 | else if( !strcasecmp( name + len - 4, ".otf" ) ) |
| 5927 | { |
| 5928 | type = FONT_OTF_ATTACH; |
| 5929 | break; |
| 5930 | } |
| 5931 | } |
| 5932 | // Ignore unrecognized attachment type |
| 5933 | return; |
| 5934 | } |
| 5935 | } |
| 5936 | |
| 5937 | hb_attachment_t *attachment = calloc( 1, sizeof(*attachment) ); |
| 5938 | |
| 5939 | // Copy the attachment name and data |
| 5940 | attachment->type = type; |
| 5941 | attachment->name = strdup( name ); |
| 5942 | attachment->data = malloc( codecpar->extradata_size ); |
| 5943 | memcpy( attachment->data, codecpar->extradata, codecpar->extradata_size ); |
| 5944 | attachment->size = codecpar->extradata_size; |
| 5945 | |
| 5946 | hb_list_add(title->list_attachment, attachment); |
| 5947 | } |
| 5948 | |
| 5949 | static void add_ffmpeg_coverart(hb_title_t *title, hb_stream_t *stream, int id) |
| 5950 | { |
no test coverage detected