H264_ENC

[English]

H264_ENC API Status

API

BK7258_AP

bk_h264_driver_init()

Y

bk_h264_driver_deinit()

Y

bk_h264_init()

Y

bk_h264_deinit()

Y

bk_h264_set_base_config()

Y

bk_h264_get_h264_base_config()

Y

bk_h264_set_pframe_num()

Y

bk_h264_get_pframe_num()

Y

bk_h264_set_qp()

Y

bk_h264_set_quality()

Y

bk_h264_encode_enable()

Y

bk_h264_encode_disable()

Y

bk_h264_soft_reset()

Y

bk_h264_config_reset()

Y

bk_h264_get_fifo_addr()

Y

bk_h264_register_isr()

Y

bk_h264_unregister_isr()

Y

bk_h264_get_encode_count()

Y

bk_h264_enc_lcd_dma_cpy()

Y

bk_h264_updata_encode_fps()

Y

H264_ENC Marco defined and config

Marco name

illustrate

CONFIG_H264

enable H264_ENC module or not

Note

CONFIG_H264 depends on CONFIG_YUV_BUF, H264 module can not work alone. Those api only for reference, user can not use them directly. Please referecnce doorbell project.

H264_ENC API Reference

Header File

Functions

bk_err_t bk_h264_driver_init(void)

init h264 driver

This API use to init h264 driver register and register system isr

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_h264_driver_deinit(void)

deinit h264 driver

This API use to deinit h264 driver register and deregister system isr

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_h264_init(uint16_t width, uint16_t height)

Init the h264 encoder.

This API init the h264 encoder

  • vote cpu to 480MHz

  • vote video power on

  • set h264 clk enable

  • enable h264 system isr

  • according image resolution, config release register

Parameters
  • width – input image width

  • height – input image height

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_h264_deinit(void)

Deinitialize the H264 module.

This API deinitialize the H264 module

  • vote cpu to default

  • vote video power off

  • disable h264 clk

  • disable h264 system isr

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_set_base_config(compress_ratio_t *config)

config h264 encode ratio

This API modify h264 register to config encode ratio, you can call anytime

Parameters

config – compress ratio config

  • profile_idc: profile idc

  • p_frame_cnt: p frame count

  • qp: qp

  • num_imb_bits: num imb bits

  • num_pmb_bits: num pmb bits

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_get_h264_base_config(h264_base_config_t *config)

get h264 encode base config

This API get h264 encode base config, you can call anytime

Parameters

config – h264 base config

  • profile_idc: profile idc

  • p_frame_cnt: p frame count

  • qp: qp

  • num_imb_bits: num imb bits

  • num_pmb_bits: num pmb bits

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_set_pframe_num(uint32_t pframe_number)

set h264 encode p frame count

This API can set h264 encode p frame count

Attention

if you use h264 pipeline, suggest modify it by CONFIG_H264_P_FRAME_CNT

Parameters

pframe_number – p frame number

Returns

  • BK_OK: Success

  • others: Other errors

uint32_t bk_h264_get_pframe_num(void)

get h264 encode p frame count

This API get h264 encode p frame count

Returns

  • p frame number

bk_err_t bk_h264_set_qp(h264_qp_t *qp)

set h264 encode qp

This API can set h264 encode qp

Parameters

qp – qp config

  • qp: qp

  • num_imb_bits: num imb bits

  • num_pmb_bits: num pmb bits

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_set_quality(uint32_t imb_bits, uint32_t pmb_bits)

set h264 encode qp

This API can set h264 encode qp

Parameters
  • imb_bits – imb bits

  • pmb_bits – pmb bits

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_encode_enable(void)

enable h264 encode

This API enable h264 encode

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_encode_disable(void)

disable h264 encode

This API disable h264 encode

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_soft_reset(void)

soft reset h264

This API soft reset h264, you can call this to reset encode logical, can regenrate idr frame

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_config_reset(void)

config reset h264 driver

This API config reset h264 driver, reset all register to init status

Attention

this api will reconfig h264 all register

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_get_fifo_addr(uint32_t *fifo_addr)

get h264 encode fifo addr

This API get h264 encode fifo addr

Parameters

fifo_addr – h264 encode fifo addr

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_register_isr(h264_isr_type_t type_id, h264_isr_t isr, void *param)

register h264 isr

This API register h264 isr

Parameters
  • type_id – isr type

  • isr – isr callback function

  • param – isr param

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_unregister_isr(h264_isr_type_t type_id)

unregister h264 isr

This API unregister h264 isr

Parameters

type_id – isr type

Returns

  • BK_OK: Success

  • others: Other errors

uint32_t bk_h264_get_encode_count(void)

get h264 encode count

This API get h264 encode count

Attention

output unit is word(4 bytes)

Returns

  • encode count

bk_err_t bk_h264_enc_lcd_dma_cpy(void *out, const void *in, uint32_t len, dma_id_t cpy_chnl)

h264 encode lcd dma copy

This API h264 encode lcd dma copy

Parameters
  • out – output addr

  • in – input addr

  • len – copy len

  • cpy_chnl – dma channel

Returns

  • BK_OK: Success

  • others: Other errors

bk_err_t bk_h264_updata_encode_fps(uint32_t fps)

h264 updata encode fps

This API h264 updata encode fps, this fps will release h264 decode fps

Parameters

fps – fps

Returns

  • BK_OK: Success

  • others: Other errors

H264_ENC API Typedefs

Header File

Structures

struct h264_base_config_t

Macros

BK_ERR_H264_DRIVER_NOT_INIT
BK_ERR_H264_ISR_INVALID_ID
BK_ERR_H264_INVALID_RESOLUTION_TYPE
BK_ERR_H264_INVALID_PFRAME_NUMBER
BK_ERR_H264_INVALID_QP
BK_ERR_H264_INVALID_IMB_BITS
BK_ERR_H264_INVALID_PMB_BITS
BK_ERR_H264_INVALID_CONFIG_PARAM
BK_ERR_H264_INVALID_PIXEL_HEIGHT
INT_SKIP_FRAME
INT_FINAL_OUT
INT_LINE_DONE
H264_CLK_SEL_480M
H264_AHB_CLK_DIV
H264_AHB_CLK_SEL
H264_INT_ENABLE
H264_INT_DISABLE
H264_CPU_INT_ENABLE
H264_CPU_INT_DISABLE
MAX_QP
MIN_QP
MAX_PFRAME
MIN_PFRAME
MAX_IFRAME_BITS
MAX_PFRAME_BITS
MIN_FRAME_BITS
DEFAULT_SKIP_MODE

Enumerations

enum h264_isr_type_t

Values:

enumerator H264_SKIP_FRAME
enumerator H264_FINAL_OUT
enumerator H264_LINE_DONE
enumerator H264_ISR_MAX

Header File

Structures

struct h264_config_t
struct h264_qp_t
struct h264_dma_config_t

Macros

PBITS_FACT1
PBITS_FACT2
PBITS_FACT3
PBITS_FACT4
PBITS_FACT5

Type Definitions

typedef uint8_t h264_unit_t
typedef void (*h264_isr_t)(h264_unit_t id, void *param)