Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  FFmpegVideoEncoder.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef DOM_MEDIA_PLATFORMS_FFMPEG_FFMPEGVIDEOENCODER_H_
#define DOM_MEDIA_PLATFORMS_FFMPEG_FFMPEGVIDEOENCODER_H_

#include "FFmpegDataEncoder.h"
#include "FFmpegLibWrapper.h"
#include "PlatformEncoderModule.h"
#include "SimpleMap.h"

// This must be the last header included
#include "FFmpegLibs.h"

#if LIBAVCODEC_VERSION_MAJOR < 60 || defined(MOZ_WIDGET_ANDROID)
#  define MOZ_FFMPEG_ENCODER_USE_DURATION_MAP
#endif

namespace mozilla {

template <int V>
class FFmpegVideoEncoder : public FFmpegDataEncoder<V> {};

template <>
class FFmpegVideoEncoder<LIBAV_VER> final
    : public FFmpegDataEncoder<LIBAV_VER> {
  using PtsMap = SimpleMap<int64_t, int64_t, NoOpPolicy>;

 public:
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FFmpegVideoEncoder, final);

  FFmpegVideoEncoder(const FFmpegLibWrapper* aLib, AVCodecID aCodecID,
                     const RefPtr<TaskQueue>& aTaskQueue,
                     const EncoderConfig& aConfig);

  RefPtr<InitPromise> Init() override;

  nsCString GetDescriptionName() const override;

  bool IsHardwareAccelerated(nsACString& aFailureReason) const override {
    return mIsHardwareAccelerated;
  }

 protected:
  virtual ~FFmpegVideoEncoder() = default;
  // Methods only called on mTaskQueue.
  virtual MediaResult InitEncoder() override;
  bool ShouldTryHardware() const;
  MediaResult InitEncoderInternal(bool aHardware);
#if LIBAVCODEC_VERSION_MAJOR >= 58
  Result<EncodedData, MediaResult> EncodeInputWithModernAPIs(
      RefPtr<const MediaData> aSample) override;
#endif
  virtual Result<RefPtr<MediaRawData>, MediaResult> ToMediaRawData(
      AVPacket* aPacket) override;
  Result<already_AddRefed<MediaByteBuffer>, MediaResult> GetExtraData(
      AVPacket* aPacket) override;
  struct SVCSettings {
    nsTArray<uint8_t> mTemporalLayerIds;
    // A key-value pair for av_opt_set.
    std::pair<nsCString, nsCString> mSettingKeyValue;
  };
  bool SvcEnabled() const;
  Maybe<SVCSettings> GetSVCSettings();
  struct H264Settings {
    int mProfile;
    int mLevel;
    // A list of key-value pairs for av_opt_set.
    nsTArray<std::pair<nsCString, nsCString>> mSettingKeyValuePairs;
  };
  H264Settings GetH264Settings(const H264Specific& aH264Specific);
  struct SVCInfo {
    explicit SVCInfo(nsTArray<uint8_t>&& aTemporalLayerIds)
        : mTemporalLayerIds(std::move(aTemporalLayerIds)), mCurrentIndex(0) {}
    const nsTArray<uint8_t> mTemporalLayerIds;
    size_t mCurrentIndex;
    void UpdateTemporalLayerId();
    void ResetTemporalLayerId();
    uint8_t CurrentTemporalLayerId();
  };
  Maybe<SVCInfo> mSVCInfo{};
  // Can be accessed on any thread, but only written on during init.
  Atomic<bool> mIsHardwareAccelerated{false};
#ifdef MOZ_FFMPEG_ENCODER_USE_DURATION_MAP
  bool mUseDurationMap = false;
#endif
  // Some codecs use the input frames pts for rate control. We'd rather only use
  // the duration. Synthetize fake pts based on integrating over the duration of
  // input frames.
  int64_t mFakePts = 0;
  int64_t mCurrentFramePts = 0;
  PtsMap mPtsMap;
  RefPtr<MediaByteBuffer> mLastExtraData;
};

}  // namespace mozilla

#endif  // DOM_MEDIA_PLATFORMS_FFMPEG_FFMPEGVIDEOENCODER_H_

Messung V0.5 in Prozent
C=91 H=98 G=94

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002