diff --git a/picard/__init__.py b/picard/__init__.py index 63fb15f6b..14516e252 100644 --- a/picard/__init__.py +++ b/picard/__init__.py @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -version_info = (0, 15, 1, 'final', 0) +version_info = (0, 16, 0, 'rc', 1) if version_info[3] == 'final': if version_info[2] == 0: diff --git a/picard/musicdns/__init__.py b/picard/musicdns/__init__.py index ac1282451..6bac634c2 100644 --- a/picard/musicdns/__init__.py +++ b/picard/musicdns/__init__.py @@ -17,6 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +import sys from PyQt4 import QtCore try: from picard.musicdns import ofa @@ -60,6 +61,8 @@ class OFA(QtCore.QObject): if ofa is None: return None, 0 filename = encode_filename(filename) + if sys.platform == 'win32': + filename = filename.encode('utf8', 'replace') for decoder in self._decoders: self.log.debug("Decoding using %r...", decoder.__name__) try: diff --git a/picard/musicdns/avcodec.c b/picard/musicdns/avcodec.c index bfc79375f..3e9e2a72c 100644 --- a/picard/musicdns/avcodec.c +++ b/picard/musicdns/avcodec.c @@ -39,123 +39,10 @@ #define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO #endif -#ifdef _WIN32 - -#include -#include -#include - -static int -ufile_open(URLContext *h, const char *filename, int flags) -{ - int access; - int fd; - int size; - const char *ptr; - wchar_t *w_filename, *w_ptr; - char *ansi_filename; - - /* skip "ufile:" */ - filename += 6; - ptr = filename; - w_filename = malloc(strlen(filename)); - w_ptr = w_filename; - while (*ptr) - { - char a = (*ptr++) - 0x20; - char b = (*ptr++) - 0x20; - char c = (*ptr++) - 0x20; - char d = (*ptr++) - 0x20; - *w_ptr = a | (b << 4) | (c << 8) | (d << 12); - if (*w_ptr == 0) - break; - w_ptr++; - } - *w_ptr = 0; - - if (flags & URL_RDWR) { - access = O_CREAT | O_TRUNC | O_RDWR; - } else if (flags & URL_WRONLY) { - access = O_CREAT | O_TRUNC | O_WRONLY; - } else { - access = O_RDONLY; - } - access |= O_BINARY; - - if (GetVersion() < 0x80000000) { - fd = _wopen(w_filename, access, 0666); - } - else { - fd = -1; - size = wcslen(w_filename) + 2; - ansi_filename = malloc(size); - if (ansi_filename) { - if (WideCharToMultiByte(CP_ACP, 0, w_filename, -1, ansi_filename, size, NULL, NULL) > 0) { - fd = _open(ansi_filename, access, 0666); - } - free(ansi_filename); - } - } - - free(w_filename); - - if (fd < 0) - return AVERROR(ENOENT); - h->priv_data = (void *)(size_t)fd; - return 0; -} - -static int -ufile_read(URLContext *h, unsigned char *buf, int size) -{ - int fd = (size_t)h->priv_data; - return _read(fd, buf, size); -} - -static int -ufile_write(URLContext *h, unsigned char *buf, int size) -{ - int fd = (size_t)h->priv_data; - return _write(fd, buf, size); -} - -#if LIBAVFORMAT_VERSION_MAJOR >= 52 -static int64_t -ufile_seek(URLContext *h, int64_t pos, int whence) -#else -static offset_t -ufile_seek(URLContext *h, offset_t pos, int whence) -#endif -{ - int fd = (size_t)h->priv_data; - return _lseek(fd, pos, whence); -} - -static int -ufile_close(URLContext *h) -{ - int fd = (size_t)h->priv_data; - return _close(fd); -} - -URLProtocol ufile_protocol = { - "ufile", - ufile_open, - ufile_read, - ufile_write, - ufile_seek, - ufile_close, -}; - -#endif - static PyObject * init(PyObject *self, PyObject *args) { av_register_all(); -#ifdef _WIN32 - register_protocol(&ufile_protocol); -#endif Py_RETURN_NONE; } @@ -178,59 +65,6 @@ decode(PyObject *self, PyObject *args) uint8_t *buffer, *buffer_ptr; PyThreadState *_save; -#ifdef _WIN32 - Py_ssize_t w_length; - wchar_t *w_filename, *w_ptr; - char *e_filename, *e_ptr; - - if (!PyArg_ParseTuple(args, "U", &filename)) - return NULL; - - /* get the original filename as wchar_t* */ - w_length = PyUnicode_GetSize(filename) + 1; - w_filename = malloc(w_length * sizeof(wchar_t)); - if (!w_filename) - return NULL; - memset(w_filename, 0, w_length * sizeof(wchar_t)); - PyUnicode_AsWideChar((PyUnicodeObject *)filename, w_filename, w_length - 1); - - /* 'encode' the filename, so we can pass it as char* */ - e_filename = malloc(w_length * sizeof(wchar_t) * 2 + w_length + 7); - if (!e_filename) - return NULL; - strcpy(e_filename, "ufile:"); - w_ptr = w_filename; - e_ptr = e_filename + 6; - while (*w_ptr) { - *e_ptr++ = 0x20 + ((*w_ptr >> 0) & 0x0F); - *e_ptr++ = 0x20 + ((*w_ptr >> 4) & 0x0F); - *e_ptr++ = 0x20 + ((*w_ptr >> 8) & 0x0F); - *e_ptr++ = 0x20 + ((*w_ptr >> 12) & 0x0F); - w_ptr++; - } - *e_ptr++ = 0x20; - *e_ptr++ = 0x20; - *e_ptr++ = 0x20; - *e_ptr++ = 0x20; - /* copy ASCII filename to the end for extension-based format detection */ - w_ptr = w_filename; - while (*w_ptr) { - *e_ptr++ = (*w_ptr++) & 0xFF; - } - *e_ptr = 0; - - Py_UNBLOCK_THREADS - if (av_open_input_file(&format_context, e_filename, NULL, 0, NULL) != 0) { - Py_BLOCK_THREADS - free(e_filename); - free(w_filename); - PyErr_SetString(PyExc_Exception, "Couldn't open the file."); - return NULL; - } - - free(e_filename); - free(w_filename); -#else if (!PyArg_ParseTuple(args, "S", &filename)) return NULL; @@ -240,7 +74,6 @@ decode(PyObject *self, PyObject *args) PyErr_SetString(PyExc_Exception, "Couldn't open the file."); return NULL; } -#endif if (av_find_stream_info(format_context) < 0) { Py_BLOCK_THREADS diff --git a/setup.py b/setup.py index cacedacf5..3a49480ba 100755 --- a/setup.py +++ b/setup.py @@ -487,7 +487,7 @@ try: self.distribution.data_files.append( ("", ["discid.dll", "libfftw3-3.dll", "libofa.dll", "python27.dll", "msvcr90.dll", "msvcp90.dll", - "avcodec-52.dll", "avformat-52.dll", "avutil-50.dll", + "avcodec-53.dll", "avformat-53.dll", "avutil-51.dll", "libstdc++-6.dll"])) for locale in self.distribution.locales: self.distribution.data_files.append(