@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/stereo3d.h"
+
#include "cbs_h264.h"
int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx,
@@ -104,3 +106,48 @@ void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
(sei->payload_count - position) * sizeof(*sei->payload));
}
}
+
+void ff_cbs_h264_fill_sei_frame_packing_arrangement(H264RawSEIFramePackingArrangement *fp,
+ const AVStereo3D *st)
+{
+ static const int type_map[] = {
+ [AV_STEREO3D_2D] = 6,
+ [AV_STEREO3D_SIDEBYSIDE] = 3,
+ [AV_STEREO3D_TOPBOTTOM] = 4,
+ [AV_STEREO3D_FRAMESEQUENCE] = 5,
+ [AV_STEREO3D_CHECKERBOARD] = 0,
+ [AV_STEREO3D_SIDEBYSIDE_QUINCUNX] = 3,
+ [AV_STEREO3D_LINES] = 2,
+ [AV_STEREO3D_COLUMNS] = 1,
+ };
+
+ memset(fp, 0, sizeof(*fp));
+
+ if (st->type >= FF_ARRAY_ELEMS(type_map))
+ return;
+
+ fp->frame_packing_arrangement_type = type_map[st->type];
+
+ fp->quincunx_sampling_flag =
+ st->type == AV_STEREO3D_CHECKERBOARD ||
+ st->type == AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+
+ if (st->type == AV_STEREO3D_2D)
+ fp->content_interpretation_type = 0;
+ else if (st->flags & AV_STEREO3D_FLAG_INVERT)
+ fp->content_interpretation_type = 2;
+ else
+ fp->content_interpretation_type = 1;
+
+ if (st->type == AV_STEREO3D_FRAMESEQUENCE) {
+ if (st->flags & AV_STEREO3D_FLAG_INVERT)
+ fp->current_frame_is_frame0_flag =
+ st->view == AV_STEREO3D_VIEW_RIGHT;
+ else
+ fp->current_frame_is_frame0_flag =
+ st->view == AV_STEREO3D_VIEW_LEFT;
+ }
+
+ fp->frame_packing_arrangement_repetition_period =
+ st->type != AV_STEREO3D_FRAMESEQUENCE;
+}
@@ -525,4 +525,12 @@ void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
CodedBitstreamUnit *nal_unit,
int position);
+struct AVStereo3D;
+/**
+ * Fill an SEI Frame Packing Arrangement structure with values derived from
+ * the AVStereo3D side-data structure.
+ */
+void ff_cbs_h264_fill_sei_frame_packing_arrangement(H264RawSEIFramePackingArrangement *fp,
+ const struct AVStereo3D *st);
+
#endif /* AVCODEC_CBS_H264_H */