Skip to content
/ FFmpeg Public
forked from mpc-hc/FFmpeg
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matroska: Support >3 chars for Language and add LanguageIETF #1

Open
wants to merge 163 commits into
base: master
Choose a base branch
from

Conversation

adipose
Copy link

@adipose adipose commented Sep 24, 2020

Matroska language strings are not limited to 3 characters, and support tags like en-US, etc. Using only 3 characters leads to funny strings like "en-". Given that LAVFilters doesn't support that format of languages, I simply truncate those to "en".

Also added LanguageIETF which is a supported Matroska tag for BCP-47 languages. When using this, set the new "langType" to identify it as BCP-47.

Cory Fields and others added 30 commits August 18, 2020 10:14
…ght or might not handle returning any completed demuxed packets correctly
This allows user code to properly detect HW decoding compat before decoding actually starts.
In this mode, the parser does completely process the frame, but timestamps
are not mangled in compute_pkt_fields.
This allows detection of some files with corruption within the first few MB and should not have a speed impact on previous functional files.
Using multi-threading for stream probing is a bad idea.
This is used by the BDMV demuxer when some streams are not detected by auto-probing
This unbreaks compilation in mingw with CRLF line endings
Alot of files have their DefaultDuration set to an calculated
value which is not directly tied to the FPS, and because Matroska
actually doesn't specify the DefaultDuration to be tied to the FPS,
this is perfectly legal.

So, before assuming the DefaultDuration is the FPS, check if the value
actually makes sense. The most basic check here is that the FPS is
below 125fps, because any more really doesn't make sense.

If the FPS from the header is not set, avformat will probe the FPS
based on the files timestamps, which will give a much better result.
This avoids using an uninitialized picture in further decode calls.
…tes otherwise

According to the H.264 standard, Annex D, Table D-1, field_pic_flag shall be 0 when sei_pic_struct signals progressive. In the case when this restriction is not fullfilled, its safer to assume the field is actually interlaced.
Not doing so can cause a renderer to assume the frame is progressive and not deinterlace it, even if required.
@ale5000-git
Copy link

@adipose: Is there something of this patch that can be ported upstream ( https://ffmpeg.org/ )?

@adipose
Copy link
Author

adipose commented Sep 20, 2021

@ale5000-git

I refuse to use mailing lists for code contributions. It's such a poorly designed interface and about 8 years out of date for collaboration. I have been on a few in the past and I really hate digging through emails to find things later.

So...you have my blessing if you want to submit my code to the ffmpeg mailing list and see if they'll accept a patch.

They also rejected my PR here: FFmpeg/FFmpeg#353 and I was too lazy to submit via mailing list.

@ale5000-git
Copy link

@adipose: Beside that (that I can do when I have time) I wonder if you know if there is something that can be ported since if I'm not wrong the "matroskadec_haali.c" was deprecated in main ffmpeg and replaced with something else.

@clsid2
Copy link
Owner

clsid2 commented Sep 21, 2021

matroskadec_haali has never been part of FFmpeg

clsid2 pushed a commit that referenced this pull request Dec 27, 2021
…ion parameter

If memory allocation fails, ERROR(ENOMEM) '-12' will be returned.
When resample() is done first, the negative size param would cause buffer-overflow and SEGV in swri_rematrix().
When swri_rematrix() is run first, resample() would not cause an error but Err num as a wrong parameter passing.
Err num should be returned immediately. And remove an unneeded term from an assert.

coredump info:
    #0 0x499517 in posix_memalign (/home/r1/ffmpeg/ffmpeg_4.4.1+0x499517)
    #1 0x6c1f0b4 in av_malloc /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:86:9
    #2 0x6c208fe in av_mallocz /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:239:17
    #3 0x6c207ad in av_mallocz_array /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:195:12
    #4 0x654b2e5 in swri_realloc_audio /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:418:14
    #5 0x654f9a1 in swr_convert_internal /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:601:17
    #6 0x654d2c0 in swr_convert /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:766:19
    #7 0x186cf56 in flush_frame /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/af_aresample.c:251:13
    #8 0x186a454 in request_frame /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/af_aresample.c:288:20
    #9 0x787d9c in ff_request_frame_to_filter /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:459:15
    #10 0x7877f1 in forward_status_change /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1257:19
    #11 0x77ed7e in ff_filter_activate_default /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1288:20
    #12 0x77e4e1 in ff_filter_activate /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1441:11
    #13 0x793b3f in ff_filter_graph_run_once /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfiltergraph.c:1403:12
    #14 0x7a7bee in get_frame_internal /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/buffersink.c:131:19
    #15 0x7a7287 in av_buffersink_get_frame_flags /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/buffersink.c:142:12
    #16 0x792888 in avfilter_graph_request_oldest /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfiltergraph.c:1356:17
    #17 0x5d07df in transcode_from_filter /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4639:11
    #18 0x59e557 in transcode_step /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4729:20
    #19 0x593970 in transcode /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4805:15
    #20 0x58f7a4 in main /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:5010:9
    #21 0x7f6fd2dee0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: negative-size-param (/home/r1/ffmpeg/ffmpeg_4.4.1+0x497e67) in __asan_memcpy

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
@clsid2 clsid2 force-pushed the master branch 2 times, most recently from b4c554a to 48d7adb Compare October 17, 2022 13:37
@clsid2 clsid2 force-pushed the master branch 2 times, most recently from 23cdfea to 3a15ce0 Compare July 1, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants