Skip to content

Commit

Permalink
default is cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Nov 17, 2021
1 parent 07459e0 commit 1c3c508
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions selfdrive/ui/replay/framereader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ FrameReader::~FrameReader() {
}
}

bool FrameReader::load(const std::string &url, AVHWDeviceType hw_device_type, std::atomic<bool> *abort) {
bool FrameReader::load(const std::string &url, bool no_cuda, std::atomic<bool> *abort) {
std::string content = read(url, abort);
if (content.empty()) return false;

Expand Down Expand Up @@ -85,8 +85,8 @@ bool FrameReader::load(const std::string &url, AVHWDeviceType hw_device_type, st
width = (decoder_ctx->width + 3) & ~3;
height = decoder_ctx->height;

if (hw_device_type != AV_HWDEVICE_TYPE_NONE) {
if (!initHardwareDecoder(hw_device_type)) {
if (!no_cuda) {
if (!initHardwareDecoder(AV_HWDEVICE_TYPE_CUDA)) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/replay/framereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FrameReader : protected FileReader {
public:
FrameReader(bool local_cache = false, int chunk_size = -1, int retries = 0);
~FrameReader();
bool load(const std::string &url, AVHWDeviceType hw_device_type = AV_HWDEVICE_TYPE_NONE, std::atomic<bool> *abort = nullptr);
bool load(const std::string &url, bool no_cuda = false, 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; }
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/replay/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) {
{"no-cache", REPLAY_FLAG_NO_FILE_CACHE, "turn off local cache"},
{"qcam", REPLAY_FLAG_QCAMERA, "load qcamera"},
{"yuv", REPLAY_FLAG_SEND_YUV, "send yuv frame"},
{"cuda", REPLAY_FLAG_CUDA, "enable CUDA accelerated decoding"},
{"no-cuda", REPLAY_FLAG_NO_CUDA, "disable CUDA"},
};

QCommandLineParser parser;
Expand Down
3 changes: 0 additions & 3 deletions selfdrive/ui/replay/replay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ Replay::Replay(QString route, QStringList allow, QStringList block, SubMaster *s
}
}
qDebug() << "services " << s;
if (flags & REPLAY_FLAG_CUDA) {
qInfo() << "decode frames with CUDA";
}

if (sm == nullptr) {
pm = new PubMaster(s);
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/replay/replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enum REPLAY_FLAGS {
REPLAY_FLAG_NO_FILE_CACHE = 0x0020,
REPLAY_FLAG_QCAMERA = 0x0040,
REPLAY_FLAG_SEND_YUV = 0x0080,
REPLAY_FLAG_CUDA = 0x0100,
REPLAY_FLAG_NO_CUDA = 0x0100,
};

class Replay : public QObject {
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/ui/replay/route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ void Segment::loadFile(int id, const std::string file) {
bool success = false;
if (id < MAX_CAMERAS) {
frames[id] = std::make_unique<FrameReader>(local_cache, 20 * 1024 * 1024, 3);

AVHWDeviceType hw_device_type = flags & REPLAY_FLAG_CUDA ? AV_HWDEVICE_TYPE_CUDA : AV_HWDEVICE_TYPE_NONE;
success = frames[id]->load(file, hw_device_type, &abort_);
success = frames[id]->load(file, flags & REPLAY_FLAG_NO_CUDA, &abort_);
} else {
log = std::make_unique<LogReader>(local_cache, -1, 3);
success = log->load(file, &abort_);
Expand Down

0 comments on commit 1c3c508

Please sign in to comment.