mirror of
https://github.com/nyanmisaka/mpp.git
synced 2026-01-24 03:00:40 +01:00
[mpp_meta]: Add mpp_meta_get with default value
Change-Id: I2285ace50341792b1979130d19a3ec642346e4bc Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
parent
98ac9b259b
commit
72a6118b99
2 changed files with 29 additions and 0 deletions
|
|
@ -158,6 +158,13 @@ MPP_RET mpp_meta_get_frame (MppMeta meta, MppMetaKey key, MppFrame *frame);
|
|||
MPP_RET mpp_meta_get_packet(MppMeta meta, MppMetaKey key, MppPacket *packet);
|
||||
MPP_RET mpp_meta_get_buffer(MppMeta meta, MppMetaKey key, MppBuffer *buffer);
|
||||
|
||||
MPP_RET mpp_meta_get_s32_d(MppMeta meta, MppMetaKey key, RK_S32 *val, RK_S32 def);
|
||||
MPP_RET mpp_meta_get_s64_d(MppMeta meta, MppMetaKey key, RK_S64 *val, RK_S64 def);
|
||||
MPP_RET mpp_meta_get_ptr_d(MppMeta meta, MppMetaKey key, void **val, void *def);
|
||||
MPP_RET mpp_meta_get_frame_d(MppMeta meta, MppMetaKey key, MppFrame *frame, MppFrame def);
|
||||
MPP_RET mpp_meta_get_packet_d(MppMeta meta, MppMetaKey key, MppPacket *packet, MppPacket def);
|
||||
MPP_RET mpp_meta_get_buffer_d(MppMeta meta, MppMetaKey key, MppBuffer *buffer, MppBuffer def);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -307,6 +307,28 @@ MPP_RET mpp_meta_dump(MppMeta meta)
|
|||
ret = MPP_OK; \
|
||||
} \
|
||||
return ret; \
|
||||
} \
|
||||
MPP_RET mpp_meta_get_##func_type##_d(MppMeta meta, MppMetaKey key, arg_type *val, arg_type def) \
|
||||
{ \
|
||||
if (NULL == meta) { \
|
||||
mpp_err_f("found NULL input\n"); \
|
||||
return MPP_ERR_NULL_PTR; \
|
||||
} \
|
||||
MppMetaService *service = MppMetaService::get_inst(); \
|
||||
RK_S32 index = service->get_index_of_key(key, key_type); \
|
||||
if (index < 0) \
|
||||
return MPP_NOK; \
|
||||
MppMetaImpl *impl = (MppMetaImpl *)meta; \
|
||||
MppMetaVal *meta_val = &impl->vals[index]; \
|
||||
MPP_RET ret = MPP_NOK; \
|
||||
if (MPP_BOOL_CAS(&meta_val->state, META_VAL_VALID | META_VAL_READY, META_VAL_INVALID)) { \
|
||||
*val = meta_val->key_field; \
|
||||
MPP_FETCH_SUB(&impl->node_count, 1); \
|
||||
ret = MPP_OK; \
|
||||
} else { \
|
||||
*val = def; \
|
||||
} \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
MPP_META_ACCESSOR(s32, RK_S32, TYPE_S32, val_s32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue