From patchwork Fri Feb 8 23:51:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 12002 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 AD0634470C5 for ; Sat, 9 Feb 2019 01:51:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D4B868A711; Sat, 9 Feb 2019 01:51:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f196.google.com (mail-it1-f196.google.com [209.85.166.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF78668A568 for ; Sat, 9 Feb 2019 01:51:06 +0200 (EET) Received: by mail-it1-f196.google.com with SMTP id z7so13223179iti.0 for ; Fri, 08 Feb 2019 15:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=6Gon3wRc7lbj6p064qd+tZ24vDt57rM92V8pdnj/d0o=; b=oW5QIFq4HkryCI4gaoITzl+jmCTopCGN9PlvTIMWViqtcGddBRs5wrRP+ghQgzsqDQ vtQ7vPuO/rt7AoCQNKtUhwZaOe+BoMmm0rY208NyGcAroIR8Gl6hJjGhukc5wIdRCYBu f+EujbWABQcQ4iGlo0tr2zm5UtHUqowef81dl3QfkIEwfGmtYwFMJgiJdnYTsYvJy9bm ha+7MjcO7PgXqmbKRYTTKxPLPb3viZOdfJuIjDw+LGOf6c6hlpl8CNFoiv7hddsRYNbh 5QIj/lKxTWTJKzGV6ho1UywTuzAWtJ9ebydGi/D71SPoIzNzHVGUpzFvKSId2IE8Tj5x QVUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=6Gon3wRc7lbj6p064qd+tZ24vDt57rM92V8pdnj/d0o=; b=JIJToWZPPlknpTxe/rEg0O+MPn+MGRDH0htJPc0DWZ2lDXnA8oWXOg5XsHXm7Aavem WDVufHV8X88DEIeYA2xPJpuO5xGd3x33QY1pAd5obSLN9QOakZ7dimBhUe02x4oeSg2m tt0HsXpziwYer1hXEunIsAfjq22oaVneipjVXMH/IM7zGB8pk4MsxZrM2u+/Wcxr16e3 /mDFEgXi8z85Vd8IFOTl2pgVCfQEymnolrD4d0N/Unil7SXSNnFEisn3Uz0tZXcmFVEU uIICg/GOTAbnqW1gaTm3FXnk8wG8OjwOxNRNfhQlG8vsBZEQdaV5A7b/4oBZxCWAXDeo FFJQ== X-Gm-Message-State: AHQUAuaoSrN5jor6CCB0GOwJRExlG5nlsv9ajTNUzpkgTwoMjspwS11G +iempGIwqigvXUueqcqHBOdj0KcyVp7zhNgiv+vbpw== X-Google-Smtp-Source: AHgI3IZ/OgFXzYepSxxgoyzKTDba2z6VoPcfeWRpBF+nMQNfmo/vhQGw4T+t2qFG8tpvHPKByMj2qxVMpfgw3j+JzU0= X-Received: by 2002:a24:6f51:: with SMTP id x78mr516977itb.121.1549669865356; Fri, 08 Feb 2019 15:51:05 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:c890:0:0:0:0:0 with HTTP; Fri, 8 Feb 2019 15:51:04 -0800 (PST) In-Reply-To: References: From: Carl Eugen Hoyos Date: Sat, 9 Feb 2019 00:51:04 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavf/mpegts: Convert service name and service provider 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2019-02-08 23:09 GMT+01:00, Marton Balint : > > > On Fri, 8 Feb 2019, Carl Eugen Hoyos wrote: > >> Hi! >> >> Attached patch fixes ticket #6320, tested with the sample from ticket >> #7069. >> >> Please comment, Carl Eugen >> >> From fdcd141a29f336925681193a9cdd3f4eaa5c368e Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Fri, 8 Feb 2019 01:35:33 +0100 >> Subject: [PATCH] lavf/mpegts: Convert service_name and service_provider to >> utf-8. >> >> Fixes ticket #6320. >> --- >> libavformat/mpegts.c | 33 +++++++++++++++++++++++++++++++++ >> 1 file changed, 33 insertions(+) >> >> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c >> index b04fd7b..dde610f 100644 >> --- a/libavformat/mpegts.c >> +++ b/libavformat/mpegts.c >> @@ -37,6 +37,9 @@ >> #include "avio_internal.h" >> #include "mpeg.h" >> #include "isom.h" >> +#if CONFIG_ICONV >> +#include >> +#endif >> >> /* maximum size in which we look for synchronization if >> * synchronization is lost */ >> @@ -674,6 +677,36 @@ static char *getstr8(const uint8_t **pp, const >> uint8_t *p_end) >> return NULL; >> if (len > p_end - p) >> return NULL; >> +#if CONFIG_ICONV >> + if (len && *p < 0x20) { >> + 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", "", >> "ISO-8859-13", >> + "ISO-8859-14", "ISO-8859-15", "", "", "", "", >> + "", "ISO-10646", "KSC_5601", "GB2312", "ISO-10646", "UTF-8", >> "", >> + "", "", "", "", "", "", "", "", "" >> + }; >> + iconv_t cd; >> + char *in, *out; >> + size_t inlen = len - 1, outlen = inlen * 6; >> + cd = iconv_open("UTF-8", encodings[*p]); > > Can you add support for the ISO-8859-any case where > p[0] == 0x10, p[1] == 0x00 > and p[2] == any? I will upload a sample to the trac ticket. New patch attached. Thank you, Carl Eugen From 9033f0a18727a7a576c4cc06b9985d6d922d46ad Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 9 Feb 2019 00:49:51 +0100 Subject: [PATCH] lavf/mpegts: Convert service_name and service_provider to utf-8. Fixes ticket #6320. --- libavformat/mpegts.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index b04fd7b..1e27500 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -37,6 +37,9 @@ #include "avio_internal.h" #include "mpeg.h" #include "isom.h" +#if CONFIG_ICONV +#include +#endif /* maximum size in which we look for synchronization if * synchronization is lost */ @@ -674,6 +677,51 @@ static char *getstr8(const uint8_t **pp, const uint8_t *p_end) return NULL; if (len > p_end - p) return NULL; +#if CONFIG_ICONV + if (len && *p < 0x20) { + char iso8859[] = "ISO-8859-00"; + 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", "", "ISO-8859-13", + "ISO-8859-14", "ISO-8859-15", "", "", "", "", + "", "ISO-10646", "KSC_5601", "GB2312", "ISO-10646", "UTF-8", "", + "", "", "", "", "", "", "", "", "" + }; + iconv_t cd; + char *in, *out; + size_t inlen = len - 1, outlen = inlen * 6 + 1; + if (len >= 3 && p[0] == 0x10 && !p[1] && p[2] && p[2] <= 0xf && p[2] != 0xc) { + if (p[2] < 10) { + iso8859[9] += p[2]; + iso8859[10] = 0; + } else { + iso8859[9]++; + iso8859[10] += p[2] - 10; + } + in = (char *)p + 3; + cd = iconv_open("UTF-8", iso8859); + } else { + in = (char *)p + 1; + cd = iconv_open("UTF-8", encodings[*p]); + } + if (cd == (iconv_t)-1) + goto no_iconv; + str = out = av_malloc(outlen); + if (!str) { + iconv_close(cd); + return NULL; + } + if (iconv(cd, &in, &inlen, &out, &outlen) == -1) { + iconv_close(cd); + goto no_iconv; + } + iconv_close(cd); + *out = 0; + *pp = p + len; + return str; + } +no_iconv: +#endif str = av_malloc(len + 1); if (!str) return NULL; -- 1.7.10.4