webrtc branch 63版本 ios硬编H264与android和pc不能互通解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tanningzhong/article/details/81302472

问题描述

ios硬编H264不能与android和pc版本互通,android和pc解码时候crash

解决方案

修改modules/video_coding/codecs/h264/h264_decoder_impl.cc文件,匹配ios硬编AV_PIX_FMT_YUVJ420P格式。


修改如下:
@@ -32,7 +32,8 @@

 namespace {

-const AVPixelFormat kPixelFormat = AV_PIX_FMT_YUV420P;
+const AVPixelFormat kPixelFormatDefault = AV_PIX_FMT_YUV420P;
+const AVPixelFormat kPixelFormatFullRange = AV_PIX_FMT_YUVJ420P;
 const size_t kYPlaneIndex = 0;
 const size_t kUPlaneIndex = 1;
 const size_t kVPlaneIndex = 2;
@@ -95,10 +96,13 @@
   H264DecoderImpl* decoder = static_cast<H264DecoderImpl*>(context->opaque);
   // DCHECK values set in |InitDecode|.
   RTC_DCHECK(decoder);
-  RTC_DCHECK_EQ(context->pix_fmt, kPixelFormat);
   // Necessary capability to be allowed to provide our own buffers.
   RTC_DCHECK(context->codec->capabilities | AV_CODEC_CAP_DR1);

+  // Limited or full range YUV420 is expected.
+  RTC_CHECK(context->pix_fmt == kPixelFormatDefault ||
+            context->pix_fmt == kPixelFormatFullRange);
+
   // |av_frame->width| and |av_frame->height| are set by FFmpeg. These are the
   // actual image's dimensions and may be different from |context->width| and
   // |context->coded_width| due to reordering.
@@ -225,7 +229,7 @@
     av_context_->coded_width = codec_settings->width;
     av_context_->coded_height = codec_settings->height;
   }
-  av_context_->pix_fmt = kPixelFormat;
+  av_context_->pix_fmt = kPixelFormatDefault;
   av_context_->extradata = nullptr;
   av_context_->extradata_size = 0;

猜你喜欢

转载自blog.csdn.net/tanningzhong/article/details/81302472