diff --git a/doc/APIchanges b/doc/APIchanges index 44a740e51f..4af69c64bd 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2017-xx-xx - xxxxxxx - lavu 56.4.100 / 56.7.0 - stereo3d.h + Add view field to AVStereo3D structure and AVStereo3DView enum. + 2017-xx-xx - xxxxxxx - lavc 58.6.100 - avcodec.h Add const to AVCodecContext.hwaccel. diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index ae5f39f775..27a37247b5 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -322,10 +322,11 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h, h->quincunx_sampling_flag = get_bits1(gb); h->content_interpretation_type = get_bits(gb, 6); - // the following skips: spatial_flipping_flag, frame0_flipped_flag, - // field_views_flag, current_frame_is_frame0_flag, + // spatial_flipping_flag, frame0_flipped_flag, field_views_flag + skip_bits(gb, 3); + h->current_frame_is_frame0_flag = get_bits1(gb); // frame0_self_contained_flag, frame1_self_contained_flag - skip_bits(gb, 6); + skip_bits(gb, 2); if (!h->quincunx_sampling_flag && h->frame_packing_arrangement_type != 5) skip_bits(gb, 16); // frame[01]_grid_position_[xy] diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index a53f1899fa..817b4eaae9 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -125,6 +125,7 @@ typedef struct H264SEIFramePacking { int frame_packing_arrangement_repetition_period; int content_interpretation_type; int quincunx_sampling_flag; + int current_frame_is_frame0_flag; } H264SEIFramePacking; typedef struct H264SEIDisplayOrientation { diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index da76b9293f..fff3112649 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1233,6 +1233,13 @@ static int h264_export_frame_props(H264Context *h) if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; + + if (fp->frame_packing_arrangement_type == 5) { + if (fp->current_frame_is_frame0_flag) + stereo->view = AV_STEREO3D_VIEW_LEFT; + else + stereo->view = AV_STEREO3D_VIEW_RIGHT; + } } } diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 6ce1669820..8dd975508a 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -95,10 +95,11 @@ static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetB s->quincunx_subsampling = get_bits1(gb); s->content_interpretation_type = get_bits(gb, 6); - // the following skips spatial_flipping_flag frame0_flipped_flag - // field_views_flag current_frame_is_frame0_flag - // frame0_self_contained_flag frame1_self_contained_flag - skip_bits(gb, 6); + // spatial_flipping_flag, frame0_flipped_flag, field_views_flag + skip_bits(gb, 3); + s->current_frame_is_frame0_flag = get_bits1(gb); + // frame0_self_contained_flag, frame1_self_contained_flag + skip_bits(gb, 2); if (!s->quincunx_subsampling && s->arrangement_type != 5) skip_bits(gb, 16); // frame[01]_grid_position_[xy] diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index d290aaab53..e92da25bbf 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -67,6 +67,7 @@ typedef struct HEVCSEIFramePacking { int arrangement_type; int content_interpretation_type; int quincunx_subsampling; + int current_frame_is_frame0_flag; } HEVCSEIFramePacking; typedef struct HEVCSEIDisplayOrientation { diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 5ec6105d2f..433a7056ea 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2647,6 +2647,13 @@ static int set_side_data(HEVCContext *s) if (s->sei.frame_packing.content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; + + if (s->sei.frame_packing.arrangement_type == 5) { + if (s->sei.frame_packing.current_frame_is_frame0_flag) + stereo->view = AV_STEREO3D_VIEW_LEFT; + else + stereo->view = AV_STEREO3D_VIEW_RIGHT; + } } if (s->sei.display_orientation.present && diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c index a5cd9540b9..12a29964c4 100644 --- a/libavfilter/vf_framepack.c +++ b/libavfilter/vf_framepack.c @@ -324,6 +324,8 @@ static int try_push_frame(AVFilterContext *ctx) if (!stereo) return AVERROR(ENOMEM); stereo->type = s->format; + stereo->view = i == LEFT ? AV_STEREO3D_VIEW_LEFT + : AV_STEREO3D_VIEW_RIGHT; // filter the frame and immediately relinquish its pointer ret = ff_filter_frame(outlink, s->input_views[i]); diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h index 54f4c4c5c7..d421aac2a2 100644 --- a/libavutil/stereo3d.h +++ b/libavutil/stereo3d.h @@ -141,6 +141,25 @@ enum AVStereo3DType { AV_STEREO3D_COLUMNS, }; +/** + * List of possible view types. + */ +enum AVStereo3DView { + /** + * Frame contains two packed views. + */ + AV_STEREO3D_VIEW_PACKED, + + /** + * Frame contains only the left view. + */ + AV_STEREO3D_VIEW_LEFT, + + /** + * Frame contains only the right view. + */ + AV_STEREO3D_VIEW_RIGHT, +}; /** * Inverted views, Right/Bottom represents the left view. @@ -164,6 +183,11 @@ typedef struct AVStereo3D { * Additional information about the frame packing. */ int flags; + + /** + * Determines which views are packed. + */ + enum AVStereo3DView view; } AVStereo3D; /** diff --git a/libavutil/version.h b/libavutil/version.h index 41dc6ad40b..285d2f1cf9 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -78,9 +78,8 @@ * @{ */ - #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/tests/ref/fate/vp8-alpha b/tests/ref/fate/vp8-alpha index 4922d52739..cc096c6d3a 100644 --- a/tests/ref/fate/vp8-alpha +++ b/tests/ref/fate/vp8-alpha @@ -3,7 +3,7 @@ #codec_id 0: vp8 #dimensions 0: 320x213 #sar 0: 1/1 -0, 0, 0, 33, 2108, 0x59b92a34, S=2, 1900, 0x8fb3adc5, 8, 0x00000000 +0, 0, 0, 33, 2108, 0x59b92a34, S=2, 1900, 0x8fb3adc5, 12, 0x00000000 0, 32, 32, 33, 142, 0x2f2a3fed, F=0x0, S=1, 160, 0xa13346af 0, 65, 65, 33, 157, 0x17804767, F=0x0, S=1, 209, 0x64115f15 0, 99, 99, 33, 206, 0x537262ca, F=0x0, S=1, 317, 0x44a09dd0