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

Add Duck IVF parsing support to the elementary stream. #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vasn1k
Copy link

@vasn1k vasn1k commented Mar 7, 2025

Add support for .ivf files when loading AV1 compressed video files and using elementary streams.

Signed-off-by: Vassili Nikolaev (NVIDIA) <vnikolaev@nvidia.com>
@CLAassistant
Copy link

CLAassistant commented Mar 7, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@zlatinski zlatinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thank you!

#define DKIF_FRAME_CONTAINER_HEADER_SIZE 12
#define DKIF_HEADER_MAGIC *((const uint32_t*)"DKIF")
#define DKIF_FILE_HEADER_SIZE 32
#define USE_SIMPLE_MALLOC 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused about this USE_SIMPLE_MALLOC. Can you add a comment to explain the use of that ?

@@ -18,6 +18,10 @@
#include <fstream>
#include "mio/mio.hpp"
#include "VkDecoderUtils/VideoStreamDemuxer.h"
#define DKIF_FRAME_CONTAINER_HEADER_SIZE 12
#define DKIF_HEADER_MAGIC *((const uint32_t*)"DKIF")
#define DKIF_FILE_HEADER_SIZE 32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to use structure and get some information from the header such as the codec.
You can get inspiration from https://github.com/Igalia/ESExtractor/blob/main/lib/eseivfstream.cpp

FILE* handle = fopen(pFilePath, "rb");
if (handle == nullptr) {
printf("Failed to open video file %s\n", pFilePath);
m_bitstreamDataSize = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for that as its already set to null and zero above


fseek(handle, 0, SEEK_END);
size_t size = ftell(handle);
uint8_t* data = (uint8_t*)malloc(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid this approach for very large file. I would read the size of the frame by the frame header and move the offset to this size.


if (data == nullptr) {
printf("Failed to allocate memory for video file: %i\n", (uint32_t)size);
m_bitstreamDataSize = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this code as it hasnt been modified so far

@@ -83,7 +130,11 @@ class ElementaryStream : public VideoStreamDemuxer {
}

virtual ~ElementaryStream() {
#ifdef USE_SIMPLE_MALLOC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use #ifndef

@zlatinski
Copy link
Contributor

We should remove the USE_SIMPLE_MALLOC from this change. @vasn1k, per our offline discussion, please do that before we merge this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants