From patchwork Sat Apr 25 18:55:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 19240 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3C57E44AB30 for ; Sat, 25 Apr 2020 21:56:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 20F0D68C4EB; Sat, 25 Apr 2020 21:56:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 51DA068C4E9 for ; Sat, 25 Apr 2020 21:56:10 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0F2C3E3DF6; Sat, 25 Apr 2020 20:56:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PqNPOabvrlL1; Sat, 25 Apr 2020 20:56:07 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A0896E366A; Sat, 25 Apr 2020 20:56:07 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Apr 2020 20:55:55 +0200 Message-Id: <20200425185555.19111-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200425185555.19111-1-cus@passwd.hu> References: <20200425185555.19111-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg_opt: use av_bsf_list_parse_str for parsing bsf lists X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- fftools/ffmpeg_opt.c | 57 +++------------------------------------------------- 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index b52aa28626..dc42fb19d6 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1416,7 +1416,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e { OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); - AVBSFList *bsf_list = NULL; int idx = oc->nb_streams - 1, ret = 0; const char *bsfs = NULL, *time_base = NULL; char *next, *codec_tag = NULL; @@ -1536,60 +1535,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st); MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st); - while (bsfs && *bsfs) { - const AVBitStreamFilter *filter; - char *bsf, *bsf_options_str, *bsf_name; - AVBSFContext *bsf_ctx; - - bsf = av_get_token(&bsfs, ","); - if (!bsf) - exit_program(1); - bsf_name = av_strtok(bsf, "=", &bsf_options_str); - if (!bsf_name) - exit_program(1); - - filter = av_bsf_get_by_name(bsf_name); - if (!filter) { - av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf_name); - exit_program(1); - } - - ret = av_bsf_alloc(filter, &bsf_ctx); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error allocating a bitstream filter context\n"); - exit_program(1); - } - - if (bsf_options_str && filter->priv_class) { - const AVOption *opt = av_opt_next(bsf_ctx->priv_data, NULL); - const char * shorthand[2] = {NULL}; - - if (opt) - shorthand[0] = opt->name; - - ret = av_opt_set_from_string(bsf_ctx->priv_data, bsf_options_str, shorthand, "=", ":"); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error parsing options for bitstream filter %s\n", bsf_name); - exit_program(1); - } - } - - if (!bsf_list) - bsf_list = av_bsf_list_alloc(); - if (!bsf_list || av_bsf_list_append(bsf_list, bsf_ctx) < 0) { - av_log(NULL, AV_LOG_ERROR, "Failed to allocate or append to bsf list\n"); - exit_program(1); - } - - av_freep(&bsf); - - if (*bsfs) - bsfs++; - } - if (bsf_list) { - ret = av_bsf_list_finalize(&bsf_list, &ost->bsf_ctx); + if (bsfs && *bsfs) { + ret = av_bsf_list_parse_str(bsfs, &ost->bsf_ctx); if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Failed to finalize bsf list\n"); + av_log(NULL, AV_LOG_ERROR, "Error parsing bitstream filter sequence '%s': %s\n", bsfs, av_err2str(ret)); exit_program(1); } }