History

avfilter/vf_mcdeint: update to new API

Michael Niedermayer committed 3 years ago

Commit 06b451d1 parent 5310c973 files · +23 −14Browse files

Unified · Split

3 files
  1. configure +0 −5
  2. doc/filters.texi +0 −2
  3. libavfilter/vf_mcdeint.c +23 −7
configure+0−5
@@ -7355,11 +7355,6 @@ esac · 7354 unmodified lines
7355 7355
7356enable frame_thread_encoder7356enable frame_thread_encoder
7357 7357
7358# these filters depend on removed avcodec APIs
7359# they are kept disabled for now, but will be removed if
7360# nobody updates and re-enables them
7361disable mcdeint_filter
7362
7363enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }7358enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
7364 7359
7365check_deps $CONFIG_LIST \7360check_deps $CONFIG_LIST \
doc/filters.texi+0−2
@@ -16986,8 +16986,6 @@ Apply motion-compensation deinterlacing. · 16985 unmodified lines
16986It needs one field per frame as input and must thus be used together16986It needs one field per frame as input and must thus be used together
16987with yadif=1/3 or equivalent.16987with yadif=1/3 or equivalent.
16988 16988
16989This filter is only available in ffmpeg version 4.4 or earlier.
16990
16991This filter accepts the following options:16989This filter accepts the following options:
16992@table @option16990@table @option
16993@item mode16991@item mode
libavfilter/vf_mcdeint.c+23−7
@@ -75,6 +75,7 @@ typedef struct MCDeintContext { · 74 unmodified lines
75 int parity; ///< MCDeintParity75 int parity; ///< MCDeintParity
76 int qp;76 int qp;
77 AVPacket *pkt;77 AVPacket *pkt;
78 AVFrame *frame_dec;
78 AVCodecContext *enc_ctx;79 AVCodecContext *enc_ctx;
79} MCDeintContext;80} MCDeintContext;
80 81
@@ -116,6 +117,9 @@ static int config_props(AVFilterLink *inlink) · 35 unmodified lines
116 mcdeint->pkt = av_packet_alloc();117 mcdeint->pkt = av_packet_alloc();
117 if (!mcdeint->pkt)118 if (!mcdeint->pkt)
118 return AVERROR(ENOMEM);119 return AVERROR(ENOMEM);
120 mcdeint->frame_dec = av_frame_alloc();
121 if (!mcdeint->frame_dec)
122 return AVERROR(ENOMEM);
119 mcdeint->enc_ctx = avcodec_alloc_context3(enc);123 mcdeint->enc_ctx = avcodec_alloc_context3(enc);
120 if (!mcdeint->enc_ctx)124 if (!mcdeint->enc_ctx)
121 return AVERROR(ENOMEM);125 return AVERROR(ENOMEM);
@@ -126,7 +130,7 @@ static int config_props(AVFilterLink *inlink) · 4 unmodified lines
126 enc_ctx->gop_size = INT_MAX;130 enc_ctx->gop_size = INT_MAX;
127 enc_ctx->max_b_frames = 0;131 enc_ctx->max_b_frames = 0;
128 enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P;132 enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
129 enc_ctx->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY;133 enc_ctx->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY | AV_CODEC_FLAG_RECON_FRAME;
130 enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;134 enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
131 enc_ctx->global_quality = 1;135 enc_ctx->global_quality = 1;
132 enc_ctx->me_cmp = enc_ctx->me_sub_cmp = FF_CMP_SAD;136 enc_ctx->me_cmp = enc_ctx->me_sub_cmp = FF_CMP_SAD;
@@ -160,15 +164,16 @@ static av_cold void uninit(AVFilterContext *ctx) · 27 unmodified lines
160 164
161 av_packet_free(&mcdeint->pkt);165 av_packet_free(&mcdeint->pkt);
162 avcodec_free_context(&mcdeint->enc_ctx);166 avcodec_free_context(&mcdeint->enc_ctx);
167 av_frame_free(&mcdeint->frame_dec);
163}168}
164 169
165static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)170static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
166{171{
167 MCDeintContext *mcdeint = inlink->dst->priv;172 MCDeintContext *mcdeint = inlink->dst->priv;
168 AVFilterLink *outlink = inlink->dst->outputs[0];173 AVFilterLink *outlink = inlink->dst->outputs[0];
169 AVFrame *outpic, *frame_dec;174 AVFrame *outpic, *frame_dec = mcdeint->frame_dec;
170 AVPacket *pkt = mcdeint->pkt;175 AVPacket *pkt = mcdeint->pkt;
171 int x, y, i, ret, got_frame = 0;176 int x, y, i, ret;
172 177
173 outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h);178 outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h);
174 if (!outpic) {179 if (!outpic) {
@@ -178,11 +183,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 3 unmodified lines
178 av_frame_copy_props(outpic, inpic);183 av_frame_copy_props(outpic, inpic);
179 inpic->quality = mcdeint->qp * FF_QP2LAMBDA;184 inpic->quality = mcdeint->qp * FF_QP2LAMBDA;
180 185
181 ret = avcodec_encode_video2(mcdeint->enc_ctx, pkt, inpic, &got_frame);186 ret = avcodec_send_frame(mcdeint->enc_ctx, inpic);
182 if (ret < 0)187 if (ret < 0) {
188 av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error sending a frame for encoding\n");
183 goto end;189 goto end;
184 190 }
185 frame_dec = mcdeint->enc_ctx->coded_frame;191 ret = avcodec_receive_packet(mcdeint->enc_ctx, pkt);
192 if (ret < 0) {
193 av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error receiving a packet from encoding\n");
194 goto end;
195 }
196 av_packet_unref(pkt);
197 ret = avcodec_receive_frame(mcdeint->enc_ctx, frame_dec);
198 if (ret < 0) {
199 av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error receiving a frame from encoding\n");
200 goto end;
201 }
186 202
187 for (i = 0; i < 3; i++) {203 for (i = 0; i < 3; i++) {
188 int is_chroma = !!i;204 int is_chroma = !!i;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t