aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-09-22 19:37:28 +0200
committerAnton Khirnov <anton@khirnov.net>2024-09-23 17:12:17 +0200
commit0fde9c609f5b87c54812daa60d66ca744294afda (patch)
treeb80f0bc1c9e969141ca6cb3c7560c222af4d0c3c
parent327080c088c53fe18070f4085a367576155a3564 (diff)
downloadffmpeg-0fde9c609f5b87c54812daa60d66ca744294afda.tar.gz
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.
-rw-r--r--libavcodec/decode.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index e5753023c2..c331bb8596 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -37,6 +37,7 @@
#include "libavutil/internal.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/mem.h"
+#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "avcodec_internal.h"
@@ -1423,6 +1424,42 @@ const AVPacketSideData *ff_get_coded_side_data(const AVCodecContext *avctx,
return packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data, type);
}
+static int side_data_stereo3d_merge(AVFrameSideData *sd_frame,
+ const AVPacketSideData *sd_pkt)
+{
+ const AVStereo3D *src;
+ AVStereo3D *dst;
+ int ret;
+
+ ret = av_buffer_make_writable(&sd_frame->buf);
+ if (ret < 0)
+ return ret;
+ sd_frame->data = sd_frame->buf->data;
+
+ dst = ( AVStereo3D*)sd_frame->data;
+ src = (const AVStereo3D*)sd_pkt->data;
+
+ if (dst->type == AV_STEREO3D_UNSPEC)
+ dst->type = src->type;
+
+ if (dst->view == AV_STEREO3D_VIEW_UNSPEC)
+ dst->view = src->view;
+
+ if (dst->primary_eye == AV_PRIMARY_EYE_NONE)
+ dst->primary_eye = src->primary_eye;
+
+ if (!dst->baseline)
+ dst->baseline = src->baseline;
+
+ if (!dst->horizontal_disparity_adjustment.num)
+ dst->horizontal_disparity_adjustment = src->horizontal_disparity_adjustment;
+
+ if (!dst->horizontal_field_of_view.num)
+ dst->horizontal_field_of_view = src->horizontal_field_of_view;
+
+ return 0;
+}
+
static int side_data_map(AVFrame *dst,
const AVPacketSideData *sd_src, int nb_sd_src,
const SideDataMap *map)
@@ -1439,8 +1476,15 @@ static int side_data_map(AVFrame *dst,
continue;
sd_frame = av_frame_get_side_data(dst, type_frame);
- if (sd_frame)
+ if (sd_frame) {
+ if (type_frame == AV_FRAME_DATA_STEREO3D) {
+ int ret = side_data_stereo3d_merge(sd_frame, sd_pkt);
+ if (ret < 0)
+ return ret;
+ }
+
continue;
+ }
sd_frame = av_frame_new_side_data(dst, type_frame, sd_pkt->size);
if (!sd_frame)