[FFmpeg-devel,2/3] avformat/mpegts: also convert strings without a specified encoding to UTF-8

Submitted by Marton Balint on Feb. 11, 2019, 10:42 p.m.

Details

Message ID 20190211224206.30345-2-cus@passwd.hu
State Accepted
Commit b35843e3913df57da3a6bb0ce80a4f2b75d374b4
Headers show

Commit Message

Marton Balint Feb. 11, 2019, 10:42 p.m.
The default codepage (ISO6937) should be used in this case.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mpegts.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Carl Eugen Hoyos Feb. 12, 2019, 12:03 a.m.
2019-02-11 23:42 GMT+01:00, Marton Balint <cus@passwd.hu>:
> The default codepage (ISO6937) should be used in this case.

lgtm

Thank you, Carl Eugen
Marton Balint Feb. 13, 2019, 10:54 p.m.
On Tue, 12 Feb 2019, Carl Eugen Hoyos wrote:

> 2019-02-11 23:42 GMT+01:00, Marton Balint <cus@passwd.hu>:
>> The default codepage (ISO6937) should be used in this case.
>
> lgtm

Thanks, applied.

Regards,
Marton

Patch hide | download patch | download mbox

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;