diff options
author | James Almer <jamrial@gmail.com> | 2023-04-11 15:02:14 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2023-05-04 18:14:02 -0300 |
commit | 2f561ba953e23887ddb25ab1b6739aab04ff9115 (patch) | |
tree | dff824910ba954804d593dbf1aee0978dd5b612e /libavcodec/h264_slice.c | |
parent | 2df4e054d4b8f69ce3c2c06aace9df9ba6d2ac2e (diff) | |
download | ffmpeg-2f561ba953e23887ddb25ab1b6739aab04ff9115.tar.gz |
avcodec: use the new AVFrame interlace flags in all decoders and encoders
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r-- | libavcodec/h264_slice.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index d05b83a121..f44b60c642 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1155,9 +1155,10 @@ static int h264_export_frame_props(H264Context *h) const SPS *sps = h->ps.sps; H264Picture *cur = h->cur_pic_ptr; AVFrame *out = cur->f; + int interlaced_frame = 0, top_field_first = 0; int ret; - out->interlaced_frame = 0; + out->flags &= ~AV_FRAME_FLAG_INTERLACED; out->repeat_pict = 0; /* Signal interlacing information externally. */ @@ -1181,15 +1182,15 @@ static int h264_export_frame_props(H264Context *h) break; case H264_SEI_PIC_STRUCT_TOP_FIELD: case H264_SEI_PIC_STRUCT_BOTTOM_FIELD: - out->interlaced_frame = 1; + interlaced_frame = 1; break; case H264_SEI_PIC_STRUCT_TOP_BOTTOM: case H264_SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(h)) - out->interlaced_frame = 1; + interlaced_frame = 1; else // try to flag soft telecine progressive - out->interlaced_frame = h->prev_interlaced_frame; + interlaced_frame = !!h->prev_interlaced_frame; break; case H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: @@ -1208,35 +1209,34 @@ static int h264_export_frame_props(H264Context *h) if ((pt->ct_type & 3) && pt->pic_struct <= H264_SEI_PIC_STRUCT_BOTTOM_TOP) - out->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; + interlaced_frame = ((pt->ct_type & (1 << 1)) != 0); } else { /* Derive interlacing flag from used decoding process. */ - out->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); + interlaced_frame = !!FIELD_OR_MBAFF_PICTURE(h); } - h->prev_interlaced_frame = out->interlaced_frame; + h->prev_interlaced_frame = interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { /* Derive top_field_first from field pocs. */ - out->top_field_first = cur->field_poc[0] < cur->field_poc[1]; + top_field_first = (cur->field_poc[0] < cur->field_poc[1]); } else { if (sps->pic_struct_present_flag && h->sei.picture_timing.present) { /* Use picture timing SEI information. Even if it is a * information of a past frame, better than nothing. */ if (h->sei.picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM || h->sei.picture_timing.pic_struct == H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP) - out->top_field_first = 1; - else - out->top_field_first = 0; - } else if (out->interlaced_frame) { + top_field_first = 1; + } else if (interlaced_frame) { /* Default to top field first when pic_struct_present_flag * is not set but interlaced frame detected */ - out->top_field_first = 1; - } else { + top_field_first = 1; + } // else /* Most likely progressive */ - out->top_field_first = 0; - } } + out->flags |= (AV_FRAME_FLAG_INTERLACED * interlaced_frame) | + (AV_FRAME_FLAG_TOP_FIELD_FIRST * top_field_first); + ret = ff_h2645_sei_to_frame(out, &h->sei.common, AV_CODEC_ID_H264, h->avctx, &sps->vui, sps->bit_depth_luma, sps->bit_depth_chroma, cur->poc + (unsigned)(h->poc_offset << 5)); |