| 1571 | } |
| 1572 | |
| 1573 | int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) |
| 1574 | { |
| 1575 | int ret; |
| 1576 | |
| 1577 | ret = side_data_map(frame, avctx->coded_side_data, avctx->nb_coded_side_data, |
| 1578 | ff_sd_global_map); |
| 1579 | if (ret < 0) |
| 1580 | return ret; |
| 1581 | |
| 1582 | for (int i = 0; i < avctx->nb_decoded_side_data; i++) { |
| 1583 | const AVFrameSideData *src = avctx->decoded_side_data[i]; |
| 1584 | if (av_frame_get_side_data(frame, src->type)) |
| 1585 | continue; |
| 1586 | ret = av_frame_side_data_clone(&frame->side_data, &frame->nb_side_data, src, 0); |
| 1587 | if (ret < 0) |
| 1588 | return ret; |
| 1589 | } |
| 1590 | |
| 1591 | if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { |
| 1592 | const AVPacket *pkt = avctx->internal->last_pkt_props; |
| 1593 | |
| 1594 | ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt); |
| 1595 | if (ret < 0) |
| 1596 | return ret; |
| 1597 | } |
| 1598 | |
| 1599 | ret = fill_frame_props(avctx, frame); |
| 1600 | if (ret < 0) |
| 1601 | return ret; |
| 1602 | |
| 1603 | switch (avctx->codec->type) { |
| 1604 | case AVMEDIA_TYPE_VIDEO: |
| 1605 | if (frame->width && frame->height && |
| 1606 | av_image_check_sar(frame->width, frame->height, |
| 1607 | frame->sample_aspect_ratio) < 0) { |
| 1608 | av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", |
| 1609 | frame->sample_aspect_ratio.num, |
| 1610 | frame->sample_aspect_ratio.den); |
| 1611 | frame->sample_aspect_ratio = (AVRational){ 0, 1 }; |
| 1612 | } |
| 1613 | break; |
| 1614 | } |
| 1615 | return 0; |
| 1616 | } |
| 1617 | |
| 1618 | static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame) |
| 1619 | { |
no test coverage detected