Skip to content

Commit a049e5f

Browse files
committed
add signature syntax for android 16 25q2
Signed-off-by: [email protected] <[email protected]>
1 parent c9a3152 commit a049e5f

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

src/oapv.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,8 @@ int oapve_encode(oapve_t eid, oapv_frms_t *ifrms, oapvm_t mid, oapv_bitb_t *bitb
13011301
oapv_bs_t bs_pbu_beg;
13021302
oapv_bsw_write(bs, 0, 32);
13031303

1304+
oapv_bsw_write(bs, 0x61507631, 32); // signature ('aPv1')
1305+
13041306
for(i = 0; i < ifrms->num_frms; i++) {
13051307
frm = &ifrms->frm[i];
13061308

@@ -1953,6 +1955,13 @@ int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms, oapvm_t mid
19531955
ctx = dec_id_to_ctx(did);
19541956
oapv_assert_rv(ctx, OAPV_ERR_INVALID_ARGUMENT);
19551957

1958+
// read signature ('aPv1')
1959+
oapv_assert_rv(bitb->ssize > 4, OAPV_ERR_MALFORMED_BITSTREAM);
1960+
u32 signature = oapv_bsr_read_direct(bitb->addr, 32);
1961+
oapv_assert_rv(signature == 0x61507631, OAPV_ERR_MALFORMED_BITSTREAM);
1962+
cur_read_size += 4;
1963+
stat->read += 4;
1964+
19561965
do {
19571966
u32 remain = bitb->ssize - cur_read_size;
19581967
oapv_assert_gv((remain >= 8), ret, OAPV_ERR_MALFORMED_BITSTREAM, ERR);
@@ -2065,6 +2074,12 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
20652074

20662075
DUMP_SET(0);
20672076

2077+
// read signature ('aPv1')
2078+
oapv_assert_rv(au_size > 4, OAPV_ERR_MALFORMED_BITSTREAM);
2079+
u32 signature = oapv_bsr_read_direct(au, 32);
2080+
oapv_assert_rv(signature == 0x61507631, OAPV_ERR_MALFORMED_BITSTREAM);
2081+
cur_read_size += 4;
2082+
20682083
/* 'au' address contains series of PBU */
20692084
do {
20702085
oapv_bs_t bs;

src/oapv_bs.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,26 @@ int oapv_bsr_read1(oapv_bs_t *bs)
370370
return code;
371371
}
372372

373+
u32 oapv_bsr_read_direct(void *addr, int len)
374+
{
375+
u32 code = 0;
376+
int shift = 24;
377+
u8 *p = (u8 *)addr;
378+
int byte = (len + 7) >> 3;
379+
380+
oapv_assert(len <= 32);
381+
382+
while(byte) {
383+
code |= *(p) << shift;
384+
shift -= 8;
385+
byte--;
386+
p++;
387+
}
388+
code = code >> (32 - len);
389+
return code;
390+
}
391+
392+
373393
///////////////////////////////////////////////////////////////////////////////
374394
// end of decoder code
375395
#endif // ENABLE_DECODER

src/oapv_bs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void *oapv_bsr_sink(oapv_bs_t *bs);
139139
void oapv_bsr_move(oapv_bs_t *bs, u8 *pos);
140140
u32 oapv_bsr_read(oapv_bs_t *bs, int size);
141141
int oapv_bsr_read1(oapv_bs_t *bs);
142+
u32 oapv_bsr_read_direct(void *addr, int len);
142143

143144
///////////////////////////////////////////////////////////////////////////////
144145
// end of decoder code

util/apv.hexpat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ struct AccessUnit {
207207
au_end = $ + au_size;
208208

209209
pbu_count = 0; // reset number of PBU
210+
211+
char signature[4]; // 'aPv1'
210212
PBU pbu[while($ < au_end)] [[inline]];
211213
};
212214

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.1.11.1
1+
v0.1.11.3.1

0 commit comments

Comments
 (0)