[FFmpeg-devel] [PATCH] avcodec/mediacodecdec: Do not abort when H264/HEVC extradata extraction fails

sfan5 sfan5 at live.de
Mon Jan 25 19:38:36 EET 2021


Although rare, extradata can be present but empty and extraction will fail.
However Android also supports passing codec-specific data inline and
will likely play such a stream anyway. So there's no reason to abort
initialization before we know for sure.
---
  libavcodec/mediacodecdec.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index ac1725e466..67adefb530 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -167,8 +167,8 @@ static int h264_set_extradata(AVCodecContext *avctx, 
FFAMediaFormat *format)
          ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, 
data_size);
          av_freep(&data);
      } else {
-        av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from 
extradata");
-        ret = AVERROR_INVALIDDATA;
+        av_log(avctx, AV_LOG_WARNING, "Could not extract PPS/SPS from 
extradata\n");
+        ret = 0;
      }
   done:
@@ -254,8 +254,8 @@ static int hevc_set_extradata(AVCodecContext *avctx, 
FFAMediaFormat *format)
           av_freep(&data);
      } else {
-        av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from 
extradata");
-        ret = AVERROR_INVALIDDATA;
+        av_log(avctx, AV_LOG_WARNING, "Could not extract VPS/PPS/SPS 
from extradata\n");
+        ret = 0;
      }
   done:
-- 
2.30.0



More information about the ffmpeg-devel mailing list