Rr/video dec mem sample update (#390)

* remove hardcoded buffer size requirement

* minor change

[ROCm/rocdecode commit: 84c1dc9d03]
This commit is contained in:
Rajy Rawther
2024-07-22 05:48:29 -07:00
committed by GitHub
parent c3f2e95f92
commit 4caf46cab4
2 changed files with 7 additions and 7 deletions
@@ -49,11 +49,7 @@ public:
fp_in_.seekg (0, fp_in_.end);
int length = fp_in_.tellg();
fp_in_.seekg (0, fp_in_.beg);
if (length > (100 * 1024 * 1024)) { // avioc_buffer_size = 100 * 1024 * 1024 in video_demuxer.h
std::cerr << "This app supports only file sizes upto 100MB! Please use a smaller file." << std::endl;
exit(-1);
}
io_buffer_size_ = length;
}
~FileStreamProvider() {
fp_in_.close();
@@ -63,9 +59,11 @@ public:
// We read a file for this example. You may get your data from network or somewhere else
return static_cast<int>(fp_in_.read(reinterpret_cast<char*>(p_buf), n_buf).gcount());
}
size_t GetBufferSize() { return io_buffer_size_; };
private:
std::ifstream fp_in_;
size_t io_buffer_size_;
};
void ShowHelpAndExit(const char *option = NULL) {
+4 -2
View File
@@ -32,6 +32,7 @@ extern "C" {
}
#include "rocdecode.h"
/*!
* \file
* \brief The AMD Video Demuxer for rocDecode Library.
@@ -125,6 +126,7 @@ class VideoDemuxer {
public:
virtual ~StreamProvider() {}
virtual int GetData(uint8_t *buf, int buf_size) = 0;
virtual size_t GetBufferSize() = 0;
};
AVCodecID GetCodecID() { return av_video_codec_id_; };
VideoDemuxer(const char *input_file_path) : VideoDemuxer(CreateFmtContextUtil(input_file_path)) {}
@@ -503,14 +505,14 @@ class VideoDemuxer {
return nullptr;
}
uint8_t *avioc_buffer = nullptr;
int avioc_buffer_size = 100 * 1024 * 1024;
int avioc_buffer_size = stream_provider->GetBufferSize();
avioc_buffer = (uint8_t *)av_malloc(avioc_buffer_size);
if (!avioc_buffer) {
std::cerr << "ERROR: av_malloc failed!" << std::endl;
return nullptr;
}
av_io_ctx_ = avio_alloc_context(avioc_buffer, avioc_buffer_size,
0, stream_provider, &ReadPacket, nullptr, nullptr);
0, stream_provider, &ReadPacket, nullptr, nullptr);
if (!av_io_ctx_) {
std::cerr << "ERROR: avio_alloc_context failed!" << std::endl;
return nullptr;