Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/oapv_app_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static const args_opt_t enc_args_opts[] = {
"level setting (1, 1.1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 6, 6.1, 7, 7.1)"
},
{
ARGS_NO_KEY, "band", ARGS_VAL_TYPE_INTEGER, 0, NULL,
ARGS_NO_KEY, "band", ARGS_VAL_TYPE_STRING, 0, NULL,
"band setting (0, 1, 2, 3)"
},
{
Expand All @@ -131,15 +131,15 @@ static const args_opt_t enc_args_opts[] = {
"number of skipped access units before encoding"
},
{
ARGS_NO_KEY, "qp-offset-c1", ARGS_VAL_TYPE_INTEGER, 0, NULL,
ARGS_NO_KEY, "qp-offset-c1", ARGS_VAL_TYPE_STRING, 0, NULL,
"QP offset value for Component 1 (Cb)"
},
{
ARGS_NO_KEY, "qp-offset-c2", ARGS_VAL_TYPE_INTEGER, 0, NULL,
ARGS_NO_KEY, "qp-offset-c2", ARGS_VAL_TYPE_STRING, 0, NULL,
"QP offset value for Component 2 (Cr)"
},
{
ARGS_NO_KEY, "qp-offset-c3", ARGS_VAL_TYPE_INTEGER, 0, NULL,
ARGS_NO_KEY, "qp-offset-c3", ARGS_VAL_TYPE_STRING, 0, NULL,
"QP offset value for Component 3"
},
{
Expand Down Expand Up @@ -546,7 +546,7 @@ static int update_param(args_var_t *vars, oapve_param_t *param)


UPDATE_A_PARAM_W_KEY_VAL(param, "tile-w", vars->tile_w);
UPDATE_A_PARAM_W_KEY_VAL(param, "tile-w", vars->tile_h);
UPDATE_A_PARAM_W_KEY_VAL(param, "tile-h", vars->tile_h);

param->csp = vars->input_csp;
return 0;
Expand Down
57 changes: 38 additions & 19 deletions inc/oapv.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,18 @@ struct oapv_frm_info {
int chroma_format_idc;
int bit_depth;
int capture_time_distance;
/* custom quantization matrix */
// flag for custom quantization matrix
int use_q_matrix;
unsigned char q_matrix[OAPV_MAX_CC][OAPV_BLK_D]; // only meaningful if use_q_matrix is true
/* color description values */
// q_matrix is meaningful if use_q_matrix is true
unsigned char q_matrix[OAPV_MAX_CC][OAPV_BLK_D];
// flag for color_description_present_flag */
int color_description_present_flag;
unsigned char color_primaries; // only meaningful if color_description_present_flag is true
unsigned char transfer_characteristics; // only meaningful if color_description_present_flag is true
unsigned char matrix_coefficients; // only meaningful if color_description_present_flag is true
int full_range_flag; // only meaningful if color_description_present_flag is true
// color_primaries, transfer_characteristics, matrix_coefficients, and
// full_range_flag are meaningful if color_description_present_flag is true
unsigned char color_primaries;
unsigned char transfer_characteristics;
unsigned char matrix_coefficients;
int full_range_flag;
};

typedef struct oapv_au_info oapv_au_info_t;
Expand Down Expand Up @@ -525,43 +528,59 @@ struct oapve_param {
};

#define OAPV_CDESC_THREADS_AUTO 0
/*****************************************************************************
* automatic assignment of number of threads in creation of encoder & decoder
*****************************************************************************/
#define OAPV_CDESC_THREADS_AUTO 0

/*****************************************************************************
* description for encoder creation
*****************************************************************************/
typedef struct oapve_cdesc oapve_cdesc_t;
struct oapve_cdesc {
int max_bs_buf_size; // max bitstream buffer size
int max_num_frms; // max number of frames to be encoded
int threads; // number of threads
oapve_param_t param[OAPV_MAX_NUM_FRAMES]; // encoding parameters
// max bitstream buffer size
int max_bs_buf_size;
// max number of frames to be encoded
int max_num_frms;
// max number of threads (or OAPV_CDESC_THREADS_AUTO for auto-assignment)
int threads;
// encoding parameters
oapve_param_t param[OAPV_MAX_NUM_FRAMES];
};

/*****************************************************************************
* encoding status
*****************************************************************************/
typedef struct oapve_stat oapve_stat_t;
struct oapve_stat {
int write; // byte size of encoded bitstream
oapv_au_info_t aui; // information of encoded frames
int frm_size[OAPV_MAX_NUM_FRAMES]; // bitstream byte size of each frame
// byte size of encoded bitstream
int write;
// information of encoded frames
oapv_au_info_t aui;
// bitstream byte size of each frame
int frm_size[OAPV_MAX_NUM_FRAMES];
};

/*****************************************************************************
* description for decoder creation
*****************************************************************************/
typedef struct oapvd_cdesc oapvd_cdesc_t;
struct oapvd_cdesc {
int threads; // number of threads
// max number of threads (or OAPV_CDESC_THREADS_AUTO for auto-assignment)
int threads;
};

/*****************************************************************************
* decoding status
*****************************************************************************/
typedef struct oapvd_stat oapvd_stat_t;
struct oapvd_stat {
int read; // byte size of decoded bitstream (read size)
oapv_au_info_t aui; // information of decoded frames
int frm_size[OAPV_MAX_NUM_FRAMES]; // bitstream byte size of each frame
// byte size of decoded bitstream (read size)
int read;
// information of decoded frames
oapv_au_info_t aui;
// bitstream byte size of each frame
int frm_size[OAPV_MAX_NUM_FRAMES];
};

/*****************************************************************************
Expand All @@ -579,7 +598,7 @@ struct oapvm_payload {
/*****************************************************************************
* interface for metadata container
*****************************************************************************/
typedef void *oapvm_t; /* instance identifier for OAPV metadata container */
typedef void *oapvm_t; // instance identifier for OAPV metadata container

oapvm_t OAPV_EXPORT oapvm_create(int *err);
void OAPV_EXPORT oapvm_delete(oapvm_t mid);
Expand Down
34 changes: 26 additions & 8 deletions src/oapv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,9 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
u8 *bs_pos_au_beg = oapv_bsw_sink(bs); // address syntax of au size
u8 *bs_pos_pbu_beg;
oapv_bs_t bs_pbu_beg;
oapv_bsw_write(bs, 0, 32);
oapv_bsw_write(bs, 0, 32); // raw bitstream byte size (skip)

oapv_bsw_write(bs, 0x61507631, 32); // signature ('aPv1')

for(i = 0; i < ifrms->num_frms; i++) {
frm = &ifrms->frm[i];
Expand Down Expand Up @@ -1419,7 +1421,7 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
}
}

u32 au_size = (u32)((u8 *)oapv_bsw_sink(bs) - bs_pos_au_beg) - 4;
u32 au_size = (u32)((u8 *)oapv_bsw_sink(bs) - bs_pos_au_beg) - 4 /* au_size */;
oapv_bsw_write_direct(bs_pos_au_beg, au_size, 32); /* u(32) */

oapv_bsw_deinit(&ctx->bs); /* de-init BSW */
Expand Down Expand Up @@ -1975,7 +1977,6 @@ void oapvd_delete(oapvd_t did)
int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid, oapvd_stat_t *stat)
{
oapvd_ctx_t *ctx;
oapv_bs_t *bs;
oapv_pbuh_t pbuh;
int ret = OAPV_OK;
u32 pbu_size;
Expand All @@ -1985,7 +1986,16 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid
ctx = dec_id_to_ctx(did);
oapv_assert_rv(ctx, OAPV_ERR_INVALID_ARGUMENT);

// read signature ('aPv1')
oapv_assert_rv(bitb->ssize > 4, OAPV_ERR_MALFORMED_BITSTREAM);
u32 signature = oapv_bsr_read_direct(bitb->addr, 32);
oapv_assert_rv(signature == 0x61507631, OAPV_ERR_MALFORMED_BITSTREAM);
cur_read_size += 4;
stat->read += 4;

// decode PBUs
do {
oapv_bs_t *bs;
u32 remain = bitb->ssize - cur_read_size;
oapv_assert_gv((remain >= 8), ret, OAPV_ERR_MALFORMED_BITSTREAM, ERR);
oapv_bsr_init(&ctx->bs, (u8 *)bitb->addr + cur_read_size, remain, NULL);
Expand Down Expand Up @@ -2048,7 +2058,7 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid

ofrms->frm[frame_cnt].pbu_type = pbuh.pbu_type;
ofrms->frm[frame_cnt].group_id = pbuh.group_id;
stat->frm_size[frame_cnt] = pbu_size + 4 /* PUB size length*/;
stat->frm_size[frame_cnt] = pbu_size + 4 /* byte size of 'pbu_size' syntax */;
frame_cnt++;
}
else if(pbuh.pbu_type == OAPV_PBU_TYPE_METADATA) {
Expand All @@ -2061,7 +2071,7 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid
ret = oapvd_vlc_filler(bs, (pbu_size - 4));
oapv_assert_g(OAPV_SUCCEEDED(ret), ERR);
}
cur_read_size += pbu_size + 4;
cur_read_size += pbu_size + 4 /* byte size of 'pbu_size' syntax */;
} while(cur_read_size < bitb->ssize);
stat->aui.num_frms = frame_cnt;
oapv_assert_gv(ofrms->num_frms == frame_cnt, ret, OAPV_ERR_MALFORMED_BITSTREAM, ERR);
Expand Down Expand Up @@ -2094,15 +2104,22 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
{
int ret, frm_count = 0;
u32 cur_read_size = 0;
int pbu_count = 0;
oapv_bs_t bs;

DUMP_SET(0);

/* 'au' address contains series of PBU */
// read signature ('aPv1')
oapv_assert_rv(au_size > 4, OAPV_ERR_MALFORMED_BITSTREAM);
u32 signature = oapv_bsr_read_direct(au, 32);
oapv_assert_rv(signature == 0x61507631, OAPV_ERR_MALFORMED_BITSTREAM);
cur_read_size += 4;

// parse PBUs
do {
oapv_bs_t bs;
u32 pbu_size = 0;
u32 remain = au_size - cur_read_size;
oapv_assert_rv((remain >= 8), OAPV_ERR_MALFORMED_BITSTREAM);
oapv_assert_rv(remain >= 8, OAPV_ERR_MALFORMED_BITSTREAM);
oapv_bsr_init(&bs, (u8 *)au + cur_read_size, remain, NULL);

ret = oapvd_vlc_pbu_size(&bs, &pbu_size); // read pbu_size (4 byte)
Expand Down Expand Up @@ -2144,6 +2161,7 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
}
aui->num_frms = frm_count;
cur_read_size += pbu_size + 4; /* 4byte is for pbu_size syntax itself */
pbu_count++;
} while(cur_read_size < au_size);
DUMP_SET(1);
return OAPV_OK;
Expand Down
24 changes: 22 additions & 2 deletions src/oapv_bs.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ void *oapv_bsw_sink(oapv_bs_t *bs)
return (void *)bs->cur;
}

int oapv_bsw_write_direct(void *bits, u32 val, int len)
int oapv_bsw_write_direct(void *addr, u32 val, int len)
{
int i;
unsigned char *p = (unsigned char *)bits;
unsigned char *p = (unsigned char *)addr;

oapv_assert_rv((len & 0x7) == 0, -1); // len should be byte-aligned

Expand Down Expand Up @@ -370,6 +370,26 @@ int oapv_bsr_read1(oapv_bs_t *bs)
return code;
}

u32 oapv_bsr_read_direct(void *addr, int len)
{
u32 code = 0;
int shift = 24;
u8 *p = (u8 *)addr;
int byte = (len + 7) >> 3;

oapv_assert(len <= 32);

while(byte) {
code |= *(p) << shift;
shift -= 8;
byte--;
p++;
}
code = code >> (32 - len);
return code;
}


///////////////////////////////////////////////////////////////////////////////
// end of decoder code
#endif // ENABLE_DECODER
Expand Down
3 changes: 2 additions & 1 deletion src/oapv_bs.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static inline int bsw_get_write_byte(oapv_bs_t *bs)
void oapv_bsw_init(oapv_bs_t *bs, u8 *buf, int size, oapv_bs_fn_flush_t fn_flush);
void oapv_bsw_deinit(oapv_bs_t *bs);
void *oapv_bsw_sink(oapv_bs_t *bs);
int oapv_bsw_write_direct(void *bits, u32 val, int len);
int oapv_bsw_write_direct(void *addr, u32 val, int len);
int oapv_bsw_write1(oapv_bs_t *bs, int val);
int oapv_bsw_write(oapv_bs_t *bs, u32 val, int len);
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -139,6 +139,7 @@ void *oapv_bsr_sink(oapv_bs_t *bs);
void oapv_bsr_move(oapv_bs_t *bs, u8 *pos);
u32 oapv_bsr_read(oapv_bs_t *bs, int size);
int oapv_bsr_read1(oapv_bs_t *bs);
u32 oapv_bsr_read_direct(void *addr, int len);

///////////////////////////////////////////////////////////////////////////////
// end of decoder code
Expand Down
2 changes: 1 addition & 1 deletion src/oapv_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/

#ifndef __OAPV_PARAM_H__32943289478329438247238643278463728473829__
#define ifndef __OAPV_PARAM_H__32943289478329438247238643278463728473829__
#define __OAPV_PARAM_H__32943289478329438247238643278463728473829__

#include "oapv.h"

Expand Down
24 changes: 12 additions & 12 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

| No. | Bitstream Name | Description | Profile&nbsp;&nbsp; | Level | Band | Frame Rate | Resolution | # of Frame | MD5 sum of bitstream |
|-----|----------------|--------------------------------------------------------------|---------------------|-------|------|------------|------------|------------|----------------------------------|
| 1 | tile_A | one-tile per one-picture | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 74c5c0ca1bd2cfb28c6e2e0673e965f9 |
| 2 | tile_B | Tile size = min size tile (256x128) | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 666ec80235a1e8f59db044d77a89a495 |
| 3 | tile_C | # of Tiles: max num tile (20x20) | 422-10 | 5 | 0 | 30 fps | 7680x4320 | 3 | 75363d036965a9dccc90a9ce8d0ae652 |
| 4 | tile_D | tile dummy data test | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | dd492519c90409a9ca5710746f45c125 |
| 5 | tile_E | tile_size_present_in_fh_flag=on | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 134c4aa46cec9ab0299824682a89eecd |
| 6 | qp_A | QP matrix enabled | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 5ca6d4ea0f65add261b44ed3532a0a73 |
| 7 | qp_B | Tile QP variation in a frame | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 85bfa477911447d994c17dea9703a9c7 |
| 8 | qp_C | Set all the QPs in a frame equal to min. QP (=0) | 422-10 | 6 | 2 | 60 fps | 3840x2160 | 3 | 8c2928ec05eb06d42d6a8bda0ceb7e8d |
| 9 | qp_D | Set all the QPs in a frame equal to max. QP (=51) | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 9c98e376fb59100f5a5585482fb33746 |
| 10 | qp_E | Set different QP betwee luma and chroma | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 6d1a1bc982d412758f353c8d041979d1 |
| 11 | syn_A | Exercise a synthetic image with QP = 0 and QP = 51 | 422-10 | 4.1 | 2 | 60 fps | 1920x1080 | 2 | db9f8f7ce57871481e5b257b79149b1e |
| 12 | syn_B | Exercise a synthetic image with Tile QP variation in Frame | 422-10 | 4.1 | 2 | 60 fps | 1920x1080 | 2 | 5f6c57f0bfe7ceb2f97a56a3bec7fb7a |
| 1 | tile_A | one-tile per one-picture | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | c5b2f4c4ec9804f0292b2f12bd558dc5 |
| 2 | tile_B | Tile size = min size tile (256x128) | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 7d626cea95f8d7a4b3f1f6e3d10e923c |
| 3 | tile_C | # of Tiles: max num tile (20x20) | 422-10 | 5 | 0 | 30 fps | 7680x4320 | 3 | 758377994717d15999f53341eb5d6038 |
| 4 | tile_D | tile dummy data test | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | e124625d4ad310e2e60e366a63f669c9 |
| 5 | tile_E | tile_size_present_in_fh_flag=on | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 77cd01a8821cd17c2188fca033edc726 |
| 6 | qp_A | QP matrix enabled | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 1ade0aed96ddf0aab286a082c17701d7 |
| 7 | qp_B | Tile QP variation in a frame | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | c7cac366f29dc6571bc814923cadeb4b |
| 8 | qp_C | Set all the QPs in a frame equal to min. QP (=0) | 422-10 | 6 | 2 | 60 fps | 3840x2160 | 3 | 6e2928f315e1670b6842955b0e7b4ad8 |
| 9 | qp_D | Set all the QPs in a frame equal to max. QP (=51) | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | c7a3e5d7f1c987a064a7bdb08944901f |
| 10 | qp_E | Set different QP betwee luma and chroma | 422-10 | 4.1 | 2 | 60 fps | 3840x2160 | 3 | 7d626cea95f8d7a4b3f1f6e3d10e923c |
| 11 | syn_A | Exercise a synthetic image with QP = 0 and QP = 51 | 422-10 | 4.1 | 2 | 60 fps | 1920x1080 | 2 | 7b0cc8fdffdfca860dcee9b69b051053 |
| 12 | syn_B | Exercise a synthetic image with Tile QP variation in Frame | 422-10 | 4.1 | 2 | 60 fps | 1920x1080 | 2 | b87a59443b009e9241393e6e1a927d61 |

## Test sequence
"sequence" folder has the uncompressed video sequence for encoder testing.
Binary file modified test/bitstream/qp_A.apv
Binary file not shown.
Binary file modified test/bitstream/qp_B.apv
Binary file not shown.
Binary file modified test/bitstream/qp_C.apv
Binary file not shown.
Binary file modified test/bitstream/qp_D.apv
Binary file not shown.
Binary file modified test/bitstream/qp_E.apv
Binary file not shown.
Binary file modified test/bitstream/syn_A.apv
Binary file not shown.
Binary file modified test/bitstream/syn_B.apv
Binary file not shown.
Binary file modified test/bitstream/tile_A.apv
Binary file not shown.
Binary file modified test/bitstream/tile_B.apv
Binary file not shown.
Binary file modified test/bitstream/tile_C.apv
Binary file not shown.
Binary file modified test/bitstream/tile_D.apv
Binary file not shown.
Binary file modified test/bitstream/tile_E.apv
Binary file not shown.
Loading