Add simple_encode.cc/h
Change-Id: I6dff1bda4bea760a32c2f8e38773e5913c830204
This commit is contained in:
27
vp9/simple_encode.cc
Normal file
27
vp9/simple_encode.cc
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "vp9/common/vp9_onyxc_int.h"
|
||||
#include "vp9/encoder/vp9_encoder.h"
|
||||
#include "vp9/simple_encode.h"
|
||||
#include "vp9/vp9_cx_iface.h"
|
||||
|
||||
class SimpleEncode::impl {
|
||||
public:
|
||||
VP9_COMP *cpi;
|
||||
BufferPool *buffer_pool;
|
||||
};
|
||||
|
||||
SimpleEncode::SimpleEncode(int frame_width, int frame_height,
|
||||
vpx_rational_t frame_rate, int target_bitrate)
|
||||
: pimpl{ std::unique_ptr<impl>(new impl()) } {
|
||||
VP9EncoderConfig oxcf = vp9_get_encoder_config(
|
||||
frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
|
||||
pimpl->buffer_pool = (BufferPool *)vpx_calloc(1, sizeof(*pimpl->buffer_pool));
|
||||
vp9_initialize_enc();
|
||||
pimpl->cpi = vp9_create_compressor(&oxcf, pimpl->buffer_pool);
|
||||
vp9_update_compressor_with_img_fmt(pimpl->cpi, VPX_IMG_FMT_I420);
|
||||
}
|
||||
|
||||
SimpleEncode::~SimpleEncode() {
|
||||
vpx_free(pimpl->buffer_pool);
|
||||
vp9_remove_compressor(pimpl->cpi);
|
||||
pimpl->cpi = nullptr;
|
||||
}
|
||||
13
vp9/simple_encode.h
Normal file
13
vp9/simple_encode.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <memory>
|
||||
class SimpleEncode {
|
||||
public:
|
||||
SimpleEncode(int frame_width, int frame_height, vpx_rational_t frame_rate,
|
||||
int target_bitrate);
|
||||
~SimpleEncode();
|
||||
SimpleEncode(SimpleEncode &&) = delete;
|
||||
SimpleEncode &operator=(SimpleEncode &&) = delete;
|
||||
|
||||
private:
|
||||
class impl;
|
||||
std::unique_ptr<impl> pimpl;
|
||||
};
|
||||
@@ -18,6 +18,9 @@ VP9_CX_SRCS_REMOVE-no += $(VP9_COMMON_SRCS_REMOVE-no)
|
||||
VP9_CX_SRCS-yes += vp9_cx_iface.c
|
||||
VP9_CX_SRCS-yes += vp9_cx_iface.h
|
||||
|
||||
VP9_CX_SRCS-$(CONFIG_RATE_CTRL) += simple_encode.cc
|
||||
VP9_CX_SRCS-$(CONFIG_RATE_CTRL) += simple_encode.h
|
||||
|
||||
VP9_CX_SRCS-yes += encoder/vp9_bitstream.c
|
||||
VP9_CX_SRCS-yes += encoder/vp9_context_tree.c
|
||||
VP9_CX_SRCS-yes += encoder/vp9_context_tree.h
|
||||
|
||||
Reference in New Issue
Block a user