mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-15 14:50:39 +01:00

WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
206 lines
7.8 KiB
C++
206 lines
7.8 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.
|
|
*/
|
|
|
|
#include "modules/video_coding/codecs/vp8/libvpx_interface.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
namespace webrtc {
|
|
namespace {
|
|
class LibvpxVp8Facade : public LibvpxInterface {
|
|
public:
|
|
LibvpxVp8Facade() = default;
|
|
~LibvpxVp8Facade() override = default;
|
|
|
|
vpx_image_t* img_alloc(vpx_image_t* img,
|
|
vpx_img_fmt_t fmt,
|
|
unsigned int d_w,
|
|
unsigned int d_h,
|
|
unsigned int align) const override {
|
|
return ::vpx_img_alloc(img, fmt, d_w, d_h, align);
|
|
}
|
|
|
|
vpx_image_t* img_wrap(vpx_image_t* img,
|
|
vpx_img_fmt_t fmt,
|
|
unsigned int d_w,
|
|
unsigned int d_h,
|
|
unsigned int stride_align,
|
|
unsigned char* img_data) const override {
|
|
return ::vpx_img_wrap(img, fmt, d_w, d_h, stride_align, img_data);
|
|
}
|
|
|
|
void img_free(vpx_image_t* img) const override { ::vpx_img_free(img); }
|
|
|
|
vpx_codec_err_t codec_enc_config_set(
|
|
vpx_codec_ctx_t* ctx,
|
|
const vpx_codec_enc_cfg_t* cfg) const override {
|
|
return ::vpx_codec_enc_config_set(ctx, cfg);
|
|
}
|
|
|
|
vpx_codec_err_t codec_enc_config_default(vpx_codec_iface_t* iface,
|
|
vpx_codec_enc_cfg_t* cfg,
|
|
unsigned int usage) const override {
|
|
return ::vpx_codec_enc_config_default(iface, cfg, usage);
|
|
}
|
|
|
|
vpx_codec_err_t codec_enc_init(vpx_codec_ctx_t* ctx,
|
|
vpx_codec_iface_t* iface,
|
|
const vpx_codec_enc_cfg_t* cfg,
|
|
vpx_codec_flags_t flags) const override {
|
|
return ::vpx_codec_enc_init(ctx, iface, cfg, flags);
|
|
}
|
|
|
|
vpx_codec_err_t codec_enc_init_multi(vpx_codec_ctx_t* ctx,
|
|
vpx_codec_iface_t* iface,
|
|
vpx_codec_enc_cfg_t* cfg,
|
|
int num_enc,
|
|
vpx_codec_flags_t flags,
|
|
vpx_rational_t* dsf) const override {
|
|
return ::vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf);
|
|
}
|
|
|
|
vpx_codec_err_t codec_destroy(vpx_codec_ctx_t* ctx) const override {
|
|
return ::vpx_codec_destroy(ctx);
|
|
}
|
|
|
|
// For types related to these parameters, see section
|
|
// "VP8 encoder control function parameter type" in vpx/vp8cx.h.
|
|
|
|
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
|
|
vp8e_enc_control_id ctrl_id,
|
|
uint32_t param) const override {
|
|
// We need an explicit call for each type since vpx_codec_control is a
|
|
// macro that gets expanded into another call based on the parameter name.
|
|
switch (ctrl_id) {
|
|
case VP8E_SET_ENABLEAUTOALTREF:
|
|
return vpx_codec_control(ctx, VP8E_SET_ENABLEAUTOALTREF, param);
|
|
case VP8E_SET_NOISE_SENSITIVITY:
|
|
return vpx_codec_control(ctx, VP8E_SET_NOISE_SENSITIVITY, param);
|
|
case VP8E_SET_SHARPNESS:
|
|
return vpx_codec_control(ctx, VP8E_SET_SHARPNESS, param);
|
|
case VP8E_SET_STATIC_THRESHOLD:
|
|
return vpx_codec_control(ctx, VP8E_SET_STATIC_THRESHOLD, param);
|
|
case VP8E_SET_ARNR_MAXFRAMES:
|
|
return vpx_codec_control(ctx, VP8E_SET_ARNR_MAXFRAMES, param);
|
|
case VP8E_SET_ARNR_STRENGTH:
|
|
return vpx_codec_control(ctx, VP8E_SET_ARNR_STRENGTH, param);
|
|
case VP8E_SET_ARNR_TYPE:
|
|
RTC_NOTREACHED() << "VP8E_SET_ARNR_TYPE is deprecated.";
|
|
return VPX_CODEC_UNSUP_FEATURE;
|
|
case VP8E_SET_CQ_LEVEL:
|
|
return vpx_codec_control(ctx, VP8E_SET_CQ_LEVEL, param);
|
|
case VP8E_SET_MAX_INTRA_BITRATE_PCT:
|
|
return vpx_codec_control(ctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, param);
|
|
case VP8E_SET_GF_CBR_BOOST_PCT:
|
|
return vpx_codec_control(ctx, VP8E_SET_GF_CBR_BOOST_PCT, param);
|
|
case VP8E_SET_SCREEN_CONTENT_MODE:
|
|
return vpx_codec_control(ctx, VP8E_SET_SCREEN_CONTENT_MODE, param);
|
|
default:
|
|
RTC_NOTREACHED() << "Unsupported libvpx ctrl_id: " << ctrl_id;
|
|
}
|
|
return VPX_CODEC_ERROR;
|
|
}
|
|
|
|
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
|
|
vp8e_enc_control_id ctrl_id,
|
|
int param) const override {
|
|
switch (ctrl_id) {
|
|
case VP8E_SET_FRAME_FLAGS:
|
|
return vpx_codec_control(ctx, VP8E_SET_FRAME_FLAGS, param);
|
|
case VP8E_SET_TEMPORAL_LAYER_ID:
|
|
return vpx_codec_control(ctx, VP8E_SET_TEMPORAL_LAYER_ID, param);
|
|
case VP8E_SET_CPUUSED:
|
|
return vpx_codec_control(ctx, VP8E_SET_CPUUSED, param);
|
|
case VP8E_SET_TOKEN_PARTITIONS:
|
|
return vpx_codec_control(ctx, VP8E_SET_TOKEN_PARTITIONS, param);
|
|
case VP8E_SET_TUNING:
|
|
return vpx_codec_control(ctx, VP8E_SET_TUNING, param);
|
|
|
|
default:
|
|
RTC_NOTREACHED() << "Unsupported libvpx ctrl_id: " << ctrl_id;
|
|
}
|
|
return VPX_CODEC_ERROR;
|
|
}
|
|
|
|
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
|
|
vp8e_enc_control_id ctrl_id,
|
|
int* param) const override {
|
|
switch (ctrl_id) {
|
|
case VP8E_GET_LAST_QUANTIZER:
|
|
return vpx_codec_control(ctx, VP8E_GET_LAST_QUANTIZER, param);
|
|
case VP8E_GET_LAST_QUANTIZER_64:
|
|
return vpx_codec_control(ctx, VP8E_GET_LAST_QUANTIZER_64, param);
|
|
default:
|
|
RTC_NOTREACHED() << "Unsupported libvpx ctrl_id: " << ctrl_id;
|
|
}
|
|
return VPX_CODEC_ERROR;
|
|
}
|
|
|
|
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
|
|
vp8e_enc_control_id ctrl_id,
|
|
vpx_roi_map* param) const override {
|
|
switch (ctrl_id) {
|
|
case VP8E_SET_ROI_MAP:
|
|
return vpx_codec_control(ctx, VP8E_SET_ROI_MAP, param);
|
|
default:
|
|
RTC_NOTREACHED() << "Unsupported libvpx ctrl_id: " << ctrl_id;
|
|
}
|
|
return VPX_CODEC_ERROR;
|
|
}
|
|
|
|
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
|
|
vp8e_enc_control_id ctrl_id,
|
|
vpx_active_map* param) const override {
|
|
switch (ctrl_id) {
|
|
case VP8E_SET_ACTIVEMAP:
|
|
return vpx_codec_control(ctx, VP8E_SET_ACTIVEMAP, param);
|
|
default:
|
|
RTC_NOTREACHED() << "Unsupported libvpx ctrl_id: " << ctrl_id;
|
|
}
|
|
return VPX_CODEC_ERROR;
|
|
}
|
|
|
|
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
|
|
vp8e_enc_control_id ctrl_id,
|
|
vpx_scaling_mode* param) const override {
|
|
switch (ctrl_id) {
|
|
case VP8E_SET_SCALEMODE:
|
|
return vpx_codec_control(ctx, VP8E_SET_SCALEMODE, param);
|
|
default:
|
|
RTC_NOTREACHED() << "Unsupported libvpx ctrl_id: " << ctrl_id;
|
|
}
|
|
return VPX_CODEC_ERROR;
|
|
}
|
|
|
|
vpx_codec_err_t codec_encode(vpx_codec_ctx_t* ctx,
|
|
const vpx_image_t* img,
|
|
vpx_codec_pts_t pts,
|
|
uint64_t duration,
|
|
vpx_enc_frame_flags_t flags,
|
|
uint64_t deadline) const override {
|
|
return ::vpx_codec_encode(ctx, img, pts, duration, flags, deadline);
|
|
}
|
|
|
|
const vpx_codec_cx_pkt_t* codec_get_cx_data(
|
|
vpx_codec_ctx_t* ctx,
|
|
vpx_codec_iter_t* iter) const override {
|
|
return ::vpx_codec_get_cx_data(ctx, iter);
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
std::unique_ptr<LibvpxInterface> LibvpxInterface::CreateEncoder() {
|
|
return std::make_unique<LibvpxVp8Facade>();
|
|
}
|
|
|
|
} // namespace webrtc
|