Files
platform-external-webrtc/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
Oleh Prypin a1d9ca47f9 Revert "Add ability to specify if rate controller of video encoder is trusted."
This reverts commit 3e335d1423cab06cca8cdb4f1fadb0b16c9e7d38.

Reason for revert: breaks downstream project

Original change's description:
> Add ability to specify if rate controller of video encoder is trusted.
>
> If rate controller is trusted, we disable the frame dropper in the
> media optimization module.
>
> Bug: webrtc:9722
> Change-Id: I821f21fd74a400ee9d5aa3f6b42d4e569033acbe
> Reviewed-on: https://webrtc-review.googlesource.com/c/105020
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Per Kjellander <perkj@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25107}

TBR=brandtr@webrtc.org,ilnik@webrtc.org,nisse@webrtc.org,sprang@webrtc.org,perkj@webrtc.org

Change-Id: Ifdb0aae684894854a184ec1e7423a7c62e7ba237
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9722
Reviewed-on: https://webrtc-review.googlesource.com/c/105360
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25117}
2018-10-11 15:37:40 +00:00

115 lines
3.9 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_ENCODER_H_
#define MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_ENCODER_H_
#include <memory>
#include <vector>
#include "api/video/encoded_image.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/video_encoder.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/video_coding/codecs/vp8/include/temporal_layers_checker.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "modules/video_coding/codecs/vp8/include/vp8_temporal_layers.h"
#include "modules/video_coding/codecs/vp8/libvpx_interface.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
namespace webrtc {
class LibvpxVp8Encoder : public VideoEncoder {
public:
LibvpxVp8Encoder();
explicit LibvpxVp8Encoder(std::unique_ptr<LibvpxInterface> interface);
~LibvpxVp8Encoder() override;
int Release() override;
int InitEncode(const VideoCodec* codec_settings,
int number_of_cores,
size_t max_payload_size) override;
int Encode(const VideoFrame& input_image,
const CodecSpecificInfo* codec_specific_info,
const std::vector<FrameType>* frame_types) override;
int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override;
int SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
int SetRateAllocation(const VideoBitrateAllocation& bitrate,
uint32_t new_framerate) override;
ScalingSettings GetScalingSettings() const override;
const char* ImplementationName() const override;
static vpx_enc_frame_flags_t EncodeFlags(
const TemporalLayers::FrameConfig& references);
private:
void SetupTemporalLayers(const VideoCodec& codec);
// Set the cpu_speed setting for encoder based on resolution and/or platform.
int SetCpuSpeed(int width, int height);
// Determine number of encoder threads to use.
int NumberOfThreads(int width, int height, int number_of_cores);
// Call encoder initialize function and set control settings.
int InitAndSetControlSettings();
void PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
const vpx_codec_cx_pkt& pkt,
int stream_idx,
int encoder_idx,
uint32_t timestamp);
int GetEncodedPartitions(const VideoFrame& input_image);
// Set the stream state for stream |stream_idx|.
void SetStreamState(bool send_stream, int stream_idx);
uint32_t MaxIntraTarget(uint32_t optimal_buffer_size);
uint32_t FrameDropThreshold(size_t spatial_idx) const;
const std::unique_ptr<LibvpxInterface> libvpx_;
const bool use_gf_boost_;
EncodedImageCallback* encoded_complete_callback_;
VideoCodec codec_;
bool inited_;
int64_t timestamp_;
int qp_max_;
int cpu_speed_default_;
int number_of_cores_;
uint32_t rc_max_intra_target_;
std::vector<std::unique_ptr<TemporalLayers>> temporal_layers_;
std::vector<std::unique_ptr<TemporalLayersChecker>> temporal_layers_checkers_;
std::vector<bool> key_frame_request_;
std::vector<bool> send_stream_;
std::vector<int> cpu_speed_;
std::vector<vpx_image_t> raw_images_;
std::vector<EncodedImage> encoded_images_;
std::vector<vpx_codec_ctx_t> encoders_;
std::vector<vpx_codec_enc_cfg_t> configurations_;
std::vector<vpx_rational_t> downsampling_factors_;
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_ENCODER_H_