32#define DECODER_DEV "/dev/nvhost-nvdec"
34#define CHUNK_SIZE 4000000
39#define MIN(a, b) (((a) < (b)) ? (a) : (b))
42#include <linux/videodev2.h>
133 uint32_t width, uint32_t height, uint32_t raw_pixfmt);
208 int sendFrames(
int dmaOutFrameFd, frame_sp outFrame);
222 uint32_t width, uint32_t height);
297 enum v4l2_buf_type buf_type,
enum v4l2_memory memory_type, uint32_t num_retries);
314 enum v4l2_buf_type buf_type,
enum v4l2_memory memory_type,
int num_planes);
329 enum v4l2_memory mem_type,
int num_buffers);
344 enum v4l2_memory mem_type,
int num_buffers);
383 int subscribe_event(
int fd, uint32_t type, uint32_t
id, uint32_t flags);
385 int process(
void* inputFrameBuffer,
size_t inputFrameSize, uint64_t inputFrameTS);
387 bool init(std::function<
void(frame_sp &)>
send, std::function<frame_sp()>
makeFrame);
398 std::function<void(frame_sp &)>
send;
Class representing a buffer.
Definition H264DecoderV4L2Helper.h:62
bool mapped
Definition H264DecoderV4L2Helper.h:136
uint32_t n_planes
Definition H264DecoderV4L2Helper.h:124
enum v4l2_buf_type buf_type
Definition H264DecoderV4L2Helper.h:118
uint32_t index
Definition H264DecoderV4L2Helper.h:122
int map()
Definition H264DecoderV4L2Helper.cpp:183
~Buffer()
Definition H264DecoderV4L2Helper.cpp:174
int fill_buffer_plane_format(uint32_t *num_planes, Buffer::BufferPlaneFormat *planefmts, uint32_t width, uint32_t height, uint32_t raw_pixfmt)
Definition H264DecoderV4L2Helper.cpp:245
enum v4l2_memory memory_type
Definition H264DecoderV4L2Helper.h:119
BufferPlane planes[MAX_PLANES]
Definition H264DecoderV4L2Helper.h:125
void unmap()
Definition H264DecoderV4L2Helper.cpp:224
Buffer()
Definition H264DecoderV4L2Helper.h:95
int sendFrames(int dmaOutFrameFd, frame_sp outFrame)
Writes a plane data of the buffer to a file.
Definition H264DecoderV4L2Helper.cpp:312
int dq_buffer(context_t *ctx, struct v4l2_buffer &v4l2_buf, Buffer **buffer, enum v4l2_buf_type buf_type, enum v4l2_memory memory_type, uint32_t num_retries)
Dequeues a buffer from the plane.
Definition H264DecoderV4L2Helper.cpp:880
int req_buffers_on_capture_plane(context_t *ctx, enum v4l2_buf_type buf_type, enum v4l2_memory mem_type, int num_buffers)
Requests for buffers on the decoder capture plane.
Definition H264DecoderV4L2Helper.cpp:995
int set_capture_plane_format(context_t *ctx, uint32_t pixfmt, uint32_t width, uint32_t height)
Sets the format on the decoder capture plane.
Definition H264DecoderV4L2Helper.cpp:326
int ret
Definition H264DecoderV4L2Helper.h:399
bool initializeDecoder()
Definition H264DecoderV4L2Helper.cpp:1138
static void * capture_thread(void *arg)
Callback function on capture thread.
Definition H264DecoderV4L2Helper.cpp:606
void query_set_capture(context_t *ctx)
Query and Set Capture plane.
Definition H264DecoderV4L2Helper.cpp:375
int process(void *inputFrameBuffer, size_t inputFrameSize, uint64_t inputFrameTS)
Definition H264DecoderV4L2Helper.cpp:1314
int set_output_plane_format(context_t &ctx, uint32_t pixfmt, uint32_t sizeimage)
Sets the format on the decoder output plane.
Definition H264DecoderV4L2Helper.cpp:1071
std::queue< uint64_t > framesTimestampEntry
Definition H264DecoderV4L2Helper.h:400
int req_buffers_on_output_plane(context_t *ctx, enum v4l2_buf_type buf_type, enum v4l2_memory mem_type, int num_buffers)
Requests for buffers on the decoder output plane.
Definition H264DecoderV4L2Helper.cpp:1033
boost::shared_ptr< Buffer > mBuffer
Definition H264DecoderV4L2Helper.h:395
int dq_event(context_t *ctx, struct v4l2_event &event, uint32_t max_wait_ms)
Dequeues an event.
Definition H264DecoderV4L2Helper.cpp:855
int set_ext_controls(int fd, uint32_t id, uint32_t value)
Sets the value of controls.
Definition H264DecoderV4L2Helper.cpp:1097
bool decode_process(context_t &ctx, void *inputFrameBuffer, size_t inputFrameSize)
Decode processing function for blocking mode.
Definition H264DecoderV4L2Helper.cpp:787
std::function< void(frame_sp &)> send
Definition H264DecoderV4L2Helper.h:398
~h264DecoderV4L2Helper()
Definition H264DecoderV4L2Helper.h:151
h264DecoderV4L2Helper()
Struct defining the decoder context. The video decoder device node is /dev/nvhost-nvdec....
Definition H264DecoderV4L2Helper.h:150
bool init(std::function< void(frame_sp &)> send, std::function< frame_sp()> makeFrame)
Definition H264DecoderV4L2Helper.cpp:1131
int subscribe_event(int fd, uint32_t type, uint32_t id, uint32_t flags)
Subscribes to an V4L2 event.
Definition H264DecoderV4L2Helper.cpp:1115
void closeAllThreads(frame_sp eosFrame)
Definition H264DecoderV4L2Helper.cpp:1414
std::function< frame_sp()> makeFrame
Definition H264DecoderV4L2Helper.h:397
void deQueAllBuffers()
Definition H264DecoderV4L2Helper.cpp:1420
int q_buffer(context_t *ctx, struct v4l2_buffer &v4l2_buf, Buffer *buffer, enum v4l2_buf_type buf_type, enum v4l2_memory memory_type, int num_planes)
Queues a buffer on the plane.
Definition H264DecoderV4L2Helper.cpp:950
std::mutex m
Definition H264DecoderV4L2Helper.h:401
context_t ctx
Definition H264DecoderV4L2Helper.h:396
void read_input_chunk_frame_sp(void *inputFrameBuffer, size_t inputFrameSize, Buffer *buffer)
Reads the encoded data from a file to the buffer structure.
Definition H264DecoderV4L2Helper.cpp:285
Definition H264DecoderV4L2Helper.h:82
int fd
Definition H264DecoderV4L2Helper.h:88
unsigned char * data
Definition H264DecoderV4L2Helper.h:85
BufferPlaneFormat fmt
Definition H264DecoderV4L2Helper.h:83
uint32_t mem_offset
Definition H264DecoderV4L2Helper.h:90
uint32_t length
Definition H264DecoderV4L2Helper.h:92
uint32_t bytesused
Definition H264DecoderV4L2Helper.h:86
Definition H264DecoderV4L2Helper.h:153
Buffer::BufferPlaneFormat cp_planefmts[MAX_PLANES]
Definition H264DecoderV4L2Helper.h:163
pthread_cond_t queue_cond
Definition H264DecoderV4L2Helper.h:175
int fd
Definition H264DecoderV4L2Helper.h:183
uint32_t display_width
Definition H264DecoderV4L2Helper.h:156
uint32_t display_height
Definition H264DecoderV4L2Helper.h:157
enum v4l2_memory op_mem_type
Definition H264DecoderV4L2Helper.h:158
uint32_t cp_num_planes
Definition H264DecoderV4L2Helper.h:164
bool got_eos
Definition H264DecoderV4L2Helper.h:180
pthread_mutex_t queue_lock
Definition H264DecoderV4L2Helper.h:174
enum v4l2_buf_type op_buf_type
Definition H264DecoderV4L2Helper.h:160
pthread_t dec_capture_thread
Definition H264DecoderV4L2Helper.h:176
uint32_t decode_pixfmt
Definition H264DecoderV4L2Helper.h:154
Buffer ** op_buffers
Definition H264DecoderV4L2Helper.h:171
bool eos
Definition H264DecoderV4L2Helper.h:179
enum v4l2_buf_type cp_buf_type
Definition H264DecoderV4L2Helper.h:161
uint32_t out_pixfmt
Definition H264DecoderV4L2Helper.h:155
Buffer ** cp_buffers
Definition H264DecoderV4L2Helper.h:172
uint32_t op_num_planes
Definition H264DecoderV4L2Helper.h:165
int dmabuff_fd[MAX_BUFFERS]
Definition H264DecoderV4L2Helper.h:185
Buffer::BufferPlaneFormat op_planefmts[MAX_PLANES]
Definition H264DecoderV4L2Helper.h:162
bool in_error
Definition H264DecoderV4L2Helper.h:178
uint32_t num_queued_op_buffers
Definition H264DecoderV4L2Helper.h:169
bool op_streamon
Definition H264DecoderV4L2Helper.h:181
enum v4l2_memory cp_mem_type
Definition H264DecoderV4L2Helper.h:159
int dst_dma_fd
Definition H264DecoderV4L2Helper.h:184
bool cp_streamon
Definition H264DecoderV4L2Helper.h:182
uint32_t op_num_buffers
Definition H264DecoderV4L2Helper.h:167
uint32_t cp_num_buffers
Definition H264DecoderV4L2Helper.h:166