xref: /rockchip-linux_mpp/mpp/hal/common/h265/hal_h265e_stream_amend.c (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */
2 /*
3  * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
4  */
5 
6 #include "hal_h265e_stream_amend.h"
7 
8 #include "mpp_common.h"
9 #include "mpp_log.h"
10 
hal_h265e_amend_temporal_id(HalEncTask * enc_task,RK_U32 strm_size)11 MPP_RET hal_h265e_amend_temporal_id(HalEncTask *enc_task, RK_U32 strm_size)
12 {
13     MPP_RET ret = MPP_OK;
14     H265eSyntax_new *syn = (H265eSyntax_new *)enc_task->syntax.data;
15     RK_U32 offset = mpp_packet_get_length(enc_task->packet);
16     RK_U8 *stream_ptr = (RK_U8 *)(mpp_buffer_get_ptr(enc_task->output) + offset);
17 
18     if (strm_size < 5) {
19         mpp_err("Stream size is too small, maybe there is hw encoder error!");
20         return MPP_NOK;
21     }
22 
23     if (syn->sp.temporal_id)
24         stream_ptr[5] = (stream_ptr[5] & 0xf8) | ((syn->sp.temporal_id + 1) & 0x7);
25 
26     return ret;
27 }