Skip to content

Commit 0c3f115

Browse files
authored
Merge pull request #94 from AcademySoftwareFoundation/restrict_odd_width
Restrict odd width
2 parents 5856125 + 46d0036 commit 0c3f115

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

inc/oapv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ extern "C" {
8585
#define OAPV_ERR_MALFORMED_BITSTREAM (-202)
8686
#define OAPV_ERR_OUT_OF_BS_BUF (-203) /* too small bitstream buffer */
8787
#define OAPV_ERR_NOT_FOUND (-204)
88-
#define OAPV_ERR_FAILED_SYSCALL (-301) /* failed system call */
88+
#define OAPV_ERR_FAILED_SYSCALL (-301) /* failed system call */
8989
#define OAPV_ERR_INVALID_LEVEL (-401)
90+
#define OAPV_ERR_INVALID_WIDTH (-405) /* invalid width (like odd) */
9091
#define OAPV_ERR_UNKNOWN (-32767) /* unknown error */
9192

9293
/* return value checking */

src/oapv_param.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ int oapve_param_update(oapve_ctx_t* ctx)
476476
int ret = OAPV_OK;
477477
int min_num_tiles = OAPV_MAX_TILES;
478478
for (int i = 0; i < ctx->cdesc.max_num_frms; i++) {
479+
if(ctx->cdesc.param[i].csp == 2 && ctx->cdesc.param[i].w & 0x1) { // check width restriction for 422
480+
return OAPV_ERR_INVALID_WIDTH; // odd width is not spec-out
481+
}
479482
ret = enc_update_param_tile(ctx, &ctx->cdesc.param[i]);
480483
oapv_assert_rv(ret == OAPV_OK, ret);
481484
int num_tiles = oapv_div_round_up(ctx->w, ctx->cdesc.param[i].tile_w) * oapv_div_round_up(ctx->h, ctx->cdesc.param[i].tile_h);

src/oapv_vlc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ int oapvd_vlc_frame_info(oapv_bs_t *bs, oapv_fi_t *fi)
702702
// check frame width in case of 422 format.
703703
if(fi->chroma_format_idc == 2) {
704704
// frame_width should be multiple of 2
705-
oapv_assert_rv((fi->frame_width & 0x1) == 0, OAPV_ERR_MALFORMED_BITSTREAM);
705+
oapv_assert_rv((fi->frame_width & 0x1) == 0, OAPV_ERR_INVALID_WIDTH);
706706
}
707707

708708
return OAPV_OK;

0 commit comments

Comments
 (0)