Skip to content

Commit 4ee075e

Browse files
authored
Add config to disable raw bitstream format (#89)
* added config for RBAU Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * clear description Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> * short variable name Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com> --------- Signed-off-by: kp5.choi@samsung.com <kp5.choi@samsung.com>
1 parent e0ce0b8 commit 4ee075e

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

inc/oapv.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ extern "C" {
152152
#define OAPV_CFG_SET_QP_MIN (208)
153153
#define OAPV_CFG_SET_QP_MAX (209)
154154
#define OAPV_CFG_SET_USE_FRM_HASH (301)
155+
#define OAPV_CFG_SET_AU_BS_FMT (302)
155156
#define OAPV_CFG_GET_QP_MIN (600)
156157
#define OAPV_CFG_GET_QP_MAX (601)
157158
#define OAPV_CFG_GET_QP (602)
@@ -161,6 +162,15 @@ extern "C" {
161162
#define OAPV_CFG_GET_FPS_DEN (606)
162163
#define OAPV_CFG_GET_WIDTH (701)
163164
#define OAPV_CFG_GET_HEIGHT (702)
165+
#define OAPV_CFG_GET_AU_BS_FMT (802)
166+
167+
/*****************************************************************************
168+
* config values
169+
*****************************************************************************/
170+
/* The output from the encoder is compliant with raw_bitstream_access_unit */
171+
#define OAPV_CFG_VAL_AU_BS_FMT_RBAU (0)
172+
/* The output from the encoder is the only AU without bitstream format */
173+
#define OAPV_CFG_VAL_AU_BS_FMT_NONE (1)
164174

165175
/*****************************************************************************
166176
* HLS configs

src/oapv.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ static int enc_ready(oapve_ctx_t *ctx)
751751

752752
ctx->rc_param.alpha = OAPV_RC_ALPHA;
753753
ctx->rc_param.beta = OAPV_RC_BETA;
754+
ctx->au_bs_fmt = OAPV_CFG_VAL_AU_BS_FMT_RBAU; // default: enable raw bitstream format
754755

755756
return OAPV_OK;
756757
ERR:
@@ -1292,8 +1293,9 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
12921293
{
12931294
oapve_ctx_t *ctx;
12941295
oapv_frm_t *frm;
1295-
oapv_bs_t *bs;
1296+
oapv_bs_t *bs, bs_pbu_beg;
12961297
int i, ret;
1298+
u8 *bs_pos_pbu_beg, *bs_pos_au_beg;
12971299

12981300
ctx = enc_id_to_ctx(eid);
12991301
oapv_assert_rv(ctx != NULL && bitb->addr && bitb->bsize > 0, OAPV_ERR_INVALID_ARGUMENT);
@@ -1303,11 +1305,11 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
13031305
oapv_bsw_init(bs, bitb->addr, bitb->bsize, NULL);
13041306
oapv_mset(stat, 0, sizeof(oapve_stat_t));
13051307

1306-
u8 *bs_pos_au_beg = oapv_bsw_sink(bs); // address syntax of au size
1307-
u8 *bs_pos_pbu_beg;
1308-
oapv_bs_t bs_pbu_beg;
1309-
oapv_bsw_write(bs, 0, 32); // raw bitstream byte size (skip)
1308+
bs_pos_au_beg = oapv_bsw_sink(bs);
13101309

1310+
if(ctx->au_bs_fmt == OAPV_CFG_VAL_AU_BS_FMT_RBAU) {
1311+
oapv_bsw_write(bs, 0, 32); // raw bitstream byte size (skip)
1312+
}
13111313
oapv_bsw_write(bs, 0x61507631, 32); // signature ('aPv1')
13121314

13131315
for(i = 0; i < ifrms->num_frms; i++) {
@@ -1318,7 +1320,7 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
13181320
ret = enc_read_param(ctx, ctx->param);
13191321
oapv_assert_rv(ret == OAPV_OK, ret);
13201322

1321-
oapv_assert_rv(ctx->param->profile_idc == OAPV_PROFILE_422_10 || ctx->param->profile_idc == OAPV_PROFILE_400_10, OAPV_ERR_UNSUPPORTED);
1323+
oapv_assert_rv(ctx->param->profile_idc == OAPV_PROFILE_422_10, OAPV_ERR_UNSUPPORTED);
13221324

13231325
// prepare for encoding a frame
13241326
ret = enc_frm_prepare(ctx, frm->imgb, (rfrms != NULL) ? rfrms->frm[i].imgb : NULL);
@@ -1382,8 +1384,10 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
13821384
}
13831385
}
13841386

1385-
u32 au_size = (u32)((u8 *)oapv_bsw_sink(bs) - bs_pos_au_beg) - 4 /* au_size */;
1386-
oapv_bsw_write_direct(bs_pos_au_beg, au_size, 32); /* u(32) */
1387+
if(ctx->au_bs_fmt == OAPV_CFG_VAL_AU_BS_FMT_RBAU) {
1388+
u32 au_size = (u32)((u8 *)oapv_bsw_sink(bs) - bs_pos_au_beg) - 4;
1389+
oapv_bsw_write_direct(bs_pos_au_beg, au_size, 32);
1390+
}
13871391

13881392
oapv_bsw_deinit(&ctx->bs); /* de-init BSW */
13891393
stat->write = bsw_get_write_byte(&ctx->bs);
@@ -1430,6 +1434,12 @@ int oapve_config(oapve_t eid, int cfg, void *buf, int *size)
14301434
oapv_assert_rv(*size == sizeof(int), OAPV_ERR_INVALID_ARGUMENT);
14311435
ctx->use_frm_hash = (*((int *)buf)) ? 1 : 0;
14321436
break;
1437+
case OAPV_CFG_SET_AU_BS_FMT:
1438+
oapv_assert_rv(*size == sizeof(int), OAPV_ERR_INVALID_ARGUMENT);
1439+
t0 = *((int *)buf);
1440+
oapv_assert_rv(t0 == OAPV_CFG_VAL_AU_BS_FMT_RBAU || t0 == OAPV_CFG_VAL_AU_BS_FMT_NONE, OAPV_ERR_INVALID_ARGUMENT);
1441+
ctx->au_bs_fmt = t0;
1442+
break;
14331443
/* get config *******************************************************/
14341444
case OAPV_CFG_GET_QP:
14351445
oapv_assert_rv(*size == sizeof(int), OAPV_ERR_INVALID_ARGUMENT);
@@ -1455,6 +1465,10 @@ int oapve_config(oapve_t eid, int cfg, void *buf, int *size)
14551465
oapv_assert_rv(*size == sizeof(int), OAPV_ERR_INVALID_ARGUMENT);
14561466
*((int *)buf) = ctx->param->bitrate;
14571467
break;
1468+
case OAPV_CFG_GET_AU_BS_FMT:
1469+
oapv_assert_rv(*size == sizeof(int), OAPV_ERR_INVALID_ARGUMENT);
1470+
*((int *)buf) = ctx->au_bs_fmt;
1471+
break;
14581472
default:
14591473
oapv_trace("unknown config value (%d)\n", cfg);
14601474
oapv_assert_rv(0, OAPV_ERR_UNSUPPORTED);

src/oapv_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ struct oapve_ctx {
311311
oapve_rc_param_t rc_param;
312312

313313
int threads; // num of thread for encoding
314+
int au_bs_fmt; // access unit bitstream format
314315
/* platform specific data, if needed */
315316
void *pf;
316317
};

0 commit comments

Comments
 (0)