Skip to content

Commit 803e75e

Browse files
committed
implemented read function for MDCV and CLL
Signed-off-by: [email protected] <[email protected]>
1 parent 7254eeb commit 803e75e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/oapv_metadata.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,22 @@ int oapvm_write_mdcv(oapvm_payload_mdcv_t *mdcv, void *data, int *size)
219219

220220
int oapvm_read_mdcv(void *data, int size, oapvm_payload_mdcv_t *mdcv)
221221
{
222+
int i;
223+
oapv_bs_t bs;
224+
oapv_assert_rv(size >= 24, OAPV_ERR_INVALID_ARGUMENT);
225+
oapv_bsr_init(&bs, data, size, NULL); // MDCV payload has 24 bytes
226+
227+
for(i = 0; i < 3; i++) {
228+
mdcv->primary_chromaticity_x[i] = oapv_bsr_read(&bs, 16);
229+
}
230+
for(i = 0; i < 3; i++) {
231+
mdcv->primary_chromaticity_y[i] = oapv_bsr_read(&bs, 16);
232+
}
233+
mdcv->white_point_chromaticity_x = oapv_bsr_read(&bs, 16);
234+
mdcv->white_point_chromaticity_y = oapv_bsr_read(&bs, 16);
235+
236+
mdcv->max_mastering_luminance = oapv_bsr_read(&bs, 32);
237+
mdcv->min_mastering_luminance = oapv_bsr_read(&bs, 32);
222238
return OAPV_OK;
223239
}
224240

@@ -242,6 +258,12 @@ int oapvm_write_cll(oapvm_payload_cll_t *cll, void *data, int *size)
242258

243259
int oapvm_read_cll(void *data, int size, oapvm_payload_cll_t *cll)
244260
{
261+
oapv_bs_t bs;
262+
oapv_assert_rv(size >= 4, OAPV_ERR_INVALID_ARGUMENT);
263+
oapv_bsr_init(&bs, data, size, NULL); // CLL payload has 4 bytes
264+
265+
cll->max_cll = oapv_bsr_read(&bs, 16);
266+
cll->max_fall = oapv_bsr_read(&bs, 16);
245267
return OAPV_OK;
246268
}
247269

0 commit comments

Comments
 (0)