From: Anton Khirnov <anton@khirnov.net> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 2/5] avcodec: use the new AVFrame interlace flags in all decoders and encoders Date: Sun, 23 Apr 2023 21:47:14 +0200 Message-ID: <168227923452.3843.16503636721396002472@lain.khirnov.net> (raw) In-Reply-To: <20230412194936.48022-2-jamrial@gmail.com> 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".
next prev parent reply other threads:[~2023-04-23 19:47 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-12 19:49 [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer 2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 2/5] avcodec: use the new AVFrame interlace flags in all decoders and encoders James Almer 2023-04-23 19:47 ` Anton Khirnov [this message] 2023-04-24 12:31 ` James Almer 2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 3/5] avfilter: use the new AVFrame interlace flags in all filters James Almer 2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 4/5] fftools: use the new AVFrame interlace flags James Almer 2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 5/5] avutil/frame: deprecate interlaced_frame and top_field_first James Almer 2023-04-15 12:55 ` [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer 2023-04-17 10:49 ` Anton Khirnov 2023-04-17 11:32 ` James Almer 2023-04-17 11:51 ` Anton Khirnov 2023-04-21 21:10 ` James Almer 2023-04-30 0:19 ` James Almer 2023-05-04 23:52 ` James Almer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=168227923452.3843.16503636721396002472@lain.khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git