From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 64FA2405A9 for ; Sun, 23 Apr 2023 19:47:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8608168BF3B; Sun, 23 Apr 2023 22:47:22 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE62E68BE80 for ; Sun, 23 Apr 2023 22:47:15 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 620D02404EE for ; Sun, 23 Apr 2023 21:47:15 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id uHfJJISBjMOH for ; Sun, 23 Apr 2023 21:47:14 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 9D6592404EC for ; Sun, 23 Apr 2023 21:47:14 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 88BBF1601B2; Sun, 23 Apr 2023 21:47:14 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20230412194936.48022-2-jamrial@gmail.com> References: <20230412194936.48022-1-jamrial@gmail.com> <20230412194936.48022-2-jamrial@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches Date: Sun, 23 Apr 2023 21:47:14 +0200 Message-ID: <168227923452.3843.16503636721396002472@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 2/5] avcodec: use the new AVFrame interlace flags in all decoders and encoders X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Quoting James Almer (2023-04-12 21:49:33) > diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c > index 76e70aa648..a407154959 100644 > --- a/libavcodec/cuviddec.c > +++ b/libavcodec/cuviddec.c > @@ -631,10 +631,10 @@ FF_DISABLE_DEPRECATION_WARNINGS > FF_ENABLE_DEPRECATION_WARNINGS > #endif > > - frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame; > + frame->flags |= AV_FRAME_FLAG_INTERLACED * (!parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame); I think the code would look better like this: if (!parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame)) { frame->flags |= AV_FRAME_FLAG_INTERLACED | (AV_FRAME_FLAG_TOP_FIELD_FIRST * !!parsed_frame.dispinfo.top_field_first); } > diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c > index 176bf972d8..a41a820ed0 100644 > --- a/libavcodec/dnxhdenc.c > +++ b/libavcodec/dnxhdenc.c > @@ -1251,7 +1251,7 @@ static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame) > ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8; > } > > - ctx->cur_field = frame->interlaced_frame && !frame->top_field_first; > + ctx->cur_field = (frame->flags &AV_FRAME_FLAG_INTERLACED) && !(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); Missing space. Also, long line. > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c > index 7767e16cf1..4c69893af8 100644 > --- a/libavcodec/h264_slice.c > +++ b/libavcodec/h264_slice.c > @@ -1150,7 +1150,7 @@ static int h264_export_frame_props(H264Context *h) > AVFrame *out = cur->f; > int ret; > > - out->interlaced_frame = 0; > + out->flags &= ~AV_FRAME_FLAG_INTERLACED; > out->repeat_pict = 0; > > /* Signal interlacing information externally. */ > @@ -1174,15 +1174,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; > + out->flags |= AV_FRAME_FLAG_INTERLACED; > 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; > + out->flags |= AV_FRAME_FLAG_INTERLACED; > else > // try to flag soft telecine progressive > - out->interlaced_frame = h->prev_interlaced_frame; > + out->flags |= AV_FRAME_FLAG_INTERLACED * !!h->prev_interlaced_frame; > break; > case H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP: > case H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: > @@ -1201,32 +1201,32 @@ 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; > + out->flags |= AV_FRAME_FLAG_INTERLACED * ((pt->ct_type & (1 << 1)) != 0); > } else { > /* Derive interlacing flag from used decoding process. */ > - out->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); > + out->flags |= AV_FRAME_FLAG_INTERLACED * !!FIELD_OR_MBAFF_PICTURE(h); > } > - h->prev_interlaced_frame = out->interlaced_frame; > + h->prev_interlaced_frame = !!(out->flags & AV_FRAME_FLAG_INTERLACED); Might be more readable to set a local 'interlaced' variable in all those checks above, which then gets synced to the frame flags here. Same below. > diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c > index 96153a2459..c7a53088bc 100644 > --- a/libavcodec/hevc_refs.c > +++ b/libavcodec/hevc_refs.c > @@ -111,8 +111,9 @@ static HEVCFrame *alloc_frame(HEVCContext *s) > for (j = 0; j < frame->ctb_count; j++) > frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data; > > - frame->frame->top_field_first = s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD; > - frame->frame->interlaced_frame = (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) || (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD); > + frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD); > + frame->frame->flags |= AV_FRAME_FLAG_INTERLACED * ((s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) || > + (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)); When the conditions are this long, seems better to make it into a if(). -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".