@@ -47,8 +47,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
4747 }
4848
4949 for (i = 0 ; i < V4L2_H264_NUM_DPB_ENTRIES ; i ++ ) {
50- u32 pic_order_count ;
51-
5250 if (!(dpb [i ].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ))
5351 continue ;
5452
@@ -59,8 +57,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
5957 /*
6058 * Handle frame_num wraparound as described in section
6159 * '8.2.4.1 Decoding process for picture numbers' of the spec.
62- * TODO: This logic will have to be adjusted when we start
63- * supporting interlaced content.
6460 * For long term references, frame_num is set to
6561 * long_term_frame_idx which requires no wrapping.
6662 */
@@ -70,24 +66,57 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
7066 else
7167 b -> refs [i ].frame_num = dpb [i ].frame_num ;
7268
73- if (dpb [i ].fields == V4L2_H264_FRAME_REF )
74- pic_order_count = min (dpb [i ].top_field_order_cnt ,
75- dpb [i ].bottom_field_order_cnt );
76- else if (dpb [i ].fields & V4L2_H264_BOTTOM_FIELD_REF )
77- pic_order_count = dpb [i ].bottom_field_order_cnt ;
78- else
79- pic_order_count = dpb [i ].top_field_order_cnt ;
69+ b -> refs [i ].top_field_order_cnt = dpb [i ].top_field_order_cnt ;
70+ b -> refs [i ].bottom_field_order_cnt = dpb [i ].bottom_field_order_cnt ;
71+
72+ if (b -> cur_pic_fields == V4L2_H264_FRAME_REF ) {
73+ u8 fields = V4L2_H264_FRAME_REF ;
74+
75+ b -> unordered_reflist [b -> num_valid ].index = i ;
76+ b -> unordered_reflist [b -> num_valid ].fields = fields ;
77+ b -> num_valid ++ ;
78+ continue ;
79+ }
80+
81+ if (dpb [i ].fields & V4L2_H264_TOP_FIELD_REF ) {
82+ u8 fields = V4L2_H264_TOP_FIELD_REF ;
83+
84+ b -> unordered_reflist [b -> num_valid ].index = i ;
85+ b -> unordered_reflist [b -> num_valid ].fields = fields ;
86+ b -> num_valid ++ ;
87+ }
8088
81- b -> refs [i ].pic_order_count = pic_order_count ;
82- b -> unordered_reflist [b -> num_valid ].index = i ;
83- b -> num_valid ++ ;
89+ if (dpb [i ].fields & V4L2_H264_BOTTOM_FIELD_REF ) {
90+ u8 fields = V4L2_H264_BOTTOM_FIELD_REF ;
91+
92+ b -> unordered_reflist [b -> num_valid ].index = i ;
93+ b -> unordered_reflist [b -> num_valid ].fields = fields ;
94+ b -> num_valid ++ ;
95+ }
8496 }
8597
8698 for (i = b -> num_valid ; i < ARRAY_SIZE (b -> unordered_reflist ); i ++ )
8799 b -> unordered_reflist [i ].index = i ;
88100}
89101EXPORT_SYMBOL_GPL (v4l2_h264_init_reflist_builder );
90102
103+ static s32 v4l2_h264_get_poc (const struct v4l2_h264_reflist_builder * b ,
104+ const struct v4l2_h264_reference * ref )
105+ {
106+ switch (ref -> fields ) {
107+ case V4L2_H264_FRAME_REF :
108+ return min (b -> refs [ref -> index ].top_field_order_cnt ,
109+ b -> refs [ref -> index ].bottom_field_order_cnt );
110+ case V4L2_H264_TOP_FIELD_REF :
111+ return b -> refs [ref -> index ].top_field_order_cnt ;
112+ case V4L2_H264_BOTTOM_FIELD_REF :
113+ return b -> refs [ref -> index ].bottom_field_order_cnt ;
114+ }
115+
116+ /* not reached */
117+ return 0 ;
118+ }
119+
91120static int v4l2_h264_p_ref_list_cmp (const void * ptra , const void * ptrb ,
92121 const void * data )
93122{
@@ -150,8 +179,8 @@ static int v4l2_h264_b0_ref_list_cmp(const void *ptra, const void *ptrb,
150179 builder -> refs [idxb ].pic_num ?
151180 -1 : 1 ;
152181
153- poca = builder -> refs [ idxa ]. pic_order_count ;
154- pocb = builder -> refs [ idxb ]. pic_order_count ;
182+ poca = v4l2_h264_get_poc ( builder , ptra ) ;
183+ pocb = v4l2_h264_get_poc ( builder , ptrb ) ;
155184
156185 /*
157186 * Short term pics with POC < cur POC first in POC descending order
@@ -195,8 +224,8 @@ static int v4l2_h264_b1_ref_list_cmp(const void *ptra, const void *ptrb,
195224 builder -> refs [idxb ].pic_num ?
196225 -1 : 1 ;
197226
198- poca = builder -> refs [ idxa ]. pic_order_count ;
199- pocb = builder -> refs [ idxb ]. pic_order_count ;
227+ poca = v4l2_h264_get_poc ( builder , ptra ) ;
228+ pocb = v4l2_h264_get_poc ( builder , ptrb ) ;
200229
201230 /*
202231 * Short term pics with POC > cur POC first in POC ascending order
0 commit comments