Added pic_struct=3 and pic_struct=4 (interlaced video encoded as a frame) handling to decode_nal_sei_pic_timing() in sei.c. Set appropriate flag(s) in alloc_frame() in refs.c.
Signed-off-by: Péter Szántó <[email protected]> --- libavcodec/avcodec.h | 10 ++++++---- libavcodec/hevc/refs.c | 7 +++++-- libavcodec/hevc/sei.c | 7 +++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index d9ec6df9fa..c68c4c628f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2629,10 +2629,12 @@ int avcodec_get_supported_config(const AVCodecContext *avctx, */ enum AVPictureStructure { - AV_PICTURE_STRUCTURE_UNKNOWN, ///< unknown - AV_PICTURE_STRUCTURE_TOP_FIELD, ///< coded as top field - AV_PICTURE_STRUCTURE_BOTTOM_FIELD, ///< coded as bottom field - AV_PICTURE_STRUCTURE_FRAME, ///< coded as frame + AV_PICTURE_STRUCTURE_UNKNOWN, ///< unknown + AV_PICTURE_STRUCTURE_TOP_FIELD, ///< coded as top field + AV_PICTURE_STRUCTURE_BOTTOM_FIELD, ///< coded as bottom field + AV_PICTURE_STRUCTURE_FRAME, ///< coded as frame + AV_PICTURE_STRUCTURE_WEAVED_TOP_FIELD_FIRST, ///< coded as frame, weaved fields, top field first + AV_PICTURE_STRUCTURE_WEAVED_BOTTOM_FIELD_FIRST, ///< coded as frame, weaved fields, bottom field first }; typedef struct AVCodecParserContext { diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c index 84418d2104..731ee3cab8 100644 --- a/libavcodec/hevc/refs.c +++ b/libavcodec/hevc/refs.c @@ -180,10 +180,13 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) for (j = 0; j < frame->ctb_count; j++) frame->rpl_tab[j] = frame->rpl; - if (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) + if ((s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) || + (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_WEAVED_TOP_FIELD_FIRST)) frame->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; if ((s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) || - (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)) + (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD) || + (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_WEAVED_TOP_FIELD_FIRST) || + (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_WEAVED_BOTTOM_FIELD_FIRST)) frame->f->flags |= AV_FRAME_FLAG_INTERLACED; ret = ff_hwaccel_frame_priv_alloc(s->avctx, &frame->hwaccel_picture_private); diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c index 83c726a217..3aefdb9feb 100644 --- a/libavcodec/hevc/sei.c +++ b/libavcodec/hevc/sei.c @@ -60,6 +60,7 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb, if (sps->vui.frame_field_info_present_flag) { int pic_struct = get_bits(gb, 4); + int source_scan_type = get_bits(gb, 2); // 0 = interlaced, 1 = progressive, 2 = unspecified h->picture_struct = AV_PICTURE_STRUCTURE_UNKNOWN; if (pic_struct == 2 || pic_struct == 10 || pic_struct == 12) { av_log(logctx, AV_LOG_DEBUG, "BOTTOM Field\n"); @@ -67,6 +68,12 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb, } else if (pic_struct == 1 || pic_struct == 9 || pic_struct == 11) { av_log(logctx, AV_LOG_DEBUG, "TOP Field\n"); h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD; + } else if (pic_struct == 3 && source_scan_type == 0) { + av_log(logctx, AV_LOG_DEBUG, "Weaved Fields TOP Field First\n"); + h->picture_struct = AV_PICTURE_STRUCTURE_WEAVED_TOP_FIELD_FIRST; + } else if (pic_struct == 4 && source_scan_type == 0) { + av_log(logctx, AV_LOG_DEBUG, "Weaved Fields BOTTOM Field First\n"); + h->picture_struct = AV_PICTURE_STRUCTURE_WEAVED_BOTTOM_FIELD_FIRST; } else if (pic_struct == 7) { av_log(logctx, AV_LOG_DEBUG, "Frame/Field Doubling\n"); h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
