[FFmpeg-devel] [PATCH] avformat/isom: enable extended language for mov
Yongle Lin
yongle.lin.94 at gmail.com
Wed Jun 17 19:10:27 EEST 2020
Dear FFmpeg Development Team,
I am an intern at Google working on FFmpeg open source project this summer.
I sent a patch in my previous email last week. Could you please take a look
at it and review the patch? I really appreciate it.
Best,
Yongle
On Thu, Jun 11, 2020 at 11:35 PM Yongle Lin <yongle.lin.94 at gmail.com> wrote:
> Allow extended language codes using ISO designation for text tracks in mov
> format when strictness is set to experimental
> ---
> This patch includes a support for mov format to extend language codes
> using ISO designation for text tracks(
> https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-27005)
> and a FATE test associates with it.
>
> libavformat/isom.c | 9 +++++++--
> libavformat/isom.h | 2 +-
> libavformat/movenc.c | 6 +++---
> tests/fate/mov.mak | 3 +++
> tests/ref/fate/mov-extended-lang | 4 ++++
> 5 files changed, 18 insertions(+), 6 deletions(-)
> create mode 100644 tests/ref/fate/mov-extended-lang
>
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 44c7b13038..e59d085d16 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -416,7 +416,7 @@ static const char mov_mdhd_language_map[][4] = {
> "cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav"
> };
>
> -int ff_mov_iso639_to_lang(const char lang[4], int mp4)
> +int ff_mov_iso639_to_lang(const char lang[4], int mp4, int
> strict_std_compliance)
> {
> int i, code = 0;
>
> @@ -426,8 +426,13 @@ int ff_mov_iso639_to_lang(const char lang[4], int mp4)
> return i;
> }
> /* XXX:can we do that in mov too? */
> - if (!mp4)
> + if (!mp4 && (strict_std_compliance != FF_COMPLIANCE_EXPERIMENTAL ||
> !strcmp(lang, "und"))) {
> + if (strcmp(lang, "und"))
> + av_log(NULL, AV_LOG_WARNING, "Non macintosh language is
> discarded for mov\n");
> return -1;
> + }
> + if (!mp4)
> + av_log(NULL, AV_LOG_WARNING, "Experimental behavior: enable
> extended language in mov\n");
> /* handle undefined as such */
> if (lang[0] == '\0')
> lang = "und";
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 41a9c64c11..9d018ebf1f 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -43,7 +43,7 @@ extern const AVCodecTag ff_codec_movaudio_tags[];
> extern const AVCodecTag ff_codec_movsubtitle_tags[];
> extern const AVCodecTag ff_codec_movdata_tags[];
>
> -int ff_mov_iso639_to_lang(const char lang[4], int mp4);
> +int ff_mov_iso639_to_lang(const char lang[4], int mp4, int
> strict_std_compliance);
> int ff_mov_lang_to_iso639(unsigned code, char to[4]);
>
> struct AVAESCTR;
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 5d8dc4fd5d..d833eba056 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -3429,7 +3429,7 @@ static int mov_write_string_data_tag(AVIOContext
> *pb, const char *data, int lang
> return size;
> } else {
> if (!lang)
> - lang = ff_mov_iso639_to_lang("und", 1);
> + lang = ff_mov_iso639_to_lang("und", 1, FF_COMPLIANCE_NORMAL);
> avio_wb16(pb, strlen(data)); /* string length */
> avio_wb16(pb, lang);
> avio_write(pb, data, strlen(data));
> @@ -3468,7 +3468,7 @@ static AVDictionaryEntry
> *get_metadata_lang(AVFormatContext *s,
> while ((t2 = av_dict_get(s->metadata, tag2, t2,
> AV_DICT_IGNORE_SUFFIX))) {
> len2 = strlen(t2->key);
> if (len2 == len + 4 && !strcmp(t->value, t2->value)
> - && (l = ff_mov_iso639_to_lang(&t2->key[len2 - 3], 1)) >= 0) {
> + && (l = ff_mov_iso639_to_lang(&t2->key[len2 - 3], 1,
> s->strict_std_compliance)) >= 0) {
> *lang = l;
> return t;
> }
> @@ -6429,7 +6429,7 @@ static int mov_init(AVFormatContext *s)
>
> track->st = st;
> track->par = st->codecpar;
> - track->language = ff_mov_iso639_to_lang(lang?lang->value:"und",
> mov->mode!=MODE_MOV);
> + track->language = ff_mov_iso639_to_lang(lang?lang->value:"und",
> mov->mode!=MODE_MOV, s->strict_std_compliance);
> if (track->language < 0)
> track->language = 32767; // Unspecified Macintosh language
> code
> track->mode = mov->mode;
> diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
> index 7a721d7c95..522011b172 100644
> --- a/tests/fate/mov.mak
> +++ b/tests/fate/mov.mak
> @@ -29,6 +29,7 @@ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
> fate-mov-guess-delay-2 \
> fate-mov-guess-delay-3 \
> fate-mov-mp4-with-mov-in24-ver \
> + fate-mov-extended-lang \
>
> FATE_MOV_FASTSTART = fate-mov-faststart-4gb-overflow \
>
> @@ -124,3 +125,5 @@ fate-mov-faststart-4gb-overflow: CMP = oneline
> fate-mov-faststart-4gb-overflow: REF = bc875921f151871e787c4b4023269b29
>
> fate-mov-mp4-with-mov-in24-ver: CMD = run ffprobe$(PROGSSUF)$(EXESUF)
> -show_entries stream=codec_name -select_streams 1
> $(TARGET_SAMPLES)/mov/mp4-with-mov-in24-ver.mp4
> +
> +fate-mov-extended-lang: CMD = ffmpeg$(PROGSSUF)$(EXESUF) -f lavfi -i
> sine=frequency=1000:duration=15 -strict experimental -metadata:s:a:0
> language=deu -y $(TARGET_PATH)/metadata.mov; run ffprobe -show_entries
> stream=index:stream_tags=language $(TARGET_PATH)/metadata.mov; rm
> metadata.mov
> diff --git a/tests/ref/fate/mov-extended-lang
> b/tests/ref/fate/mov-extended-lang
> new file mode 100644
> index 0000000000..6d1f61169d
> --- /dev/null
> +++ b/tests/ref/fate/mov-extended-lang
> @@ -0,0 +1,4 @@
> +[STREAM]
> +index=0
> +TAG:language=deu
> +[/STREAM]
> --
> 2.27.0.278.ge193c7cf3a9-goog
>
>
More information about the ffmpeg-devel
mailing list