Commit 0cbdd515 authored by Francois Cartegnie's avatar Francois Cartegnie Committed by Jean-Baptiste Kempf

demux: mp4: use new lang tables

The "```" case could also never happen as this is the
decoding of value 0 which should map to mac.

(cherry picked from commit 07a88c4b37cb6e38082966679bb8f1e40c9894eb)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 42100068
...@@ -884,12 +884,8 @@ static int MP4_ReadBox_mdhd( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -884,12 +884,8 @@ static int MP4_ReadBox_mdhd( stream_t *p_stream, MP4_Box_t *p_box )
} }
MP4_GET2BYTES( i_language ); MP4_GET2BYTES( i_language );
p_box->data.p_mdhd->i_language_code = i_language; decodeQtLanguageCode( i_language, p_box->data.p_mdhd->rgs_language,
for( unsigned i = 0; i < 3; i++ ) &p_box->data.p_mdhd->b_mac_encoding );
{
p_box->data.p_mdhd->i_language[i] =
( ( i_language >> ( (2-i)*5 ) )&0x1f ) + 0x60;
}
MP4_GET2BYTES( p_box->data.p_mdhd->i_predefined ); MP4_GET2BYTES( p_box->data.p_mdhd->i_predefined );
...@@ -897,14 +893,12 @@ static int MP4_ReadBox_mdhd( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -897,14 +893,12 @@ static int MP4_ReadBox_mdhd( stream_t *p_stream, MP4_Box_t *p_box )
MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mdhd->i_creation_time, false ); MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mdhd->i_creation_time, false );
MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mdhd->i_modification_time, false ); MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mdhd->i_modification_time, false );
MP4_ConvertDate2Str( s_duration, p_box->data.p_mdhd->i_duration, true ); MP4_ConvertDate2Str( s_duration, p_box->data.p_mdhd->i_duration, true );
msg_Dbg( p_stream, "read box: \"mdhd\" creation %s modification %s time scale %d duration %s language %c%c%c", msg_Dbg( p_stream, "read box: \"mdhd\" creation %s modification %s time scale %d duration %s language %3.3s",
s_creation_time, s_creation_time,
s_modification_time, s_modification_time,
(uint32_t)p_box->data.p_mdhd->i_timescale, (uint32_t)p_box->data.p_mdhd->i_timescale,
s_duration, s_duration,
p_box->data.p_mdhd->i_language[0], (char*) &p_box->data.p_mdhd->rgs_language );
p_box->data.p_mdhd->i_language[1],
p_box->data.p_mdhd->i_language[2] );
#endif #endif
MP4_READBOX_EXIT( 1 ); MP4_READBOX_EXIT( 1 );
} }
......
...@@ -379,10 +379,9 @@ typedef struct MP4_Box_data_mdhd_s ...@@ -379,10 +379,9 @@ typedef struct MP4_Box_data_mdhd_s
uint32_t i_timescale; uint32_t i_timescale;
uint64_t i_duration; uint64_t i_duration;
/* one bit for pad */ char rgs_language[3]; /* ISO-639-2/T or Mac lang table */
uint16_t i_language_code; bool b_mac_encoding; /* media using mac encoding */
/* unsigned int(5)[3] language difference with 0x60*/
unsigned char i_language[3];
uint16_t i_predefined; uint16_t i_predefined;
} MP4_Box_data_mdhd_t; } MP4_Box_data_mdhd_t;
......
...@@ -125,7 +125,6 @@ static int MP4_TrackNextSample( demux_t *, mp4_track_t *, uint32_t ); ...@@ -125,7 +125,6 @@ static int MP4_TrackNextSample( demux_t *, mp4_track_t *, uint32_t );
static void MP4_TrackSetELST( demux_t *, mp4_track_t *, int64_t ); static void MP4_TrackSetELST( demux_t *, mp4_track_t *, int64_t );
static void MP4_UpdateSeekpoint( demux_t * ); static void MP4_UpdateSeekpoint( demux_t * );
static const char *MP4_ConvertMacCode( uint16_t );
static MP4_Box_t * MP4_GetTrexByTrackID( MP4_Box_t *p_moov, const uint32_t i_id ); static MP4_Box_t * MP4_GetTrexByTrackID( MP4_Box_t *p_moov, const uint32_t i_id );
...@@ -3115,19 +3114,8 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, ...@@ -3115,19 +3114,8 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
if( p_track->i_timescale == 0 ) if( p_track->i_timescale == 0 )
return; return;
if( BOXDATA(p_mdhd)->i_language_code < 0x400 ) memcpy( &language, BOXDATA(p_mdhd)->rgs_language, 3 );
{ p_track->b_mac_encoding = BOXDATA(p_mdhd)->b_mac_encoding;
strcpy( language, MP4_ConvertMacCode( BOXDATA(p_mdhd)->i_language_code ) );
p_track->b_mac_encoding = true;
}
else if( BOXDATA(p_mdhd)->i_language_code == 0x7fff )
p_track->b_mac_encoding = true;
else
{
for( unsigned i = 0; i < 3; i++ )
language[i] = BOXDATA(p_mdhd)->i_language[i];
language[3] = '\0';
}
switch( p_hdlr->data.p_hdlr->i_handler_type ) switch( p_hdlr->data.p_hdlr->i_handler_type )
{ {
...@@ -3627,47 +3615,6 @@ static void MP4_TrackSetELST( demux_t *p_demux, mp4_track_t *tk, ...@@ -3627,47 +3615,6 @@ static void MP4_TrackSetELST( demux_t *p_demux, mp4_track_t *tk,
} }
} }
/* */
static const char *MP4_ConvertMacCode( uint16_t i_code )
{
static const struct { const char psz_iso639_1[3]; uint16_t i_code; } p_cvt[] = {
{ "en", 0 }, { "fr", 1 }, { "de", 2 }, { "it", 3 }, { "nl", 4 },
{ "sv", 5 }, { "es", 6 }, { "da", 7 }, { "pt", 8 }, { "no", 9 },
{ "he", 10 }, { "ja", 11 }, { "ar", 12 }, { "fi", 13 }, { "el", 14 },
{ "is", 15 }, { "mt", 16 }, { "tr", 17 }, { "hr", 18 }, { "zh", 19 },
{ "ur", 20 }, { "hi", 21 }, { "th", 22 }, { "ko", 23 }, { "lt", 24 },
{ "pl", 25 }, { "hu", 26 }, { "et", 27 }, { "lv", 28 }, //{ "??", 29 },
{ "fo", 30 }, { "fa", 31 }, { "ru", 32 }, { "zh", 33 }, { "nl", 34 },
{ "ga", 35 }, { "sq", 36 }, { "ro", 37 }, { "cs", 38 }, { "sk", 39 },
{ "sl", 40 }, { "yi", 41 }, { "sr", 42 }, { "mk", 43 }, { "bg", 44 },
{ "uk", 45 }, { "be", 46 }, { "uz", 47 }, { "az", 48 }, { "kk", 48 },
{ "az", 50 }, { "hy", 51 }, { "ka", 52 }, { "mo", 53 }, { "ky", 54 },
{ "tg", 55 }, { "tk", 56 }, { "mn", 57 }, { "mn", 58 }, { "ps", 59 },
{ "ku", 60 }, { "ks", 61 }, { "sd", 62 }, { "bo", 63 }, { "ne", 64 },
{ "sa", 65 }, { "mr", 66 }, { "bn", 67 }, { "as", 68 }, { "gu", 69 },
{ "pa", 70 }, { "or", 71 }, { "ml", 72 }, { "kn", 73 }, { "ta", 74 },
{ "te", 75 }, { "si", 76 }, { "my", 77 }, { "km", 78 }, { "lo", 79 },
{ "vi", 80 }, { "id", 81 }, { "tl", 82 }, { "ms", 83 }, { "ms", 84 },
{ "am", 85 }, { "ti", 86 }, { "om", 87 }, { "so", 88 }, { "sw", 89 },
{ "rw", 90 }, { "rn", 91 }, { "ny", 92 }, { "mg", 93 }, { "eo", 94 },
{ "cy", 128 }, { "eu", 129 },
{ "ca", 130 }, { "la", 131 }, { "qu", 132 }, { "gn", 133 }, { "ay", 134 },
{ "tt", 135 }, { "ug", 136 }, { "dz", 137 }, { "jv", 138 }, { "su", 139 },
{ "gl", 140 }, { "af", 141 }, { "br", 142 }, { "iu", 143 }, { "gd", 144 },
{ "gv", 145 }, { "ga", 146 }, { "to", 147 }, { "el", 148 },
/* */
{ "", 0 }
};
int i;
for( i = 0; *p_cvt[i].psz_iso639_1; i++ )
{
if( p_cvt[i].i_code == i_code )
return p_cvt[i].psz_iso639_1;
}
return "";
}
/****************************************************************************** /******************************************************************************
* Here are the functions used for fragmented MP4 * Here are the functions used for fragmented MP4
*****************************************************************************/ *****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment