Remove too old __MMFILE_FFMPEG_V085__ and related code. because __MMFILE_FFMPEG_V085_... 55/139755/1
authorHaejeong Kim <backto.kim@samsung.com>
Thu, 20 Jul 2017 09:05:56 +0000 (18:05 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Thu, 20 Jul 2017 09:05:56 +0000 (18:05 +0900)
Change-Id: Ibc3e6e96f89b5c4e1d69ade2f7ef8a32f2b40aae

formats/ffmpeg/mm_file_format_ffmpeg.c
formats/ffmpeg/mm_file_format_frame.c

index 960397c..9358c07 100755 (executable)
@@ -26,9 +26,7 @@
 #include <libavformat/url.h>
 #include <libavcodec/avcodec.h>
 #include <libavutil/samplefmt.h>
-#ifdef __MMFILE_FFMPEG_V085__
 #include <libswscale/swscale.h>
-#endif
 #include <mm_error.h>
 #include <mm_types.h>
 #include "mm_file_debug.h"
@@ -40,8 +38,6 @@
 
 #define _SHORT_MEDIA_LIMIT             2000    /* under X seconds duration*/
 
-extern int img_convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src, int src_pix_fmt, int src_width, int src_height);
-
 /* internal functions */
 static int _is_good_pgm(unsigned char *buf, int wrap, int xsize, int ysize);
 #ifdef MMFILE_FORMAT_DEBUG_DUMP
@@ -102,11 +98,8 @@ int mmfile_format_open_ffmpg(MMFileFormatContext *formatContext)
 
        if (formatContext->filesrc->type  == MM_FILE_SRC_TYPE_MEMORY) {
 
-#if (defined __MMFILE_FFMPEG_V085__  && !defined __MMFILE_LIBAV_VERSION__)
-               ffurl_register_protocol(&MMFileMEMProtocol, sizeof(URLProtocol));
-#else
                ffurl_register_protocol(&MMFileMEMProtocol);
-#endif
+
                if (getMimeType(formatContext->filesrc->memory.format, mimeType, MMFILE_MIMETYPE_MAX_LEN) < 0) {
                        debug_error(DEBUG, "error: Error in MIME Type finding\n");
                        return MMFILE_FORMAT_FAIL;
@@ -128,11 +121,7 @@ int mmfile_format_open_ffmpg(MMFileFormatContext *formatContext)
                        goto exception;
                }
 
-#ifdef __MMFILE_FFMPEG_V085__
                ret = avformat_open_input(&pFormatCtx, formatContext->uriFileName, grab_iformat, NULL);
-#else
-               ret = av_open_input_file(&pFormatCtx, formatContext->uriFileName, grab_iformat, 0, NULL);
-#endif
                if (ret < 0) {
                        debug_error(DEBUG, "error: cannot open %s %d\n", formatContext->uriFileName, ret);
                        goto exception;
@@ -141,11 +130,8 @@ int mmfile_format_open_ffmpg(MMFileFormatContext *formatContext)
        }
 
        if (formatContext->filesrc->type  == MM_FILE_SRC_TYPE_FILE) {
-#ifdef __MMFILE_FFMPEG_V085__
+
                ret = avformat_open_input(&pFormatCtx, formatContext->filesrc->file.path, NULL, NULL);
-#else
-               ret = av_open_input_file(&pFormatCtx, formatContext->filesrc->file.path, NULL, 0, NULL);
-#endif
                if (ret < 0) {
                        debug_error(DEBUG, "error: cannot open %s %d\n", formatContext->filesrc->file.path, ret);
                        goto exception;
@@ -165,7 +151,6 @@ int mmfile_format_open_ffmpg(MMFileFormatContext *formatContext)
        formatContext->audioTotalTrackNum = 0;
 
        for (i = 0; i < pFormatCtx->nb_streams; i++) {
-#ifdef __MMFILE_FFMPEG_V085__
                if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
                        debug_msg(RELEASE, "FFMPEG video codec id: 0x%08X\n", pFormatCtx->streams[i]->codec->codec_id);
 
@@ -180,25 +165,11 @@ int mmfile_format_open_ffmpg(MMFileFormatContext *formatContext)
                        debug_msg(RELEASE, "FFMPEG audio codec id: 0x%08X\n", pFormatCtx->streams[i]->codec->codec_id);
                        formatContext->audioTotalTrackNum += 1;
                }
-#else
-               if (pFormatCtx->streams[i]->codec->codec_type == AV_CODEC_TYPE_VIDEO) {
-                       debug_msg(RELEASE, "FFMPEG video codec id: 0x%08X\n", pFormatCtx->streams[i]->codec->codec_id);
-                       formatContext->videoTotalTrackNum += 1;
-               }
-               if (pFormatCtx->streams[i]->codec->codec_type == AV_CODEC_TYPE_AUDIO) {
-                       debug_msg(RELEASE, "FFMPEG audio codec id: 0x%08X\n", pFormatCtx->streams[i]->codec->codec_id);
-                       formatContext->audioTotalTrackNum += 1;
-               }
-#endif
        }
 
        debug_msg(RELEASE, "format: %s (%s)\n", pFormatCtx->iformat->name, pFormatCtx->iformat->long_name);
 #ifdef __MMFILE_TEST_MODE__
-#ifdef __MMFILE_FFMPEG_V085__
        av_dump_format(pFormatCtx, 0, formatContext->filesrc->file.path, 0);
-#else
-       dump_format(pFormatCtx, 0, formatContext->filesrc->file.path, 0);
-#endif
 #endif
 
        return MMFILE_FORMAT_SUCCESS;
@@ -280,11 +251,7 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
 
        unsigned int i = 0;
        for (i = 0; i < pFormatCtx->nb_streams; i++) {
-#ifdef __MMFILE_FFMPEG_V085__
                if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-#else
-               if (pFormatCtx->streams[i]->codec->codec_type == AV_CODEC_TYPE_VIDEO) {
-#endif
                        if (formatContext->videoStreamId == -1) {
                                videoStream = mmfile_malloc(sizeof(MMFileFormatStream));
                                if (NULL == videoStream) {
@@ -334,11 +301,7 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
                                }
                        }
                }
-#ifdef __MMFILE_FFMPEG_V085__
                else if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
-#else
-               else if (pFormatCtx->streams[i]->codec->codec_type == AV_CODEC_TYPE_AUDIO) {
-#endif
                        if (formatContext->audioStreamId == -1) {
                                audioStream = mmfile_malloc(sizeof(MMFileFormatStream));
                                if (NULL == audioStream) {
@@ -422,7 +385,6 @@ int mmfile_format_read_tag_ffmpg(MMFileFormatContext *formatContext)
                MMFileUtilGetMetaDataFromMP4(formatContext);
        }
 
-#ifdef __MMFILE_FFMPEG_V085__
        /*metadata extracted by ffmpeg*/
        unsigned int idx = 0;
 
@@ -575,56 +537,6 @@ int mmfile_format_read_tag_ffmpg(MMFileFormatContext *formatContext)
 #endif
                }
        }
-#else
-       if (pFormatCtx->title[0])               {
-               if (formatContext->title)
-                       free(formatContext->title);
-               formatContext->title = mmfile_strdup(pFormatCtx->title);
-       }
-       if (pFormatCtx->author[0]) {
-               if (formatContext->author)
-                       free(formatContext->author);
-               formatContext->author = mmfile_strdup(pFormatCtx->author);
-       }
-       if (pFormatCtx->copyright[0])   {
-               if (formatContext->copyright)
-                       free(formatContext->copyright);
-               formatContext->copyright = mmfile_strdup(pFormatCtx->copyright);
-       }
-       if (pFormatCtx->comment[0])             {
-               if (formatContext->comment)
-                       free(formatContext->comment);
-               formatContext->comment = mmfile_strdup(pFormatCtx->comment);
-       }
-       if (pFormatCtx->album[0])               {
-               if (formatContext->album)
-                       free(formatContext->album);
-               formatContext->album = mmfile_strdup(pFormatCtx->album);
-       }
-       if (pFormatCtx->genre[0])               {
-               if (formatContext->genre)
-                       free(formatContext->genre);
-               formatContext->genre = mmfile_strdup(pFormatCtx->genre);
-       }
-
-       if (pFormatCtx->year) {
-               char year[10] = {0, };
-               snprintf(year, 10, "%d", pFormatCtx->year);
-               year[9] = '\0';
-               if (formatContext->year)
-                       free(formatContext->year);
-               formatContext->year = mmfile_strdup(year);
-       }
-
-       if (pFormatCtx->track) {
-               char tracknum[10] = {0, };
-               snprintf(tracknum, 10, "%d", pFormatCtx->track);
-               tracknum[9] = '\0';
-               if (formatContext->tagTrackNum)
-                       free(formatContext->tagTrackNum);
-               formatContext->tagTrackNum = mmfile_strdup(tracknum);
-       }
-#endif
 
        return MMFILE_FORMAT_SUCCESS;
 }
@@ -750,7 +662,6 @@ int mmfile_format_read_frame_ffmpg(MMFileFormatContext *formatContext, unsigned
                        goto exception;
                }
 
-#ifdef __MMFILE_FFMPEG_V085__
                struct SwsContext *img_convert_ctx = NULL;
 
                img_convert_ctx = sws_getContext(width, height, pVideoCodecCtx->pix_fmt, width, height, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
@@ -772,14 +683,7 @@ int mmfile_format_read_frame_ffmpg(MMFileFormatContext *formatContext, unsigned
 
                sws_freeContext(img_convert_ctx);
                img_convert_ctx = NULL;
-#else
-               ret = img_convert((AVPicture *)pFrameRGB, AV_PIX_FMT_RGB24, (AVPicture *)pFrame, pVideoCodecCtx->pix_fmt, width, height);
-               if (ret < 0) {
-                       debug_error(DEBUG, "failed to convet image\n");
-                       ret = MMFILE_FORMAT_FAIL;
-                       goto exception;
-               }
-#endif
+
                frame->frameSize = numBytes;
                frame->frameWidth = width;
                frame->frameHeight = height;
@@ -960,11 +864,7 @@ static void _dump_av_packet(AVPacket *pkt)
        debug_msg(RELEASE, " data: %p\n", pkt->data);
        debug_msg(RELEASE, " size: %d\n", pkt->size);
        debug_msg(RELEASE, " stream_index: %d\n", pkt->stream_index);
-#ifdef __MMFILE_FFMPEG_V085__
        debug_msg(RELEASE, " flags: 0x%08X, %s\n", pkt->flags, (pkt->flags & AV_PKT_FLAG_KEY) ? "Keyframe" : "_");
-#else
-       debug_msg(RELEASE, " flags: 0x%08X, %s\n", pkt->flags, (pkt->flags & PKT_FLAG_KEY) ? "Keyframe" : "_");
-#endif
        debug_msg(RELEASE, " duration: %d\n", pkt->duration);
        /*debug_msg(RELEASE, " destruct: %p\n", pkt->destruct);*/
        /*debug_msg(RELEASE, " priv: %p\n", pkt->priv);*/
@@ -1016,11 +916,7 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
 
        debug_msg(RELEASE, "frame: 1. %p, 2. %p\n", first_frame, tmp_frame);
 
-#ifdef __MMFILE_FFMPEG_V085__
        pCodecCtx->skip_frame = AVDISCARD_BIDIR;
-#else
-       pCodecCtx->hurry_up = 1;
-#endif
 
        if (cdis == 1) {
                key_search_limit = _KEY_SEARCH_LIMIT_CDIS;
@@ -1041,11 +937,7 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
                } else {
                        if (avcodec_get_type(pFormatCtx->streams[pkt.stream_index]->codec->codec_id) == AVMEDIA_TYPE_VIDEO) {
                                v++;
-#ifdef __MMFILE_FFMPEG_V085__
                                if ((pkt.flags & AV_PKT_FLAG_KEY) || (key_detected == 1))
-#else
-                               if ((pkt.flags & PKT_FLAG_KEY) || (key_detected == 1))
-#endif
                                {
                                        debug_msg(RELEASE, "video frame: %d, %d, %d\n", retry, i, v);
 #ifdef __MMFILE_TEST_MODE__
@@ -1054,11 +946,8 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
 
                                        i++;
                                        key_detected = 0;
-#ifdef __MMFILE_FFMPEG_V085__
+
                                        len = avcodec_decode_video2(pCodecCtx, frame, &got_picture, &pkt);
-#else
-                                       len = avcodec_decode_video(pCodecCtx, frame, &got_picture, pkt.data, pkt.size);
-#endif
                                        if (len < 0) {
                                                debug_warning(DEBUG, "Error while decoding frame %dth\n", i);
                                        } else if (got_picture) {
@@ -1137,11 +1026,7 @@ static int _get_first_good_video_frame(AVFormatContext *pFormatCtx, AVCodecConte
 
        debug_msg(RELEASE, "out frame: %p\n", *pFrame);
 
-#ifdef __MMFILE_FFMPEG_V085__
        pCodecCtx->skip_frame = AVDISCARD_NONE;
-#else
-       pCodecCtx->hurry_up = 0;
-#endif
 
        return ret;
 }
@@ -1210,11 +1095,6 @@ static int ConvertVideoCodecEnum(int AVVideoCodecID)
                case AV_CODEC_ID_CINEPAK:
                        ret_codecid = MM_VIDEO_CODEC_CINEPAK;
                        break;
-#if (!defined __MMFILE_FFMPEG_V085__ && !defined __MMFILE_LIBAV_VERSION__)
-               case AV_CODEC_ID_XVID:
-                       ret_codecid = MM_VIDEO_CODEC_XVID;
-                       break;
-#endif
                case AV_CODEC_ID_VC1:
                        ret_codecid = MM_VIDEO_CODEC_VC1;
                        break;
index df04a1c..a1869fc 100755 (executable)
@@ -449,7 +449,6 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, double timestamp, boo
                        goto exception;
                }
 
-#ifdef __MMFILE_FFMPEG_V085__
                struct SwsContext *img_convert_ctx = NULL;
 
                img_convert_ctx = sws_getContext(*width, *height, pVideoCodecCtx->pix_fmt,
@@ -473,14 +472,6 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, double timestamp, boo
 
                sws_freeContext(img_convert_ctx);
                img_convert_ctx = NULL;
-#else
-               ret = img_convert((AVPicture *)pFrameRGB, AV_PIX_FMT_RGB24, (AVPicture *)pFrame, pVideoCodecCtx->pix_fmt, *width, *height);
-               if (ret < 0) {
-                       debug_error(DEBUG, "failed to convet image\n");
-                       ret = MMFILE_FORMAT_FAIL;
-                       goto exception;
-               }
-#endif
 
 #ifdef MMFILE_FORMAT_DEBUG_DUMP
                __save_frame(pFrameRGB, pVideoCodecCtx->width, pVideoCodecCtx->height, (int)(pos / 1000));
@@ -573,11 +564,7 @@ int mmfile_format_get_frame_from_memory(const void *data, unsigned int datasize,
                return MMFILE_FORMAT_FAIL;
        }
 
-#if (defined __MMFILE_FFMPEG_V085__ && !defined __MMFILE_LIBAV_VERSION__)
-       ffurl_register_protocol(&MMFileMEMProtocol, sizeof(URLProtocol));
-#else
        ffurl_register_protocol(&MMFileMEMProtocol);
-#endif
 
        if (__getMimeType(format, mimeType, MMFILE_MIMETYPE_MAX_LEN) < 0) {
                debug_error(DEBUG, "error: Error in MIME Type finding\n");
@@ -600,11 +587,7 @@ int mmfile_format_get_frame_from_memory(const void *data, unsigned int datasize,
                goto exception;
        }
 
-#ifdef __MMFILE_FFMPEG_V085__
        ret = avformat_open_input(&pFormatCtx, urifilename, grab_iformat, NULL);
-#else
-       ret = av_open_input_file(&pFormatCtx, urifilename, grab_iformat, 0, NULL);
-#endif
        if (ret < 0) {
                debug_error(DEBUG, "error: cannot open %s %d\n", urifilename, ret);
                goto exception;