History

doc/examples/transcode: stop using avfilter_graph_create_filter() incorrectly

See previous commits for details.

Anton Khirnov committed 2 years ago

Commit d18d1191 parent 87faa8a1 file · +18 −6Browse files

Unified · Split

doc/examples/transcode.c+18−6
@@ -283,10 +283,10 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, · 282 unmodified lines
283283 goto end;
284284 }
285285
286− ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
287− NULL, NULL, filter_graph);
288− if (ret < 0) {
286+ buffersink_ctx = avfilter_graph_alloc_filter(filter_graph, buffersink, "out");
287+ if (!buffersink_ctx) {
289288 av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
289+ ret = AVERROR(ENOMEM);
290290 goto end;
291291 }
292292
@@ -297,6 +297,12 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, · 4 unmodified lines
297297 av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n");
298298 goto end;
299299 }
300+
301+ ret = avfilter_init_dict(buffersink_ctx, NULL);
302+ if (ret < 0) {
303+ av_log(NULL, AV_LOG_ERROR, "Cannot initialize buffer sink\n");
304+ goto end;
305+ }
300306 } else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
301307 char buf[64];
302308 buffersrc = avfilter_get_by_name("abuffer");
@@ -322,10 +328,10 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, · 19 unmodified lines
322328 goto end;
323329 }
324330
325− ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
326− NULL, NULL, filter_graph);
327− if (ret < 0) {
331+ buffersink_ctx = avfilter_graph_alloc_filter(filter_graph, buffersink, "out");
332+ if (!buffersink_ctx) {
328333 av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
334+ ret = AVERROR(ENOMEM);
329335 goto end;
330336 }
331337
@@ -352,6 +358,12 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, · 20 unmodified lines
352358 av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
353359 goto end;
354360 }
361+
362+ ret = avfilter_init_dict(buffersink_ctx, NULL);
363+ if (ret < 0) {
364+ av_log(NULL, AV_LOG_ERROR, "Cannot initialize audio buffer sink\n");
365+ goto end;
366+ }
355367 } else {
356368 ret = AVERROR_UNKNOWN;
357369 goto end;

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