Mercurial > libavformat.hg
changeset 2238:98ac80739c58 libavformat
properly set AVStream.language according to Matroska track header
author | aurel |
---|---|
date | Mon, 09 Jul 2007 13:33:34 +0000 |
parents | db097a051c65 |
children | 3682caa1584b |
files | matroskadec.c |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/matroskadec.c Sun Jul 08 13:42:52 2007 +0000 +++ b/matroskadec.c Mon Jul 09 13:33:34 2007 +0000 @@ -44,7 +44,7 @@ int stream_index; char *name; - char *language; + char language[4]; char *codec_id; char *codec_name; @@ -994,6 +994,7 @@ /* Allocate a generic track. As soon as we know its type we'll realloc. */ track = av_mallocz(MAX_TRACK_SIZE); matroska->num_tracks++; + strcpy(track->language, "eng"); /* start with the master */ if ((res = ebml_read_master(matroska, &id)) < 0) @@ -1353,10 +1354,14 @@ /* language (matters for audio/subtitles, mostly) */ case MATROSKA_ID_TRACKLANGUAGE: { - char *text; + char *text, *end; if ((res = ebml_read_utf8(matroska, &id, &text)) < 0) break; - track->language = text; + if ((end = strchr(text, '-'))) + *end = '\0'; + if (strlen(text) == 3) + strcpy(track->language, text); + av_free(text); break; } @@ -2158,6 +2163,8 @@ st->codec->codec_id = codec_id; st->start_time = 0; + if (strcmp(track->language, "und")) + strcpy(st->language, track->language); if (track->default_duration) av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, @@ -2702,7 +2709,6 @@ av_free(track->codec_name); av_free(track->codec_priv); av_free(track->name); - av_free(track->language); if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;