Add to limit 'probesize' for getting stream information. 77/266177/7 accepted/tizen/unified/20211115.141625 submit/tizen/20211112.015536
authorJiyong Min <jiyong.min@samsung.com>
Tue, 9 Nov 2021 02:40:16 +0000 (11:40 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Thu, 11 Nov 2021 03:25:06 +0000 (12:25 +0900)
[Problem]
Crash occurred for 8k contents due to mem-usage limitation on TV.
[Cause]
After getting stream information, 'ffmpeg' decode frames to probe it.
Decoding 8k video need lots of memory. About 33MB is used for each video frame.
[Solution]
Prevent probing stream information by 'probesize' limitation.

- The 'analyzeduration' and 'probesize' options affect the accuracy of stream information.
 If it could not find some parameters for stream info, we consider increasing the values.

Change-Id: Ice2917732ce6148597a7cb6cc7186e0ac06a0b05

formats/ffmpeg/Makefile.am
formats/ffmpeg/mm_file_format_ffmpeg.c
packaging/libmm-fileinfo.spec

index 653a8a4..eb5befc 100755 (executable)
@@ -45,7 +45,7 @@ endif
 
 if USE_IOMMAP
 libmmfile_formats_la_CFLAGS += -D__MMFILE_MMAP_MODE__
-endif  
+endif
 
 
 libmmfile_formats_la_LIBADD = $(MMCOMMON_LIBS) \
index 66f1714..b34fee7 100644 (file)
@@ -452,11 +452,24 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
        pFormatCtx->start_time = -1;
 
        /**
+        * If you could not find codec parameters for stream info,
+        * consider increasing the value for the 'analyzeduration' and 'probesize' options.
+        */
+       /**
         *@important if data is corrupted, occur segment fault by av_find_stream_info().
         *                      - fixed 2009-06-25.
         */
+       /**
+        * fixed 2021-11-09
+        * if the content is 8k, the mem-usage in avformat_find_stream_info() is too large, 300MB or more.
+        * so we adjust 'probesize' to reduce memory usage in avformat_find_stream_info().
+        * Please refer to below for detail.
+        * https://ffmpeg.org/ffmpeg-formats.html#Format-Options
+        */
        if (formatContext->formatType == MM_FILE_FORMAT_M2TS)
                pFormatCtx->max_analyze_duration = 100000;      // MPEGTS file timeout set
+       else
+               pFormatCtx->probesize = 900000;
 
        if (formatContext->cdis != 1) {
                if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
index 8e68cf0..a0379c3 100644 (file)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    1.0.4
+Version:    1.0.5
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0