Bug fix of extracting thumbnail 03/304103/3 accepted/tizen/unified/20240111.074626
authorhjkim <backto.kim@samsung.com>
Wed, 10 Jan 2024 05:41:40 +0000 (14:41 +0900)
committerhjkim <backto.kim@samsung.com>
Wed, 10 Jan 2024 05:56:03 +0000 (14:56 +0900)
when extracting a thumbnail with ffmpeg, use av_read_frame() to read the frame.
av_read_frame() returns all frames such as audio, video, 'attached pic'.
some content have 'attached pic' and it can be processed as a video, then avcodec_send_packet could return error.
so, fixed to compare frame's stream_index with exact video stream id to avoid above problem.

Change-Id: Id0f2cf6ca1888e0fe4edca274152c991e3e53017

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

index ea3f6c2..9cd144d 100644 (file)
@@ -55,7 +55,7 @@ static void _dump_av_packet(AVPacket *pkt)
 }
 #endif
 
-static int     _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, AVFrame **pFrame, int cdis);
+static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, AVFrame **pFrame, int cdis, int videoStreamId);
 
 static int __convert_vidio_codec_type(int AVVideoCodecID)
 {
@@ -868,7 +868,7 @@ int mmfile_format_read_frame_ffmpg(MMFileFormatContext *formatContext, unsigned
        }
 
        /* search & decode */
-       ret = _get_first_good_video_frame(pFormatCtx, pVideoCodecCtx, &pFrame, formatContext->cdis);
+       ret = _get_first_good_video_frame(pFormatCtx, pVideoCodecCtx, &pFrame, formatContext->cdis, formatContext->videoStreamId);
        if (ret != MMFILE_FORMAT_SUCCESS) {
                debug_error(DEBUG, "error: get key frame");
                goto EXCEPTION;
@@ -1055,7 +1055,7 @@ static void _save_pgm(unsigned char *buf, int wrap, int xsize, int ysize, char *
 }
 #endif
 
-static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, AVFrame **pFrame, int cdis)
+static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, AVFrame **pFrame, int cdis, int videoStreamId)
 {
 #define        _RETRY_SEARCH_LIMIT             250
 #define        _KEY_SEARCH_LIMIT               (_RETRY_SEARCH_LIMIT*2)         /*2 = 1 read. some frame need to read one more*/
@@ -1111,7 +1111,7 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
                        break;
                }
 
-               if (avcodec_get_type(pFormatCtx->streams[pkt->stream_index]->codecpar->codec_id) != AVMEDIA_TYPE_VIDEO)
+               if (pkt->stream_index != videoStreamId)
                        goto NEXT;
 
                v++;
index cd1d2c6..653cf12 100644 (file)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    1.0.21
+Version:    1.0.22
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0