[FFmpeg-devel] [PATCH] "Mojibake" in Japanese
Michael Niedermayer
michaelni at gmx.at
Sat Mar 17 17:16:53 CET 2012
On Fri, Feb 24, 2012 at 07:01:25AM +0900, Tetsuya Yoshida wrote:
> Hi Michael Niedermayer!
>
> > It is maybe easier for the end user of a package if it could be
> > selected at runtime.
> > For example with a environment variable.
>
> Thanks for your idea!
> I rewrote patch with a environment variable.
thanks, it seems to not work when the environment variable isnt set
though. (that is it produces random output from ASCII in that case)
Metadata:
title : )J*ÿ
artist : )J*ÿ
album : )J*ÿ
vs.
Metadata:
title : Ghost Love Score
artist : Nightwish
album : Once
a few more comments below
[...]
> diff -u -r ffmpeg-0.10_org/libavformat/id3v1.c ffmpeg-0.10/libavformat/id3v1.c
> --- ffmpeg-0.10_org/libavformat/id3v1.c 2012-02-14 07:02:14.525818597 +0900
> +++ ffmpeg-0.10/libavformat/id3v1.c 2012-02-24 15:54:10.813775052 +0900
> @@ -23,6 +23,10 @@
> #include "libavcodec/avcodec.h"
> #include "libavutil/dict.h"
>
> +#if CONFIG_ICONV
> +#include <iconv.h>
> +#endif
> +
> const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
> [0] = "Blues",
> [1] = "Classic Rock",
> @@ -174,11 +178,32 @@
> [147] = "SynthPop",
> };
>
> +#if CONFIG_ICONV
> +static void string_to_utf8(char *from, size_t from_size, char *to, size_t to_size)
> +{
> + iconv_t ic;
> + char *p_to;
> + size_t ic_ret;
> + char *id3_encoding;
> +
> + id3_encoding = getenv("FFMPEG_ID3_ENCODING");
> + p_to = to;
> + if (id3_encoding && id3_encoding[0] && (ic = iconv_open("UTF-8", id3_encoding))!=(iconv_t)-1) {
> + ic_ret = iconv(ic, &from, &from_size, &p_to, &to_size);
> + iconv_close(ic);
> + }
> + p_to = '\0';
> +}
looks like a typo as this doesnt do anything.
> +#endif
> +
> static void get_string(AVFormatContext *s, const char *key,
> const uint8_t *buf, int buf_size)
> {
> int i, c;
> char *q, str[512];
> +#if CONFIG_ICONV
> + char str2[1536];
> +#endif
>
> q = str;
> for(i = 0; i < buf_size; i++) {
> @@ -191,8 +216,17 @@
> }
> *q = '\0';
>
> +#if CONFIG_ICONV
> + string_to_utf8(str, i+1, str2, 1536);
sizeof(str2) is safer here in case str2s size is changed.
> + if (*str2) {
> + av_dict_set(&s->metadata, key, str2, 0);
> + } else if (*str) {
> + av_dict_set(&s->metadata, key, str, 0);
> + }
> +#else
> if (*str)
> av_dict_set(&s->metadata, key, str, 0);
> +#endif
> }
>
> /**
> diff -u -r ffmpeg-0.10_org/libavformat/id3v2.c ffmpeg-0.10/libavformat/id3v2.c
> --- ffmpeg-0.10_org/libavformat/id3v2.c 2012-02-14 07:02:15.673814052 +0900
> +++ ffmpeg-0.10/libavformat/id3v2.c 2012-02-24 15:53:29.837844611 +0900
> @@ -32,6 +32,10 @@
> #include <zlib.h>
> #endif
>
> +#if CONFIG_ICONV
> +#include <iconv.h>
> +#endif
> +
> #include "id3v2.h"
> #include "id3v1.h"
> #include "libavutil/avstring.h"
> @@ -167,6 +171,15 @@
> unsigned int (*get)(AVIOContext*) = avio_rb16;
> AVIOContext *dynbuf;
>
> +#if CONFIG_ICONV
> + iconv_t ic;
> + char *id3_encoding;
> + char *from, *p_from;
> + size_t from_size;
> + char *to, *p_to;
> + size_t to_size;
> +#endif
> +
> if ((ret = avio_open_dyn_buf(&dynbuf)) < 0) {
> av_log(s, AV_LOG_ERROR, "Error opening memory stream\n");
> return ret;
> @@ -175,11 +188,45 @@
> switch (encoding) {
>
> case ID3v2_ENCODING_ISO8859:
> +#if CONFIG_ICONV
> + id3_encoding = getenv("FFMPEG_ID3_ENCODING");
tabs arent allowed in ffmpeg git
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120317/483c312b/attachment.asc>
More information about the ffmpeg-devel
mailing list