From: Seungha Yang Date: Sun, 15 Nov 2020 15:27:28 +0000 (+0900) Subject: codecs: h264decoder: Add util macro for frame/field picture identification X-Git-Tag: 1.19.3~507^2~1069 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b42b1f9fb49d70f40d0aaa8eb0a2551e15c44a2;p=platform%2Fupstream%2Fgstreamer.git codecs: h264decoder: Add util macro for frame/field picture identification Add a macro to check whether given GstH264Picture is for frame or field decoding. Part-of: --- diff --git a/gst-libs/gst/codecs/gsth264decoder.c b/gst-libs/gst/codecs/gsth264decoder.c index 40446d9..9cd8328 100644 --- a/gst-libs/gst/codecs/gsth264decoder.c +++ b/gst-libs/gst/codecs/gsth264decoder.c @@ -582,7 +582,7 @@ gst_h264_decoder_update_pic_nums (GstH264Decoder * self, continue; if (GST_H264_PICTURE_IS_LONG_TERM_REF (picture)) { - if (current_picture->field == GST_H264_PICTURE_FIELD_FRAME) + if (GST_H264_PICTURE_IS_FRAME (current_picture)) picture->long_term_pic_num = picture->long_term_frame_idx; else if (current_picture->field == picture->field) picture->long_term_pic_num = 2 * picture->long_term_frame_idx + 1; @@ -594,7 +594,7 @@ gst_h264_decoder_update_pic_nums (GstH264Decoder * self, else picture->frame_num_wrap = picture->frame_num; - if (current_picture->field == GST_H264_PICTURE_FIELD_FRAME) + if (GST_H264_PICTURE_IS_FRAME (current_picture)) picture->pic_num = picture->frame_num_wrap; else if (picture->field == current_picture->field) picture->pic_num = 2 * picture->frame_num_wrap + 1; @@ -832,8 +832,7 @@ gst_h264_decoder_find_first_field_picture (GstH264Decoder * self, /* This is not a field picture */ if (!slice_hdr->field_pic_flag) { /* Check whether the last picture is complete or not */ - if (prev_picture->field != GST_H264_PICTURE_FIELD_FRAME && - !prev_picture->other_field) { + if (!GST_H264_PICTURE_IS_FRAME (prev_picture) && !prev_picture->other_field) { GST_WARNING_OBJECT (self, "Previous picture %p (poc %d) is not complete", prev_picture, prev_picture->pic_order_cnt); @@ -845,8 +844,7 @@ gst_h264_decoder_find_first_field_picture (GstH264Decoder * self, } /* Previous picture was not a field picture or complete already */ - if (prev_picture->field == GST_H264_PICTURE_FIELD_FRAME || - prev_picture->other_field) + if (GST_H264_PICTURE_IS_FRAME (prev_picture) || prev_picture->other_field) return TRUE; if (prev_picture->frame_num == slice_hdr->frame_num) { @@ -1142,8 +1140,7 @@ gst_h264_decoder_fill_picture_from_slice (GstH264Decoder * self, else picture->field = GST_H264_PICTURE_FIELD_FRAME; - if (picture->field != GST_H264_PICTURE_FIELD_FRAME && - !klass->new_field_picture) { + if (!GST_H264_PICTURE_IS_FRAME (picture) && !klass->new_field_picture) { GST_FIXME_OBJECT (self, "Subclass doesn't support interlace stream"); return FALSE; } @@ -1238,7 +1235,7 @@ gst_h264_decoder_calculate_poc (GstH264Decoder * self, GstH264Picture * picture) } if (picture->field != GST_H264_PICTURE_FIELD_TOP_FIELD) { - if (picture->field == GST_H264_PICTURE_FIELD_FRAME) { + if (GST_H264_PICTURE_IS_FRAME (picture)) { picture->bottom_field_order_cnt = picture->top_field_order_cnt + picture->delta_pic_order_cnt_bottom; @@ -1305,7 +1302,7 @@ gst_h264_decoder_calculate_poc (GstH264Decoder * self, GstH264Picture * picture) if (!picture->nal_ref_idc) expected_pic_order_cnt += sps->offset_for_non_ref_pic; - if (picture->field == GST_H264_PICTURE_FIELD_FRAME) { + if (GST_H264_PICTURE_IS_FRAME (picture)) { picture->top_field_order_cnt = expected_pic_order_cnt + picture->delta_pic_order_cnt0; picture->bottom_field_order_cnt = picture->top_field_order_cnt + @@ -1345,7 +1342,7 @@ gst_h264_decoder_calculate_poc (GstH264Decoder * self, GstH264Picture * picture) 2 * (picture->frame_num_offset + picture->frame_num); } - if (picture->field == GST_H264_PICTURE_FIELD_FRAME) { + if (GST_H264_PICTURE_IS_FRAME (picture)) { picture->top_field_order_cnt = temp_pic_order_cnt; picture->bottom_field_order_cnt = temp_pic_order_cnt; } else if (picture->field == GST_H264_PICTURE_FIELD_BOTTOM_FIELD) { diff --git a/gst-libs/gst/codecs/gsth264picture.c b/gst-libs/gst/codecs/gsth264picture.c index 0671c58..1df0530 100644 --- a/gst-libs/gst/codecs/gsth264picture.c +++ b/gst-libs/gst/codecs/gsth264picture.c @@ -259,7 +259,7 @@ gst_h264_dpb_add (GstH264Dpb * dpb, GstH264Picture * picture) if (!picture->nonexisting) { picture->needed_for_output = TRUE; - if (picture->field == GST_H264_PICTURE_FIELD_FRAME) { + if (GST_H264_PICTURE_IS_FRAME (picture)) { dpb->num_output_needed++; } else { /* We can do output only when field pair are complete */ @@ -613,7 +613,7 @@ gst_h264_dpb_get_lowest_output_needed_picture (GstH264Dpb * dpb, if (!picture->needed_for_output) continue; - if (picture->field != GST_H264_PICTURE_FIELD_FRAME && + if (!GST_H264_PICTURE_IS_FRAME (picture) && (!picture->other_field || picture->second_field)) continue; diff --git a/gst-libs/gst/codecs/gsth264picture.h b/gst-libs/gst/codecs/gsth264picture.h index 6e2698e..1199cf5 100644 --- a/gst-libs/gst/codecs/gsth264picture.h +++ b/gst-libs/gst/codecs/gsth264picture.h @@ -70,6 +70,17 @@ typedef struct _GstH264Picture GstH264Picture; #define GST_H264_PICTURE_IS_LONG_TERM_REF(picture) \ ((picture)->ref == GST_H264_PICTURE_REF_LONG_TERM) +/** + * GST_H264_PICTURE_IS_FRAME: + * @picture: a #GstH264Picture + * + * Check whether @picture is a frame (not a field picture) + * + * Since: 1.20 + */ +#define GST_H264_PICTURE_IS_FRAME(picture) \ + ((picture)->field == GST_H264_PICTURE_FIELD_FRAME) + struct _GstH264Slice { GstH264SliceHdr header;