-
Notifications
You must be signed in to change notification settings - Fork 16
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
ffmpeg software decoder implementation #461
base: beta-testing
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the additional lines in the changelogs are for 6.3, please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few minor formatting and some suggestions.
void DecodeThread(); | ||
int DecodeAvFrame(AVPacket *av_pkt, AVFrame *p_frame); | ||
void InitOutputFrameInfo(AVFrame *p_frame); | ||
void PushPacket(AVPacket *pkt){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor formatting: add a space *pkt){
-> *pkt) {
cv_pkt_.notify_one(); | ||
} | ||
|
||
AVPacket *PopPacket(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor formatting: add a space *PopPacket(){
-> *PopPacket() {
return pkt; | ||
} | ||
|
||
void PushFrame(AVFrame *av_frame){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor formatting: add a space *av_frame){
-> *av_frame) {
cv_frame_.notify_one(); | ||
}; | ||
|
||
AVFrame *PopFrame(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor formatting: add a space *PopFrame(){
-> *PopFrame() {
switch (av_pixel_format) { | ||
case AV_PIX_FMT_YUV420P : | ||
case AV_PIX_FMT_YUVJ420P : | ||
return rocDecVideoSurfaceFormat_YUV420; // need to see if this is actually correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant? If so, what needs to be done to ensure we return the correct rocdecode surface format?
// vp_frames_ffmpeg_.size() is empty, wait for decoding to finish | ||
// this will happen during PopFrame() | ||
AVFrame *p_av_frame; | ||
//std::cout << "Before pop frame " << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment if it is unnecessary.
std::cerr << "Invalid avframe decode output" << std::endl; | ||
return 0; | ||
} | ||
void * src_ptr[3] = { 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor formatting: remove the space -> void *
-> void*
{ | ||
std::lock_guard<std::mutex> lock(mtx_vp_frame_); | ||
// if not enough frames in stock, allocate | ||
if ((unsigned)++output_frame_cnt_ > vp_frames_ffmpeg_.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use static_cast
here
// so we need to flush FFMpeg decoder when we have received the lastpacket with 0 bytes | ||
if (!last_packet_.payload_size && !end_of_stream_) { | ||
AVPacket pkt = { 0 }; | ||
#if NO_DECODE_THREAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using an environment variable to control whether decoding is performed with or without a thread. This change would enable us to test both options without the need to recompile the program. For instance, we could create an environment variable called ROCDEC_FFMPEG_DISABLE_DECODE_THREAD
. By setting it with the command export ROCDEC_FFMPEG_DISABLE_DECODE_THREAD=1
, we can disable threading for FFMPEG. The following code can then be used to check whether threading is disabled.
const char *is_threading_disabled = std::getenv("ROCDEC_FFMPEG_DISABLE_DECODE_THREAD");
if (std::string(is_threading_disabled) != "1")
DecodeAvFrame(&pkt, dec_frames_[av_frame_cnt_]);
else
PushPacket(&pkt);
// this will happen during PopFrame() | ||
AVFrame *p_av_frame; | ||
//std::cout << "Before pop frame " << std::endl; | ||
#if NO_DECODE_THREAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, it is recommended to use an environment variable to check if threading is disabled.
Implemented ffmpeg based software decoder
Modified videoDecode sample to allow ffmpeg based decoding