From: hjkim Date: Wed, 10 Jan 2024 05:41:40 +0000 (+0900) Subject: Bug fix of extracting thumbnail X-Git-Tag: accepted/tizen/unified/20240111.074626^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36a4f7f6d6c810f253ccedf9c11a28e60befb8e1;p=platform%2Fcore%2Fmultimedia%2Flibmm-fileinfo.git Bug fix of extracting thumbnail 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 --- diff --git a/formats/ffmpeg/mm_file_format_ffmpeg.c b/formats/ffmpeg/mm_file_format_ffmpeg.c index ea3f6c2..9cd144d 100644 --- a/formats/ffmpeg/mm_file_format_ffmpeg.c +++ b/formats/ffmpeg/mm_file_format_ffmpeg.c @@ -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++; diff --git a/packaging/libmm-fileinfo.spec b/packaging/libmm-fileinfo.spec index cd1d2c6..653cf12 100644 --- a/packaging/libmm-fileinfo.spec +++ b/packaging/libmm-fileinfo.spec @@ -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