| @@ -555,7 +555,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) · 554 unmodified lines |
| 555 | 555 | return AV_PIX_FMT_NONE; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | | − ret = avcodec_get_supported_config(ost->enc_ctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, |
| 558 | + ret = avcodec_get_supported_config(ost->enc->enc_ctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, |
| 559 | 559 | 0, (const void **) &fmts, NULL); |
| 560 | 560 | if (ret < 0) |
| 561 | 561 | return AV_PIX_FMT_NONE; |
| @@ -587,7 +587,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) · 25 unmodified lines |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | if (fmts && !fmt_in_list(fmts, fmt)) |
| 590 | | − fmt = choose_pixel_fmt(ost->enc_ctx, fmt); |
| 590 | + fmt = choose_pixel_fmt(ost->enc->enc_ctx, fmt); |
| 591 | 591 | |
| 592 | 592 | return fmt; |
| 593 | 593 | } |
| @@ -632,8 +632,8 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 38 unmodified lines |
| 632 | 632 | ost->frame_aspect_ratio = q; |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | | − if (ost->enc_ctx) { |
| 636 | | − AVCodecContext *video_enc = ost->enc_ctx; |
| 635 | + if (ost->enc) { |
| 636 | + AVCodecContext *video_enc = ost->enc->enc_ctx; |
| 637 | 637 | const char *p = NULL, *fps_mode = NULL; |
| 638 | 638 | const char *frame_size = NULL; |
| 639 | 639 | const char *frame_pix_fmt = NULL; |
| @@ -746,10 +746,10 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 106 unmodified lines |
| 746 | 746 | ost->logfile_prefix ? ost->logfile_prefix : |
| 747 | 747 | DEFAULT_PASS_LOGFILENAME_PREFIX, |
| 748 | 748 | ost_idx); |
| 749 | | − if (!strcmp(ost->enc_ctx->codec->name, "libx264") || !strcmp(ost->enc_ctx->codec->name, "libvvenc")) { |
| 750 | | − if (av_opt_is_set_to_default_by_name(ost->enc_ctx, "stats", |
| 749 | + if (!strcmp(video_enc->codec->name, "libx264") || !strcmp(video_enc->codec->name, "libvvenc")) { |
| 750 | + if (av_opt_is_set_to_default_by_name(video_enc, "stats", |
| 751 | 751 | AV_OPT_SEARCH_CHILDREN) > 0) |
| 752 | | − av_opt_set(ost->enc_ctx, "stats", logfilename, |
| 752 | + av_opt_set(video_enc, "stats", logfilename, |
| 753 | 753 | AV_OPT_SEARCH_CHILDREN); |
| 754 | 754 | } else { |
| 755 | 755 | if (video_enc->flags & AV_CODEC_FLAG_PASS2) { |
| @@ -842,8 +842,8 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o, · 86 unmodified lines |
| 842 | 842 | AVFormatContext *oc = mux->fc; |
| 843 | 843 | AVStream *st = ost->st; |
| 844 | 844 | |
| 845 | | − if (ost->enc_ctx) { |
| 846 | | − AVCodecContext *audio_enc = ost->enc_ctx; |
| 845 | + if (ost->enc) { |
| 846 | + AVCodecContext *audio_enc = ost->enc->enc_ctx; |
| 847 | 847 | int channels = 0; |
| 848 | 848 | const char *layout = NULL; |
| 849 | 849 | const char *sample_fmt = NULL; |
| @@ -881,8 +881,8 @@ static int new_stream_subtitle(Muxer *mux, const OptionsContext *o, · 31 unmodified lines |
| 881 | 881 | |
| 882 | 882 | st = ost->st; |
| 883 | 883 | |
| 884 | | − if (ost->enc_ctx) { |
| 885 | | − AVCodecContext *subtitle_enc = ost->enc_ctx; |
| 884 | + if (ost->enc) { |
| 885 | + AVCodecContext *subtitle_enc = ost->enc->enc_ctx; |
| 886 | 886 | |
| 887 | 887 | AVCodecDescriptor const *input_descriptor = |
| 888 | 888 | avcodec_descriptor_get(ost->ist->par->codec_id); |
| @@ -923,7 +923,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter, · 34 unmodified lines |
| 923 | 923 | const ViewSpecifier *vs) |
| 924 | 924 | { |
| 925 | 925 | OutputStream *ost = &ms->ost; |
| 926 | | − AVCodecContext *enc_ctx = ost->enc_ctx; |
| 926 | + AVCodecContext *enc_ctx = ost->enc->enc_ctx; |
| 927 | 927 | char name[16]; |
| 928 | 928 | int ret; |
| 929 | 929 | |
| @@ -1245,10 +1245,6 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 315 unmodified lines |
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | if (enc) { |
| 1248 | | − ost->enc_ctx = avcodec_alloc_context3(enc); |
| 1249 | | − if (!ost->enc_ctx) |
| 1250 | | − return AVERROR(ENOMEM); |
| 1251 | | − |
| 1252 | 1248 | ret = sch_add_enc(mux->sch, encoder_thread, ost, |
| 1253 | 1249 | ost->type == AVMEDIA_TYPE_SUBTITLE ? NULL : enc_open); |
| 1254 | 1250 | if (ret < 0) |
| @@ -1290,21 +1286,21 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 35 unmodified lines |
| 1290 | 1286 | if (!ms->pkt) |
| 1291 | 1287 | return AVERROR(ENOMEM); |
| 1292 | 1288 | |
| 1293 | | − if (ost->enc_ctx) { |
| 1289 | + if (ost->enc) { |
| 1294 | 1290 | AVIOContext *s = NULL; |
| 1295 | 1291 | char *buf = NULL, *arg = NULL; |
| 1296 | 1292 | const char *enc_stats_pre = NULL, *enc_stats_post = NULL, *mux_stats = NULL; |
| 1297 | 1293 | const char *enc_time_base = NULL, *preset = NULL; |
| 1298 | 1294 | |
| 1299 | | − ret = filter_codec_opts(o->g->codec_opts, ost->enc_ctx->codec_id, |
| 1300 | | − oc, st, ost->enc_ctx->codec, &encoder_opts, |
| 1295 | + ret = filter_codec_opts(o->g->codec_opts, enc->id, |
| 1296 | + oc, st, enc, &encoder_opts, |
| 1301 | 1297 | &mux->enc_opts_used); |
| 1302 | 1298 | if (ret < 0) |
| 1303 | 1299 | goto fail; |
| 1304 | 1300 | |
| 1305 | 1301 | opt_match_per_stream_str(ost, &o->presets, oc, st, &preset); |
| 1306 | 1302 | opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale); |
| 1307 | | − if (preset && (!(ret = get_preset_file_2(preset, ost->enc_ctx->codec->name, &s)))) { |
| 1303 | + if (preset && (!(ret = get_preset_file_2(preset, enc->name, &s)))) { |
| 1308 | 1304 | AVBPrint bprint; |
| 1309 | 1305 | av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); |
| 1310 | 1306 | do { |
| @@ -1404,7 +1400,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 93 unmodified lines |
| 1404 | 1400 | |
| 1405 | 1401 | threads_manual = !!av_dict_get(encoder_opts, "threads", NULL, 0); |
| 1406 | 1402 | |
| 1407 | | − ret = av_opt_set_dict2(ost->enc_ctx, &encoder_opts, AV_OPT_SEARCH_CHILDREN); |
| 1403 | + ret = av_opt_set_dict2(ost->enc->enc_ctx, &encoder_opts, AV_OPT_SEARCH_CHILDREN); |
| 1408 | 1404 | if (ret < 0) { |
| 1409 | 1405 | av_log(ost, AV_LOG_ERROR, "Error applying encoder options: %s\n", |
| 1410 | 1406 | av_err2str(ret)); |
| @@ -1417,7 +1413,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 6 unmodified lines |
| 1417 | 1413 | |
| 1418 | 1414 | // default to automatic thread count |
| 1419 | 1415 | if (!threads_manual) |
| 1420 | | − ost->enc_ctx->thread_count = 0; |
| 1416 | + ost->enc->enc_ctx->thread_count = 0; |
| 1421 | 1417 | } else { |
| 1422 | 1418 | ret = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, |
| 1423 | 1419 | NULL, &encoder_opts, |
| @@ -1429,8 +1425,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 5 unmodified lines |
| 1429 | 1425 | |
| 1430 | 1426 | if (o->bitexact) { |
| 1431 | 1427 | ost->bitexact = 1; |
| 1432 | | − } else if (ost->enc_ctx) { |
| 1433 | | − ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT); |
| 1428 | + } else if (ost->enc) { |
| 1429 | + ost->bitexact = !!(ost->enc->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT); |
| 1434 | 1430 | } |
| 1435 | 1431 | |
| 1436 | 1432 | if (enc) { |
| @@ -1482,14 +1478,14 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 45 unmodified lines |
| 1482 | 1478 | } |
| 1483 | 1479 | ost->st->codecpar->codec_tag = tag; |
| 1484 | 1480 | ms->par_in->codec_tag = tag; |
| 1485 | | − if (ost->enc_ctx) |
| 1486 | | − ost->enc_ctx->codec_tag = tag; |
| 1481 | + if (ost->enc) |
| 1482 | + ost->enc->enc_ctx->codec_tag = tag; |
| 1487 | 1483 | } |
| 1488 | 1484 | |
| 1489 | 1485 | opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale); |
| 1490 | | − if (ost->enc_ctx && qscale >= 0) { |
| 1491 | | − ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; |
| 1492 | | − ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; |
| 1486 | + if (ost->enc && qscale >= 0) { |
| 1487 | + ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; |
| 1488 | + ost->enc->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; |
| 1493 | 1489 | } |
| 1494 | 1490 | |
| 1495 | 1491 | if (ms->sch_idx >= 0) { |
| @@ -1511,8 +1507,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 15 unmodified lines |
| 1511 | 1507 | opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat, |
| 1512 | 1508 | oc, st, &ost->fix_sub_duration_heartbeat); |
| 1513 | 1509 | |
| 1514 | | − if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx) |
| 1515 | | − ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; |
| 1510 | + if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc) |
| 1511 | + ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; |
| 1516 | 1512 | |
| 1517 | 1513 | opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes, |
| 1518 | 1514 | oc, st, &ms->copy_initial_nonkeyframes); |
| @@ -2047,7 +2043,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, · 528 unmodified lines |
| 2047 | 2043 | int limit_frames = 0, limit_frames_av_enc = 0; |
| 2048 | 2044 | |
| 2049 | 2045 | #define IS_AV_ENC(ost, type) \ |
| 2050 | | − (ost->enc_ctx && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) |
| 2046 | + (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) |
| 2051 | 2047 | #define IS_INTERLEAVED(type) (type != AVMEDIA_TYPE_ATTACHMENT) |
| 2052 | 2048 | |
| 2053 | 2049 | for (int i = 0; i < oc->nb_streams; i++) { |
| @@ -2059,8 +2055,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, · 5 unmodified lines |
| 2059 | 2055 | |
| 2060 | 2056 | nb_interleaved += IS_INTERLEAVED(type); |
| 2061 | 2057 | nb_av_enc += IS_AV_ENC(ost, type); |
| 2062 | | − nb_audio_fs += (ost->enc_ctx && type == AVMEDIA_TYPE_AUDIO && |
| 2063 | | − !(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)); |
| 2058 | + nb_audio_fs += (ost->enc && type == AVMEDIA_TYPE_AUDIO && |
| 2059 | + !(ost->enc->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)); |
| 2064 | 2060 | |
| 2065 | 2061 | limit_frames |= ms->max_frames < INT64_MAX; |
| 2066 | 2062 | limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); |
| @@ -3193,7 +3189,7 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o) · 1126 unmodified lines |
| 3193 | 3189 | mux->fc, ost->st, &forced_keyframes); |
| 3194 | 3190 | |
| 3195 | 3191 | if (!(ost->type == AVMEDIA_TYPE_VIDEO && |
| 3196 | | − ost->enc_ctx && forced_keyframes)) |
| 3192 | + ost->enc && forced_keyframes)) |
| 3197 | 3193 | continue; |
| 3198 | 3194 | |
| 3199 | 3195 | if (!strncmp(forced_keyframes, "expr:", 5)) { |