Skip to content
Open
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
4 changes: 2 additions & 2 deletions include/enc/h264-encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef void (*h264_encoder_packet_handler_fn)(const void* payload, size_t size,

struct h264_encoder_impl {
struct h264_encoder* (*create)(uint32_t width, uint32_t height,
uint32_t format, int quality);
uint32_t format, int quality, bool hw);
void (*destroy)(struct h264_encoder*);
void (*feed)(struct h264_encoder*, struct nvnc_frame*);
};
Expand All @@ -40,7 +40,7 @@ struct h264_encoder {
};

struct h264_encoder* h264_encoder_create(uint32_t width, uint32_t height,
uint32_t format, int quality);
uint32_t format, int quality, bool hw);

void h264_encoder_destroy(struct h264_encoder*);

Expand Down
13 changes: 8 additions & 5 deletions src/enc/h264/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ extern struct h264_encoder_impl h264_encoder_v4l2m2m_impl;
#endif

struct h264_encoder* h264_encoder_create(uint32_t width, uint32_t height,
uint32_t format, int quality)
uint32_t format, int quality, bool hw)
{
struct h264_encoder* encoder = NULL;

#ifdef HAVE_V4L2
encoder = h264_encoder_v4l2m2m_impl.create(width, height, format, quality);
if (encoder) {
return encoder;
// V4L2 is useless for sw frames
if (!hw) {
encoder = h264_encoder_v4l2m2m_impl.create(width, height, format, quality, /* hw = */ true);
if (encoder) {
return encoder;
}
}
#endif

#ifdef HAVE_FFMPEG
encoder = h264_encoder_ffmpeg_impl.create(width, height, format, quality);
encoder = h264_encoder_ffmpeg_impl.create(width, height, format, quality, hw);
if (encoder) {
return encoder;
}
Expand Down
Loading