From patchwork Mon Feb 11 22:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 12043 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EF67A4495BD for ; Tue, 12 Feb 2019 00:42:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DDCD968A3AF; Tue, 12 Feb 2019 00:42:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 394CF68A489 for ; Tue, 12 Feb 2019 00:42:13 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 239E6E1600; Mon, 11 Feb 2019 23:42:13 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dWYY0JiK9zTZ; Mon, 11 Feb 2019 23:42:12 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 51222E1661; Mon, 11 Feb 2019 23:42:12 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Feb 2019 23:42:05 +0100 Message-Id: <20190211224206.30345-2-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190211224206.30345-1-cus@passwd.hu> References: <20190211224206.30345-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 2/3] avformat/mpegts: also convert strings without a specified encoding to UTF-8 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The default codepage (ISO6937) should be used in this case. Signed-off-by: Marton Balint --- libavformat/mpegts.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 2594b1eeb1..e7bbf3e488 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -678,7 +678,7 @@ static char *getstr8(const uint8_t **pp, const uint8_t *p_end) if (len > p_end - p) return NULL; #if CONFIG_ICONV - if (len && *p < 0x20) { + if (len) { const char *encodings[] = { "ISO6937", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", @@ -688,16 +688,20 @@ static char *getstr8(const uint8_t **pp, const uint8_t *p_end) }; iconv_t cd; char *in, *out; - size_t inlen = len - 1, outlen = inlen * 6 + 1; + size_t inlen = len, outlen = inlen * 6 + 1; if (len >= 3 && p[0] == 0x10 && !p[1] && p[2] && p[2] <= 0xf && p[2] != 0xc) { char iso8859[12]; snprintf(iso8859, sizeof(iso8859), "ISO-8859-%d", p[2]); - inlen -= 2; + inlen -= 3; in = (char *)p + 3; cd = iconv_open("UTF-8", iso8859); - } else { + } else if (p[0] < 0x20) { + inlen -= 1; in = (char *)p + 1; cd = iconv_open("UTF-8", encodings[*p]); + } else { + in = (char *)p; + cd = iconv_open("UTF-8", encodings[0]); } if (cd == (iconv_t)-1) goto no_iconv;