From patchwork Fri Feb 8 00:38:35 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: 11996 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 6C0A2447F4E for ; Fri, 8 Feb 2019 02:38:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 573A068A9AD; Fri, 8 Feb 2019 02:38:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f178.google.com (mail-it1-f178.google.com [209.85.166.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4791268A659 for ; Fri, 8 Feb 2019 02:38:38 +0200 (EET) Received: by mail-it1-f178.google.com with SMTP id h193so4872684ita.5 for ; Thu, 07 Feb 2019 16:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=TdkRgVu9QwYSZrFiYvqEJnkQzSg5oul36U46UT23SKg=; b=qQeUu+U3zUQ8Oqx9GvwBFrfv4yKy200AZCsT3xwwDVqbBILf066Pns2VCMidMmQCdv FUjVG3UU6yCbt4yTpv80uOZ7nG1RA0R+0WkX7baq4nlfvhouku/iXllkRUF1vIAppW9q F5RfEFATkxqZ1jU0vtLF2Uzb2Z8g85N3ntbKJbbP0FV4e1hNsRN0E31EUNnnrthcik6i msslQhqjI4psTqQaxp0Tg4tkd5Uu3LxNeA7uSnkPrUd9DzBGoWuT+Hw6pD1qQC58DH6n eHHIenZpSm+Sv+WtbjKFSqQaOytVI3ygstVfBGAIX4DlrdXlO3jedOY7r6+gobdasQDw flkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=TdkRgVu9QwYSZrFiYvqEJnkQzSg5oul36U46UT23SKg=; b=SujLM1pc+xBfjIcafx9bW3mivuUqIEq/a04Emz1kKDKfTyjS+d6IYNyWa4R9tFB16J I7cQiYFpY8bOG2/EgIu0lWWgWC+PI5PeZQrxfPDZ8WIF9se75fhMKpbuQw5hgZpasjEy atLRaHjiSflp/2SVZZAfplVYx5V/B56zwOsGaYS4gmXFIN6cxrHcGNFhLvYYWmAj5Tkl Rfwi8L+MOnIiEypY6K3RlqTZ2gbGpwA3ME7B45ptceqyyWhHs0AneScWfs0slewoqdBb sxM7achToijMwfksGBK7X8vpN0k2TF+jDdqBBZo7s5vHssKMUECah+R9fUhCfmT+sW9z wQpg== X-Gm-Message-State: AHQUAuaFwqZ2PJUager0/GANQj3CYSFBPduyfvCHWEfbcJS56DYU9/Lo YvSx9NVD6exH12nkp4zfmCNKDTmfTQz5NowCzd5s9g== X-Google-Smtp-Source: AHgI3IZFUsAT9op5I4P2hTZlZpo2W5Xec/DuDl2jxE3zX1lj/ReFP489KKd9ugdKtw1TifzHDT85zXOugxugz2SEzYQ= X-Received: by 2002:a24:100d:: with SMTP id 13mr6716856ity.58.1549586316442; Thu, 07 Feb 2019 16:38:36 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:c890:0:0:0:0:0 with HTTP; Thu, 7 Feb 2019 16:38:35 -0800 (PST) From: Carl Eugen Hoyos Date: Fri, 8 Feb 2019 01:38:35 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [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" 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]); + if (cd == (iconv_t)-1) + goto no_iconv; + str = + out = av_malloc(outlen); + if (!str) + return NULL; + in = (char *)p + 1; + if (iconv(cd, &in, &inlen, &out, &outlen) == -1) { + iconv_close(cd); + goto no_iconv; + } + *out = 0; + *pp = in; + return str; + } +no_iconv: +#endif str = av_malloc(len + 1); if (!str) return NULL; -- 1.7.10.4