The HEVC decoder will start setting stereoscopic view position (left or right) based on 3D Reference Displays Info SEI message in future commits. This information should be merged with container-derived stereo3D side data.
Unified · Split
| @@ -37,6 +37,7 @@ · 36 unmodified lines | |||
| 37 | #include "libavutil/internal.h" | 37 | #include "libavutil/internal.h" |
| 38 | #include "libavutil/mastering_display_metadata.h" | 38 | #include "libavutil/mastering_display_metadata.h" |
| 39 | #include "libavutil/mem.h" | 39 | #include "libavutil/mem.h" |
| 40 | #include "libavutil/stereo3d.h" | ||
| 40 | 41 | ||
| 41 | #include "avcodec.h" | 42 | #include "avcodec.h" |
| 42 | #include "avcodec_internal.h" | 43 | #include "avcodec_internal.h" |
| @@ -1423,6 +1424,42 @@ const AVPacketSideData *ff_get_coded_side_data(const AVCodecContext *avctx, · 1380 unmodified lines | |||
| 1423 | return packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data, type); | 1424 | return packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data, type); |
| 1424 | } | 1425 | } |
| 1425 | 1426 | ||
| 1427 | static int side_data_stereo3d_merge(AVFrameSideData *sd_frame, | ||
| 1428 | const AVPacketSideData *sd_pkt) | ||
| 1429 | { | ||
| 1430 | const AVStereo3D *src; | ||
| 1431 | AVStereo3D *dst; | ||
| 1432 | int ret; | ||
| 1433 | |||
| 1434 | ret = av_buffer_make_writable(&sd_frame->buf); | ||
| 1435 | if (ret < 0) | ||
| 1436 | return ret; | ||
| 1437 | sd_frame->data = sd_frame->buf->data; | ||
| 1438 | |||
| 1439 | dst = ( AVStereo3D*)sd_frame->data; | ||
| 1440 | src = (const AVStereo3D*)sd_pkt->data; | ||
| 1441 | |||
| 1442 | if (dst->type == AV_STEREO3D_UNSPEC) | ||
| 1443 | dst->type = src->type; | ||
| 1444 | |||
| 1445 | if (dst->view == AV_STEREO3D_VIEW_UNSPEC) | ||
| 1446 | dst->view = src->view; | ||
| 1447 | |||
| 1448 | if (dst->primary_eye == AV_PRIMARY_EYE_NONE) | ||
| 1449 | dst->primary_eye = src->primary_eye; | ||
| 1450 | |||
| 1451 | if (!dst->baseline) | ||
| 1452 | dst->baseline = src->baseline; | ||
| 1453 | |||
| 1454 | if (!dst->horizontal_disparity_adjustment.num) | ||
| 1455 | dst->horizontal_disparity_adjustment = src->horizontal_disparity_adjustment; | ||
| 1456 | |||
| 1457 | if (!dst->horizontal_field_of_view.num) | ||
| 1458 | dst->horizontal_field_of_view = src->horizontal_field_of_view; | ||
| 1459 | |||
| 1460 | return 0; | ||
| 1461 | } | ||
| 1462 | |||
| 1426 | static int side_data_map(AVFrame *dst, | 1463 | static int side_data_map(AVFrame *dst, |
| 1427 | const AVPacketSideData *sd_src, int nb_sd_src, | 1464 | const AVPacketSideData *sd_src, int nb_sd_src, |
| 1428 | const SideDataMap *map) | 1465 | const SideDataMap *map) |
| @@ -1439,8 +1476,15 @@ static int side_data_map(AVFrame *dst, · 10 unmodified lines | |||
| 1439 | continue; | 1476 | continue; |
| 1440 | 1477 | ||
| 1441 | sd_frame = av_frame_get_side_data(dst, type_frame); | 1478 | sd_frame = av_frame_get_side_data(dst, type_frame); |
| 1442 | if (sd_frame) | 1479 | if (sd_frame) { |
| 1480 | if (type_frame == AV_FRAME_DATA_STEREO3D) { | ||
| 1481 | int ret = side_data_stereo3d_merge(sd_frame, sd_pkt); | ||
| 1482 | if (ret < 0) | ||
| 1483 | return ret; | ||
| 1484 | } | ||
| 1485 | |||
| 1443 | continue; | 1486 | continue; |
| 1487 | } | ||
| 1444 | 1488 | ||
| 1445 | sd_frame = av_frame_new_side_data(dst, type_frame, sd_pkt->size); | 1489 | sd_frame = av_frame_new_side_data(dst, type_frame, sd_pkt->size); |
| 1446 | if (!sd_frame) | 1490 | if (!sd_frame) |