mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-08 12:34:59 +08:00
* initial codex * remove ISP delay from encode ms * try something simpler * not allowing increase bug * decrease bitrate increase rate * upsample only on consecutive good checks * rearrange * clean * Revert frame timing processing time change * clean * remove bitrate option and just do it on --stream * make set_bitrate a lot more simple * clean default impl * further cleaning * struct for bitrate to pass ci * refactor a bit * add comment * small clean * add init() * increase bitrate * update ffmpeg message * remove unnecessary include * modify set_bitrate * change to Param * remove getInt helper; add back in diff pr * reword unclear error message * move webrtcd change to new branch
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
|
|
// has to be in this order
|
|
#ifdef __linux__
|
|
#include <linux/v4l2-controls.h>
|
|
#include <linux/videodev2.h>
|
|
#else
|
|
#define V4L2_BUF_FLAG_KEYFRAME 8
|
|
#endif
|
|
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
#include "cereal/messaging/messaging.h"
|
|
#include "msgq/visionipc/visionipc.h"
|
|
#include "common/queue.h"
|
|
#include "system/loggerd/loggerd.h"
|
|
|
|
class VideoEncoder {
|
|
public:
|
|
VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height);
|
|
virtual ~VideoEncoder() {}
|
|
virtual int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra) = 0;
|
|
virtual void encoder_open() = 0;
|
|
virtual void encoder_close() = 0;
|
|
virtual void set_bitrate(int bitrate) = 0;
|
|
|
|
void publisher_publish(int segment_num, uint32_t idx, VisionIpcBufExtra &extra, unsigned int flags, kj::ArrayPtr<capnp::byte> header, kj::ArrayPtr<capnp::byte> dat);
|
|
|
|
protected:
|
|
int in_width, in_height;
|
|
int out_width, out_height;
|
|
const EncoderInfo encoder_info;
|
|
|
|
private:
|
|
// total frames encoded
|
|
int cnt = 0;
|
|
std::unique_ptr<PubMaster> pm;
|
|
std::vector<capnp::byte> msg_cache;
|
|
};
|