History

avfilter/vf_mcdeint: update to new API

Michael Niedermayer committed 3 years ago

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

Showing the changes to libavfilter (1 of 3 files). Show all

Unified · Split

libavfilter/vf_mcdeint.c+23−7
@@ -75,6 +75,7 @@ typedef struct MCDeintContext { · 74 unmodified lines
7575 int parity; ///< MCDeintParity
7676 int qp;
7777 AVPacket *pkt;
78+ AVFrame *frame_dec;
7879 AVCodecContext *enc_ctx;
7980 } MCDeintContext;
8081
@@ -116,6 +117,9 @@ static int config_props(AVFilterLink *inlink) · 35 unmodified lines
116117 mcdeint->pkt = av_packet_alloc();
117118 if (!mcdeint->pkt)
118119 return AVERROR(ENOMEM);
120+ mcdeint->frame_dec = av_frame_alloc();
121+ if (!mcdeint->frame_dec)
122+ return AVERROR(ENOMEM);
119123 mcdeint->enc_ctx = avcodec_alloc_context3(enc);
120124 if (!mcdeint->enc_ctx)
121125 return AVERROR(ENOMEM);
@@ -126,7 +130,7 @@ static int config_props(AVFilterLink *inlink) · 4 unmodified lines
126130 enc_ctx->gop_size = INT_MAX;
127131 enc_ctx->max_b_frames = 0;
128132 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;
130134 enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
131135 enc_ctx->global_quality = 1;
132136 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
160164
161165 av_packet_free(&mcdeint->pkt);
162166 avcodec_free_context(&mcdeint->enc_ctx);
167+ av_frame_free(&mcdeint->frame_dec);
163168 }
164169
165170 static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
166171 {
167172 MCDeintContext *mcdeint = inlink->dst->priv;
168173 AVFilterLink *outlink = inlink->dst->outputs[0];
169− AVFrame *outpic, *frame_dec;
174+ AVFrame *outpic, *frame_dec = mcdeint->frame_dec;
170175 AVPacket *pkt = mcdeint->pkt;
171− int x, y, i, ret, got_frame = 0;
176+ int x, y, i, ret;
172177
173178 outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h);
174179 if (!outpic) {
@@ -178,11 +183,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 3 unmodified lines
178183 av_frame_copy_props(outpic, inpic);
179184 inpic->quality = mcdeint->qp * FF_QP2LAMBDA;
180185
181− ret = avcodec_encode_video2(mcdeint->enc_ctx, pkt, inpic, &got_frame);
182− if (ret < 0)
186+ ret = avcodec_send_frame(mcdeint->enc_ctx, inpic);
187+ if (ret < 0) {
188+ av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error sending a frame for encoding\n");
183189 goto end;
184−
185− frame_dec = mcdeint->enc_ctx->coded_frame;
190+ }
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+ }
186202
187203 for (i = 0; i < 3; i++) {
188204 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