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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1810>
This commit is contained in:
parent
a516c79ac9
commit
7b42b1f9fb
@ -582,7 +582,7 @@ gst_h264_decoder_update_pic_nums (GstH264Decoder * self,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (GST_H264_PICTURE_IS_LONG_TERM_REF (picture)) {
|
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;
|
picture->long_term_pic_num = picture->long_term_frame_idx;
|
||||||
else if (current_picture->field == picture->field)
|
else if (current_picture->field == picture->field)
|
||||||
picture->long_term_pic_num = 2 * picture->long_term_frame_idx + 1;
|
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
|
else
|
||||||
picture->frame_num_wrap = picture->frame_num;
|
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;
|
picture->pic_num = picture->frame_num_wrap;
|
||||||
else if (picture->field == current_picture->field)
|
else if (picture->field == current_picture->field)
|
||||||
picture->pic_num = 2 * picture->frame_num_wrap + 1;
|
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 */
|
/* This is not a field picture */
|
||||||
if (!slice_hdr->field_pic_flag) {
|
if (!slice_hdr->field_pic_flag) {
|
||||||
/* Check whether the last picture is complete or not */
|
/* Check whether the last picture is complete or not */
|
||||||
if (prev_picture->field != GST_H264_PICTURE_FIELD_FRAME &&
|
if (!GST_H264_PICTURE_IS_FRAME (prev_picture) && !prev_picture->other_field) {
|
||||||
!prev_picture->other_field) {
|
|
||||||
GST_WARNING_OBJECT (self, "Previous picture %p (poc %d) is not complete",
|
GST_WARNING_OBJECT (self, "Previous picture %p (poc %d) is not complete",
|
||||||
prev_picture, prev_picture->pic_order_cnt);
|
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 */
|
/* Previous picture was not a field picture or complete already */
|
||||||
if (prev_picture->field == GST_H264_PICTURE_FIELD_FRAME ||
|
if (GST_H264_PICTURE_IS_FRAME (prev_picture) || prev_picture->other_field)
|
||||||
prev_picture->other_field)
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (prev_picture->frame_num == slice_hdr->frame_num) {
|
if (prev_picture->frame_num == slice_hdr->frame_num) {
|
||||||
@ -1142,8 +1140,7 @@ gst_h264_decoder_fill_picture_from_slice (GstH264Decoder * self,
|
|||||||
else
|
else
|
||||||
picture->field = GST_H264_PICTURE_FIELD_FRAME;
|
picture->field = GST_H264_PICTURE_FIELD_FRAME;
|
||||||
|
|
||||||
if (picture->field != GST_H264_PICTURE_FIELD_FRAME &&
|
if (!GST_H264_PICTURE_IS_FRAME (picture) && !klass->new_field_picture) {
|
||||||
!klass->new_field_picture) {
|
|
||||||
GST_FIXME_OBJECT (self, "Subclass doesn't support interlace stream");
|
GST_FIXME_OBJECT (self, "Subclass doesn't support interlace stream");
|
||||||
return FALSE;
|
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_TOP_FIELD) {
|
||||||
if (picture->field == GST_H264_PICTURE_FIELD_FRAME) {
|
if (GST_H264_PICTURE_IS_FRAME (picture)) {
|
||||||
picture->bottom_field_order_cnt =
|
picture->bottom_field_order_cnt =
|
||||||
picture->top_field_order_cnt +
|
picture->top_field_order_cnt +
|
||||||
picture->delta_pic_order_cnt_bottom;
|
picture->delta_pic_order_cnt_bottom;
|
||||||
@ -1305,7 +1302,7 @@ gst_h264_decoder_calculate_poc (GstH264Decoder * self, GstH264Picture * picture)
|
|||||||
if (!picture->nal_ref_idc)
|
if (!picture->nal_ref_idc)
|
||||||
expected_pic_order_cnt += sps->offset_for_non_ref_pic;
|
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 =
|
picture->top_field_order_cnt =
|
||||||
expected_pic_order_cnt + picture->delta_pic_order_cnt0;
|
expected_pic_order_cnt + picture->delta_pic_order_cnt0;
|
||||||
picture->bottom_field_order_cnt = picture->top_field_order_cnt +
|
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);
|
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->top_field_order_cnt = temp_pic_order_cnt;
|
||||||
picture->bottom_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) {
|
} else if (picture->field == GST_H264_PICTURE_FIELD_BOTTOM_FIELD) {
|
||||||
|
@ -259,7 +259,7 @@ gst_h264_dpb_add (GstH264Dpb * dpb, GstH264Picture * picture)
|
|||||||
if (!picture->nonexisting) {
|
if (!picture->nonexisting) {
|
||||||
picture->needed_for_output = TRUE;
|
picture->needed_for_output = TRUE;
|
||||||
|
|
||||||
if (picture->field == GST_H264_PICTURE_FIELD_FRAME) {
|
if (GST_H264_PICTURE_IS_FRAME (picture)) {
|
||||||
dpb->num_output_needed++;
|
dpb->num_output_needed++;
|
||||||
} else {
|
} else {
|
||||||
/* We can do output only when field pair are complete */
|
/* 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)
|
if (!picture->needed_for_output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (picture->field != GST_H264_PICTURE_FIELD_FRAME &&
|
if (!GST_H264_PICTURE_IS_FRAME (picture) &&
|
||||||
(!picture->other_field || picture->second_field))
|
(!picture->other_field || picture->second_field))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -70,6 +70,17 @@ typedef struct _GstH264Picture GstH264Picture;
|
|||||||
#define GST_H264_PICTURE_IS_LONG_TERM_REF(picture) \
|
#define GST_H264_PICTURE_IS_LONG_TERM_REF(picture) \
|
||||||
((picture)->ref == GST_H264_PICTURE_REF_LONG_TERM)
|
((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
|
struct _GstH264Slice
|
||||||
{
|
{
|
||||||
GstH264SliceHdr header;
|
GstH264SliceHdr header;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user