mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-15 01:42:05 +08:00
2b4a477fbc
* no-cache mode * fix test cases build error * space * don't create cache dir in no-cache mode * fix errors in test cases * no_local_cache_ * set the number of connections by chunk_size * use size_t instead of int64_t * add test case for no-cache mode * rename variables * fix SIGSEGV * cleanup * faster decompressBZ2 * always decompress bz2 * add test cases * prepare for python interface * fix test cases build error * continue * camera_replay: cache remote file * protected inheritance * single option name * TODO * test_case for LogReader&FrameReader * fix wrong require * test case for FileReader * cleanup test * test:fix wrong filename * check cached file's checksum * fix mkdir permissions err cleanup filereader * remove initialize libav network libraries. dd * abort all loading if one failed * cleanup tests * use threadpool to limit concurrent downloads * cache more segments * merge 3 segments for replay * one segment uses about 100M of memory * use segments_need_merge.size() * shutdown * fix stuck if exit replay before keyboard thread started * load one segment at a time * small cleanup * cleanup filereader * space * tiny cleanup * merge master * cleanup test cases * use util:create_directories * cleanup framereader
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include "selfdrive/ui/replay/filereader.h"
|
|
|
|
extern "C" {
|
|
#include <libavcodec/avcodec.h>
|
|
#include <libavformat/avformat.h>
|
|
#include <libswscale/swscale.h>
|
|
#include <libavutil/imgutils.h>
|
|
}
|
|
|
|
class FrameReader : protected FileReader {
|
|
public:
|
|
FrameReader(bool local_cache = false, int chunk_size = -1, int retries = 0);
|
|
~FrameReader();
|
|
bool load(const std::string &url, std::atomic<bool> *abort = nullptr);
|
|
bool get(int idx, uint8_t *rgb, uint8_t *yuv);
|
|
int getRGBSize() const { return width * height * 3; }
|
|
int getYUVSize() const { return width * height * 3 / 2; }
|
|
size_t getFrameCount() const { return frames_.size(); }
|
|
bool valid() const { return valid_; }
|
|
|
|
int width = 0, height = 0;
|
|
|
|
private:
|
|
bool decode(int idx, uint8_t *rgb, uint8_t *yuv);
|
|
bool decodeFrame(AVFrame *f, uint8_t *rgb, uint8_t *yuv);
|
|
|
|
struct Frame {
|
|
AVPacket pkt = {};
|
|
int decoded = false;
|
|
bool failed = false;
|
|
};
|
|
std::vector<Frame> frames_;
|
|
SwsContext *rgb_sws_ctx_ = nullptr, *yuv_sws_ctx_ = nullptr;
|
|
AVFrame *av_frame_, *rgb_frame_, *yuv_frame_ = nullptr;
|
|
AVFormatContext *pFormatCtx_ = nullptr;
|
|
AVCodecContext *pCodecCtx_ = nullptr;
|
|
int key_frames_count_ = 0;
|
|
bool valid_ = false;
|
|
AVIOContext *avio_ctx_ = nullptr;
|
|
};
|