[Camera]高通平台 camera 的 super buffer

super buffer 在 qcamera2\hal 层的使用

super buffer 是高通hal1中常用的概念,对应的数据结构是:mm_camera_super_buf_t

/** mm_camera_super_buf_t: super buf structure for bundled
*   stream frames
*    @camera_handle : camera handler to uniquely identify
*              a camera object
*    @ch_id : channel handler to uniquely ideentify a channel
*           object
*    @num_bufs : number of buffers in the super buf, should not
*              exceeds MAX_STREAM_NUM_IN_BUNDLE
*    @bufs : array of buffers in the bundle
**/
typedef struct {
   
    uint32_t camera_handle;
    uint32_t ch_id;
    uint32_t num_bufs;
    uint8_t bUnlockAEC;
    uint8_t bReadyForPrepareSnapshot;
    mm_camera_buf_def_t* bufs[MAX_STREAM_NUM_IN_BUNDLE];
} mm_camera_super_buf_t;

很明显mm_camera_super_buf_t 是由mm_camera_buf_def_t 组合而成。
其中 mm_camera_buf_def_t 是具体管理图像数据并且和v4l2交互的:

/** mm_camera_buf_def_t: structure for stream frame buf
*    @stream_id : stream handler to uniquely identify a stream
*               object
*    @buf_idx : index of the buf within the stream bufs, to be
*               filled during mem allocation
*    @timespec_ts : time stamp, to be filled when DQBUF is
*                 called
*    @frame_idx : frame sequence num, to be filled when DQBUF
*    @plane_buf  : Frame plane definition
*    @fd : file descriptor of the frame buffer, to be filled
*        during mem allocation
*    @buffer : pointer to the frame buffer, to be filled during
*            mem allocation
*    @frame_len : length of the whole frame, to be filled during
*               mem allocation
*    @mem_info : user specific pointer to additional mem info
*    @flags:  v4l2_buffer flags, used to report error in data buffers
*    @cache_flags: Stores cache related read/write flags
**/
typedef struct mm_camera_buf_def {
   
    uint32_t stream_id;
    cam_stream_type_t stream_type;
    cam_stream_buf_type buf_type;
    uint32_t buf_idx;
    uint8_t is_uv_subsampled;
    struct timespec ts;
    uint32_t frame_idx;
    union {
   
        mm_camera_plane_buf_def_t planes_buf;
        mm_camera_user_buf_def_t user_buf;
    };
    int fd;
    void *buffer;
    size_t frame_len;
    void *mem_info;
    uint32_t flags;
    uint32_t cache_flags;
} mm_camera_buf_def_t;

super buffer广泛用于 stream 和 channel 的回调函数中:
源自高通开源代码QCamera2HWI.h
图片源自高通开源代码QCamera2HWI.h

stream 和 channel 都需要 super buffer,他们不同之处在于:

  1. stream 回调用来处理实时性较强的场景:如Preview。
    2.channel 回调用来处理 需要从多个 stream 中取出数据的任务,例如:Snapshot 场景会用到图像数据和metadata 数据。

这些回调函数拿到 super buffer 后会进一步会取出自己需要的子buffer(也就是上文中提到的mm_camera_buf_def_t* bufs[])。例如 Preview 回调中:

void QCamera2HardwareInterface::preview_stream_cb_routine(mm_camera_super_buf_t *super_frame,
                                                          QCameraStream * stream,
                                                          void *userdata)
 {
   
 	......
 	/*只需要取到预览buffer bufs[0] 就可以*/
 	QCameraGrallocMemory *memory = (QCameraGrallocMemory *)super_frame->bufs[0]->mem_info
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值