Skip to content

Commit 61d7fc0

Browse files
committed
libhb: remove UTF-8 to Windows code page conversion, it's not needed anymore in recent libdvdread versions.
1 parent b65d4c6 commit 61d7fc0

File tree

4 files changed

+10
-65
lines changed

4 files changed

+10
-65
lines changed

libhb/dvd.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,13 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path )
113113
hb_dvd_t * e;
114114
hb_dvdread_t * d;
115115
int region_mask;
116-
char * path_ccp;
117116

118117
e = calloc( sizeof( hb_dvd_t ), 1 );
119118
d = &(e->dvdread);
120119
d->h = h;
121120

122-
/*
123-
* Convert UTF-8 path to current code page on Windows
124-
* hb_utf8_to_cp() is the same as strdup on non-Windows,
125-
* so no #ifdef required here
126-
*/
127-
path_ccp = hb_utf8_to_cp( path );
128-
129121
/* Log DVD drive region code */
130-
if ( hb_dvd_region( path_ccp, &region_mask ) == 0 )
122+
if ( hb_dvd_region( path, &region_mask ) == 0 )
131123
{
132124
hb_log( "dvd: Region mask 0x%02x", region_mask );
133125
if ( region_mask == 0xFF )
@@ -137,7 +129,7 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path )
137129
}
138130

139131
/* Open device */
140-
if( !( d->reader = DVDOpen( path_ccp ) ) )
132+
if( !( d->reader = DVDOpen( path ) ) )
141133
{
142134
/*
143135
* Not an error, may be a stream - which we'll try in a moment.
@@ -153,16 +145,14 @@ hb_dvd_t * hb_dvdread_init( hb_handle_t * h, const char * path )
153145
goto fail;
154146
}
155147

156-
d->path = strdup( path ); /* hb_dvdread_title_scan assumes UTF-8 path, so not path_ccp here */
157-
free( path_ccp );
148+
d->path = strdup( path );
158149

159150
return e;
160151

161152
fail:
162153
if( d->vmg ) ifoClose( d->vmg );
163154
if( d->reader ) DVDClose( d->reader );
164155
free( e );
165-
free( path_ccp );
166156
return NULL;
167157
}
168158

libhb/dvdnav.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ static char * hb_dvdnav_name( char * path )
103103
**********************************************************************/
104104
static int hb_dvdnav_reset( hb_dvdnav_t * d )
105105
{
106-
char * path_ccp = hb_utf8_to_cp( d->path );
107106
if ( d->dvdnav )
108107
dvdnav_close( d->dvdnav );
109108

110109
/* Open device */
111-
if( dvdnav_open(&d->dvdnav, path_ccp) != DVDNAV_STATUS_OK )
110+
if( dvdnav_open(&d->dvdnav, d->path) != DVDNAV_STATUS_OK )
112111
{
113112
/*
114113
* Not an error, may be a stream - which we'll try in a moment.
@@ -137,13 +136,10 @@ static int hb_dvdnav_reset( hb_dvdnav_t * d )
137136
goto fail;
138137
}
139138

140-
free( path_ccp );
141-
142139
return 1;
143140

144141
fail:
145142
if( d->dvdnav ) dvdnav_close( d->dvdnav );
146-
free( path_ccp );
147143
return 0;
148144
}
149145

@@ -157,21 +153,13 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path )
157153
hb_dvd_t * e;
158154
hb_dvdnav_t * d;
159155
int region_mask;
160-
char * path_ccp;
161156

162157
e = calloc( sizeof( hb_dvd_t ), 1 );
163158
d = &(e->dvdnav);
164159
d->h = h;
165160

166-
/*
167-
* Convert UTF-8 path to current code page on Windows
168-
* hb_utf8_to_cp() is the same as strdup on non-Windows,
169-
* so no #ifdef required here
170-
*/
171-
path_ccp = hb_utf8_to_cp( path );
172-
173161
/* Log DVD drive region code */
174-
if ( hb_dvd_region( path_ccp, &region_mask ) == 0 )
162+
if ( hb_dvd_region( path, &region_mask ) == 0 )
175163
{
176164
hb_log( "dvd: Region mask 0x%02x", region_mask );
177165
if ( region_mask == 0xFF )
@@ -181,7 +169,7 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path )
181169
}
182170

183171
/* Open device */
184-
if( dvdnav_open(&d->dvdnav, path_ccp) != DVDNAV_STATUS_OK )
172+
if( dvdnav_open(&d->dvdnav, path) != DVDNAV_STATUS_OK )
185173
{
186174
/*
187175
* Not an error, may be a stream - which we'll try in a moment.
@@ -211,7 +199,7 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path )
211199
}
212200

213201
/* Open device */
214-
if( !( d->reader = DVDOpen( path_ccp ) ) )
202+
if( !( d->reader = DVDOpen( path ) ) )
215203
{
216204
/*
217205
* Not an error, may be a stream - which we'll try in a moment.
@@ -227,8 +215,7 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path )
227215
goto fail;
228216
}
229217

230-
d->path = strdup( path ); /* hb_dvdnav_title_scan assumes UTF-8 path, so not path_ccp here */
231-
free( path_ccp );
218+
d->path = strdup( path );
232219

233220
return e;
234221

@@ -237,7 +224,6 @@ static hb_dvd_t * hb_dvdnav_init( hb_handle_t * h, const char * path )
237224
if( d->vmg ) ifoClose( d->vmg );
238225
if( d->reader ) DVDClose( d->reader );
239226
free( e );
240-
free( path_ccp );
241227
return NULL;
242228
}
243229

libhb/handbrake/ports.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,12 @@ size_t hb_getline(char **lineptr, size_t *n, FILE *fp);
134134

135135
#ifdef __LIBHB__
136136

137-
// Convert utf8 string to current code page.
138-
char * hb_utf8_to_cp(const char *src);
139-
140137
/* Everything from now is only used internally and hidden to the UI */
141138

142139
/************************************************************************
143140
* DVD utils
144141
***********************************************************************/
145-
int hb_dvd_region(char *device, int *region_mask);
142+
int hb_dvd_region(const char *device, int *region_mask);
146143

147144
#if defined( SYS_DARWIN )
148145
int macOS_get_user_config_directory( char path[512] );

libhb/ports.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,7 @@ int gettimeofday( struct timeval * tv, struct timezone * tz )
109109
#endif
110110
*/
111111

112-
// Convert utf8 string to current code page.
113-
// The internal string representation in hb is utf8. But some
114-
// libraries (libmkv, and mp4v2) expect filenames in the current
115-
// code page. So we must convert.
116-
char * hb_utf8_to_cp(const char *src)
117-
{
118-
char *dst = NULL;
119-
120-
#if defined( SYS_MINGW )
121-
int num_chars = MultiByteToWideChar(CP_UTF8, 0, src, -1, NULL, 0);
122-
if (num_chars <= 0)
123-
return NULL;
124-
wchar_t * tmp = calloc(num_chars, sizeof(wchar_t));
125-
MultiByteToWideChar(CP_UTF8, 0, src, -1, tmp, num_chars);
126-
int len = WideCharToMultiByte(GetACP(), 0, tmp, num_chars, NULL, 0, NULL, NULL);
127-
if (len <= 0)
128-
return NULL;
129-
dst = calloc(len, sizeof(char));
130-
WideCharToMultiByte(GetACP(), 0, tmp, num_chars, dst, len, NULL, NULL);
131-
free(tmp);
132-
#else
133-
// Other platforms don't have code pages
134-
dst = strdup(src);
135-
#endif
136-
137-
return dst;
138-
}
139-
140-
int hb_dvd_region(char *device, int *region_mask)
112+
int hb_dvd_region(const char *device, int *region_mask)
141113
{
142114
#if defined( DVD_LU_SEND_RPC_STATE ) && defined( DVD_AUTH )
143115
struct stat st;

0 commit comments

Comments
 (0)