Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using MD5 functionality from its new MD5 class #140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Full documentation for for rocPyDecode is available at [https://rocm.docs.amd.co
### Changed

* AMD Clang is now the default CXX and C compiler.
* MD5 code moved in rocDecode to a separate class provider under utilities. This move is transparent to rocPyDecode.

### Removed

Expand Down
27 changes: 26 additions & 1 deletion src/roc_pyvideodecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ int PyReconfigureFlushCallback(void *p_viddec_obj, uint32_t flush_mode, void * p
}
} else if (flush_mode == ReconfigFlushMode::RECONFIG_FLUSH_MODE_CALCULATE_MD5) {
#if MD5_MOVED_CHECK
ReconfigDumpFileStruct *p_dump_file_struct = static_cast<ReconfigDumpFileStruct *>(p_user_struct);
if (p_dump_file_struct) {
if (p_dump_file_struct->md5_generator_handle) {
MD5Generator *md5_generator = static_cast<MD5Generator *>(p_dump_file_struct->md5_generator_handle);
md5_generator->UpdateMd5ForFrame(pframe, surf_info);
}
}
#else
viddec->UpdateMd5ForFrame(pframe, surf_info);
#endif
Expand All @@ -99,6 +106,11 @@ py::object PyRocVideoDecoder::PySetReconfigParams(int flush_mode, std::string& o
if(!output_file_name_in.empty()) {
PyReconfigDumpFileStruct.output_file_name = output_file_name_in;
PyReconfigDumpFileStruct.b_dump_frames_to_file = true;
#if MD5_MOVED_CHECK
if(!md5_generator)
PyInitMd5();
PyReconfigDumpFileStruct.md5_generator_handle = static_cast<void*>(md5_generator);
#endif
} else {
if(mode == RECONFIG_FLUSH_MODE_DUMP_TO_FILE)
mode = RECONFIG_FLUSH_MODE_NONE;
Expand Down Expand Up @@ -384,6 +396,10 @@ uintptr_t PyRocVideoDecoder::PyGetOutputSurfaceInfo() {
// for python binding
py::object PyRocVideoDecoder::PyInitMd5() {
#if MD5_MOVED_CHECK
if (!md5_generator) {
md5_generator = new MD5Generator();
}
md5_generator->InitMd5();
#else
InitMd5();
#endif
Expand All @@ -392,17 +408,26 @@ py::object PyRocVideoDecoder::PyInitMd5() {

// for python binding
py::object PyRocVideoDecoder::PyUpdateMd5ForFrame(uintptr_t& surf_mem, uintptr_t& surface_info) {
if(surface_info && surf_mem) {
#if MD5_MOVED_CHECK
if(md5_generator) {
md5_generator->UpdateMd5ForFrame((void *)surf_mem, reinterpret_cast<OutputSurfaceInfo*>(surface_info));
}
#else
if(surface_info && surf_mem)
UpdateMd5ForFrame((void *)surf_mem, reinterpret_cast<OutputSurfaceInfo*>(surface_info));
#endif
}
return py::cast<py::none>(Py_None);
}

// for python binding
py::object PyRocVideoDecoder::PyFinalizeMd5(uintptr_t& digest_back) {
#if MD5_MOVED_CHECK
if(md5_generator) {
uint8_t * digest;
md5_generator->FinalizeMd5(&digest);
memcpy(reinterpret_cast<uint8_t*>(digest_back), digest, sizeof(uint8_t) * 16);
}
#else
uint8_t * digest;
FinalizeMd5(&digest);
Expand Down
9 changes: 9 additions & 0 deletions src/roc_pyvideodecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ THE SOFTWARE.
#include "roc_video_dec.h"
#include "roc_pydecode.h"
#include "video_post_process.h"
#ifdef MD5_MOVED_CHECK
#include "md5.h"
#endif

typedef enum ReconfigFlushMode_enum {
RECONFIG_FLUSH_MODE_NONE = 0, /**< Just flush to get the frame count */
Expand All @@ -36,6 +39,9 @@ typedef enum ReconfigFlushMode_enum {
typedef struct ReconfigDumpFileStruct_t {
bool b_dump_frames_to_file;
std::string output_file_name;
#ifdef MD5_MOVED_CHECK
void *md5_generator_handle;
#endif
} ReconfigDumpFileStruct;

//
Expand Down Expand Up @@ -118,6 +124,9 @@ class PyRocVideoDecoder : public RocVideoDecoder {
size_t CalculateRgbImageSize(OutputFormatEnum& e_output_format, OutputSurfaceInfo* p_surf_info);
std::shared_ptr <ConfigInfo> configInfo;
void InitConfigStructure();
#ifdef MD5_MOVED_CHECK
MD5Generator *md5_generator = nullptr;
#endif

// for flush back to support multi-resolution video streams
ReconfigParams PyReconfigParams;
Expand Down