Commit 99e9697e authored by Vittorio Giovara's avatar Vittorio Giovara

stereo3d: Support view type for frame sequence type

Implement detection in h264 and hevc and insertion in framepack filter.
Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent 45d7be7f
...@@ -13,6 +13,9 @@ libavutil: 2017-03-23 ...@@ -13,6 +13,9 @@ libavutil: 2017-03-23
API changes, most recent first: API changes, most recent first:
2017-xx-xx - xxxxxxx - lavu 56.7.0 - stereo3d.h
Add view field to AVStereo3D structure and AVStereo3DView enum.
2017-xx-xx - xxxxxxx - lavc 58.5.0 - avcodec.h 2017-xx-xx - xxxxxxx - lavc 58.5.0 - avcodec.h
Add avcodec_get_hw_frames_parameters(). Add avcodec_get_hw_frames_parameters().
......
...@@ -314,10 +314,11 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h, ...@@ -314,10 +314,11 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h,
h->quincunx_subsampling = get_bits1(gb); h->quincunx_subsampling = get_bits1(gb);
h->content_interpretation_type = get_bits(gb, 6); h->content_interpretation_type = get_bits(gb, 6);
// the following skips: spatial_flipping_flag, frame0_flipped_flag, // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
// field_views_flag, current_frame_is_frame0_flag, skip_bits(gb, 3);
h->current_frame_is_frame0_flag = get_bits1(gb);
// frame0_self_contained_flag, frame1_self_contained_flag // frame0_self_contained_flag, frame1_self_contained_flag
skip_bits(gb, 6); skip_bits(gb, 2);
if (!h->quincunx_subsampling && h->arrangement_type != 5) if (!h->quincunx_subsampling && h->arrangement_type != 5)
skip_bits(gb, 16); // frame[01]_grid_position_[xy] skip_bits(gb, 16); // frame[01]_grid_position_[xy]
......
...@@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking { ...@@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
int arrangement_type; int arrangement_type;
int content_interpretation_type; int content_interpretation_type;
int quincunx_subsampling; int quincunx_subsampling;
int current_frame_is_frame0_flag;
} H264SEIFramePacking; } H264SEIFramePacking;
typedef struct H264SEIDisplayOrientation { typedef struct H264SEIDisplayOrientation {
......
...@@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context *h) ...@@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context *h)
if (fp->content_interpretation_type == 2) if (fp->content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT; stereo->flags = AV_STEREO3D_FLAG_INVERT;
if (fp->arrangement_type == 5) {
if (fp->current_frame_is_frame0_flag)
stereo->view = AV_STEREO3D_VIEW_LEFT;
else
stereo->view = AV_STEREO3D_VIEW_RIGHT;
}
} }
if (h->sei.display_orientation.present && if (h->sei.display_orientation.present &&
......
...@@ -57,10 +57,11 @@ static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetB ...@@ -57,10 +57,11 @@ static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetB
s->quincunx_subsampling = get_bits1(gb); s->quincunx_subsampling = get_bits1(gb);
s->content_interpretation_type = get_bits(gb, 6); s->content_interpretation_type = get_bits(gb, 6);
// the following skips spatial_flipping_flag frame0_flipped_flag // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
// field_views_flag current_frame_is_frame0_flag skip_bits(gb, 3);
// frame0_self_contained_flag frame1_self_contained_flag s->current_frame_is_frame0_flag = get_bits1(gb);
skip_bits(gb, 6); // frame0_self_contained_flag, frame1_self_contained_flag
skip_bits(gb, 2);
if (!s->quincunx_subsampling && s->arrangement_type != 5) if (!s->quincunx_subsampling && s->arrangement_type != 5)
skip_bits(gb, 16); // frame[01]_grid_position_[xy] skip_bits(gb, 16); // frame[01]_grid_position_[xy]
......
...@@ -67,6 +67,7 @@ typedef struct HEVCSEIFramePacking { ...@@ -67,6 +67,7 @@ typedef struct HEVCSEIFramePacking {
int arrangement_type; int arrangement_type;
int content_interpretation_type; int content_interpretation_type;
int quincunx_subsampling; int quincunx_subsampling;
int current_frame_is_frame0_flag;
} HEVCSEIFramePacking; } HEVCSEIFramePacking;
typedef struct HEVCSEIDisplayOrientation { typedef struct HEVCSEIDisplayOrientation {
......
...@@ -2397,6 +2397,13 @@ static int set_side_data(HEVCContext *s) ...@@ -2397,6 +2397,13 @@ static int set_side_data(HEVCContext *s)
if (s->sei.frame_packing.content_interpretation_type == 2) if (s->sei.frame_packing.content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT; 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 && if (s->sei.display_orientation.present &&
......
...@@ -310,6 +310,8 @@ static int request_frame(AVFilterLink *outlink) ...@@ -310,6 +310,8 @@ static int request_frame(AVFilterLink *outlink)
if (!stereo) if (!stereo)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
stereo->type = s->format; stereo->type = s->format;
stereo->view = i == LEFT ? AV_STEREO3D_VIEW_LEFT
: AV_STEREO3D_VIEW_RIGHT;
// filter the frame and immediately relinquish its pointer // filter the frame and immediately relinquish its pointer
ret = ff_filter_frame(outlink, s->input_views[i]); ret = ff_filter_frame(outlink, s->input_views[i]);
......
...@@ -141,6 +141,25 @@ enum AVStereo3DType { ...@@ -141,6 +141,25 @@ enum AVStereo3DType {
AV_STEREO3D_COLUMNS, 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. * Inverted views, Right/Bottom represents the left view.
...@@ -164,6 +183,11 @@ typedef struct AVStereo3D { ...@@ -164,6 +183,11 @@ typedef struct AVStereo3D {
* Additional information about the frame packing. * Additional information about the frame packing.
*/ */
int flags; int flags;
/**
* Determines which views are packed.
*/
enum AVStereo3DView view;
} AVStereo3D; } AVStereo3D;
/** /**
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 56 #define LIBAVUTIL_VERSION_MAJOR 56
#define LIBAVUTIL_VERSION_MINOR 6 #define LIBAVUTIL_VERSION_MINOR 7
#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment