History

lavc/decode: merge stereo3d information from decoder with packet side data

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.

Anton Khirnov committed 2 years ago

Commit 0fde9c61 parent 327080c1 file · +45 −1Browse files

Unified · Split

libavcodec/decode.c+45−1
@@ -37,6 +37,7 @@ · 36 unmodified lines
3737 #include "libavutil/internal.h"
3838 #include "libavutil/mastering_display_metadata.h"
3939 #include "libavutil/mem.h"
40+#include "libavutil/stereo3d.h"
4041
4142 #include "avcodec.h"
4243 #include "avcodec_internal.h"
@@ -1423,6 +1424,42 @@ const AVPacketSideData *ff_get_coded_side_data(const AVCodecContext *avctx, · 1380 unmodified lines
14231424 return packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data, type);
14241425 }
14251426
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+
14261463 static int side_data_map(AVFrame *dst,
14271464 const AVPacketSideData *sd_src, int nb_sd_src,
14281465 const SideDataMap *map)
@@ -1439,8 +1476,15 @@ static int side_data_map(AVFrame *dst, · 10 unmodified lines
14391476 continue;
14401477
14411478 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+
14431486 continue;
1487+ }
14441488
14451489 sd_frame = av_frame_new_side_data(dst, type_frame, sd_pkt->size);
14461490 if (!sd_frame)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t