* [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
@ 2023-04-12 19:49 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
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: James Almer @ 2023-04-12 19:49 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
Missing version bump and APIChanges entry.
libavutil/frame.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5b58c14ac3..87e0a51226 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -586,6 +586,15 @@ typedef struct AVFrame {
* A flag to mark the frames which need to be decoded, but shouldn't be output.
*/
#define AV_FRAME_FLAG_DISCARD (1 << 2)
+/**
+ * A flag to mark frames whose content is interlaced.
+ */
+#define AV_FRAME_FLAG_INTERLACED (1 << 3)
+/**
+ * A flag to mark frames where the top field is displayed first if the content
+ * is interlaced.
+ */
+#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4)
/**
* @}
*/
--
2.40.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* [FFmpeg-devel] [PATCH 2/5] avcodec: use the new AVFrame interlace flags in all decoders and encoders
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 ` James Almer
2023-04-23 19:47 ` Anton Khirnov
2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 3/5] avfilter: use the new AVFrame interlace flags in all filters James Almer
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: James Almer @ 2023-04-12 19:49 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
Unlike the fields, the flags need to be unset with a mask. For decoders that
use ff_reget_buffer this is a must. I think i didn't miss any case where
either flag needs to be unset, but more eyes would come in handy.
libavcodec/cfhd.c | 6 +++---
libavcodec/crystalhd.c | 4 ++--
libavcodec/cuviddec.c | 6 +++---
libavcodec/decode.c | 2 ++
libavcodec/dnxhddec.c | 14 +++++++-------
libavcodec/dnxhdenc.c | 2 +-
libavcodec/dvdec.c | 12 ++++++------
libavcodec/dvenc.c | 4 ++--
libavcodec/encode.c | 5 +++++
libavcodec/error_resilience.c | 2 +-
libavcodec/ffv1dec.c | 14 +++++++-------
libavcodec/ffv1enc.c | 4 ++--
libavcodec/h264_slice.c | 26 +++++++++++++-------------
libavcodec/hevc_refs.c | 5 +++--
libavcodec/libx264.c | 6 +++---
libavcodec/m101.c | 10 +++++-----
libavcodec/mjpegdec.c | 4 ++--
libavcodec/mmaldec.c | 4 ++--
libavcodec/mpeg12enc.c | 2 +-
libavcodec/mpeg4videoenc.c | 2 +-
libavcodec/mpegvideo_dec.c | 10 +++++-----
libavcodec/nvenc.c | 2 +-
libavcodec/pngdec.c | 2 +-
libavcodec/proresdec2.c | 6 +++---
libavcodec/proresenc_anatoliy.c | 2 +-
libavcodec/proresenc_kostya.c | 6 +++---
libavcodec/qsvdec.c | 6 +++---
libavcodec/qsvenc.c | 6 +++---
libavcodec/rawdec.c | 8 ++++----
libavcodec/rkmppdec.c | 4 ++--
libavcodec/utvideodec.c | 2 +-
libavcodec/v210dec.c | 4 ++--
libavcodec/vaapi_hevc.c | 4 ++--
libavcodec/vc1_mc.c | 18 +++++++++---------
libavcodec/vc1dec.c | 4 ++--
35 files changed, 113 insertions(+), 105 deletions(-)
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index c23eb069c6..42d7dcc3f6 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -1087,8 +1087,8 @@ finish:
dst += dst_linesize;
}
} else {
- av_log(avctx, AV_LOG_DEBUG, "interlaced frame ? %d", pic->interlaced_frame);
- pic->interlaced_frame = 1;
+ av_log(avctx, AV_LOG_DEBUG, "interlaced frame ? %d", !!(pic->flags & AV_FRAME_FLAG_INTERLACED));
+ pic->flags |= AV_FRAME_FLAG_INTERLACED;
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[7];
output = s->plane[plane].l_h[6];
@@ -1284,7 +1284,7 @@ finish:
dst += dst_linesize;
}
} else {
- pic->interlaced_frame = 1;
+ pic->flags |= AV_FRAME_FLAG_INTERLACED;
low = s->plane[plane].l_h[7];
high = s->plane[plane].subband[14];
output = s->plane[plane].l_h[6];
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index a48d60f123..86f6cfa6c1 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -543,9 +543,9 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
- frame->interlaced_frame = interlaced;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * !!interlaced;
if (interlaced)
- frame->top_field_first = !bottom_first;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !bottom_first;
frame->pts = pkt_pts;
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);
- if (frame->interlaced_frame)
- frame->top_field_first = parsed_frame.dispinfo.top_field_first;
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!parsed_frame.dispinfo.top_field_first;
} else if (ctx->decoder_flushing) {
ret = AVERROR_EOF;
} else {
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 40f5a3ba59..73bba99750 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -570,6 +570,8 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
}
if (!ret) {
+ frame->interlaced_frame = !!(frame->flags & AV_FRAME_FLAG_INTERLACED);
+ frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
frame->best_effort_timestamp = guess_correct_pts(avctx,
frame->pts,
frame->pkt_dts);
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 7cc4f94c7f..b98a0237ab 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -195,8 +195,8 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
}
if (buf[5] & 2) { /* interlaced */
ctx->cur_field = first_field ? buf[5] & 1 : !ctx->cur_field;
- frame->interlaced_frame = 1;
- frame->top_field_first = first_field ^ ctx->cur_field;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!(first_field ^ ctx->cur_field);
av_log(ctx->avctx, AV_LOG_DEBUG,
"interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
} else {
@@ -298,7 +298,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
ctx->mb_width = (ctx->width + 15)>> 4;
ctx->mb_height = AV_RB16(buf + 0x16c);
- if ((ctx->height + 15) >> 4 == ctx->mb_height && frame->interlaced_frame)
+ if ((ctx->height + 15) >> 4 == ctx->mb_height && (frame->flags & AV_FRAME_FLAG_INTERLACED))
ctx->height <<= 1;
av_log(ctx->avctx, AV_LOG_VERBOSE, "%dx%d, 4:%s %d bits, MBAFF=%d ACT=%d\n",
@@ -316,7 +316,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
}
ctx->data_offset = 0x280;
}
- if ((ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
+ if ((ctx->mb_height << !!(frame->flags & AV_FRAME_FLAG_INTERLACED)) > (ctx->height + 15) >> 4) {
av_log(ctx->avctx, AV_LOG_ERROR,
"mb height too big: %d\n", ctx->mb_height);
return AVERROR_INVALIDDATA;
@@ -530,7 +530,7 @@ static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row,
return AVERROR_INVALIDDATA;
}
- if (frame->interlaced_frame) {
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
dct_linesize_luma <<= 1;
dct_linesize_chroma <<= 1;
}
@@ -539,7 +539,7 @@ static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row,
dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
- if (frame->interlaced_frame && ctx->cur_field) {
+ if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && ctx->cur_field) {
dest_y += frame->linesize[0];
dest_u += frame->linesize[1];
dest_v += frame->linesize[2];
@@ -659,7 +659,7 @@ decode_coding_unit:
ctx->buf = buf + ctx->data_offset;
avctx->execute2(avctx, dnxhd_decode_row, picture, NULL, ctx->mb_height);
- if (first_field && picture->interlaced_frame) {
+ if (first_field && picture->flags & AV_FRAME_FLAG_INTERLACED) {
buf += ctx->cid_table->coding_unit_size;
buf_size -= ctx->cid_table->coding_unit_size;
first_field = 0;
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);
}
static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index afc4bb0bcd..2b4d70ac3d 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -670,14 +670,14 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame,
/* Determine the codec's field order from the packet */
if ( *vsc_pack == DV_VIDEO_CONTROL ) {
if (avctx->height == 720) {
- frame->interlaced_frame = 0;
- frame->top_field_first = 0;
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else if (avctx->height == 1080) {
- frame->interlaced_frame = 1;
- frame->top_field_first = (vsc_pack[3] & 0x40) == 0x40;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * ((vsc_pack[3] & 0x40) == 0x40);
} else {
- frame->interlaced_frame = (vsc_pack[3] & 0x10) == 0x10;
- frame->top_field_first = !(vsc_pack[3] & 0x40);
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * ((vsc_pack[3] & 0x10) == 0x10);
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !(vsc_pack[3] & 0x40);
}
}
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 11dd5763af..368f47d337 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -1046,9 +1046,9 @@ static inline int dv_write_pack(enum DVPackType pack_id, DVEncContext *c,
int fs;
if (c->avctx->height >= 720)
- fs = c->avctx->height == 720 || c->frame->top_field_first ? 0x40 : 0x00;
+ fs = c->avctx->height == 720 || (c->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 0x40 : 0x00;
else
- fs = c->frame->top_field_first ? 0x00 : 0x40;
+ fs = (c->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 0x00 : 0x40;
if (DV_PROFILE_IS_HD(c->sys) ||
(int)(av_q2d(c->avctx->sample_aspect_ratio) *
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 041fc7670e..37cf6d0820 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -192,6 +192,11 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
av_frame_move_ref(frame, avci->buffer_frame);
+ if (frame->interlaced_frame)
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (frame->top_field_first)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+
return 0;
}
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index bd7050062c..04c2aeb1f9 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -908,7 +908,7 @@ void ff_er_frame_end(ERContext *s)
return;
}
- if (!s->warned_fields && (s->cur_pic.field_picture || s->cur_pic.f->interlaced_frame)) {
+ if (!s->warned_fields && (s->cur_pic.field_picture || (s->cur_pic.f->flags & AV_FRAME_FLAG_INTERLACED))) {
av_log(s->avctx, AV_LOG_WARNING, "Error concealment is not fully implemented for field pictures.\n");
s->warned_fields = 1;
}
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index a3f9302233..c49db83b5c 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -217,13 +217,13 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs)
ps = get_symbol(c, state, 0);
if (ps == 1) {
- f->cur->interlaced_frame = 1;
- f->cur->top_field_first = 1;
+ f->cur->flags |= AV_FRAME_FLAG_INTERLACED;
+ f->cur->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else if (ps == 2) {
- f->cur->interlaced_frame = 1;
- f->cur->top_field_first = 0;
+ f->cur->flags |= AV_FRAME_FLAG_INTERLACED;
+ f->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else if (ps == 3) {
- f->cur->interlaced_frame = 0;
+ f->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
}
f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0);
f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0);
@@ -881,9 +881,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (f->version < 3 && avctx->field_order > AV_FIELD_PROGRESSIVE) {
/* we have interlaced material flagged in container */
- p->interlaced_frame = 1;
+ p->flags |= AV_FRAME_FLAG_INTERLACED;
if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
- p->top_field_first = 1;
+ p->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
f->avctx = avctx;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index fb12776cc2..746f717568 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -916,10 +916,10 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs)
put_symbol(c, state, f->plane[j].quant_table_index, 0);
av_assert0(f->plane[j].quant_table_index == f->context_model);
}
- if (!f->cur_enc_frame->interlaced_frame)
+ if (!(f->cur_enc_frame->flags & AV_FRAME_FLAG_INTERLACED))
put_symbol(c, state, 3, 0);
else
- put_symbol(c, state, 1 + !f->cur_enc_frame->top_field_first, 0);
+ put_symbol(c, state, 1 + !(f->cur_enc_frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST), 0);
put_symbol(c, state, f->cur_enc_frame->sample_aspect_ratio.num, 0);
put_symbol(c, state, f->cur_enc_frame->sample_aspect_ratio.den, 0);
if (f->version > 3) {
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);
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];
+ out->flags |= AV_FRAME_FLAG_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;
+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
else
- out->top_field_first = 0;
- } else if (out->interlaced_frame) {
+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ } else if (out->flags & AV_FRAME_FLAG_INTERLACED) {
/* Default to top field first when pic_struct_present_flag
* is not set but interlaced frame detected */
- out->top_field_first = 1;
+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else {
/* Most likely progressive */
- out->top_field_first = 0;
+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
}
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));
if (s->avctx->hwaccel) {
const AVHWAccel *hwaccel = s->avctx->hwaccel;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index cfdd422236..3aea29e995 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -196,9 +196,9 @@ static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
if (x4->avcintra_class < 0) {
- if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) {
+ if (x4->params.b_interlaced && x4->params.b_tff != !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) {
- x4->params.b_tff = frame->top_field_first;
+ x4->params.b_tff = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
x264_encoder_reconfig(x4->enc, &x4->params);
}
if (x4->params.vui.i_sar_height*ctx->sample_aspect_ratio.num != ctx->sample_aspect_ratio.den * x4->params.vui.i_sar_width) {
@@ -339,7 +339,7 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth,
av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
}
return 0;
- } else if (frame->interlaced_frame) {
+ } else if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
if (!x4->roi_warned) {
x4->roi_warned = 1;
av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
diff --git a/libavcodec/m101.c b/libavcodec/m101.c
index 3def577b74..2d2855a770 100644
--- a/libavcodec/m101.c
+++ b/libavcodec/m101.c
@@ -68,14 +68,14 @@ static int m101_decode_frame(AVCodecContext *avctx, AVFrame *frame,
return ret;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
- frame->interlaced_frame = ((avctx->extradata[3*4] & 3) != 3);
- if (frame->interlaced_frame)
- frame->top_field_first = avctx->extradata[3*4] & 1;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * ((avctx->extradata[3*4] & 3) != 3);
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (avctx->extradata[3*4] & 1);
for (y = 0; y < avctx->height; y++) {
int src_y = y;
- if (frame->interlaced_frame)
- src_y = ((y&1)^frame->top_field_first) ? y/2 : (y/2 + avctx->height/2);
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED)
+ src_y = ((y&1) ^ !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) ? y/2 : (y/2 + avctx->height/2);
if (bits == 8) {
uint8_t *line = frame->data[0] + y*frame->linesize[0];
memcpy(line, buf + src_y*stride, 2*avctx->width);
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 3fc18aac73..737385c65f 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -441,8 +441,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->height < ((s->orig_height * 3) / 4)) {
s->interlaced = 1;
s->bottom_field = s->interlace_polarity;
- s->picture_ptr->interlaced_frame = 1;
- s->picture_ptr->top_field_first = !s->interlace_polarity;
+ s->picture_ptr->flags |= AV_FRAME_FLAG_INTERLACED;
+ s->picture_ptr->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !s->interlace_polarity;
height *= 2;
}
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 3092f58510..f4b86af1fe 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -622,8 +622,8 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame,
MMALDecodeContext *ctx = avctx->priv_data;
int ret = 0;
- frame->interlaced_frame = ctx->interlaced_frame;
- frame->top_field_first = ctx->top_field_first;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * !!ctx->interlaced_frame;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!ctx->top_field_first;
if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
if (!ctx->pool_out)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index a932b59678..c7438fbe07 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -530,7 +530,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s)
if (s->progressive_sequence)
put_bits(&s->pb, 1, 0); /* no repeat */
else
- put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
+ put_bits(&s->pb, 1, !!(s->current_picture_ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
/* XXX: optimize the generation of this flag with entropy measures */
s->frame_pred_frame_dct = s->progressive_sequence;
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index c3e9ebea45..777635c40c 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1101,7 +1101,7 @@ int ff_mpeg4_encode_picture_header(MpegEncContext *s)
}
put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */
if (!s->progressive_sequence) {
- put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
+ put_bits(&s->pb, 1, !!(s->current_picture_ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
put_bits(&s->pb, 1, s->alternate_scan);
}
// FIXME sprite stuff
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 522a0aada5..482f388b99 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -331,15 +331,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->current_picture_ptr = pic;
// FIXME use only the vars from current_pic
- s->current_picture_ptr->f->top_field_first = s->top_field_first;
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first;
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->picture_structure != PICT_FRAME)
- s->current_picture_ptr->f->top_field_first =
- (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
+ ((s->picture_structure == PICT_TOP_FIELD) == s->first_field);
}
- s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&
- !s->progressive_sequence;
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (!s->progressive_frame &&
+ !s->progressive_sequence);
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
s->current_picture_ptr->f->pict_type = s->pict_type;
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 50a4fa6f69..b2f6253a43 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2634,7 +2634,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
pic_params.outputBitstream = in_surf->output_surface;
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
- if (frame->top_field_first)
+ if (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM;
else
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP;
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 8fbb71f60f..03b3efdabc 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -841,7 +841,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
- p->interlaced_frame = !!s->interlace_type;
+ p->flags |= AV_FRAME_FLAG_INTERLACED * !!s->interlace_type;
if ((ret = populate_avctx_color_fields(avctx, p)) < 0)
return ret;
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index c821a07849..e9d219000a 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -252,8 +252,8 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
ctx->scan = ctx->progressive_scan; // permuted
} else {
ctx->scan = ctx->interlaced_scan; // permuted
- ctx->frame->interlaced_frame = 1;
- ctx->frame->top_field_first = ctx->frame_type == 1;
+ ctx->frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ ctx->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (ctx->frame_type == 1);
}
if (ctx->alpha_info) {
@@ -706,7 +706,7 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
- if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {
+ if (ctx->frame_type && ctx->first_field ^ !!(ctx->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) {
dest_y += pic->linesize[0];
dest_u += pic->linesize[1];
dest_v += pic->linesize[2];
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 09196c7aa1..7b01aebf72 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -746,7 +746,7 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (avctx->profile >= FF_PROFILE_PRORES_4444) /* 4444 or 4444 Xq */
frame_flags |= 0x40; /* 444 chroma */
if (ctx->is_interlaced) {
- if (pict->top_field_first || !pict->interlaced_frame) { /* tff frame or progressive frame interpret as tff */
+ if ((pict->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) || !(pict->flags & AV_FRAME_FLAG_INTERLACED)) { /* tff frame or progressive frame interpret as tff */
av_log(avctx, AV_LOG_DEBUG, "use interlaced encoding, top field first\n");
frame_flags |= 0x04; /* interlaced tff */
is_top_field_first = 1;
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 1940e0378a..77ab524046 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -585,7 +585,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
if (ctx->pictures_per_frame == 1)
line_add = 0;
else
- line_add = ctx->cur_picture_idx ^ !pic->top_field_first;
+ line_add = ctx->cur_picture_idx ^ !(pic->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
if (ctx->force_quant) {
qmat = ctx->quants[0];
@@ -838,7 +838,7 @@ static int find_slice_quant(AVCodecContext *avctx,
if (ctx->pictures_per_frame == 1)
line_add = 0;
else
- line_add = ctx->cur_picture_idx ^ !ctx->pic->top_field_first;
+ line_add = ctx->cur_picture_idx ^ !(ctx->pic->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
mbs = x + mbs_per_slice;
for (i = 0; i < ctx->num_planes; i++) {
@@ -1045,7 +1045,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
frame_flags = ctx->chroma_factor << 6;
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT)
- frame_flags |= pic->top_field_first ? 0x04 : 0x08;
+ frame_flags |= (pic->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 0x04 : 0x08;
bytestream_put_byte (&buf, frame_flags);
bytestream_put_byte (&buf, 0); // reserved
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 6bc85116ad..e137a38e3c 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -828,9 +828,9 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_TRIPLING ? 4 :
outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_DOUBLING ? 2 :
outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_REPEATED ? 1 : 0;
- frame->top_field_first =
- outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
- frame->interlaced_frame =
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
+ !!(outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF);
+ frame->flags |= AV_FRAME_FLAG_INTERLACED *
!(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
frame->pict_type = ff_qsv_map_pictype(aframe.frame->dec_info.FrameType);
//Key frame is IDR frame is only suitable for H264. For HEVC, IRAPs are key frames.
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c975302b4f..0ed1f757d4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1947,8 +1947,8 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
qf->surface.Info = q->param.mfx.FrameInfo;
qf->surface.Info.PicStruct =
- !frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
- frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? MFX_PICSTRUCT_PROGRESSIVE :
+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? MFX_PICSTRUCT_FIELD_TFF :
MFX_PICSTRUCT_FIELD_BFF;
if (frame->repeat_pict == 1)
qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
@@ -2402,7 +2402,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
goto free;
}
- if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame && frame->interlaced_frame)
+ if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame && (frame->flags & AV_FRAME_FLAG_INTERLACED))
print_interlace_msg(avctx, q);
ret = 0;
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index c20c317fed..5aa1030640 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -234,8 +234,8 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
return res;
if (context->tff >= 0) {
- frame->interlaced_frame = 1;
- frame->top_field_first = context->tff;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!context->tff;
}
if ((res = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
@@ -459,9 +459,9 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
}
if (avctx->field_order > AV_FIELD_PROGRESSIVE) { /* we have interlaced material flagged in container */
- frame->interlaced_frame = 1;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
- frame->top_field_first = 1;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
*got_frame = 1;
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
index 8bf7c6ed16..e869a932d5 100644
--- a/libavcodec/rkmppdec.c
+++ b/libavcodec/rkmppdec.c
@@ -404,8 +404,8 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
frame->colorspace = mpp_frame_get_colorspace(mppframe);
mode = mpp_frame_get_mode(mppframe);
- frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
- frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 83120d1b22..52d6e76479 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -871,7 +871,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
- frame->interlaced_frame = !!c->interlaced;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * !!c->interlaced;
*got_frame = 1;
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 43b92f6ec9..26c9841d83 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -207,9 +207,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
if (avctx->field_order > AV_FIELD_PROGRESSIVE) {
/* we have interlaced material flagged in container */
- pic->interlaced_frame = 1;
+ pic->flags |= AV_FRAME_FLAG_INTERLACED;
if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
- pic->top_field_first = 1;
+ pic->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
*got_frame = 1;
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 984af75c84..cd3ca42971 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -60,10 +60,10 @@ static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_
if (pic->flags & HEVC_FRAME_FLAG_LONG_REF)
va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
- if (pic->frame->interlaced_frame) {
+ if (pic->frame->flags & AV_FRAME_FLAG_INTERLACED) {
va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
- if (!pic->frame->top_field_first)
+ if (!(pic->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
}
}
diff --git a/libavcodec/vc1_mc.c b/libavcodec/vc1_mc.c
index 1b8d8799b3..8f0b3f6fab 100644
--- a/libavcodec/vc1_mc.c
+++ b/libavcodec/vc1_mc.c
@@ -233,7 +233,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir)
luty = v->last_luty;
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
} else {
srcY = s->next_picture.f->data[0];
@@ -242,7 +242,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir)
luty = v->next_luty;
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcY || !srcU) {
@@ -482,13 +482,13 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
srcY = s->last_picture.f->data[0];
luty = v->last_luty;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
} else {
srcY = s->next_picture.f->data[0];
luty = v->next_luty;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcY) {
@@ -708,14 +708,14 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
srcV = s->last_picture.f->data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
} else {
srcU = s->next_picture.f->data[1];
srcV = s->next_picture.f->data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcU) {
@@ -884,13 +884,13 @@ void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
srcV = s->next_picture.f->data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
} else {
srcU = s->last_picture.f->data[1];
srcV = s->last_picture.f->data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcU)
return;
@@ -1034,7 +1034,7 @@ void ff_vc1_interp_mc(VC1Context *v)
srcU = s->next_picture.f->data[1];
srcV = s->next_picture.f->data[2];
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
src_x = s->mb_x * 16 + (mx >> 2);
src_y = s->mb_y * 16 + (my >> 2);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 18fb616fff..a103a73445 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1078,8 +1078,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
}
v->s.current_picture_ptr->field_picture = v->field_mode;
- v->s.current_picture_ptr->f->interlaced_frame = (v->fcm != PROGRESSIVE);
- v->s.current_picture_ptr->f->top_field_first = v->tff;
+ v->s.current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (v->fcm != PROGRESSIVE);
+ v->s.current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!v->tff;
// process pulldown flags
s->current_picture_ptr->f->repeat_pict = 0;
--
2.40.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* [FFmpeg-devel] [PATCH 3/5] avfilter: use the new AVFrame interlace flags in all filters
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-12 19:49 ` James Almer
2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 4/5] fftools: use the new AVFrame interlace flags James Almer
` (4 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-04-12 19:49 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
Same situation as with lavc, double checking if i missed any filter that needs
to explicitly unset the flags is welcome.
libavfilter/avfilter.c | 4 ++--
libavfilter/buffersrc.c | 5 +++++
libavfilter/f_select.c | 8 ++++----
libavfilter/phase_template.c | 4 ++--
libavfilter/qsvvpp.c | 4 ++--
libavfilter/setpts.c | 2 +-
libavfilter/vf_coreimage.m | 1 +
libavfilter/vf_deinterlace_vaapi.c | 5 +++--
libavfilter/vf_estdif.c | 7 ++++---
libavfilter/vf_field.c | 1 +
libavfilter/vf_fieldhint.c | 2 ++
libavfilter/vf_fieldmatch.c | 15 +++++++++++----
libavfilter/vf_fieldorder.c | 10 +++++++---
libavfilter/vf_framerate.c | 2 +-
libavfilter/vf_idet.c | 17 +++++++++++++----
libavfilter/vf_kerndeint.c | 1 +
libavfilter/vf_nnedi.c | 7 ++++---
libavfilter/vf_pullup.c | 3 ++-
libavfilter/vf_repeatfields.c | 7 ++++---
libavfilter/vf_scale.c | 3 ++-
libavfilter/vf_separatefields.c | 7 ++++---
libavfilter/vf_setparams.c | 6 ++++++
libavfilter/vf_showinfo.c | 4 ++--
libavfilter/vf_telecine.c | 18 ++++++++++++++++--
libavfilter/vf_tinterlace.c | 16 ++++++++++++++--
libavfilter/vf_w3fdif.c | 7 ++++---
libavfilter/vf_weave.c | 2 ++
libavfilter/vsrc_gradients.c | 1 +
libavfilter/vsrc_testsrc.c | 1 +
libavfilter/yadif_common.c | 12 +++++++-----
30 files changed, 129 insertions(+), 53 deletions(-)
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 8d5702a0c8..0edaf17684 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -57,8 +57,8 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end)
ff_tlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
ref->sample_aspect_ratio.num, ref->sample_aspect_ratio.den,
ref->width, ref->height,
- !ref->interlaced_frame ? 'P' : /* Progressive */
- ref->top_field_first ? 'T' : 'B', /* Top / Bottom */
+ !(ref->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' : /* Progressive */
+ (ref->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B', /* Top / Bottom */
ref->key_frame,
av_get_picture_type_char(ref->pict_type));
}
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index a1740da054..927b16ea06 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -247,6 +247,11 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+ if (copy->interlaced_frame)
+ copy->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (copy->top_field_first)
+ copy->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+
ret = ff_filter_frame(ctx->outputs[0], copy);
if (ret < 0)
return ret;
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index d76c248fc5..6eab92b32f 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -356,8 +356,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_INTERLACE_TYPE] =
- !frame->interlaced_frame ? INTERLACE_TYPE_P :
- frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? INTERLACE_TYPE_P :
+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
select->var_values[VAR_PICT_TYPE] = frame->pict_type;
if (select->do_scene_detect) {
char buf[32];
@@ -380,8 +380,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
switch (inlink->type) {
case AVMEDIA_TYPE_VIDEO:
av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f",
- (!frame->interlaced_frame) ? 'P' :
- frame->top_field_first ? 'T' : 'B',
+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' :
+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B',
av_get_picture_type_char(frame->pict_type),
select->var_values[VAR_SCENE]);
break;
diff --git a/libavfilter/phase_template.c b/libavfilter/phase_template.c
index 8450670234..2621a543a1 100644
--- a/libavfilter/phase_template.c
+++ b/libavfilter/phase_template.c
@@ -57,10 +57,10 @@ static enum PhaseMode fn(analyze_plane)(void *ctx, enum PhaseMode mode, AVFrame
double bdiff, tdiff, pdiff;
if (mode == AUTO) {
- mode = new->interlaced_frame ? new->top_field_first ?
+ mode = (new->flags & AV_FRAME_FLAG_INTERLACED) ? (new->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ?
TOP_FIRST : BOTTOM_FIRST : PROGRESSIVE;
} else if (mode == AUTO_ANALYZE) {
- mode = new->interlaced_frame ? new->top_field_first ?
+ mode = (new->flags & AV_FRAME_FLAG_INTERLACED) ? (new->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ?
TOP_FIRST_ANALYZE : BOTTOM_FIRST_ANALYZE : FULL_ANALYZE;
}
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 54e7284234..b233b81243 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -460,8 +460,8 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p
inlink->time_base, default_tb);
qsv_frame->surface.Info.PicStruct =
- !qsv_frame->frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
- (qsv_frame->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
+ !(qsv_frame->frame->flags & AV_FRAME_FLAG_INTERLACED) ? MFX_PICSTRUCT_PROGRESSIVE :
+ ((qsv_frame->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? MFX_PICSTRUCT_FIELD_TFF :
MFX_PICSTRUCT_FIELD_BFF);
if (qsv_frame->frame->repeat_pict == 1)
qsv_frame->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index 5bcc0c2dcf..7a5cd3ef78 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -174,7 +174,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (frame) {
if (inlink->type == AVMEDIA_TYPE_VIDEO) {
- setpts->var_values[VAR_INTERLACED] = frame->interlaced_frame;
+ setpts->var_values[VAR_INTERLACED] = !!(frame->flags & AV_FRAME_FLAG_INTERLACED);
} else if (inlink->type == AVMEDIA_TYPE_AUDIO) {
setpts->var_values[VAR_S] = frame->nb_samples;
setpts->var_values[VAR_NB_SAMPLES] = frame->nb_samples;
diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index b1959861de..a5bfdaef6d 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -303,6 +303,7 @@ static int request_frame(AVFilterLink *link)
frame->duration = 1;
frame->key_frame = 1;
frame->interlaced_frame = 0;
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->sample_aspect_ratio = ctx->sar;
diff --git a/libavfilter/vf_deinterlace_vaapi.c b/libavfilter/vf_deinterlace_vaapi.c
index 1304561034..d4246eb4fc 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -252,7 +252,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
if (err < 0)
goto fail;
- if (!ctx->auto_enable || input_frame->interlaced_frame) {
+ if (!ctx->auto_enable || (input_frame->flags & AV_FRAME_FLAG_INTERLACED)) {
vas = vaMapBuffer(vpp_ctx->hwctx->display, vpp_ctx->filter_buffers[0],
&filter_params_addr);
if (vas != VA_STATUS_SUCCESS) {
@@ -263,7 +263,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
}
filter_params = filter_params_addr;
filter_params->flags = 0;
- if (input_frame->top_field_first) {
+ if (input_frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) {
filter_params->flags |= field ? VA_DEINTERLACING_BOTTOM_FIELD : 0;
} else {
filter_params->flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
@@ -304,6 +304,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
ctx->frame_queue[current_frame_index + 1]->pts;
}
output_frame->interlaced_frame = 0;
+ output_frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
av_get_pix_fmt_name(output_frame->format),
diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c
index 0164f4638a..d71d39e268 100644
--- a/libavfilter/vf_estdif.c
+++ b/libavfilter/vf_estdif.c
@@ -345,8 +345,8 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg,
const int rslope = s->rslope;
const int redge = s->redge;
const int depth = s->depth;
- const int interlaced = in->interlaced_frame;
- const int tff = (s->field == (s->parity == -1 ? interlaced ? in->top_field_first : 1 :
+ const int interlaced = !!(in->flags & AV_FRAME_FLAG_INTERLACED);
+ const int tff = (s->field == (s->parity == -1 ? interlaced ? (in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
s->parity ^ 1));
for (int plane = 0; plane < s->nb_planes; plane++) {
@@ -444,6 +444,7 @@ static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts, int64_t durati
return AVERROR(ENOMEM);
av_frame_copy_props(out, in);
out->interlaced_frame = 0;
+ out->flags &= ~AV_FRAME_FLAG_INTERLACED;
out->pts = pts;
out->duration = duration;
@@ -502,7 +503,7 @@ static int config_input(AVFilterLink *inlink)
return 0;
}
- if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) {
+ if ((s->deint && !(s->prev->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
s->prev->pts *= 2;
s->prev->duration *= 2;
ret = ff_filter_frame(ctx->outputs[0], s->prev);
diff --git a/libavfilter/vf_field.c b/libavfilter/vf_field.c
index 8d06ffe663..66b646c72d 100644
--- a/libavfilter/vf_field.c
+++ b/libavfilter/vf_field.c
@@ -74,6 +74,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
inpicref->height = outlink->h;
inpicref->interlaced_frame = 0;
+ inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED;
for (i = 0; i < field->nb_planes; i++) {
if (field->type == FIELD_TYPE_BOTTOM)
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index 4af9e26925..df6fb0b8df 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -218,9 +218,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
switch (hint) {
case '+':
out->interlaced_frame = 1;
+ out->flags |= AV_FRAME_FLAG_INTERLACED;
break;
case '-':
out->interlaced_frame = 0;
+ out->flags &= ~AV_FRAME_FLAG_INTERLACED;
break;
case '=':
break;
diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
index bf946beec9..a177cb3fd8 100644
--- a/libavfilter/vf_fieldmatch.c
+++ b/libavfilter/vf_fieldmatch.c
@@ -714,7 +714,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
in = fm->src;
/* parity */
- order = fm->order != FM_PARITY_AUTO ? fm->order : (in->interlaced_frame ? in->top_field_first : 1);
+ order = fm->order != FM_PARITY_AUTO ? fm->order : ((in->flags & AV_FRAME_FLAG_INTERLACED) ?
+ !!(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1);
field = fm->field != FM_PARITY_AUTO ? fm->field : order;
av_assert0(order == 0 || order == 1 || field == 0 || field == 1);
fxo = field ^ order ? fxo1m : fxo0m;
@@ -820,15 +821,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
/* mark the frame we are unable to match properly as interlaced so a proper
* de-interlacer can take the relay */
dst->interlaced_frame = interlaced_frame;
- if (dst->interlaced_frame) {
+ if (interlaced_frame) {
+ dst->flags |= AV_FRAME_FLAG_INTERLACED;
av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n",
outlink->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base));
dst->top_field_first = field;
- }
+ if (field)
+ dst->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ dst->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ } else
+ dst->flags &= ~AV_FRAME_FLAG_INTERLACED;
av_log(ctx, AV_LOG_DEBUG, "SC:%d | COMBS: %3d %3d %3d %3d %3d (combpel=%d)"
" match=%d combed=%s\n", sc, combs[0], combs[1], combs[2], combs[3], combs[4],
- fm->combpel, match, dst->interlaced_frame ? "YES" : "NO");
+ fm->combpel, match, (dst->flags & AV_FRAME_FLAG_INTERLACED) ? "YES" : "NO");
fail:
for (i = 0; i < FF_ARRAY_ELEMS(gen_frames); i++)
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index 52b4b3d8aa..e4d0eda1a4 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -76,11 +76,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
uint8_t *dst, *src;
AVFrame *out;
- if (!frame->interlaced_frame ||
- frame->top_field_first == s->dst_tff) {
+ if (!(frame->flags & AV_FRAME_FLAG_INTERLACED) ||
+ !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) == s->dst_tff) {
av_log(ctx, AV_LOG_VERBOSE,
"Skipping %s.\n",
- frame->interlaced_frame ?
+ (frame->flags & AV_FRAME_FLAG_INTERLACED) ?
"frame with same field order" : "progressive frame");
return ff_filter_frame(outlink, frame);
}
@@ -141,6 +141,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
}
}
out->top_field_first = s->dst_tff;
+ if (s->dst_tff)
+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
if (frame != out)
av_frame_free(&frame);
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 49bf6cdfff..6ef5dca27a 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -318,7 +318,7 @@ retry:
return ret;
if (inpicref) {
- if (inpicref->interlaced_frame)
+ if (inpicref->flags & AV_FRAME_FLAG_INTERLACED)
av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct.\n");
if (inpicref->pts == AV_NOPTS_VALUE) {
diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c
index 83d992add1..0f150a273d 100644
--- a/libavfilter/vf_idet.c
+++ b/libavfilter/vf_idet.c
@@ -185,11 +185,15 @@ static void filter(AVFilterContext *ctx)
if (idet->last_type == TFF){
idet->cur->top_field_first = 1;
idet->cur->interlaced_frame = 1;
+ idet->cur->flags |= (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST);
}else if(idet->last_type == BFF){
idet->cur->top_field_first = 0;
idet->cur->interlaced_frame = 1;
+ idet->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ idet->cur->flags |= AV_FRAME_FLAG_INTERLACED;
}else if(idet->last_type == PROGRESSIVE){
idet->cur->interlaced_frame = 0;
+ idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
}
for(i=0; i<3; i++)
@@ -238,13 +242,15 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref)
// initial frame(s) and not interlaced, just pass through for
// the analyze_interlaced_flag mode
if (idet->analyze_interlaced_flag &&
- !picref->interlaced_frame &&
+ !(picref->flags & AV_FRAME_FLAG_INTERLACED) &&
!idet->next) {
return ff_filter_frame(ctx->outputs[0], picref);
}
if (idet->analyze_interlaced_flag_done) {
- if (picref->interlaced_frame && idet->interlaced_flag_accuracy < 0)
+ if ((picref->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
picref->interlaced_frame = 0;
+ picref->flags &= ~AV_FRAME_FLAG_INTERLACED;
+ }
return ff_filter_frame(ctx->outputs[0], picref);
}
@@ -282,8 +288,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref)
}
if (idet->analyze_interlaced_flag) {
- if (idet->cur->interlaced_frame) {
+ if (idet->cur->flags & AV_FRAME_FLAG_INTERLACED) {
idet->cur->interlaced_frame = 0;
+ idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
filter(ctx);
if (idet->last_type == PROGRESSIVE) {
idet->interlaced_flag_accuracy --;
@@ -295,8 +302,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref)
if (idet->analyze_interlaced_flag == 1) {
ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->cur));
- if (idet->next->interlaced_frame && idet->interlaced_flag_accuracy < 0)
+ if ((idet->next->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
idet->next->interlaced_frame = 0;
+ idet->next->flags &= ~AV_FRAME_FLAG_INTERLACED;
+ }
idet->analyze_interlaced_flag_done = 1;
av_log(ctx, AV_LOG_INFO, "Final flag accuracy %d\n", idet->interlaced_flag_accuracy);
return ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->next));
diff --git a/libavfilter/vf_kerndeint.c b/libavfilter/vf_kerndeint.c
index dd320fbebf..e8ec1f474a 100644
--- a/libavfilter/vf_kerndeint.c
+++ b/libavfilter/vf_kerndeint.c
@@ -142,6 +142,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
}
av_frame_copy_props(outpic, inpic);
outpic->interlaced_frame = 0;
+ outpic->flags &= ~AV_FRAME_FLAG_INTERLACED;
for (plane = 0; plane < 4 && inpic->data[plane] && inpic->linesize[plane]; plane++) {
h = plane == 0 ? inlink->h : AV_CEIL_RSHIFT(inlink->h, kerndeint->vsub);
diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c
index 63b83e5efd..39cb4f5a85 100644
--- a/libavfilter/vf_nnedi.c
+++ b/libavfilter/vf_nnedi.c
@@ -540,8 +540,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const float in_scale = s->in_scale;
const float out_scale = s->out_scale;
const int depth = s->depth;
- const int interlaced = in->interlaced_frame;
- const int tff = s->field_n == (s->field < 0 ? interlaced ? in->top_field_first : 1 :
+ const int interlaced = !!(in->flags & AV_FRAME_FLAG_INTERLACED);
+ const int tff = s->field_n == (s->field < 0 ? interlaced ? (in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
(s->field & 1) ^ 1);
@@ -666,6 +666,7 @@ static int get_frame(AVFilterContext *ctx, int is_second)
return AVERROR(ENOMEM);
av_frame_copy_props(dst, s->prev);
dst->interlaced_frame = 0;
+ dst->flags &= ~AV_FRAME_FLAG_INTERLACED;
dst->pts = s->pts;
ff_filter_execute(ctx, filter_slice, dst, NULL,
@@ -688,7 +689,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return 0;
}
- if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) {
+ if ((s->deint && !(s->prev->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
s->prev->pts *= 2;
ret = ff_filter_frame(ctx->outputs[0], s->prev);
s->prev = in;
diff --git a/libavfilter/vf_pullup.c b/libavfilter/vf_pullup.c
index 054e3f90a9..fcdcfc44af 100644
--- a/libavfilter/vf_pullup.c
+++ b/libavfilter/vf_pullup.c
@@ -670,7 +670,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
(const uint8_t**)in->data, in->linesize,
inlink->format, inlink->w, inlink->h);
- p = in->interlaced_frame ? !in->top_field_first : 0;
+ p = (in->flags & AV_FRAME_FLAG_INTERLACED) ?
+ !(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 0;
pullup_submit_field(s, b, p );
pullup_submit_field(s, b, p^1);
diff --git a/libavfilter/vf_repeatfields.c b/libavfilter/vf_repeatfields.c
index 4d31f3b4f5..782b1e543f 100644
--- a/libavfilter/vf_repeatfields.c
+++ b/libavfilter/vf_repeatfields.c
@@ -93,11 +93,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
s->frame->pts = AV_NOPTS_VALUE;
}
- if ((state == 0 && !in->top_field_first) ||
- (state == 1 && in->top_field_first)) {
+ if ((state == 0 && !(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) ||
+ (state == 1 && (in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))) {
av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: "
"state=%d top_field_first=%d repeat_first_field=%d\n",
- state, in->top_field_first, in->repeat_pict);
+ state, !!(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST),
+ in->repeat_pict);
state ^= 1;
}
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 6b82763596..b0221e8538 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -884,7 +884,8 @@ scale:
(int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
INT_MAX);
- if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) {
+ if (scale->interlaced>0 || (scale->interlaced<0 &&
+ (in->flags & AV_FRAME_FLAG_INTERLACED))) {
ret = scale_field(scale, out, in, 0);
if (ret >= 0)
ret = scale_field(scale, out, in, 1);
diff --git a/libavfilter/vf_separatefields.c b/libavfilter/vf_separatefields.c
index 7db64c5479..814ea52e21 100644
--- a/libavfilter/vf_separatefields.c
+++ b/libavfilter/vf_separatefields.c
@@ -71,13 +71,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
inpicref->height = outlink->h;
inpicref->interlaced_frame = 0;
+ inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (!s->second) {
goto clone;
} else {
AVFrame *second = s->second;
- extract_field(second, s->nb_planes, second->top_field_first);
+ extract_field(second, s->nb_planes, !!(second->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
if (second->pts != AV_NOPTS_VALUE &&
inpicref->pts != AV_NOPTS_VALUE)
@@ -94,7 +95,7 @@ clone:
return AVERROR(ENOMEM);
}
- extract_field(inpicref, s->nb_planes, !inpicref->top_field_first);
+ extract_field(inpicref, s->nb_planes, !(inpicref->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
if (inpicref->pts != AV_NOPTS_VALUE)
inpicref->pts *= 2;
@@ -110,7 +111,7 @@ static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
if (s->second) {
*out_pts = s->second->pts += pts;
- extract_field(s->second, s->nb_planes, s->second->top_field_first);
+ extract_field(s->second, s->nb_planes, !!(s->second->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
ret = ff_filter_frame(outlink, s->second);
s->second = NULL;
}
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index 95a2d15c02..0165a5aaa6 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -128,9 +128,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
/* set field */
if (s->field_mode == MODE_PROG) {
frame->interlaced_frame = 0;
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
} else if (s->field_mode != MODE_AUTO) {
frame->interlaced_frame = 1;
frame->top_field_first = s->field_mode;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (s->field_mode)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
/* set range */
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 9caa618b01..6ecab2bf71 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -722,8 +722,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
desc->name,
frame->sample_aspect_ratio.num, frame->sample_aspect_ratio.den,
frame->width, frame->height,
- !frame->interlaced_frame ? 'P' : /* Progressive */
- frame->top_field_first ? 'T' : 'B', /* Top / Bottom */
+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' : /* Progressive */
+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B', /* Top / Bottom */
frame->key_frame,
av_get_picture_type_char(frame->pict_type));
diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 227de6f733..0af23d3a86 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -206,6 +206,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
}
s->frame[nout]->interlaced_frame = 1;
s->frame[nout]->top_field_first = !s->first_field;
+ s->frame[nout]->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (s->first_field)
+ s->frame[nout]->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ s->frame[nout]->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
nout++;
len--;
s->occupied = 0;
@@ -225,6 +230,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
s->planeheight[i]);
s->frame[nout]->interlaced_frame = inpicref->interlaced_frame;
s->frame[nout]->top_field_first = inpicref->top_field_first;
+ s->frame[nout]->flags |= (inpicref->flags & (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST));
nout++;
len -= 2;
}
@@ -241,8 +247,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
for (i = 0; i < nout; i++) {
AVFrame *frame = av_frame_clone(s->frame[i]);
- int interlaced = frame ? frame->interlaced_frame : 0;
- int tff = frame ? frame->top_field_first : 0;
+ int interlaced = frame ? (frame->flags & AV_FRAME_FLAG_INTERLACED) : 0;
+ int tff = frame ? (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 0;
if (!frame) {
av_frame_free(&inpicref);
@@ -252,6 +258,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
av_frame_copy_props(frame, inpicref);
frame->interlaced_frame = interlaced;
frame->top_field_first = tff;
+ if (interlaced)
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ else
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
+ if (tff)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
av_rescale(outlink->frame_count_in, s->ts_unit.num,
s->ts_unit.den);
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index 032629279a..742d4e195a 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -393,6 +393,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
out->height = outlink->h;
out->interlaced_frame = 1;
out->top_field_first = 1;
+ out->flags |= AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST;
out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1));
/* write odd frame lines into the upper field of the new frame */
@@ -444,7 +445,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
* halving the frame rate and preserving image height */
case MODE_INTERLEAVE_TOP: /* top field first */
case MODE_INTERLEAVE_BOTTOM: /* bottom field first */
- if ((tinterlace->flags & TINTERLACE_FLAG_BYPASS_IL) && cur->interlaced_frame) {
+ if ((tinterlace->flags & TINTERLACE_FLAG_BYPASS_IL) && (cur->flags & AV_FRAME_FLAG_INTERLACED)) {
av_log(ctx, AV_LOG_WARNING,
"video is already interlaced, adjusting framerate only\n");
out = av_frame_clone(cur);
@@ -461,6 +462,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
av_frame_copy_props(out, cur);
out->interlaced_frame = 1;
out->top_field_first = tff;
+ out->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (tff)
+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
/* copy upper/lower field from cur */
copy_picture_field(tinterlace, out->data, out->linesize,
@@ -482,6 +488,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
if (!out)
return AVERROR(ENOMEM);
out->interlaced_frame = 1;
+ out->flags |= AV_FRAME_FLAG_INTERLACED;
if (cur->pts != AV_NOPTS_VALUE)
out->pts = cur->pts*2;
@@ -490,13 +497,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
return ret;
/* output mix of current and next frame */
- tff = next->top_field_first;
+ tff = !!(next->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
av_frame_copy_props(out, next);
out->interlaced_frame = 1;
out->top_field_first = !tff;
+ out->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (tff)
+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
if (next->pts != AV_NOPTS_VALUE && cur->pts != AV_NOPTS_VALUE)
out->pts = cur->pts + next->pts;
diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index 512c8070c7..14800ef6bd 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -379,8 +379,8 @@ static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg,
const int start = (height * jobnr) / nb_jobs;
const int end = (height * (jobnr+1)) / nb_jobs;
const int max = s->max;
- const int interlaced = cur->interlaced_frame;
- const int tff = s->field == (s->parity == -1 ? interlaced ? cur->top_field_first : 1 :
+ const int interlaced = !!(cur->flags & AV_FRAME_FLAG_INTERLACED);
+ const int tff = s->field == (s->parity == -1 ? interlaced ? (cur->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
s->parity ^ 1);
int j, y_in, y_out;
@@ -487,6 +487,7 @@ static int filter(AVFilterContext *ctx, int is_second)
return AVERROR(ENOMEM);
av_frame_copy_props(out, s->cur);
out->interlaced_frame = 0;
+ out->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (!is_second) {
if (out->pts != AV_NOPTS_VALUE)
@@ -533,7 +534,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if (!s->prev)
return 0;
- if ((s->deint && !s->cur->interlaced_frame) || ctx->is_disabled) {
+ if ((s->deint && !(s->cur->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
AVFrame *out = av_frame_clone(s->cur);
if (!out)
return AVERROR(ENOMEM);
diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
index 2bd3994e5e..73684baf6a 100644
--- a/libavfilter/vf_weave.c
+++ b/libavfilter/vf_weave.c
@@ -150,6 +150,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
out->pts = s->double_weave ? s->prev->pts : in->pts / 2;
out->interlaced_frame = 1;
out->top_field_first = !s->first_field;
+ out->flags |= AV_FRAME_FLAG_INTERLACED;
+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !s->first_field;
if (!s->double_weave)
av_frame_free(&in);
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index 3c524b9242..2811dd8bb6 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -399,6 +399,7 @@ static int activate(AVFilterContext *ctx)
frame->key_frame = 1;
frame->interlaced_frame = 0;
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->sample_aspect_ratio = (AVRational) {1, 1};
frame->pts = s->pts++;
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 9760e5fc80..cef3a9be36 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -186,6 +186,7 @@ static int activate(AVFilterContext *ctx)
frame->duration = 1;
frame->key_frame = 1;
frame->interlaced_frame = 0;
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->sample_aspect_ratio = test->sar;
if (!test->draw_once)
diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c
index a10cf7a17f..3086027a4a 100644
--- a/libavfilter/yadif_common.c
+++ b/libavfilter/yadif_common.c
@@ -31,8 +31,8 @@ static int return_frame(AVFilterContext *ctx, int is_second)
int tff, ret;
if (yadif->parity == -1) {
- tff = yadif->cur->interlaced_frame ?
- yadif->cur->top_field_first : 1;
+ tff = (yadif->cur->flags & AV_FRAME_FLAG_INTERLACED) ?
+ (yadif->cur->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1;
} else {
tff = yadif->parity ^ 1;
}
@@ -44,6 +44,7 @@ static int return_frame(AVFilterContext *ctx, int is_second)
av_frame_copy_props(yadif->out, yadif->cur);
yadif->out->interlaced_frame = 0;
+ yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (yadif->current_field == YADIF_FIELD_BACK_END)
yadif->current_field = YADIF_FIELD_END;
}
@@ -128,10 +129,10 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
if (!yadif->prev)
return 0;
- if ((yadif->deint && !yadif->cur->interlaced_frame) ||
+ if ((yadif->deint && !(yadif->cur->flags & AV_FRAME_FLAG_INTERLACED)) ||
ctx->is_disabled ||
- (yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
- (yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
+ (yadif->deint && !(yadif->prev->flags & AV_FRAME_FLAG_INTERLACED) && yadif->prev->repeat_pict) ||
+ (yadif->deint && !(yadif->next->flags & AV_FRAME_FLAG_INTERLACED) && yadif->next->repeat_pict)
) {
yadif->out = av_frame_clone(yadif->cur);
if (!yadif->out)
@@ -149,6 +150,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
av_frame_copy_props(yadif->out, yadif->cur);
yadif->out->interlaced_frame = 0;
+ yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
--
2.40.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* [FFmpeg-devel] [PATCH 4/5] fftools: use the new AVFrame interlace flags
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-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 ` James Almer
2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 5/5] avutil/frame: deprecate interlaced_frame and top_field_first James Almer
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-04-12 19:49 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
fftools/ffmpeg.c | 2 +-
fftools/ffmpeg_enc.c | 11 +++++++----
fftools/ffprobe.c | 4 ++--
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 750ab76693..3b271e8f59 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1502,7 +1502,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
return ret;
if(ist->top_field_first>=0)
- decoded_frame->top_field_first = ist->top_field_first;
+ decoded_frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
ist->frames_decoded++;
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 2f1803a74c..969aa0d019 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -238,13 +238,16 @@ int enc_open(OutputStream *ost, AVFrame *frame)
if (frame) {
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
- frame->top_field_first = !!ost->top_field_first;
+ if (ost->top_field_first)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+ else
+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
- if (frame->interlaced_frame) {
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
if (enc->id == AV_CODEC_ID_MJPEG)
- enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
+ enc_ctx->field_order = (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TT:AV_FIELD_BB;
else
- enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
+ enc_ctx->field_order = (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB:AV_FIELD_BT;
} else
enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
}
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index d6e5a79c7e..cb765bd95b 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2640,8 +2640,8 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
print_int("display_picture_number", frame->display_picture_number);
)
#endif
- print_int("interlaced_frame", frame->interlaced_frame);
- print_int("top_field_first", frame->top_field_first);
+ print_int("interlaced_frame", !!(frame->flags & AV_FRAME_FLAG_INTERLACED));
+ print_int("top_field_first", !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
print_int("repeat_pict", frame->repeat_pict);
print_color_range(w, frame->color_range);
--
2.40.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* [FFmpeg-devel] [PATCH 5/5] avutil/frame: deprecate interlaced_frame and top_field_first
2023-04-12 19:49 [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer
` (2 preceding siblings ...)
2023-04-12 19:49 ` [FFmpeg-devel] [PATCH 4/5] fftools: use the new AVFrame interlace flags James Almer
@ 2023-04-12 19:49 ` James Almer
2023-04-15 12:55 ` [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-04-12 19:49 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/decode.c | 4 ++++
libavcodec/encode.c | 4 ++++
libavfilter/buffersrc.c | 4 ++++
libavfilter/vf_coreimage.m | 2 ++
libavfilter/vf_deinterlace_vaapi.c | 4 ++++
libavfilter/vf_estdif.c | 4 ++++
libavfilter/vf_field.c | 4 ++++
libavfilter/vf_fieldhint.c | 8 ++++++++
libavfilter/vf_fieldmatch.c | 8 ++++++++
libavfilter/vf_fieldorder.c | 4 ++++
libavfilter/vf_idet.c | 24 ++++++++++++++++++++++++
libavfilter/vf_kerndeint.c | 4 ++++
libavfilter/vf_nnedi.c | 4 ++++
libavfilter/vf_separatefields.c | 4 ++++
libavfilter/vf_setparams.c | 8 ++++++++
libavfilter/vf_telecine.c | 12 ++++++++++++
libavfilter/vf_tinterlace.c | 16 ++++++++++++++++
libavfilter/vf_w3fdif.c | 4 ++++
libavfilter/vf_weave.c | 4 ++++
libavfilter/vsrc_gradients.c | 4 ++++
libavfilter/vsrc_testsrc.c | 4 ++++
libavfilter/yadif_common.c | 8 ++++++++
libavutil/frame.c | 4 ++++
libavutil/frame.h | 8 ++++++++
libavutil/version.h | 1 +
25 files changed, 155 insertions(+)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 73bba99750..64a448b54c 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -570,8 +570,12 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
}
if (!ret) {
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
frame->interlaced_frame = !!(frame->flags & AV_FRAME_FLAG_INTERLACED);
frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
frame->best_effort_timestamp = guess_correct_pts(avctx,
frame->pts,
frame->pkt_dts);
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 37cf6d0820..20082ad7f1 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -192,10 +192,14 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
av_frame_move_ref(frame, avci->buffer_frame);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
if (frame->interlaced_frame)
frame->flags |= AV_FRAME_FLAG_INTERLACED;
if (frame->top_field_first)
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return 0;
}
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 927b16ea06..1d2f357bbc 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -247,10 +247,14 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
if (copy->interlaced_frame)
copy->flags |= AV_FRAME_FLAG_INTERLACED;
if (copy->top_field_first)
copy->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
ret = ff_filter_frame(ctx->outputs[0], copy);
if (ret < 0)
diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index a5bfdaef6d..a2e3dbea46 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -302,7 +302,9 @@ static int request_frame(AVFilterLink *link)
frame->pts = ctx->pts;
frame->duration = 1;
frame->key_frame = 1;
+#if FF_API_INTERLACED_FRAME
frame->interlaced_frame = 0;
+#endif
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->sample_aspect_ratio = ctx->sar;
diff --git a/libavfilter/vf_deinterlace_vaapi.c b/libavfilter/vf_deinterlace_vaapi.c
index d4246eb4fc..cb4f7b32d7 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -303,7 +303,11 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
output_frame->pts = input_frame->pts +
ctx->frame_queue[current_frame_index + 1]->pts;
}
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
output_frame->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
output_frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c
index d71d39e268..2bb1680f43 100644
--- a/libavfilter/vf_estdif.c
+++ b/libavfilter/vf_estdif.c
@@ -443,7 +443,11 @@ static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts, int64_t durati
if (!out)
return AVERROR(ENOMEM);
av_frame_copy_props(out, in);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags &= ~AV_FRAME_FLAG_INTERLACED;
out->pts = pts;
out->duration = duration;
diff --git a/libavfilter/vf_field.c b/libavfilter/vf_field.c
index 66b646c72d..5c4ff0881c 100644
--- a/libavfilter/vf_field.c
+++ b/libavfilter/vf_field.c
@@ -73,7 +73,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
int i;
inpicref->height = outlink->h;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
inpicref->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED;
for (i = 0; i < field->nb_planes; i++) {
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index df6fb0b8df..ff940a50e6 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -217,11 +217,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
switch (hint) {
case '+':
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags |= AV_FRAME_FLAG_INTERLACED;
break;
case '-':
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags &= ~AV_FRAME_FLAG_INTERLACED;
break;
case '=':
diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
index a177cb3fd8..71bef7b30f 100644
--- a/libavfilter/vf_fieldmatch.c
+++ b/libavfilter/vf_fieldmatch.c
@@ -820,12 +820,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
/* mark the frame we are unable to match properly as interlaced so a proper
* de-interlacer can take the relay */
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
dst->interlaced_frame = interlaced_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (interlaced_frame) {
dst->flags |= AV_FRAME_FLAG_INTERLACED;
av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n",
outlink->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base));
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
dst->top_field_first = field;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (field)
dst->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
else
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index e4d0eda1a4..cf6efa6e54 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -140,7 +140,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
}
}
}
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->top_field_first = s->dst_tff;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (s->dst_tff)
out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
else
diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c
index 0f150a273d..abd375230a 100644
--- a/libavfilter/vf_idet.c
+++ b/libavfilter/vf_idet.c
@@ -183,16 +183,28 @@ static void filter(AVFilterContext *ctx)
}
if (idet->last_type == TFF){
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
idet->cur->top_field_first = 1;
idet->cur->interlaced_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
idet->cur->flags |= (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST);
}else if(idet->last_type == BFF){
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
idet->cur->top_field_first = 0;
idet->cur->interlaced_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
idet->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
idet->cur->flags |= AV_FRAME_FLAG_INTERLACED;
}else if(idet->last_type == PROGRESSIVE){
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
idet->cur->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
}
@@ -248,7 +260,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref)
}
if (idet->analyze_interlaced_flag_done) {
if ((picref->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
picref->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
picref->flags &= ~AV_FRAME_FLAG_INTERLACED;
}
return ff_filter_frame(ctx->outputs[0], picref);
@@ -289,7 +305,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref)
if (idet->analyze_interlaced_flag) {
if (idet->cur->flags & AV_FRAME_FLAG_INTERLACED) {
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
idet->cur->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
filter(ctx);
if (idet->last_type == PROGRESSIVE) {
@@ -303,7 +323,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref)
ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->cur));
if ((idet->next->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
idet->next->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
idet->next->flags &= ~AV_FRAME_FLAG_INTERLACED;
}
idet->analyze_interlaced_flag_done = 1;
diff --git a/libavfilter/vf_kerndeint.c b/libavfilter/vf_kerndeint.c
index e8ec1f474a..8aec5afe98 100644
--- a/libavfilter/vf_kerndeint.c
+++ b/libavfilter/vf_kerndeint.c
@@ -141,7 +141,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
return AVERROR(ENOMEM);
}
av_frame_copy_props(outpic, inpic);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
outpic->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
outpic->flags &= ~AV_FRAME_FLAG_INTERLACED;
for (plane = 0; plane < 4 && inpic->data[plane] && inpic->linesize[plane]; plane++) {
diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c
index 39cb4f5a85..1bb8c21e10 100644
--- a/libavfilter/vf_nnedi.c
+++ b/libavfilter/vf_nnedi.c
@@ -665,7 +665,11 @@ static int get_frame(AVFilterContext *ctx, int is_second)
if (!dst)
return AVERROR(ENOMEM);
av_frame_copy_props(dst, s->prev);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
dst->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
dst->flags &= ~AV_FRAME_FLAG_INTERLACED;
dst->pts = s->pts;
diff --git a/libavfilter/vf_separatefields.c b/libavfilter/vf_separatefields.c
index 814ea52e21..723974afaa 100644
--- a/libavfilter/vf_separatefields.c
+++ b/libavfilter/vf_separatefields.c
@@ -70,7 +70,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
int ret;
inpicref->height = outlink->h;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
inpicref->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (!s->second) {
diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index 0165a5aaa6..321a64a14e 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -127,11 +127,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
/* set field */
if (s->field_mode == MODE_PROG) {
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
frame->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
} else if (s->field_mode != MODE_AUTO) {
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
frame->interlaced_frame = 1;
frame->top_field_first = s->field_mode;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
frame->flags |= AV_FRAME_FLAG_INTERLACED;
if (s->field_mode)
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c
index 0af23d3a86..17654d1394 100644
--- a/libavfilter/vf_telecine.c
+++ b/libavfilter/vf_telecine.c
@@ -204,8 +204,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
s->stride[i],
(s->planeheight[i] - !s->first_field + 1) / 2);
}
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
s->frame[nout]->interlaced_frame = 1;
s->frame[nout]->top_field_first = !s->first_field;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->frame[nout]->flags |= AV_FRAME_FLAG_INTERLACED;
if (s->first_field)
s->frame[nout]->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
@@ -228,8 +232,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
inpicref->data[i], inpicref->linesize[i],
s->stride[i],
s->planeheight[i]);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
s->frame[nout]->interlaced_frame = inpicref->interlaced_frame;
s->frame[nout]->top_field_first = inpicref->top_field_first;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->frame[nout]->flags |= (inpicref->flags & (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST));
nout++;
len -= 2;
@@ -256,8 +264,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
}
av_frame_copy_props(frame, inpicref);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
frame->interlaced_frame = interlaced;
frame->top_field_first = tff;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (interlaced)
frame->flags |= AV_FRAME_FLAG_INTERLACED;
else
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index 742d4e195a..8b0cbbcf95 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -391,8 +391,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
return AVERROR(ENOMEM);
av_frame_copy_props(out, cur);
out->height = outlink->h;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 1;
out->top_field_first = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags |= AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST;
out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1));
@@ -460,8 +464,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
if (!out)
return AVERROR(ENOMEM);
av_frame_copy_props(out, cur);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 1;
out->top_field_first = tff;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags |= AV_FRAME_FLAG_INTERLACED;
if (tff)
out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
@@ -487,7 +495,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
out = av_frame_clone(cur);
if (!out)
return AVERROR(ENOMEM);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags |= AV_FRAME_FLAG_INTERLACED;
if (cur->pts != AV_NOPTS_VALUE)
out->pts = cur->pts*2;
@@ -502,8 +514,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
if (!out)
return AVERROR(ENOMEM);
av_frame_copy_props(out, next);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 1;
out->top_field_first = !tff;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags |= AV_FRAME_FLAG_INTERLACED;
if (tff)
out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index 14800ef6bd..02e8524884 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -486,7 +486,11 @@ static int filter(AVFilterContext *ctx, int is_second)
if (!out)
return AVERROR(ENOMEM);
av_frame_copy_props(out, s->cur);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (!is_second) {
diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
index 73684baf6a..f44840d686 100644
--- a/libavfilter/vf_weave.c
+++ b/libavfilter/vf_weave.c
@@ -148,8 +148,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
out->pts = s->double_weave ? s->prev->pts : in->pts / 2;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
out->interlaced_frame = 1;
out->top_field_first = !s->first_field;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
out->flags |= AV_FRAME_FLAG_INTERLACED;
out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !s->first_field;
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index 2811dd8bb6..f50b4d3cc7 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -398,7 +398,11 @@ static int activate(AVFilterContext *ctx)
return AVERROR(ENOMEM);
frame->key_frame = 1;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
frame->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->sample_aspect_ratio = (AVRational) {1, 1};
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index cef3a9be36..c358f9ada2 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -185,7 +185,11 @@ static int activate(AVFilterContext *ctx)
frame->pts = test->pts;
frame->duration = 1;
frame->key_frame = 1;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
frame->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->sample_aspect_ratio = test->sar;
diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c
index 3086027a4a..378c3bf4cd 100644
--- a/libavfilter/yadif_common.c
+++ b/libavfilter/yadif_common.c
@@ -43,7 +43,11 @@ static int return_frame(AVFilterContext *ctx, int is_second)
return AVERROR(ENOMEM);
av_frame_copy_props(yadif->out, yadif->cur);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
yadif->out->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (yadif->current_field == YADIF_FIELD_BACK_END)
yadif->current_field = YADIF_FIELD_END;
@@ -149,7 +153,11 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
return AVERROR(ENOMEM);
av_frame_copy_props(yadif->out, yadif->cur);
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
yadif->out->interlaced_frame = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (yadif->out->pts != AV_NOPTS_VALUE)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index c905e8d611..a23520c929 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -275,8 +275,12 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
dst->pts = src->pts;
dst->duration = src->duration;
dst->repeat_pict = src->repeat_pict;
+#if FF_API_INTERLACED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
dst->interlaced_frame = src->interlaced_frame;
dst->top_field_first = src->top_field_first;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
dst->palette_has_changed = src->palette_has_changed;
dst->sample_rate = src->sample_rate;
dst->opaque = src->opaque;
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 87e0a51226..f60ad6fbec 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -491,15 +491,23 @@ typedef struct AVFrame {
*/
int repeat_pict;
+#if FF_API_INTERLACED_FRAME
/**
* The content of the picture is interlaced.
+ *
+ * @deprecated Use AV_FRAME_FLAG_INTERLACED instead
*/
+ attribute_deprecated
int interlaced_frame;
/**
* If the content is interlaced, is top field displayed first.
+ *
+ * @deprecated Use AV_FRAME_FLAG_TOP_FIELD_FIRST instead
*/
+ attribute_deprecated
int top_field_first;
+#endif
/**
* Tell user application that palette has changed from previous frame.
diff --git a/libavutil/version.h b/libavutil/version.h
index 40f92af055..6a5e2c4881 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -115,6 +115,7 @@
#define FF_API_FRAME_PICTURE_NUMBER (LIBAVUTIL_VERSION_MAJOR < 59)
#define FF_API_HDR_VIVID_THREE_SPLINE (LIBAVUTIL_VERSION_MAJOR < 59)
#define FF_API_FRAME_PKT (LIBAVUTIL_VERSION_MAJOR < 59)
+#define FF_API_INTERLACED_FRAME (LIBAVUTIL_VERSION_MAJOR < 59)
/**
* @}
--
2.40.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-12 19:49 [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer
` (3 preceding siblings ...)
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 ` James Almer
2023-04-17 10:49 ` Anton Khirnov
2023-04-30 0:19 ` James Almer
6 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-04-15 12:55 UTC (permalink / raw)
To: ffmpeg-devel
On 4/12/2023 4:49 PM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Missing version bump and APIChanges entry.
>
> libavutil/frame.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 5b58c14ac3..87e0a51226 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -586,6 +586,15 @@ typedef struct AVFrame {
> * A flag to mark the frames which need to be decoded, but shouldn't be output.
> */
> #define AV_FRAME_FLAG_DISCARD (1 << 2)
> +/**
> + * A flag to mark frames whose content is interlaced.
> + */
> +#define AV_FRAME_FLAG_INTERLACED (1 << 3)
> +/**
> + * A flag to mark frames where the top field is displayed first if the content
> + * is interlaced.
> + */
> +#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4)
> /**
> * @}
> */
I'll be pushing this set soon unless there are objections.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-12 19:49 [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer
` (4 preceding siblings ...)
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-30 0:19 ` James Almer
6 siblings, 1 reply; 14+ messages in thread
From: Anton Khirnov @ 2023-04-17 10:49 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting James Almer (2023-04-12 21:49:32)
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Missing version bump and APIChanges entry.
>
> libavutil/frame.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
Changing all those into bitfields of size 1 might be better, because no
code would need to be changed.
--
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-17 10:49 ` Anton Khirnov
@ 2023-04-17 11:32 ` James Almer
2023-04-17 11:51 ` Anton Khirnov
0 siblings, 1 reply; 14+ messages in thread
From: James Almer @ 2023-04-17 11:32 UTC (permalink / raw)
To: ffmpeg-devel
On 4/17/2023 7:49 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-04-12 21:49:32)
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> Missing version bump and APIChanges entry.
>>
>> libavutil/frame.h | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>
> Changing all those into bitfields of size 1 might be better, because no
> code would need to be changed.
Can you elaborate on this? If i do
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index f85d630c5c..3f3deab657 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -494,12 +494,12 @@ typedef struct AVFrame {
> /**
> * The content of the picture is interlaced.
> */
> - int interlaced_frame;
> + int interlaced_frame: 1;
>
> /**
> * If the content is interlaced, is top field displayed first.
> */
> - int top_field_first;
> + int top_field_first: 1;
>
> /**
> * Tell user application that palette has changed from previous frame.
It's not only an ABI break, but i assume the compiler will still
pad/align the struct for the next field, so you're not saving many bytes.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-17 11:32 ` James Almer
@ 2023-04-17 11:51 ` Anton Khirnov
2023-04-21 21:10 ` James Almer
0 siblings, 1 reply; 14+ messages in thread
From: Anton Khirnov @ 2023-04-17 11:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting James Almer (2023-04-17 13:32:16)
> On 4/17/2023 7:49 AM, Anton Khirnov wrote:
> > Quoting James Almer (2023-04-12 21:49:32)
> >> Signed-off-by: James Almer <jamrial@gmail.com>
> >> ---
> >> Missing version bump and APIChanges entry.
> >>
> >> libavutil/frame.h | 9 +++++++++
> >> 1 file changed, 9 insertions(+)
> >>
> >
> > Changing all those into bitfields of size 1 might be better, because no
> > code would need to be changed.
>
> Can you elaborate on this? If i do
>
> > diff --git a/libavutil/frame.h b/libavutil/frame.h
> > index f85d630c5c..3f3deab657 100644
> > --- a/libavutil/frame.h
> > +++ b/libavutil/frame.h
> > @@ -494,12 +494,12 @@ typedef struct AVFrame {
> > /**
> > * The content of the picture is interlaced.
> > */
> > - int interlaced_frame;
> > + int interlaced_frame: 1;
> >
> > /**
> > * If the content is interlaced, is top field displayed first.
> > */
> > - int top_field_first;
> > + int top_field_first: 1;
> >
> > /**
> > * Tell user application that palette has changed from previous frame.
>
> It's not only an ABI break, but i assume the compiler will still
> pad/align the struct for the next field, so you're not saving many bytes.
Yes it's an ABI break, so the savings will only appear at the next major
bump. But with a deprecation we'd have to wait even longer.
The idea is to put all these fields next to each other so they'd form a
single unit. We could also reduce flags to 8 or 16 bits until/unless we
need more. Then all of these would fit in the size of a single int.
--
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-17 11:51 ` Anton Khirnov
@ 2023-04-21 21:10 ` James Almer
0 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-04-21 21:10 UTC (permalink / raw)
To: ffmpeg-devel
On 4/17/2023 8:51 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-04-17 13:32:16)
>> On 4/17/2023 7:49 AM, Anton Khirnov wrote:
>>> Quoting James Almer (2023-04-12 21:49:32)
>>>> Signed-off-by: James Almer <jamrial@gmail.com>
>>>> ---
>>>> Missing version bump and APIChanges entry.
>>>>
>>>> libavutil/frame.h | 9 +++++++++
>>>> 1 file changed, 9 insertions(+)
>>>>
>>>
>>> Changing all those into bitfields of size 1 might be better, because no
>>> code would need to be changed.
>>
>> Can you elaborate on this? If i do
>>
>>> diff --git a/libavutil/frame.h b/libavutil/frame.h
>>> index f85d630c5c..3f3deab657 100644
>>> --- a/libavutil/frame.h
>>> +++ b/libavutil/frame.h
>>> @@ -494,12 +494,12 @@ typedef struct AVFrame {
>>> /**
>>> * The content of the picture is interlaced.
>>> */
>>> - int interlaced_frame;
>>> + int interlaced_frame: 1;
>>>
>>> /**
>>> * If the content is interlaced, is top field displayed first.
>>> */
>>> - int top_field_first;
>>> + int top_field_first: 1;
>>>
>>> /**
>>> * Tell user application that palette has changed from previous frame.
>>
>> It's not only an ABI break, but i assume the compiler will still
>> pad/align the struct for the next field, so you're not saving many bytes.
>
> Yes it's an ABI break, so the savings will only appear at the next major
> bump. But with a deprecation we'd have to wait even longer.
>
> The idea is to put all these fields next to each other so they'd form a
> single unit. We could also reduce flags to 8 or 16 bits until/unless we
> need more. Then all of these would fit in the size of a single int.
So, on IRC it was decided that bitfields is not the way to go as it's
implementation dependent, plus it would break FFI usage of our headers.
As such, this set and the key_frame one are still open.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/5] avcodec: use the new AVFrame interlace flags in all decoders and encoders
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
2023-04-24 12:31 ` James Almer
0 siblings, 1 reply; 14+ messages in thread
From: Anton Khirnov @ 2023-04-23 19:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* [FFmpeg-devel] [PATCH 2/5] avcodec: use the new AVFrame interlace flags in all decoders and encoders
2023-04-23 19:47 ` Anton Khirnov
@ 2023-04-24 12:31 ` James Almer
0 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-04-24 12:31 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/cfhd.c | 6 +++---
libavcodec/crystalhd.c | 4 ++--
libavcodec/cuviddec.c | 9 ++++++---
libavcodec/decode.c | 2 ++
libavcodec/dnxhddec.c | 14 +++++++-------
libavcodec/dnxhdenc.c | 3 ++-
libavcodec/dvdec.c | 12 ++++++------
libavcodec/dvenc.c | 4 ++--
libavcodec/encode.c | 5 +++++
libavcodec/ffv1dec.c | 14 +++++++-------
libavcodec/ffv1enc.c | 4 ++--
libavcodec/h264_slice.c | 32 ++++++++++++++++----------------
libavcodec/hevc_refs.c | 7 +++++--
libavcodec/libx264.c | 6 +++---
libavcodec/m101.c | 10 +++++-----
libavcodec/mjpegdec.c | 4 ++--
libavcodec/mmaldec.c | 4 ++--
libavcodec/mpeg12enc.c | 2 +-
libavcodec/mpeg4videoenc.c | 2 +-
libavcodec/mpegvideo_dec.c | 10 +++++-----
libavcodec/nvenc.c | 2 +-
libavcodec/pngdec.c | 2 +-
libavcodec/proresdec2.c | 6 +++---
libavcodec/proresenc_anatoliy.c | 3 ++-
libavcodec/proresenc_kostya.c | 6 +++---
libavcodec/qsvdec.c | 6 +++---
libavcodec/qsvenc.c | 6 +++---
libavcodec/rawdec.c | 8 ++++----
libavcodec/rkmppdec.c | 6 ++++--
libavcodec/utvideodec.c | 2 +-
libavcodec/v210dec.c | 4 ++--
libavcodec/vaapi_hevc.c | 4 ++--
libavcodec/vc1_mc.c | 18 +++++++++---------
libavcodec/vc1dec.c | 4 ++--
34 files changed, 124 insertions(+), 107 deletions(-)
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index c23eb069c6..42d7dcc3f6 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -1087,8 +1087,8 @@ finish:
dst += dst_linesize;
}
} else {
- av_log(avctx, AV_LOG_DEBUG, "interlaced frame ? %d", pic->interlaced_frame);
- pic->interlaced_frame = 1;
+ av_log(avctx, AV_LOG_DEBUG, "interlaced frame ? %d", !!(pic->flags & AV_FRAME_FLAG_INTERLACED));
+ pic->flags |= AV_FRAME_FLAG_INTERLACED;
low = s->plane[plane].subband[0];
high = s->plane[plane].subband[7];
output = s->plane[plane].l_h[6];
@@ -1284,7 +1284,7 @@ finish:
dst += dst_linesize;
}
} else {
- pic->interlaced_frame = 1;
+ pic->flags |= AV_FRAME_FLAG_INTERLACED;
low = s->plane[plane].l_h[7];
high = s->plane[plane].subband[14];
output = s->plane[plane].l_h[6];
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index a48d60f123..86f6cfa6c1 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -543,9 +543,9 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
- frame->interlaced_frame = interlaced;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * !!interlaced;
if (interlaced)
- frame->top_field_first = !bottom_first;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !bottom_first;
frame->pts = pkt_pts;
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 76e70aa648..5904cce583 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -631,10 +631,13 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame;
+ 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);
+ }
- if (frame->interlaced_frame)
- frame->top_field_first = parsed_frame.dispinfo.top_field_first;
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!parsed_frame.dispinfo.top_field_first;
} else if (ctx->decoder_flushing) {
ret = AVERROR_EOF;
} else {
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 40f5a3ba59..73bba99750 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -570,6 +570,8 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
}
if (!ret) {
+ frame->interlaced_frame = !!(frame->flags & AV_FRAME_FLAG_INTERLACED);
+ frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
frame->best_effort_timestamp = guess_correct_pts(avctx,
frame->pts,
frame->pkt_dts);
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 7cc4f94c7f..b98a0237ab 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -195,8 +195,8 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
}
if (buf[5] & 2) { /* interlaced */
ctx->cur_field = first_field ? buf[5] & 1 : !ctx->cur_field;
- frame->interlaced_frame = 1;
- frame->top_field_first = first_field ^ ctx->cur_field;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!(first_field ^ ctx->cur_field);
av_log(ctx->avctx, AV_LOG_DEBUG,
"interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
} else {
@@ -298,7 +298,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
ctx->mb_width = (ctx->width + 15)>> 4;
ctx->mb_height = AV_RB16(buf + 0x16c);
- if ((ctx->height + 15) >> 4 == ctx->mb_height && frame->interlaced_frame)
+ if ((ctx->height + 15) >> 4 == ctx->mb_height && (frame->flags & AV_FRAME_FLAG_INTERLACED))
ctx->height <<= 1;
av_log(ctx->avctx, AV_LOG_VERBOSE, "%dx%d, 4:%s %d bits, MBAFF=%d ACT=%d\n",
@@ -316,7 +316,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
}
ctx->data_offset = 0x280;
}
- if ((ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
+ if ((ctx->mb_height << !!(frame->flags & AV_FRAME_FLAG_INTERLACED)) > (ctx->height + 15) >> 4) {
av_log(ctx->avctx, AV_LOG_ERROR,
"mb height too big: %d\n", ctx->mb_height);
return AVERROR_INVALIDDATA;
@@ -530,7 +530,7 @@ static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row,
return AVERROR_INVALIDDATA;
}
- if (frame->interlaced_frame) {
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
dct_linesize_luma <<= 1;
dct_linesize_chroma <<= 1;
}
@@ -539,7 +539,7 @@ static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row,
dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
- if (frame->interlaced_frame && ctx->cur_field) {
+ if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && ctx->cur_field) {
dest_y += frame->linesize[0];
dest_u += frame->linesize[1];
dest_v += frame->linesize[2];
@@ -659,7 +659,7 @@ decode_coding_unit:
ctx->buf = buf + ctx->data_offset;
avctx->execute2(avctx, dnxhd_decode_row, picture, NULL, ctx->mb_height);
- if (first_field && picture->interlaced_frame) {
+ if (first_field && picture->flags & AV_FRAME_FLAG_INTERLACED) {
buf += ctx->cid_table->coding_unit_size;
buf_size -= ctx->cid_table->coding_unit_size;
first_field = 0;
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 176bf972d8..a1852fa6b7 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -1251,7 +1251,8 @@ 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);
}
static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index afc4bb0bcd..2b4d70ac3d 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -670,14 +670,14 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame,
/* Determine the codec's field order from the packet */
if ( *vsc_pack == DV_VIDEO_CONTROL ) {
if (avctx->height == 720) {
- frame->interlaced_frame = 0;
- frame->top_field_first = 0;
+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else if (avctx->height == 1080) {
- frame->interlaced_frame = 1;
- frame->top_field_first = (vsc_pack[3] & 0x40) == 0x40;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * ((vsc_pack[3] & 0x40) == 0x40);
} else {
- frame->interlaced_frame = (vsc_pack[3] & 0x10) == 0x10;
- frame->top_field_first = !(vsc_pack[3] & 0x40);
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * ((vsc_pack[3] & 0x10) == 0x10);
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !(vsc_pack[3] & 0x40);
}
}
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index cd442b524d..7bd50174b7 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -1048,9 +1048,9 @@ static inline int dv_write_pack(enum DVPackType pack_id, DVEncContext *c,
int fs;
if (c->avctx->height >= 720)
- fs = c->avctx->height == 720 || c->frame->top_field_first ? 0x40 : 0x00;
+ fs = c->avctx->height == 720 || (c->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 0x40 : 0x00;
else
- fs = c->frame->top_field_first ? 0x00 : 0x40;
+ fs = (c->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 0x00 : 0x40;
if (DV_PROFILE_IS_HD(c->sys) ||
(int)(av_q2d(c->avctx->sample_aspect_ratio) *
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 0f11efc481..dfcdce6a3c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -192,6 +192,11 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
av_frame_move_ref(frame, avci->buffer_frame);
+ if (frame->interlaced_frame)
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ if (frame->top_field_first)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+
return 0;
}
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index a3f9302233..c49db83b5c 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -217,13 +217,13 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs)
ps = get_symbol(c, state, 0);
if (ps == 1) {
- f->cur->interlaced_frame = 1;
- f->cur->top_field_first = 1;
+ f->cur->flags |= AV_FRAME_FLAG_INTERLACED;
+ f->cur->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else if (ps == 2) {
- f->cur->interlaced_frame = 1;
- f->cur->top_field_first = 0;
+ f->cur->flags |= AV_FRAME_FLAG_INTERLACED;
+ f->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
} else if (ps == 3) {
- f->cur->interlaced_frame = 0;
+ f->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
}
f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0);
f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0);
@@ -881,9 +881,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (f->version < 3 && avctx->field_order > AV_FIELD_PROGRESSIVE) {
/* we have interlaced material flagged in container */
- p->interlaced_frame = 1;
+ p->flags |= AV_FRAME_FLAG_INTERLACED;
if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
- p->top_field_first = 1;
+ p->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
f->avctx = avctx;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index fb12776cc2..746f717568 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -916,10 +916,10 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs)
put_symbol(c, state, f->plane[j].quant_table_index, 0);
av_assert0(f->plane[j].quant_table_index == f->context_model);
}
- if (!f->cur_enc_frame->interlaced_frame)
+ if (!(f->cur_enc_frame->flags & AV_FRAME_FLAG_INTERLACED))
put_symbol(c, state, 3, 0);
else
- put_symbol(c, state, 1 + !f->cur_enc_frame->top_field_first, 0);
+ put_symbol(c, state, 1 + !(f->cur_enc_frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST), 0);
put_symbol(c, state, f->cur_enc_frame->sample_aspect_ratio.num, 0);
put_symbol(c, state, f->cur_enc_frame->sample_aspect_ratio.den, 0);
if (f->version > 3) {
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));
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 96153a2459..e9be02c489 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -111,8 +111,11 @@ 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);
+ if (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
+ frame->frame->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))
+ frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
if (s->avctx->hwaccel) {
const AVHWAccel *hwaccel = s->avctx->hwaccel;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index cfdd422236..3aea29e995 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -196,9 +196,9 @@ static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
if (x4->avcintra_class < 0) {
- if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) {
+ if (x4->params.b_interlaced && x4->params.b_tff != !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) {
- x4->params.b_tff = frame->top_field_first;
+ x4->params.b_tff = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
x264_encoder_reconfig(x4->enc, &x4->params);
}
if (x4->params.vui.i_sar_height*ctx->sample_aspect_ratio.num != ctx->sample_aspect_ratio.den * x4->params.vui.i_sar_width) {
@@ -339,7 +339,7 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth,
av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
}
return 0;
- } else if (frame->interlaced_frame) {
+ } else if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
if (!x4->roi_warned) {
x4->roi_warned = 1;
av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
diff --git a/libavcodec/m101.c b/libavcodec/m101.c
index 3def577b74..2d2855a770 100644
--- a/libavcodec/m101.c
+++ b/libavcodec/m101.c
@@ -68,14 +68,14 @@ static int m101_decode_frame(AVCodecContext *avctx, AVFrame *frame,
return ret;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
- frame->interlaced_frame = ((avctx->extradata[3*4] & 3) != 3);
- if (frame->interlaced_frame)
- frame->top_field_first = avctx->extradata[3*4] & 1;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * ((avctx->extradata[3*4] & 3) != 3);
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (avctx->extradata[3*4] & 1);
for (y = 0; y < avctx->height; y++) {
int src_y = y;
- if (frame->interlaced_frame)
- src_y = ((y&1)^frame->top_field_first) ? y/2 : (y/2 + avctx->height/2);
+ if (frame->flags & AV_FRAME_FLAG_INTERLACED)
+ src_y = ((y&1) ^ !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) ? y/2 : (y/2 + avctx->height/2);
if (bits == 8) {
uint8_t *line = frame->data[0] + y*frame->linesize[0];
memcpy(line, buf + src_y*stride, 2*avctx->width);
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 9b55002c4b..a710d21793 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -441,8 +441,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->height < ((s->orig_height * 3) / 4)) {
s->interlaced = 1;
s->bottom_field = s->interlace_polarity;
- s->picture_ptr->interlaced_frame = 1;
- s->picture_ptr->top_field_first = !s->interlace_polarity;
+ s->picture_ptr->flags |= AV_FRAME_FLAG_INTERLACED;
+ s->picture_ptr->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !s->interlace_polarity;
height *= 2;
}
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 3092f58510..f4b86af1fe 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -622,8 +622,8 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame,
MMALDecodeContext *ctx = avctx->priv_data;
int ret = 0;
- frame->interlaced_frame = ctx->interlaced_frame;
- frame->top_field_first = ctx->top_field_first;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * !!ctx->interlaced_frame;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!ctx->top_field_first;
if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
if (!ctx->pool_out)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index a932b59678..c7438fbe07 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -530,7 +530,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s)
if (s->progressive_sequence)
put_bits(&s->pb, 1, 0); /* no repeat */
else
- put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
+ put_bits(&s->pb, 1, !!(s->current_picture_ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
/* XXX: optimize the generation of this flag with entropy measures */
s->frame_pred_frame_dct = s->progressive_sequence;
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index c3e9ebea45..777635c40c 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1101,7 +1101,7 @@ int ff_mpeg4_encode_picture_header(MpegEncContext *s)
}
put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */
if (!s->progressive_sequence) {
- put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
+ put_bits(&s->pb, 1, !!(s->current_picture_ptr->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
put_bits(&s->pb, 1, s->alternate_scan);
}
// FIXME sprite stuff
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 522a0aada5..482f388b99 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -331,15 +331,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->current_picture_ptr = pic;
// FIXME use only the vars from current_pic
- s->current_picture_ptr->f->top_field_first = s->top_field_first;
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!s->top_field_first;
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->picture_structure != PICT_FRAME)
- s->current_picture_ptr->f->top_field_first =
- (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
+ ((s->picture_structure == PICT_TOP_FIELD) == s->first_field);
}
- s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&
- !s->progressive_sequence;
+ s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (!s->progressive_frame &&
+ !s->progressive_sequence);
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
s->current_picture_ptr->f->pict_type = s->pict_type;
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 50a4fa6f69..b2f6253a43 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2634,7 +2634,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
pic_params.outputBitstream = in_surf->output_surface;
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
- if (frame->top_field_first)
+ if (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM;
else
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP;
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 8fbb71f60f..03b3efdabc 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -841,7 +841,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
- p->interlaced_frame = !!s->interlace_type;
+ p->flags |= AV_FRAME_FLAG_INTERLACED * !!s->interlace_type;
if ((ret = populate_avctx_color_fields(avctx, p)) < 0)
return ret;
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index c821a07849..e9d219000a 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -252,8 +252,8 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
ctx->scan = ctx->progressive_scan; // permuted
} else {
ctx->scan = ctx->interlaced_scan; // permuted
- ctx->frame->interlaced_frame = 1;
- ctx->frame->top_field_first = ctx->frame_type == 1;
+ ctx->frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ ctx->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (ctx->frame_type == 1);
}
if (ctx->alpha_info) {
@@ -706,7 +706,7 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
- if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {
+ if (ctx->frame_type && ctx->first_field ^ !!(ctx->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) {
dest_y += pic->linesize[0];
dest_u += pic->linesize[1];
dest_v += pic->linesize[2];
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 09196c7aa1..fc48c97d5b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -746,7 +746,8 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (avctx->profile >= FF_PROFILE_PRORES_4444) /* 4444 or 4444 Xq */
frame_flags |= 0x40; /* 444 chroma */
if (ctx->is_interlaced) {
- if (pict->top_field_first || !pict->interlaced_frame) { /* tff frame or progressive frame interpret as tff */
+ if ((pict->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) || !(pict->flags & AV_FRAME_FLAG_INTERLACED)) {
+ /* tff frame or progressive frame interpret as tff */
av_log(avctx, AV_LOG_DEBUG, "use interlaced encoding, top field first\n");
frame_flags |= 0x04; /* interlaced tff */
is_top_field_first = 1;
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 1940e0378a..77ab524046 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -585,7 +585,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
if (ctx->pictures_per_frame == 1)
line_add = 0;
else
- line_add = ctx->cur_picture_idx ^ !pic->top_field_first;
+ line_add = ctx->cur_picture_idx ^ !(pic->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
if (ctx->force_quant) {
qmat = ctx->quants[0];
@@ -838,7 +838,7 @@ static int find_slice_quant(AVCodecContext *avctx,
if (ctx->pictures_per_frame == 1)
line_add = 0;
else
- line_add = ctx->cur_picture_idx ^ !ctx->pic->top_field_first;
+ line_add = ctx->cur_picture_idx ^ !(ctx->pic->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
mbs = x + mbs_per_slice;
for (i = 0; i < ctx->num_planes; i++) {
@@ -1045,7 +1045,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
frame_flags = ctx->chroma_factor << 6;
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT)
- frame_flags |= pic->top_field_first ? 0x04 : 0x08;
+ frame_flags |= (pic->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 0x04 : 0x08;
bytestream_put_byte (&buf, frame_flags);
bytestream_put_byte (&buf, 0); // reserved
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 6bc85116ad..e137a38e3c 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -828,9 +828,9 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_TRIPLING ? 4 :
outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_DOUBLING ? 2 :
outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_REPEATED ? 1 : 0;
- frame->top_field_first =
- outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
- frame->interlaced_frame =
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST *
+ !!(outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF);
+ frame->flags |= AV_FRAME_FLAG_INTERLACED *
!(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
frame->pict_type = ff_qsv_map_pictype(aframe.frame->dec_info.FrameType);
//Key frame is IDR frame is only suitable for H264. For HEVC, IRAPs are key frames.
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c975302b4f..0ed1f757d4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1947,8 +1947,8 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
qf->surface.Info = q->param.mfx.FrameInfo;
qf->surface.Info.PicStruct =
- !frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
- frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? MFX_PICSTRUCT_PROGRESSIVE :
+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? MFX_PICSTRUCT_FIELD_TFF :
MFX_PICSTRUCT_FIELD_BFF;
if (frame->repeat_pict == 1)
qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
@@ -2402,7 +2402,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
goto free;
}
- if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame && frame->interlaced_frame)
+ if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame && (frame->flags & AV_FRAME_FLAG_INTERLACED))
print_interlace_msg(avctx, q);
ret = 0;
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index c20c317fed..5aa1030640 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -234,8 +234,8 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
return res;
if (context->tff >= 0) {
- frame->interlaced_frame = 1;
- frame->top_field_first = context->tff;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!context->tff;
}
if ((res = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
@@ -459,9 +459,9 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
}
if (avctx->field_order > AV_FIELD_PROGRESSIVE) { /* we have interlaced material flagged in container */
- frame->interlaced_frame = 1;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
- frame->top_field_first = 1;
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
*got_frame = 1;
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
index 8bf7c6ed16..5768568b00 100644
--- a/libavcodec/rkmppdec.c
+++ b/libavcodec/rkmppdec.c
@@ -404,8 +404,10 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
frame->colorspace = mpp_frame_get_colorspace(mppframe);
mode = mpp_frame_get_mode(mppframe);
- frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
- frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
+ if ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED)
+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
+ if ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST)
+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 83120d1b22..52d6e76479 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -871,7 +871,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
- frame->interlaced_frame = !!c->interlaced;
+ frame->flags |= AV_FRAME_FLAG_INTERLACED * !!c->interlaced;
*got_frame = 1;
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 43b92f6ec9..26c9841d83 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -207,9 +207,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
if (avctx->field_order > AV_FIELD_PROGRESSIVE) {
/* we have interlaced material flagged in container */
- pic->interlaced_frame = 1;
+ pic->flags |= AV_FRAME_FLAG_INTERLACED;
if (avctx->field_order == AV_FIELD_TT || avctx->field_order == AV_FIELD_TB)
- pic->top_field_first = 1;
+ pic->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
}
*got_frame = 1;
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 984af75c84..cd3ca42971 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -60,10 +60,10 @@ static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_
if (pic->flags & HEVC_FRAME_FLAG_LONG_REF)
va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
- if (pic->frame->interlaced_frame) {
+ if (pic->frame->flags & AV_FRAME_FLAG_INTERLACED) {
va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
- if (!pic->frame->top_field_first)
+ if (!(pic->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
}
}
diff --git a/libavcodec/vc1_mc.c b/libavcodec/vc1_mc.c
index 1b8d8799b3..8f0b3f6fab 100644
--- a/libavcodec/vc1_mc.c
+++ b/libavcodec/vc1_mc.c
@@ -233,7 +233,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir)
luty = v->last_luty;
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
} else {
srcY = s->next_picture.f->data[0];
@@ -242,7 +242,7 @@ void ff_vc1_mc_1mv(VC1Context *v, int dir)
luty = v->next_luty;
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcY || !srcU) {
@@ -482,13 +482,13 @@ void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
srcY = s->last_picture.f->data[0];
luty = v->last_luty;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
} else {
srcY = s->next_picture.f->data[0];
luty = v->next_luty;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcY) {
@@ -708,14 +708,14 @@ void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
srcV = s->last_picture.f->data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
} else {
srcU = s->next_picture.f->data[1];
srcV = s->next_picture.f->data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcU) {
@@ -884,13 +884,13 @@ void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
srcV = s->next_picture.f->data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
} else {
srcU = s->last_picture.f->data[1];
srcV = s->last_picture.f->data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
- interlace = s->last_picture.f->interlaced_frame;
+ interlace = !!(s->last_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
}
if (!srcU)
return;
@@ -1034,7 +1034,7 @@ void ff_vc1_interp_mc(VC1Context *v)
srcU = s->next_picture.f->data[1];
srcV = s->next_picture.f->data[2];
- interlace = s->next_picture.f->interlaced_frame;
+ interlace = !!(s->next_picture.f->flags & AV_FRAME_FLAG_INTERLACED);
src_x = s->mb_x * 16 + (mx >> 2);
src_y = s->mb_y * 16 + (my >> 2);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 18fb616fff..a103a73445 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1078,8 +1078,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
}
v->s.current_picture_ptr->field_picture = v->field_mode;
- v->s.current_picture_ptr->f->interlaced_frame = (v->fcm != PROGRESSIVE);
- v->s.current_picture_ptr->f->top_field_first = v->tff;
+ v->s.current_picture_ptr->f->flags |= AV_FRAME_FLAG_INTERLACED * (v->fcm != PROGRESSIVE);
+ v->s.current_picture_ptr->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * !!v->tff;
// process pulldown flags
s->current_picture_ptr->f->repeat_pict = 0;
--
2.40.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-12 19:49 [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags James Almer
` (5 preceding siblings ...)
2023-04-17 10:49 ` Anton Khirnov
@ 2023-04-30 0:19 ` James Almer
2023-05-04 23:52 ` James Almer
6 siblings, 1 reply; 14+ messages in thread
From: James Almer @ 2023-04-30 0:19 UTC (permalink / raw)
To: ffmpeg-devel
On 4/12/2023 4:49 PM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Missing version bump and APIChanges entry.
>
> libavutil/frame.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 5b58c14ac3..87e0a51226 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -586,6 +586,15 @@ typedef struct AVFrame {
> * A flag to mark the frames which need to be decoded, but shouldn't be output.
> */
> #define AV_FRAME_FLAG_DISCARD (1 << 2)
> +/**
> + * A flag to mark frames whose content is interlaced.
> + */
> +#define AV_FRAME_FLAG_INTERLACED (1 << 3)
> +/**
> + * A flag to mark frames where the top field is displayed first if the content
> + * is interlaced.
> + */
> +#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4)
> /**
> * @}
> */
If no one objects, I'll push this set and the key_frame one this week.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avutil/frame: add new interlaced and top_field_first flags
2023-04-30 0:19 ` James Almer
@ 2023-05-04 23:52 ` James Almer
0 siblings, 0 replies; 14+ messages in thread
From: James Almer @ 2023-05-04 23:52 UTC (permalink / raw)
To: ffmpeg-devel
On 4/29/2023 9:19 PM, James Almer wrote:
> On 4/12/2023 4:49 PM, James Almer wrote:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> Missing version bump and APIChanges entry.
>>
>> libavutil/frame.h | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/libavutil/frame.h b/libavutil/frame.h
>> index 5b58c14ac3..87e0a51226 100644
>> --- a/libavutil/frame.h
>> +++ b/libavutil/frame.h
>> @@ -586,6 +586,15 @@ typedef struct AVFrame {
>> * A flag to mark the frames which need to be decoded, but shouldn't
>> be output.
>> */
>> #define AV_FRAME_FLAG_DISCARD (1 << 2)
>> +/**
>> + * A flag to mark frames whose content is interlaced.
>> + */
>> +#define AV_FRAME_FLAG_INTERLACED (1 << 3)
>> +/**
>> + * A flag to mark frames where the top field is displayed first if
>> the content
>> + * is interlaced.
>> + */
>> +#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4)
>> /**
>> * @}
>> */
>
> If no one objects, I'll push this set and the key_frame one this week.
Applied.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2023-05-04 23:52 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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