Conversation
|
|
||
| inline void safe_exit(int status, const char* function_name, int line_number, const char* description) { | ||
| printf("Exiting from %s:%d - %s (status: %d)\n", function_name, line_number, description, status); | ||
| exit(status); |
There was a problem hiding this comment.
Using an additional file was done so implementations of this code could leave it out and easily define their own safe_exit function. Defining safe_exit in the header, requires additional MACRO's to go around the exit call, preventing it from being compiled in. So there we would need the BUILD_DECODER_APP_AS_LIB check which will switch between exit and printf.
There was a problem hiding this comment.
I kind of agree with @vasn1k here regarding the separate .cpp file, although one other header-only approach is for other uses of this code to provide their own ExitWrapper.h with a different definition of safe_exit().
There was a problem hiding this comment.
Per our discussion, this morning. Lets get rid of ExitWrapper and convert all exit() calls into returns.
I'll look into compiler settings to disallow exit() entirely later.
vasn1k
left a comment
There was a problem hiding this comment.
There are a few minor things:
Exit wrapper - needs the cpp file or an abstract overloadable interface. The cpp file is a lot simpler.
Another thing that seems to have been missed is: VulkanVideoProcessor::GetVideoExtent()
Where the extent attempts to call a constructor with an object present. But extent is a structure without a constructor. This causes a compilation error: /VulkanVideoProcessor.cpp(221): error C2100: illegal indirection
Same for: VulkanVideoProcessor::GetVkProfile
And the opposite for: VkVideoCoreProfile videoProfile(m_videoStreamDemuxer->GetVideoCodec()
safe_exits in: vk_video_encoder/libs/VkVideoEncoder/VkEncoderDpbH264.cpp
are missing.
So we don't forget, below changes have been dropped but are necessary:
cpudetect changes are missing.
m_crcOutput is missing, important.
REDUCE_VK_VIDEO_STDOUT_SPEW is missing.
da3950d to
2baf0d3
Compare
Sorry, fixed with the latest change.
I see all the exit functions in place, including the ones in VkEncoderDpbH264.cpp The rest of the changes should go with a different change. |
2baf0d3 to
e4f3145
Compare
Yes, I've included that one two. |
This one needs a more robust change using a local vector that the client would request to copy from.
Can we rename this one to VK_VIDEO_NO_STDOUT_INFO? |
I think this boils down to preference, my preference was caller allocation and management. Your voiced preference is lib ownership, allocation and management, with a potential needed copy. It's really just a vector<uint32_t>. I'm not extremely picky on how it happens, it will just be more changes. On both sides.
Sounds good to me. What about: #if !defined(DISABLE_VK_VIDEO_PARSER_SIMD_OPTIMIZATIONS)? It would be good to get ExitWrapper.cpp back. That way we get all flexibility. And you want the implementation of the function in cpp, otherwise the pre-processor will copy it at every include. |
e4f3145 to
7a4db15
Compare
| // Returns true if the caller would need to handle the exit | ||
| // Otherwise, the function will call exit() that would exit the process. | ||
| inline bool safe_exit(int status, const char* function_name, int line_number, const char* description) { | ||
| printf("Exiting with a critical error from %s:%d - %s (status: %d)\n", function_name, line_number, description, status); |
There was a problem hiding this comment.
I find the "with a critical error" part problematic -- we have cases where the call site is safe_exit(EXIT_SUCCESS, ...).
|
|
||
| inline void safe_exit(int status, const char* function_name, int line_number, const char* description) { | ||
| printf("Exiting from %s:%d - %s (status: %d)\n", function_name, line_number, description, status); | ||
| exit(status); |
There was a problem hiding this comment.
I kind of agree with @vasn1k here regarding the separate .cpp file, although one other header-only approach is for other uses of this code to provide their own ExitWrapper.h with a different definition of safe_exit().
|
|
||
| // Returns true if the caller would need to handle the exit | ||
| // Otherwise, the function will call exit() that would exit the process. | ||
| inline bool safe_exit(int status, const char* function_name, int line_number, const char* description) { |
There was a problem hiding this comment.
Why does this return bool ? void is perfectly good because no caller checks for the return value from SAFE_EXIT().
| if (m_currDpbIdx >= MAX_DPB_SLOTS) { | ||
| VK_DPB_DBG_PRINT(("could not allocate a frame buffer\n")); | ||
| exit(1); | ||
| SAFE_EXIT(1, "Failed to allocate frame buffer - DPB slots exhausted"); |
There was a problem hiding this comment.
For the elimination of exit() from the code, this entire block (lines 280 - 283) can be deleted. We will not have a case where m_currDpbIdx >= MAX_DPB_SLOTS because if it were true, we would have not come out of the while (IsDpbFull()) loop above. It's probably sufficient to add a comment here stating this while deleting this code.
| if (m_currDpbIdx >= MAX_DPB_SLOTS) { | ||
| VK_DPB_DBG_PRINT(("could not allocate a frame buffer\n")); | ||
| exit(1); | ||
| SAFE_EXIT(1, "Failed to allocate frame buffer - DPB slots exhausted"); |
There was a problem hiding this comment.
This block of code in lines 357 - 360 can be deleted because this is the else branch of an if-else, where the DBP is not full, so the above for loop (lines 354 - 356) will find an empty entry. Just like I wrote in the previous comment, it's probably sufficient to leave a comment here stating this while deleting this code (which will eliminate the exit()).
Signed-off-by: Vassili Nikolaev (NVIDIA) <vnikolaev@nvidia.com>
7a4db15 to
e514b85
Compare
|
Updated the change as agreed, removing the exit code. |
|
The latest changes (as of commit e514b85) LGTM. |
|
I thought you were going to replace the exits with returns, not just revert? Please also add VkVideoFrameOutput::GetCrcValues() and remove the dependency on supplying a crc output file. Facilitating initCRCValue should force the CRC to be calculated and output into the crcAllocation, it should avoid printing. I still don't see an update for: #if !defined(DISABLE_VK_VIDEO_PARSER_SIMD_OPTIMIZATIONS) Where is VK_VIDEO_NO_STDOUT_INFO? I've created an MR into this branch to add the missing pieces: |
|
I'm merging these basic changes and compiler fixes so far. There are going to be follow-up changes from #140 |
common: Code compilation fixes
common: SAFE_EXIT macro to print and exit
common: Use the CRC generator instead of embedding it
encoder: Deal with the Vulkan chained stuctures
Fix frame to file from adding .yuv to filenames with .y4m already
@vasn1k @srinathkr-nv please review.