mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-11 03:50:03 +08:00
[mpp_bitread]: add new type for sei payload parse
The quantity of emulation prevention bytes is not included in the size payloadSize of an SEI payload. So add PSEUDO_CODE_H264_H265_SEI type for sei payload parse. Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com> Change-Id: I92554de98ffca2f81785aa81b2f652099dbe6ae9
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
typedef enum PseudoCodeType_e {
|
||||
PSEUDO_CODE_NONE = 0,
|
||||
PSEUDO_CODE_H264_H265,
|
||||
PSEUDO_CODE_H264_H265_SEI,
|
||||
PSEUDO_CODE_AVS2,
|
||||
PSEUDO_CODE_BUT
|
||||
} PseudoCodeType;
|
||||
|
@@ -63,6 +63,29 @@ static MPP_RET update_curbyte_h264(BitReadCtx_t *bitctx)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
static MPP_RET update_curbyte_h2645_sei(BitReadCtx_t *bitctx)
|
||||
{
|
||||
if (bitctx->bytes_left_ < 1)
|
||||
return MPP_ERR_READ_BIT;
|
||||
|
||||
// Emulation prevention three-byte detection.
|
||||
// If a sequence of 0x000003 is found, skip (ignore) the last byte (0x03).
|
||||
if ((*bitctx->data_ == 0x03)
|
||||
&& ((bitctx->prev_two_bytes_ & 0xffff) == 0)) {
|
||||
// Detected 0x000003, skip last byte.
|
||||
++bitctx->data_;
|
||||
// Need another full three bytes before we can detect the sequence again.
|
||||
bitctx->prev_two_bytes_ = 0xffff;
|
||||
}
|
||||
// Load a new byte and advance pointers.
|
||||
bitctx->curr_byte_ = *bitctx->data_++ & 0xff;
|
||||
--bitctx->bytes_left_;
|
||||
bitctx->num_remaining_bits_in_curr_byte_ = 8;
|
||||
bitctx->prev_two_bytes_ = (bitctx->prev_two_bytes_ << 8) | bitctx->curr_byte_;
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
static MPP_RET update_curbyte_avs2(BitReadCtx_t *bitctx)
|
||||
{
|
||||
if (bitctx->bytes_left_ < 1)
|
||||
@@ -320,6 +343,9 @@ void mpp_set_bitread_pseudo_code_type(BitReadCtx_t *bitctx, PseudoCodeType type)
|
||||
case PSEUDO_CODE_H264_H265:
|
||||
bitctx->update_curbyte = update_curbyte_h264;
|
||||
break;
|
||||
case PSEUDO_CODE_H264_H265_SEI:
|
||||
bitctx->update_curbyte = update_curbyte_h2645_sei;
|
||||
break;
|
||||
case PSEUDO_CODE_AVS2:
|
||||
bitctx->update_curbyte = update_curbyte_avs2;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user