]> git.pld-linux.org Git - packages/mediastreamer-plugin-msopenh264.git/commitdiff
- added b64-refactor patch from git; release 2 (mediastreamer 5.3.x) master auto/th/mediastreamer-plugin-msopenh264-5.2.0-2
authorJakub Bogusz <qboosh@pld-linux.org>
Sun, 7 Apr 2024 11:59:30 +0000 (13:59 +0200)
committerJakub Bogusz <qboosh@pld-linux.org>
Sun, 7 Apr 2024 11:59:30 +0000 (13:59 +0200)
mediastreamer-plugin-msopenh264.spec
msopenh264-b64-refactor.patch [new file with mode: 0644]

index 7c9f57b7516cd98d30ae35cff96131036ec29917..f0295a3ba4e6672c0d1318d6c72e85f10227d8e9 100644 (file)
@@ -2,13 +2,14 @@ Summary:      H.264 video codec for mediastreamer based on the openh264 library
 Summary(pl.UTF-8):     Kodek obrazu H.264 dla mediastreamera oparty na bibliotece openh264
 Name:          mediastreamer-plugin-msopenh264
 Version:       5.2.0
-Release:       1
+Release:       2
 License:       GPL v2+
 Group:         Libraries
 #Source0Download: https://gitlab.linphone.org/BC/public/msopenh264/-/tags
 Source0:       https://gitlab.linphone.org/BC/public/msopenh264/-/archive/%{version}/msopenh264-%{version}.tar.bz2
 # Source0-md5: f854bfa3db3244b388571c2359a895ee
-URL:           https://www.linphone.org/technical-corner/mediastreamer2/overview
+Patch0:                msopenh264-b64-refactor.patch
+URL:           https://www.linphone.org/technical-corner/mediastreamer2-ortp
 BuildRequires: autoconf >= 2.50
 BuildRequires: automake
 BuildRequires: mediastreamer-devel >= 5
@@ -30,6 +31,7 @@ opartÄ… na bibliotece openh264.
 
 %prep
 %setup -q -n msopenh264-%{version}
+%patch0 -p1
 
 %build
 %{__libtoolize}
diff --git a/msopenh264-b64-refactor.patch b/msopenh264-b64-refactor.patch
new file mode 100644 (file)
index 0000000..77a352d
--- /dev/null
@@ -0,0 +1,732 @@
+From a7c4a130a1fd0a2d1f18df748d370430cfbe936a Mon Sep 17 00:00:00 2001
+From: Clemence Him <clemence.him@belledonne-communications.com>
+Date: Fri, 22 Sep 2023 14:26:40 +0200
+Subject: [PATCH] Base64 functions refactoring
+
+---
+ src/msopenh264dec.cpp | 575 +++++++++++++++++++++---------------------
+ src/msopenh264dec.h   |  73 +++---
+ 2 files changed, 321 insertions(+), 327 deletions(-)
+
+diff --git a/src/msopenh264dec.cpp b/src/msopenh264dec.cpp
+index a8fa6f0..819f225 100644
+--- a/src/msopenh264dec.cpp
++++ b/src/msopenh264dec.cpp
+@@ -17,338 +17,333 @@ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+-
+ #include "msopenh264dec.h"
++
++#include "bctoolbox/crypto.h"
+ #include "mediastreamer2/msticker.h"
+-#include "ortp/b64.h"
+ #include "wels/codec_ver.h"
+-static void decoder_log(void* context, int level, const char* message){
+-      ms_message("OpenH264 decoder: %s", message);
++static void decoder_log(void *context, int level, const char *message) {
++  ms_message("OpenH264 decoder: %s", message);
+ }
+ MSOpenH264Decoder::MSOpenH264Decoder(MSFilter *f)
+-      : mFilter(f), mDecoder(0), mUnpacker(0), mSPS(0), mPPS(0), mYUVMsg(0),
+-      mBitstream(0), mBitstreamSize(65536), mLastErrorReportTime(0),
+-      mWidth(MS_VIDEO_SIZE_UNKNOWN_W), mHeight(MS_VIDEO_SIZE_UNKNOWN_H),
+-      mInitialized(false), mFirstImageDecoded(false)
+-{
+-      long ret = WelsCreateDecoder(&mDecoder);
+-      if (ret != 0) {
+-              ms_error("OpenH264 decoder: Failed to create decoder: %li", ret);
+-      } else {
+-              mBitstream = static_cast<uint8_t *>(ms_malloc0(mBitstreamSize));
+-              WelsTraceCallback cb = &decoder_log;
+-              mDecoder->SetOption(DECODER_OPTION_TRACE_CALLBACK, (void*)&cb);
+-              int logLevel = WELS_LOG_WARNING;
+-              mDecoder->SetOption(DECODER_OPTION_TRACE_LEVEL, &logLevel);
+-      }
++    : mFilter(f), mDecoder(0), mUnpacker(0), mSPS(0), mPPS(0), mYUVMsg(0),
++      mBitstream(0), mBitstreamSize(65536), mLastErrorReportTime(0),
++      mWidth(MS_VIDEO_SIZE_UNKNOWN_W), mHeight(MS_VIDEO_SIZE_UNKNOWN_H),
++      mInitialized(false), mFirstImageDecoded(false) {
++  long ret = WelsCreateDecoder(&mDecoder);
++  if (ret != 0) {
++    ms_error("OpenH264 decoder: Failed to create decoder: %li", ret);
++  } else {
++    mBitstream = static_cast<uint8_t *>(ms_malloc0(mBitstreamSize));
++    WelsTraceCallback cb = &decoder_log;
++    mDecoder->SetOption(DECODER_OPTION_TRACE_CALLBACK, (void *)&cb);
++    int logLevel = WELS_LOG_WARNING;
++    mDecoder->SetOption(DECODER_OPTION_TRACE_LEVEL, &logLevel);
++  }
+ }
+-MSOpenH264Decoder::~MSOpenH264Decoder()
+-{
+-      if (mBitstream != 0) {
+-              ms_free(mBitstream);
+-      }
+-      if (mDecoder != 0) {
+-              WelsDestroyDecoder(mDecoder);
+-      }
++MSOpenH264Decoder::~MSOpenH264Decoder() {
++  if (mBitstream != 0) {
++    ms_free(mBitstream);
++  }
++  if (mDecoder != 0) {
++    WelsDestroyDecoder(mDecoder);
++  }
+ }
+-void MSOpenH264Decoder::initialize()
+-{
+-      if (!mInitialized) {
+-              mFirstImageDecoded = false;
+-              mUnpacker=rfc3984_new_with_factory(mFilter->factory);
+-              if (mDecoder != 0) {
+-                      SDecodingParam params = { 0 };
+-#if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <6)
+-                      params.eOutputColorFormat = videoFormatI420;
++void MSOpenH264Decoder::initialize() {
++  if (!mInitialized) {
++    mFirstImageDecoded = false;
++    mUnpacker = rfc3984_new_with_factory(mFilter->factory);
++    if (mDecoder != 0) {
++      SDecodingParam params = {0};
++#if (OPENH264_MAJOR == 1) && (OPENH264_MINOR < 6)
++      params.eOutputColorFormat = videoFormatI420;
+ #endif
+-                      params.uiTargetDqLayer = (unsigned char) -1;
+-                      params.eEcActiveIdc = ERROR_CON_FRAME_COPY_CROSS_IDR;
+-                      params.sVideoProperty.size = sizeof(params.sVideoProperty);
+-                      params.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
+-                      long ret = mDecoder->Initialize(&params);
+-                      if (ret != 0) {
+-                              ms_error("OpenH264 decoder: Failed to initialize: %li", ret);
+-                      } else {
+-                              ms_average_fps_init(&mFPS, "OpenH264 decoder: FPS=%f");
+-                              mInitialized = true;
+-                      }
+-              }
+-      }
++      params.uiTargetDqLayer = (unsigned char)-1;
++      params.eEcActiveIdc = ERROR_CON_FRAME_COPY_CROSS_IDR;
++      params.sVideoProperty.size = sizeof(params.sVideoProperty);
++      params.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
++      long ret = mDecoder->Initialize(&params);
++      if (ret != 0) {
++        ms_error("OpenH264 decoder: Failed to initialize: %li", ret);
++      } else {
++        ms_average_fps_init(&mFPS, "OpenH264 decoder: FPS=%f");
++        mInitialized = true;
++      }
++    }
++  }
+ }
+-void MSOpenH264Decoder::feed()
+-{
+-      if (!isInitialized()){
+-              ms_error("MSOpenH264Decoder::feed(): not initialized");
+-              ms_queue_flush(mFilter->inputs[0]);
+-              return;
+-      }
+-
+-      MSQueue nalus;
+-      ms_queue_init(&nalus);
+-
+-      mblk_t *im;
+-      bool requestPLI = false;
+-      while ((im = ms_queue_get(mFilter->inputs[0])) != NULL) {
+-              unsigned int ret;
+-              if ((getIDRPicId() == 0) && (mSPS != 0) && (mPPS != 0)) {
+-                      // Push the sps/pps given in sprop-parameter-sets if any
+-                      rfc3984_unpack_out_of_band_sps_pps(mUnpacker, mSPS, mPPS);
+-                      mSPS = NULL;
+-                      mPPS = NULL;
+-              }
+-              ret = rfc3984_unpack2(mUnpacker, im, &nalus);
+-              if (ret & Rfc3984FrameAvailable) {
+-                      void * pData[3] = { 0 };
+-                      SBufferInfo sDstBufInfo = { 0 };
+-                      int len = nalusToFrame(&nalus);
+-                      
+-                      if (ret & Rfc3984FrameCorrupted)
+-                              requestPLI = true;
+-                      
+-                      DECODING_STATE state = mDecoder->DecodeFrame2(mBitstream, len, (uint8_t**)pData, &sDstBufInfo);
+-                      if (state != dsErrorFree) {
+-                              ms_error("OpenH264 decoder: DecodeFrame2 failed: 0x%x", (int)state);
+-                              requestPLI = true;
+-                      }
+-                      if (sDstBufInfo.iBufferStatus == 1) {
+-                              uint8_t * pDst[3] = { 0 };
+-                              pDst[0] = (uint8_t *)pData[0];
+-                              pDst[1] = (uint8_t *)pData[1];
+-                              pDst[2] = (uint8_t *)pData[2];
+-
+-                              // Update video size and (re)allocate YUV buffer if needed
+-                              if ((mWidth != sDstBufInfo.UsrData.sSystemBuffer.iWidth)
+-                                      || (mHeight != sDstBufInfo.UsrData.sSystemBuffer.iHeight)) {
+-                                      if (mYUVMsg) {
+-                                              freemsg(mYUVMsg);
+-                                      }
+-                                      mWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
+-                                      mHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
+-                                      mYUVMsg = ms_yuv_buf_alloc(&mOutbuf, mWidth, mHeight);
+-                                      ms_filter_notify_no_arg(mFilter,MS_FILTER_OUTPUT_FMT_CHANGED);
+-                              }
+-
+-                              // Scale/copy frame to destination mblk_t
+-                              for (int i = 0; i < 3; i++) {
+-                                      uint8_t *dst = mOutbuf.planes[i];
+-                                      uint8_t *src = pDst[i];
+-                                      int h = mHeight >> (( i > 0) ? 1 : 0);
+-
+-                                      for(int j = 0; j < h; j++) {
+-                                              memcpy(dst, src, mOutbuf.strides[i]);
+-                                              dst += mOutbuf.strides[i];
+-                                              src += sDstBufInfo.UsrData.sSystemBuffer.iStride[(i == 0) ? 0 : 1];
+-                                      }
+-                              }
+-                              ms_queue_put(mFilter->outputs[0], dupmsg(mYUVMsg));
+-
+-                              // Update average FPS
+-                              if (ms_average_fps_update(&mFPS, mFilter->ticker->time)) {
+-                                      ms_message("OpenH264 decoder: Frame size: %dx%d", mWidth, mHeight);
+-                              }
+-
+-                              // Notify first decoded image
+-                              if (!mFirstImageDecoded) {
+-                                      mFirstImageDecoded = true;
+-                                      ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
+-                              }
++void MSOpenH264Decoder::feed() {
++  if (!isInitialized()) {
++    ms_error("MSOpenH264Decoder::feed(): not initialized");
++    ms_queue_flush(mFilter->inputs[0]);
++    return;
++  }
++
++  MSQueue nalus;
++  ms_queue_init(&nalus);
++
++  mblk_t *im;
++  bool requestPLI = false;
++  while ((im = ms_queue_get(mFilter->inputs[0])) != NULL) {
++    unsigned int ret;
++    if ((getIDRPicId() == 0) && (mSPS != 0) && (mPPS != 0)) {
++      // Push the sps/pps given in sprop-parameter-sets if any
++      rfc3984_unpack_out_of_band_sps_pps(mUnpacker, mSPS, mPPS);
++      mSPS = NULL;
++      mPPS = NULL;
++    }
++    ret = rfc3984_unpack2(mUnpacker, im, &nalus);
++    if (ret & Rfc3984FrameAvailable) {
++      void *pData[3] = {0};
++      SBufferInfo sDstBufInfo = {0};
++      int len = nalusToFrame(&nalus);
++
++      if (ret & Rfc3984FrameCorrupted)
++        requestPLI = true;
++
++      DECODING_STATE state = mDecoder->DecodeFrame2(
++          mBitstream, len, (uint8_t **)pData, &sDstBufInfo);
++      if (state != dsErrorFree) {
++        ms_error("OpenH264 decoder: DecodeFrame2 failed: 0x%x", (int)state);
++        requestPLI = true;
++      }
++      if (sDstBufInfo.iBufferStatus == 1) {
++        uint8_t *pDst[3] = {0};
++        pDst[0] = (uint8_t *)pData[0];
++        pDst[1] = (uint8_t *)pData[1];
++        pDst[2] = (uint8_t *)pData[2];
++
++        // Update video size and (re)allocate YUV buffer if needed
++        if ((mWidth != sDstBufInfo.UsrData.sSystemBuffer.iWidth) ||
++            (mHeight != sDstBufInfo.UsrData.sSystemBuffer.iHeight)) {
++          if (mYUVMsg) {
++            freemsg(mYUVMsg);
++          }
++          mWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
++          mHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
++          mYUVMsg = ms_yuv_buf_alloc(&mOutbuf, mWidth, mHeight);
++          ms_filter_notify_no_arg(mFilter, MS_FILTER_OUTPUT_FMT_CHANGED);
++        }
++
++        // Scale/copy frame to destination mblk_t
++        for (int i = 0; i < 3; i++) {
++          uint8_t *dst = mOutbuf.planes[i];
++          uint8_t *src = pDst[i];
++          int h = mHeight >> ((i > 0) ? 1 : 0);
++
++          for (int j = 0; j < h; j++) {
++            memcpy(dst, src, mOutbuf.strides[i]);
++            dst += mOutbuf.strides[i];
++            src += sDstBufInfo.UsrData.sSystemBuffer.iStride[(i == 0) ? 0 : 1];
++          }
++        }
++        ms_queue_put(mFilter->outputs[0], dupmsg(mYUVMsg));
++
++        // Update average FPS
++        if (ms_average_fps_update(&mFPS, mFilter->ticker->time)) {
++          ms_message("OpenH264 decoder: Frame size: %dx%d", mWidth, mHeight);
++        }
++
++        // Notify first decoded image
++        if (!mFirstImageDecoded) {
++          mFirstImageDecoded = true;
++          ms_filter_notify_no_arg(mFilter,
++                                  MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
++        }
+ #if MSOPENH264_DEBUG
+-                              ms_message("OpenH264 decoder: IDR pic id: %d, Frame num: %d, Temporal id: %d, VCL NAL: %d", getIDRPicId(), getFrameNum(), getTemporalId(), getVCLNal());
++        ms_message("OpenH264 decoder: IDR pic id: %d, Frame num: %d, Temporal "
++                   "id: %d, VCL NAL: %d",
++                   getIDRPicId(), getFrameNum(), getTemporalId(), getVCLNal());
+ #endif
+-                      }
+-              }
+-      }
+-
+-      if (requestPLI) {
+-              if (mAVPFEnabled){
+-                      ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_SEND_PLI);
+-              }else if (((mFilter->ticker->time - mLastErrorReportTime) > 5000) || (mLastErrorReportTime == 0)) {
+-                      mLastErrorReportTime = mFilter->ticker->time;
+-                      ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_DECODING_ERRORS);
+-              }
+-      }
++      }
++    }
++  }
++
++  if (requestPLI) {
++    if (mAVPFEnabled) {
++      ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_SEND_PLI);
++    } else if (((mFilter->ticker->time - mLastErrorReportTime) > 5000) ||
++               (mLastErrorReportTime == 0)) {
++      mLastErrorReportTime = mFilter->ticker->time;
++      ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_DECODING_ERRORS);
++    }
++  }
+ }
+-void MSOpenH264Decoder::uninitialize()
+-{
+-      if (mSPS != 0) {
+-              freemsg(mSPS);
+-              mSPS=NULL;
+-      }
+-      if (mPPS != 0) {
+-              freemsg(mPPS);
+-              mPPS=NULL;
+-      }
+-      if (mYUVMsg != 0) {
+-              freemsg(mYUVMsg);
+-              mYUVMsg=NULL;
+-      }
+-      if (mDecoder != 0) {
+-              mDecoder->Uninitialize();
+-      }
+-      if (mUnpacker){
+-              rfc3984_destroy(mUnpacker);
+-              mUnpacker=NULL;
+-      }
+-      mInitialized = false;
++void MSOpenH264Decoder::uninitialize() {
++  if (mSPS != 0) {
++    freemsg(mSPS);
++    mSPS = NULL;
++  }
++  if (mPPS != 0) {
++    freemsg(mPPS);
++    mPPS = NULL;
++  }
++  if (mYUVMsg != 0) {
++    freemsg(mYUVMsg);
++    mYUVMsg = NULL;
++  }
++  if (mDecoder != 0) {
++    mDecoder->Uninitialize();
++  }
++  if (mUnpacker) {
++    rfc3984_destroy(mUnpacker);
++    mUnpacker = NULL;
++  }
++  mInitialized = false;
+ }
+-void MSOpenH264Decoder::provideSpropParameterSets(char *value, int valueSize)
+-{
+-      char *b64_sps = value;
+-      char *b64_pps = strchr(value, ',');
+-      if (b64_pps) {
+-              *b64_pps = '\0';
+-              ++b64_pps;
+-              ms_message("OpenH264 decoder: Got sprop-parameter-sets sps=%s, pps=%s", b64_sps, b64_pps);
+-              mSPS = allocb(valueSize, 0);
+-              mSPS->b_wptr += b64::b64_decode(b64_sps, strlen(b64_sps), mSPS->b_wptr, valueSize);
+-              mPPS = allocb(valueSize, 0);
+-              mPPS->b_wptr += b64::b64_decode(b64_pps, strlen(b64_pps), mPPS->b_wptr, valueSize);
+-      }
++void MSOpenH264Decoder::provideSpropParameterSets(char *value,
++                                                  size_t valueSize) {
++  char *b64_sps = value;
++  char *b64_pps = strchr(value, ',');
++  if (b64_pps) {
++    *b64_pps = '\0';
++    ++b64_pps;
++    ms_message("OpenH264 decoder: Got sprop-parameter-sets sps=%s, pps=%s",
++               b64_sps, b64_pps);
++    mSPS = allocb(valueSize, 0);
++    bctbx_base64_decode(mSPS->b_wptr, &valueSize, (unsigned char *)b64_sps,
++                        strlen(b64_sps));
++    mSPS->b_wptr += valueSize;
++    mPPS = allocb(valueSize, 0);
++    bctbx_base64_decode(mPPS->b_wptr, &valueSize, (unsigned char *)b64_pps,
++                        strlen(b64_pps));
++    mPPS->b_wptr += valueSize;
++  }
+ }
+-void MSOpenH264Decoder::resetFirstImageDecoded()
+-{
+-      mFirstImageDecoded = false;
+-      mWidth = MS_VIDEO_SIZE_UNKNOWN_W;
+-      mHeight = MS_VIDEO_SIZE_UNKNOWN_H;
++void MSOpenH264Decoder::resetFirstImageDecoded() {
++  mFirstImageDecoded = false;
++  mWidth = MS_VIDEO_SIZE_UNKNOWN_W;
++  mHeight = MS_VIDEO_SIZE_UNKNOWN_H;
+ }
+-MSVideoSize MSOpenH264Decoder::getSize() const
+-{
+-      MSVideoSize size;
+-      size.width = mWidth;
+-      size.height = mHeight;
+-      return size;
++MSVideoSize MSOpenH264Decoder::getSize() const {
++  MSVideoSize size;
++  size.width = mWidth;
++  size.height = mHeight;
++  return size;
+ }
+-float MSOpenH264Decoder::getFps()const{
+-      return ms_average_fps_get(&mFPS);
+-}
++float MSOpenH264Decoder::getFps() const { return ms_average_fps_get(&mFPS); }
+-const MSFmtDescriptor * MSOpenH264Decoder::getOutFmt()const{
+-      MSVideoSize vsize={mWidth,mHeight};
+-      return ms_factory_get_video_format(mFilter->factory,"YUV420P",vsize,0,NULL);
++const MSFmtDescriptor *MSOpenH264Decoder::getOutFmt() const {
++  MSVideoSize vsize = {mWidth, mHeight};
++  return ms_factory_get_video_format(mFilter->factory, "YUV420P", vsize, 0,
++                                     NULL);
+ }
+-int MSOpenH264Decoder::nalusToFrame(MSQueue *nalus)
+-{
+-      mblk_t *im;
+-      uint8_t *dst = mBitstream;
+-      uint8_t *end = mBitstream + mBitstreamSize;
+-      bool startPicture = true;
+-
+-      while ((im = ms_queue_get(nalus)) != NULL) {
+-              uint8_t *src = im->b_rptr;
+-              int nalLen = im->b_wptr - src;
+-              if ((dst + nalLen + 128) > end) {
+-                      int pos = dst - mBitstream;
+-                      enlargeBitstream(mBitstreamSize + nalLen + 128);
+-                      dst = mBitstream + pos;
+-                      end = mBitstream + mBitstreamSize;
+-              }
+-              if ((src[0] == 0) && (src[1] == 0) && (src[2] == 0) && (src[3] == 1)) {
+-                      // Workaround for stupid RTP H264 sender that includes nal markers
++int MSOpenH264Decoder::nalusToFrame(MSQueue *nalus) {
++  mblk_t *im;
++  uint8_t *dst = mBitstream;
++  uint8_t *end = mBitstream + mBitstreamSize;
++  bool startPicture = true;
++
++  while ((im = ms_queue_get(nalus)) != NULL) {
++    uint8_t *src = im->b_rptr;
++    int nalLen = im->b_wptr - src;
++    if ((dst + nalLen + 128) > end) {
++      int pos = dst - mBitstream;
++      enlargeBitstream(mBitstreamSize + nalLen + 128);
++      dst = mBitstream + pos;
++      end = mBitstream + mBitstreamSize;
++    }
++    if ((src[0] == 0) && (src[1] == 0) && (src[2] == 0) && (src[3] == 1)) {
++      // Workaround for stupid RTP H264 sender that includes nal markers
+ #if MSOPENH264_DEBUG
+-                      ms_warning("OpenH264 decoder: stupid RTP H264 encoder");
++      ms_warning("OpenH264 decoder: stupid RTP H264 encoder");
+ #endif
+-                      int size = im->b_wptr - src;
+-                      memcpy(dst, src, size);
+-                      dst += size;
+-              } else {
+-                      uint8_t naluType = *src & 0x1f;
++      int size = im->b_wptr - src;
++      memcpy(dst, src, size);
++      dst += size;
++    } else {
++      uint8_t naluType = *src & 0x1f;
+ #if MSOPENH264_DEBUG
+-                      if ((naluType != 1) && (naluType != 7) && (naluType != 8)) {
+-                              ms_message("OpenH264 decoder: naluType=%d", naluType);
+-                      }
+-                      if (naluType == 7) {
+-                              ms_message("OpenH264 decoder: Got SPS");
+-                      }
+-                      if (naluType == 8) {
+-                              ms_message("OpenH264 decoder: Got PPS");
+-                      }
++      if ((naluType != 1) && (naluType != 7) && (naluType != 8)) {
++        ms_message("OpenH264 decoder: naluType=%d", naluType);
++      }
++      if (naluType == 7) {
++        ms_message("OpenH264 decoder: Got SPS");
++      }
++      if (naluType == 8) {
++        ms_message("OpenH264 decoder: Got PPS");
++      }
+ #endif
+-                      if (startPicture
+-                              || (naluType == 6) // SEI
+-                              || (naluType == 7) // SPS
+-                              || (naluType == 8) // PPS
+-                              || ((naluType >= 14) && (naluType <= 18))) { // Reserved
+-                              *dst++ = 0;
+-                              startPicture = false;
+-                      }
+-
+-                      // Prepend nal marker
+-                      *dst++ = 0;
+-                      *dst++ = 0;
+-                      *dst++ = 1;
+-                      *dst++ = *src++;
+-                      while (src < (im->b_wptr - 3)) {
+-                              if ((src[0] == 0) && (src[1] == 0) && (src[2] < 3)) {
+-                                      *dst++ = 0;
+-                                      *dst++ = 0;
+-                                      *dst++ = 3;
+-                                      src += 2;
+-                              }
+-                              *dst++ = *src++;
+-                      }
+-                      while (src < im->b_wptr) {
+-                              *dst++ = *src++;
+-                      }
+-              }
+-              freemsg(im);
+-      }
+-      return dst - mBitstream;
++      if (startPicture || (naluType == 6)              // SEI
++          || (naluType == 7)                           // SPS
++          || (naluType == 8)                           // PPS
++          || ((naluType >= 14) && (naluType <= 18))) { // Reserved
++        *dst++ = 0;
++        startPicture = false;
++      }
++
++      // Prepend nal marker
++      *dst++ = 0;
++      *dst++ = 0;
++      *dst++ = 1;
++      *dst++ = *src++;
++      while (src < (im->b_wptr - 3)) {
++        if ((src[0] == 0) && (src[1] == 0) && (src[2] < 3)) {
++          *dst++ = 0;
++          *dst++ = 0;
++          *dst++ = 3;
++          src += 2;
++        }
++        *dst++ = *src++;
++      }
++      while (src < im->b_wptr) {
++        *dst++ = *src++;
++      }
++    }
++    freemsg(im);
++  }
++  return dst - mBitstream;
+ }
+-void MSOpenH264Decoder::enlargeBitstream(int newSize)
+-{
+-      mBitstreamSize = newSize;
+-      mBitstream = static_cast<uint8_t *>(ms_realloc(mBitstream, mBitstreamSize));
++void MSOpenH264Decoder::enlargeBitstream(int newSize) {
++  mBitstreamSize = newSize;
++  mBitstream = static_cast<uint8_t *>(ms_realloc(mBitstream, mBitstreamSize));
+ }
+-int32_t MSOpenH264Decoder::getFrameNum()
+-{
+-      int32_t frameNum = -1;
+-      int ret = mDecoder->GetOption(DECODER_OPTION_FRAME_NUM, &frameNum);
+-      if (ret != 0) {
+-              ms_error("OpenH264 decoder: Failed getting frame number: %d", ret);
+-      }
+-      return frameNum;
++int32_t MSOpenH264Decoder::getFrameNum() {
++  int32_t frameNum = -1;
++  int ret = mDecoder->GetOption(DECODER_OPTION_FRAME_NUM, &frameNum);
++  if (ret != 0) {
++    ms_error("OpenH264 decoder: Failed getting frame number: %d", ret);
++  }
++  return frameNum;
+ }
+-int32_t MSOpenH264Decoder::getIDRPicId()
+-{
+-      int32_t IDRPicId = -1;
+-      int ret = mDecoder->GetOption(DECODER_OPTION_IDR_PIC_ID, &IDRPicId);
+-      if (ret != 0) {
+-              ms_error("OpenH264 decoder: Failed getting IDR pic id: %d", ret);
+-      }
+-      return IDRPicId;
++int32_t MSOpenH264Decoder::getIDRPicId() {
++  int32_t IDRPicId = -1;
++  int ret = mDecoder->GetOption(DECODER_OPTION_IDR_PIC_ID, &IDRPicId);
++  if (ret != 0) {
++    ms_error("OpenH264 decoder: Failed getting IDR pic id: %d", ret);
++  }
++  return IDRPicId;
+ }
+-int32_t MSOpenH264Decoder::getTemporalId()
+-{
+-      int32_t temporalId = -1;
+-      int ret = mDecoder->GetOption(DECODER_OPTION_TEMPORAL_ID, &temporalId);
+-      if (ret != 0) {
+-              ms_error("OpenH264 decoder: Failed getting temporal id: %d", ret);
+-      }
+-      return temporalId;
++int32_t MSOpenH264Decoder::getTemporalId() {
++  int32_t temporalId = -1;
++  int ret = mDecoder->GetOption(DECODER_OPTION_TEMPORAL_ID, &temporalId);
++  if (ret != 0) {
++    ms_error("OpenH264 decoder: Failed getting temporal id: %d", ret);
++  }
++  return temporalId;
+ }
+-int32_t MSOpenH264Decoder::getVCLNal()
+-{
+-      int32_t vclNal = -1;
+-      int ret = mDecoder->GetOption(DECODER_OPTION_VCL_NAL, &vclNal);
+-      if (ret != 0) {
+-              ms_error("OpenH264 decoder: Failed getting VCL NAL: %d", ret);
+-      }
+-      return vclNal;
++int32_t MSOpenH264Decoder::getVCLNal() {
++  int32_t vclNal = -1;
++  int ret = mDecoder->GetOption(DECODER_OPTION_VCL_NAL, &vclNal);
++  if (ret != 0) {
++    ms_error("OpenH264 decoder: Failed getting VCL NAL: %d", ret);
++  }
++  return vclNal;
+ }
+diff --git a/src/msopenh264dec.h b/src/msopenh264dec.h
+index 9b07e62..ed6ad53 100644
+--- a/src/msopenh264dec.h
++++ b/src/msopenh264dec.h
+@@ -17,50 +17,49 @@ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+-
+ #include "mediastreamer2/msfilter.h"
+ #include "mediastreamer2/msvideo.h"
+ #include "mediastreamer2/rfc3984.h"
+-#include "wels/codec_api.h"
+ #include "msopenh264.h"
+-
++#include "wels/codec_api.h"
+ class MSOpenH264Decoder {
+ public:
+-      MSOpenH264Decoder(MSFilter *f);
+-      virtual ~MSOpenH264Decoder();
+-      bool isInitialized() const { return mInitialized; }
+-      void initialize();
+-      void feed();
+-      void uninitialize();
+-      void provideSpropParameterSets(char *value, int valueSize);
+-      void resetFirstImageDecoded();
+-      void enableAVPF(bool enable) { mAVPFEnabled = enable; }
+-      MSVideoSize getSize() const;
+-      float getFps()const;
+-      const MSFmtDescriptor *getOutFmt()const;
++  MSOpenH264Decoder(MSFilter *f);
++  virtual ~MSOpenH264Decoder();
++  bool isInitialized() const { return mInitialized; }
++  void initialize();
++  void feed();
++  void uninitialize();
++  void provideSpropParameterSets(char *value, size_t valueSize);
++  void resetFirstImageDecoded();
++  void enableAVPF(bool enable) { mAVPFEnabled = enable; }
++  MSVideoSize getSize() const;
++  float getFps() const;
++  const MSFmtDescriptor *getOutFmt() const;
++
+ private:
+-      int nalusToFrame(MSQueue *nalus);
+-      void enlargeBitstream(int newSize);
+-      int32_t getFrameNum();
+-      int32_t getIDRPicId();
+-      int32_t getTemporalId();
+-      int32_t getVCLNal();
++  int nalusToFrame(MSQueue *nalus);
++  void enlargeBitstream(int newSize);
++  int32_t getFrameNum();
++  int32_t getIDRPicId();
++  int32_t getTemporalId();
++  int32_t getVCLNal();
+-      MSFilter *mFilter;
+-      ISVCDecoder *mDecoder;
+-      Rfc3984Context *mUnpacker;
+-      MSPicture mOutbuf;
+-      MSAverageFPS mFPS;
+-      mblk_t *mSPS;
+-      mblk_t *mPPS;
+-      mblk_t *mYUVMsg;
+-      uint8_t *mBitstream;
+-      int mBitstreamSize;
+-      uint64_t mLastErrorReportTime;
+-      int mWidth;
+-      int mHeight;
+-      bool mInitialized;
+-      bool mFirstImageDecoded;
+-      bool mAVPFEnabled;
++  MSFilter *mFilter;
++  ISVCDecoder *mDecoder;
++  Rfc3984Context *mUnpacker;
++  MSPicture mOutbuf;
++  MSAverageFPS mFPS;
++  mblk_t *mSPS;
++  mblk_t *mPPS;
++  mblk_t *mYUVMsg;
++  uint8_t *mBitstream;
++  int mBitstreamSize;
++  uint64_t mLastErrorReportTime;
++  int mWidth;
++  int mHeight;
++  bool mInitialized;
++  bool mFirstImageDecoded;
++  bool mAVPFEnabled;
+ };
+-- 
+GitLab
+
This page took 0.145394 seconds and 4 git commands to generate.