Skip to content

Commit 99e9697

Browse files
committed
stereo3d: Support view type for frame sequence type
Implement detection in h264 and hevc and insertion in framepack filter. Signed-off-by: Vittorio Giovara <[email protected]>
1 parent 45d7be7 commit 99e9697

File tree

10 files changed

+55
-8
lines changed

10 files changed

+55
-8
lines changed

doc/APIchanges

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ libavutil: 2017-03-23
1313

1414
API changes, most recent first:
1515

16+
2017-xx-xx - xxxxxxx - lavu 56.7.0 - stereo3d.h
17+
Add view field to AVStereo3D structure and AVStereo3DView enum.
18+
1619
2017-xx-xx - xxxxxxx - lavc 58.5.0 - avcodec.h
1720
Add avcodec_get_hw_frames_parameters().
1821

libavcodec/h264_sei.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,11 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h,
314314
h->quincunx_subsampling = get_bits1(gb);
315315
h->content_interpretation_type = get_bits(gb, 6);
316316

317-
// the following skips: spatial_flipping_flag, frame0_flipped_flag,
318-
// field_views_flag, current_frame_is_frame0_flag,
317+
// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
318+
skip_bits(gb, 3);
319+
h->current_frame_is_frame0_flag = get_bits1(gb);
319320
// frame0_self_contained_flag, frame1_self_contained_flag
320-
skip_bits(gb, 6);
321+
skip_bits(gb, 2);
321322

322323
if (!h->quincunx_subsampling && h->arrangement_type != 5)
323324
skip_bits(gb, 16); // frame[01]_grid_position_[xy]

libavcodec/h264_sei.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
108108
int arrangement_type;
109109
int content_interpretation_type;
110110
int quincunx_subsampling;
111+
int current_frame_is_frame0_flag;
111112
} H264SEIFramePacking;
112113

113114
typedef struct H264SEIDisplayOrientation {

libavcodec/h264_slice.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context *h)
11121112

11131113
if (fp->content_interpretation_type == 2)
11141114
stereo->flags = AV_STEREO3D_FLAG_INVERT;
1115+
1116+
if (fp->arrangement_type == 5) {
1117+
if (fp->current_frame_is_frame0_flag)
1118+
stereo->view = AV_STEREO3D_VIEW_LEFT;
1119+
else
1120+
stereo->view = AV_STEREO3D_VIEW_RIGHT;
1121+
}
11151122
}
11161123

11171124
if (h->sei.display_orientation.present &&

libavcodec/hevc_sei.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetB
5757
s->quincunx_subsampling = get_bits1(gb);
5858
s->content_interpretation_type = get_bits(gb, 6);
5959

60-
// the following skips spatial_flipping_flag frame0_flipped_flag
61-
// field_views_flag current_frame_is_frame0_flag
62-
// frame0_self_contained_flag frame1_self_contained_flag
63-
skip_bits(gb, 6);
60+
// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
61+
skip_bits(gb, 3);
62+
s->current_frame_is_frame0_flag = get_bits1(gb);
63+
// frame0_self_contained_flag, frame1_self_contained_flag
64+
skip_bits(gb, 2);
6465

6566
if (!s->quincunx_subsampling && s->arrangement_type != 5)
6667
skip_bits(gb, 16); // frame[01]_grid_position_[xy]

libavcodec/hevc_sei.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ typedef struct HEVCSEIFramePacking {
6767
int arrangement_type;
6868
int content_interpretation_type;
6969
int quincunx_subsampling;
70+
int current_frame_is_frame0_flag;
7071
} HEVCSEIFramePacking;
7172

7273
typedef struct HEVCSEIDisplayOrientation {

libavcodec/hevcdec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,13 @@ static int set_side_data(HEVCContext *s)
23972397

23982398
if (s->sei.frame_packing.content_interpretation_type == 2)
23992399
stereo->flags = AV_STEREO3D_FLAG_INVERT;
2400+
2401+
if (s->sei.frame_packing.arrangement_type == 5) {
2402+
if (s->sei.frame_packing.current_frame_is_frame0_flag)
2403+
stereo->view = AV_STEREO3D_VIEW_LEFT;
2404+
else
2405+
stereo->view = AV_STEREO3D_VIEW_RIGHT;
2406+
}
24002407
}
24012408

24022409
if (s->sei.display_orientation.present &&

libavfilter/vf_framepack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ static int request_frame(AVFilterLink *outlink)
310310
if (!stereo)
311311
return AVERROR(ENOMEM);
312312
stereo->type = s->format;
313+
stereo->view = i == LEFT ? AV_STEREO3D_VIEW_LEFT
314+
: AV_STEREO3D_VIEW_RIGHT;
313315

314316
// filter the frame and immediately relinquish its pointer
315317
ret = ff_filter_frame(outlink, s->input_views[i]);

libavutil/stereo3d.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ enum AVStereo3DType {
141141
AV_STEREO3D_COLUMNS,
142142
};
143143

144+
/**
145+
* List of possible view types.
146+
*/
147+
enum AVStereo3DView {
148+
/**
149+
* Frame contains two packed views.
150+
*/
151+
AV_STEREO3D_VIEW_PACKED,
152+
153+
/**
154+
* Frame contains only the left view.
155+
*/
156+
AV_STEREO3D_VIEW_LEFT,
157+
158+
/**
159+
* Frame contains only the right view.
160+
*/
161+
AV_STEREO3D_VIEW_RIGHT,
162+
};
144163

145164
/**
146165
* Inverted views, Right/Bottom represents the left view.
@@ -164,6 +183,11 @@ typedef struct AVStereo3D {
164183
* Additional information about the frame packing.
165184
*/
166185
int flags;
186+
187+
/**
188+
* Determines which views are packed.
189+
*/
190+
enum AVStereo3DView view;
167191
} AVStereo3D;
168192

169193
/**

libavutil/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*/
5555

5656
#define LIBAVUTIL_VERSION_MAJOR 56
57-
#define LIBAVUTIL_VERSION_MINOR 6
57+
#define LIBAVUTIL_VERSION_MINOR 7
5858
#define LIBAVUTIL_VERSION_MICRO 0
5959

6060
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

0 commit comments

Comments
 (0)