| 399 | } |
| 400 | |
| 401 | static int apv_decode_metadata(AVCodecContext *avctx, AVFrame *frame, |
| 402 | const APVRawMetadata *md) |
| 403 | { |
| 404 | int err; |
| 405 | |
| 406 | for (int i = 0; i < md->metadata_count; i++) { |
| 407 | const APVRawMetadataPayload *pl = &md->payloads[i]; |
| 408 | |
| 409 | switch (pl->payload_type) { |
| 410 | case APV_METADATA_MDCV: |
| 411 | { |
| 412 | const APVRawMetadataMDCV *mdcv = &pl->mdcv; |
| 413 | AVMasteringDisplayMetadata *mdm; |
| 414 | |
| 415 | err = ff_decode_mastering_display_new(avctx, frame, &mdm); |
| 416 | if (err < 0) |
| 417 | return err; |
| 418 | |
| 419 | if (mdm) { |
| 420 | for (int j = 0; j < 3; j++) { |
| 421 | mdm->display_primaries[j][0] = |
| 422 | av_make_q(mdcv->primary_chromaticity_x[j], 1 << 16); |
| 423 | mdm->display_primaries[j][1] = |
| 424 | av_make_q(mdcv->primary_chromaticity_y[j], 1 << 16); |
| 425 | } |
| 426 | |
| 427 | mdm->white_point[0] = |
| 428 | av_make_q(mdcv->white_point_chromaticity_x, 1 << 16); |
| 429 | mdm->white_point[1] = |
| 430 | av_make_q(mdcv->white_point_chromaticity_y, 1 << 16); |
| 431 | |
| 432 | mdm->max_luminance = |
| 433 | av_make_q(mdcv->max_mastering_luminance, 1 << 8); |
| 434 | mdm->min_luminance = |
| 435 | av_make_q(mdcv->min_mastering_luminance, 1 << 14); |
| 436 | |
| 437 | mdm->has_primaries = 1; |
| 438 | mdm->has_luminance = 1; |
| 439 | } |
| 440 | } |
| 441 | break; |
| 442 | case APV_METADATA_CLL: |
| 443 | { |
| 444 | const APVRawMetadataCLL *cll = &pl->cll; |
| 445 | AVContentLightMetadata *clm; |
| 446 | |
| 447 | err = ff_decode_content_light_new(avctx, frame, &clm); |
| 448 | if (err < 0) |
| 449 | return err; |
| 450 | |
| 451 | if (clm) { |
| 452 | clm->MaxCLL = cll->max_cll; |
| 453 | clm->MaxFALL = cll->max_fall; |
| 454 | } |
| 455 | } |
| 456 | break; |
| 457 | default: |
| 458 | // Ignore other types of metadata. |
no test coverage detected