mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-09-26 21:03:43 +08:00
fixup! lavc/rkmppenc: add UDU SEI support for H26x encoders
polish the udu-sei impl. Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
@@ -182,8 +182,8 @@ static void clear_unused_frames(MPPEncFrame *list)
|
||||
mpp_frame_deinit(&list->mpp_frame);
|
||||
list->mpp_frame = NULL;
|
||||
|
||||
av_freep(&list->mpp_sei);
|
||||
list->mpp_sei_sz = 0;
|
||||
av_freep(&list->mpp_sei_set.datas);
|
||||
list->mpp_sei_set.count = 0;
|
||||
|
||||
av_frame_free(&list->frame);
|
||||
list->queued = 0;
|
||||
@@ -214,8 +214,8 @@ static void clear_frame_list(MPPEncFrame **list)
|
||||
frame->mpp_frame = NULL;
|
||||
}
|
||||
|
||||
av_freep(&frame->mpp_sei);
|
||||
frame->mpp_sei_sz = 0;
|
||||
av_freep(&frame->mpp_sei_set.datas);
|
||||
frame->mpp_sei_set.count = 0;
|
||||
|
||||
av_frame_free(&frame->frame);
|
||||
av_freep(&frame);
|
||||
@@ -577,6 +577,7 @@ static int rkmpp_prepare_udu_sei_data(AVCodecContext *avctx, MPPEncFrame *mpp_en
|
||||
|
||||
/* user data unregistered SEI of H26X */
|
||||
for (i = 0; i < mpp_enc_frame->frame->nb_side_data; i++) {
|
||||
MppEncUserDataSet *mpp_sei_set = &mpp_enc_frame->mpp_sei_set;
|
||||
AVFrameSideData *sd = mpp_enc_frame->frame->side_data[i];
|
||||
uint8_t *user_data = sd->data;
|
||||
void *buf = NULL;
|
||||
@@ -591,37 +592,31 @@ static int rkmpp_prepare_udu_sei_data(AVCodecContext *avctx, MPPEncFrame *mpp_en
|
||||
continue;
|
||||
}
|
||||
|
||||
buf = av_fast_realloc(mpp_enc_frame->mpp_sei,
|
||||
&mpp_enc_frame->mpp_sei_sz,
|
||||
(sei_count + 1) * sizeof(*(mpp_enc_frame->mpp_sei)));
|
||||
buf = av_fast_realloc(mpp_sei_set->datas,
|
||||
&mpp_sei_set->count,
|
||||
(sei_count + 1) * sizeof(*(mpp_sei_set->datas)));
|
||||
if (!buf) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to realloc UDU SEI buffer\n");
|
||||
return AVERROR(ENOMEM);
|
||||
} else {
|
||||
mpp_enc_frame->mpp_sei = buf;
|
||||
mpp_sei_set->datas = (MppEncUserDataFull *)buf;
|
||||
|
||||
mpp_enc_frame->mpp_sei[sei_count].len = sd->size - AV_UUID_LEN;
|
||||
mpp_enc_frame->mpp_sei[sei_count].uuid = (RK_U8 *)user_data;
|
||||
mpp_enc_frame->mpp_sei[sei_count].pdata = &user_data[AV_UUID_LEN];
|
||||
mpp_sei_set->datas[sei_count].len = sd->size - AV_UUID_LEN;
|
||||
mpp_sei_set->datas[sei_count].uuid = (RK_U8 *)user_data;
|
||||
mpp_sei_set->datas[sei_count].pdata = &user_data[AV_UUID_LEN];
|
||||
|
||||
++sei_count;
|
||||
mpp_sei_set->count = ++sei_count;
|
||||
}
|
||||
}
|
||||
|
||||
if (sei_count > 0) {
|
||||
MppMeta mpp_meta = NULL;
|
||||
MppEncUserDataSet *mpp_sei_set = &mpp_enc_frame->mpp_sei_set;
|
||||
|
||||
mpp_sei_set->datas = mpp_enc_frame->mpp_sei;
|
||||
mpp_sei_set->count = sei_count;
|
||||
|
||||
mpp_meta = mpp_frame_get_meta(mpp_enc_frame->mpp_frame);
|
||||
MppMeta mpp_meta = mpp_frame_get_meta(mpp_enc_frame->mpp_frame);
|
||||
if (!mpp_meta) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to get frame meta\n");
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
if ((ret = mpp_meta_set_ptr(mpp_meta, KEY_USER_DATAS,
|
||||
mpp_sei_set)) != MPP_OK) {
|
||||
&mpp_enc_frame->mpp_sei_set)) != MPP_OK) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to set the UDU SEI datas ptr\n");
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
|
@@ -48,8 +48,6 @@ typedef struct MPPEncFrame {
|
||||
AVFrame *frame;
|
||||
MppFrame mpp_frame;
|
||||
MppEncUserDataSet mpp_sei_set;
|
||||
MppEncUserDataFull *mpp_sei;
|
||||
int mpp_sei_sz;
|
||||
struct MPPEncFrame *next;
|
||||
int queued;
|
||||
} MPPEncFrame;
|
||||
|
Reference in New Issue
Block a user