Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
9dd307f7
Commit
9dd307f7
authored
Feb 05, 2016
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atsc_a65.h : add simple UTF16 decoding through handle
parent
6f444b6e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
9 deletions
+49
-9
modules/codec/atsc_a65.c
modules/codec/atsc_a65.c
+48
-9
modules/codec/atsc_a65.h
modules/codec/atsc_a65.h
+1
-0
No files found.
modules/codec/atsc_a65.c
View file @
9dd307f7
...
@@ -64,7 +64,8 @@ const uint8_t ATSC_A65_MODE_RESERVED_RANGES[12] = {
...
@@ -64,7 +64,8 @@ const uint8_t ATSC_A65_MODE_RESERVED_RANGES[12] = {
struct
atsc_a65_handle_t
struct
atsc_a65_handle_t
{
{
char
*
psz_lang
;
char
*
psz_lang
;
vlc_iconv_t
iconv16
;
vlc_iconv_t
iconv_ucs2
;
vlc_iconv_t
iconv_u16be
;
};
};
atsc_a65_handle_t
*
atsc_a65_handle_New
(
const
char
*
psz_lang
)
atsc_a65_handle_t
*
atsc_a65_handle_New
(
const
char
*
psz_lang
)
...
@@ -77,15 +78,18 @@ atsc_a65_handle_t *atsc_a65_handle_New( const char *psz_lang )
...
@@ -77,15 +78,18 @@ atsc_a65_handle_t *atsc_a65_handle_New( const char *psz_lang )
else
else
p_handle
->
psz_lang
=
NULL
;
p_handle
->
psz_lang
=
NULL
;
p_handle
->
iconv16
=
NULL
;
p_handle
->
iconv_ucs2
=
NULL
;
p_handle
->
iconv_u16be
=
NULL
;
}
}
return
p_handle
;
return
p_handle
;
}
}
void
atsc_a65_handle_Release
(
atsc_a65_handle_t
*
p_handle
)
void
atsc_a65_handle_Release
(
atsc_a65_handle_t
*
p_handle
)
{
{
if
(
p_handle
->
iconv16
)
if
(
p_handle
->
iconv_ucs2
)
vlc_iconv_close
(
p_handle
->
iconv16
);
vlc_iconv_close
(
p_handle
->
iconv_ucs2
);
if
(
p_handle
->
iconv_u16be
)
vlc_iconv_close
(
p_handle
->
iconv_u16be
);
free
(
p_handle
->
psz_lang
);
free
(
p_handle
->
psz_lang
);
free
(
p_handle
);
free
(
p_handle
);
}
}
...
@@ -145,12 +149,12 @@ static bool convert_encoding_set( atsc_a65_handle_t *p_handle,
...
@@ -145,12 +149,12 @@ static bool convert_encoding_set( atsc_a65_handle_t *p_handle,
else
if
(
i_mode
>
ATSC_A65_MODE_UNICODE_RANGE_START
&&
/* 8 range prefix + 8 */
else
if
(
i_mode
>
ATSC_A65_MODE_UNICODE_RANGE_START
&&
/* 8 range prefix + 8 */
i_mode
<=
ATSC_A65_MODE_UNICODE_RANGE_END
)
i_mode
<=
ATSC_A65_MODE_UNICODE_RANGE_END
)
{
{
if
(
!
p_handle
->
iconv
16
)
if
(
!
p_handle
->
iconv
_ucs2
)
{
{
if
(
!
(
p_handle
->
iconv
16
=
vlc_iconv_open
(
"UTF-8"
,
"UCS-2BE"
))
)
if
(
!
(
p_handle
->
iconv
_ucs2
=
vlc_iconv_open
(
"UTF-8"
,
"UCS-2BE"
))
)
return
false
;
return
false
;
}
}
else
if
(
VLC_ICONV_ERR
==
vlc_iconv
(
p_handle
->
iconv
16
,
NULL
,
NULL
,
NULL
,
NULL
)
)
/* reset */
else
if
(
VLC_ICONV_ERR
==
vlc_iconv
(
p_handle
->
iconv
_ucs2
,
NULL
,
NULL
,
NULL
,
NULL
)
)
/* reset */
{
{
return
false
;
return
false
;
}
}
...
@@ -166,7 +170,7 @@ static bool convert_encoding_set( atsc_a65_handle_t *p_handle,
...
@@ -166,7 +170,7 @@ static bool convert_encoding_set( atsc_a65_handle_t *p_handle,
const
size_t
i_outbuf_size
=
i_src
*
4
;
const
size_t
i_outbuf_size
=
i_src
*
4
;
size_t
i_inbuf_remain
=
i_src
*
2
;
size_t
i_inbuf_remain
=
i_src
*
2
;
size_t
i_outbuf_remain
=
i_outbuf_size
;
size_t
i_outbuf_remain
=
i_outbuf_size
;
b_ret
=
(
VLC_ICONV_ERR
!=
vlc_iconv
(
p_handle
->
iconv
16
,
&
p_inbuf
,
&
i_inbuf_remain
,
b_ret
=
(
VLC_ICONV_ERR
!=
vlc_iconv
(
p_handle
->
iconv
_ucs2
,
&
p_inbuf
,
&
i_inbuf_remain
,
&
p_outbuf
,
&
i_outbuf_remain
)
);
&
p_outbuf
,
&
i_outbuf_remain
)
);
psz_dest
=
psz_realloc
;
psz_dest
=
psz_realloc
;
i_mergmin1
+=
(
i_outbuf_size
-
i_outbuf_remain
);
i_mergmin1
+=
(
i_outbuf_size
-
i_outbuf_remain
);
...
@@ -246,3 +250,38 @@ error:
...
@@ -246,3 +250,38 @@ error:
}
}
#undef BUF_ADVANCE
#undef BUF_ADVANCE
char
*
atsc_a65_Decode_simple_UTF16_string
(
atsc_a65_handle_t
*
p_handle
,
const
uint8_t
*
p_buffer
,
size_t
i_buffer
)
{
if
(
i_buffer
<
1
)
return
NULL
;
if
(
!
p_handle
->
iconv_u16be
)
{
if
(
!
(
p_handle
->
iconv_u16be
=
vlc_iconv_open
(
"UTF-8"
,
"UTF-16BE"
))
)
return
NULL
;
}
else
if
(
VLC_ICONV_ERR
==
vlc_iconv
(
p_handle
->
iconv_u16be
,
NULL
,
NULL
,
NULL
,
NULL
)
)
/* reset */
{
return
NULL
;
}
const
size_t
i_target_buffer
=
i_buffer
*
3
/
2
;
size_t
i_target_remaining
=
i_target_buffer
;
const
char
*
psz_toconvert
=
(
const
char
*
)
p_buffer
;
char
*
psz_converted_end
;
char
*
psz_converted
=
psz_converted_end
=
malloc
(
i_target_buffer
);
if
(
unlikely
(
!
psz_converted
)
)
return
NULL
;
if
(
VLC_ICONV_ERR
==
vlc_iconv
(
p_handle
->
iconv_u16be
,
&
psz_toconvert
,
&
i_buffer
,
&
psz_converted_end
,
&
i_target_remaining
)
)
{
free
(
psz_converted
);
psz_converted
=
NULL
;
}
psz_converted
[
i_target_buffer
-
i_target_remaining
-
1
]
=
0
;
return
psz_converted
;
}
modules/codec/atsc_a65.h
View file @
9dd307f7
...
@@ -27,6 +27,7 @@ atsc_a65_handle_t *atsc_a65_handle_New( const char *psz_lang );
...
@@ -27,6 +27,7 @@ atsc_a65_handle_t *atsc_a65_handle_New( const char *psz_lang );
void
atsc_a65_handle_Release
(
atsc_a65_handle_t
*
);
void
atsc_a65_handle_Release
(
atsc_a65_handle_t
*
);
char
*
atsc_a65_Decode_multiple_string
(
atsc_a65_handle_t
*
,
const
uint8_t
*
,
size_t
);
char
*
atsc_a65_Decode_multiple_string
(
atsc_a65_handle_t
*
,
const
uint8_t
*
,
size_t
);
char
*
atsc_a65_Decode_simple_UTF16_string
(
atsc_a65_handle_t
*
,
const
uint8_t
*
,
size_t
);
static
inline
time_t
atsc_a65_GPSTimeToEpoch
(
time_t
i_seconds
,
time_t
i_gpstoepoch_leaptime_offset
)
static
inline
time_t
atsc_a65_GPSTimeToEpoch
(
time_t
i_seconds
,
time_t
i_gpstoepoch_leaptime_offset
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment