OSDN Git Service

stagefright-plugins: Skip stream with jpeg tag
authorKeith Mok <kmok@cyngn.com>
Mon, 18 Jan 2016 23:39:01 +0000 (15:39 -0800)
committerKeith Mok <kmok@cyngn.com>
Mon, 18 Jan 2016 23:39:01 +0000 (15:39 -0800)
 * MJPEG is used internally by FFMPEG to represent embedded art as
   stream of images. Normally, AV_DISPOSITION_ATTACHED_PIC will be set
   on these streams to denote it should be handled as such. We are
   seeing certain streams in the wild for which this isn't happening
   which causes a hang during decode.
 * Fixes NIGHTLIES-2346

Change-Id: Ie86d3ffb5b7b676a77dc0ae5e7d10a828c8532cf

extractor/FFmpegExtractor.cpp

index 4576611..c1e841d 100644 (file)
@@ -595,11 +595,12 @@ int FFmpegExtractor::stream_component_open(int stream_index)
     if (!supported) {
         ALOGE("unsupport the codec(%s)", avcodec_get_name(avctx->codec_id));
         return -1;
-    } else if (mFormatCtx->streams[stream_index]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
+    } else if ((mFormatCtx->streams[stream_index]->disposition & AV_DISPOSITION_ATTACHED_PIC) ||
+                avctx->codec_tag == MKTAG('j', 'p', 'e', 'g')) {
         ALOGD("not opening attached picture(%s)", avcodec_get_name(avctx->codec_id));
         return -1;
     }
-    ALOGI("support the codec(%s)", avcodec_get_name(avctx->codec_id));
+    ALOGI("support the codec(%s) disposition(%x)", avcodec_get_name(avctx->codec_id), mFormatCtx->streams[stream_index]->disposition);
 
     unsigned streamType;
     for (size_t i = 0; i < mTracks.size(); ++i) {
@@ -1591,6 +1592,10 @@ static AVCodecContext* getCodecContext(AVFormatContext *ic, AVMediaType codec_ty
         }
 
         avctx = ic->streams[idx]->codec;
+        if (avctx->codec_tag == MKTAG('j', 'p', 'e', 'g')) {
+            // Sometimes the disposition isn't set
+            continue;
+        }
         if (avctx->codec_type == codec_type) {
             return avctx;
         }