From d07999009d82b1dccb8fd36450066722efe80df2 Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Sat, 16 Oct 2021 00:17:06 +0800 Subject: [PATCH] change ffmpeg_opt.c to ffmpeg_opt.cpp --- app/CMakeLists.txt | 2 +- .../ffmpeg/{ffmpeg_opt.c => ffmpeg_opt.cpp} | 396 +++++++++++------- 2 files changed, 244 insertions(+), 154 deletions(-) rename app/src/main/cpp/ffmpeg/{ffmpeg_opt.c => ffmpeg_opt.cpp} (89%) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index bd05653..970579a 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -21,7 +21,7 @@ add_library( # Sets the name of the library. src/main/cpp/ffmpeg/cmdutils.c src/main/cpp/ffmpeg/ffmpeg.cpp src/main/cpp/ffmpeg/ffmpeg_filter.c - src/main/cpp/ffmpeg/ffmpeg_opt.c + src/main/cpp/ffmpeg/ffmpeg_opt.cpp src/main/cpp/ffmpeg_cmd.c src/main/cpp/ffmpeg/ffprobe.c src/main/cpp/ffmpeg/ffmpeg_hw.cpp diff --git a/app/src/main/cpp/ffmpeg/ffmpeg_opt.c b/app/src/main/cpp/ffmpeg/ffmpeg_opt.cpp similarity index 89% rename from app/src/main/cpp/ffmpeg/ffmpeg_opt.c rename to app/src/main/cpp/ffmpeg/ffmpeg_opt.cpp index f5ca18a..2d0b5f2 100644 --- a/app/src/main/cpp/ffmpeg/ffmpeg_opt.c +++ b/app/src/main/cpp/ffmpeg/ffmpeg_opt.cpp @@ -132,8 +132,8 @@ static void uninit_options(OptionsContext *o) void *dst = (uint8_t*)o + po->u.off; if (po->flags & OPT_SPEC) { - SpecifierOpt **so = dst; - int i, *count = (int*)(so + 1); + SpecifierOpt **so = static_cast(dst); + int *count = (int*)(so + 1); for (i = 0; i < *count; i++) { av_freep(&(*so)[i].specifier); if (po->flags & OPT_STRING) @@ -208,13 +208,13 @@ static int opt_abort_on(void *optctx, const char *opt, const char *arg) { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" }, { NULL }, }; - static const AVClass class = { + static const AVClass clazz = { .class_name = "", .item_name = av_default_item_name, .option = opts, .version = LIBAVUTIL_VERSION_INT, }; - const AVClass *pclass = &class; + const AVClass *pclass = &clazz; return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags); } @@ -242,31 +242,31 @@ static int opt_video_standard(void *optctx, const char *opt, const char *arg) static int opt_audio_codec(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "codec:a", arg, options); } static int opt_video_codec(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "codec:v", arg, options); } static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "codec:s", arg, options); } static int opt_data_codec(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "codec:d", arg, options); } static int opt_map(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); StreamMap *m = NULL; int i, negative = 0, file_idx, disabled = 0; int sync_file_idx = -1, sync_stream_idx = 0; @@ -314,7 +314,9 @@ static int opt_map(void *optctx, const char *opt, const char *arg) if (map[0] == '[') { /* this mapping refers to lavfi output */ const char *c = map + 1; - GROW_ARRAY(o->stream_maps, o->nb_stream_maps); +// GROW_ARRAY(o->stream_maps, o->nb_stream_maps); + o->stream_maps = (StreamMap *)(grow_array(o->stream_maps, sizeof(o->stream_maps), + &o->nb_stream_maps, o->nb_stream_maps + 1)); m = &o->stream_maps[o->nb_stream_maps - 1]; m->linklabel = av_get_token(&c, "]"); if (!m->linklabel) { @@ -348,7 +350,9 @@ static int opt_map(void *optctx, const char *opt, const char *arg) disabled = 1; continue; } - GROW_ARRAY(o->stream_maps, o->nb_stream_maps); +// GROW_ARRAY(o->stream_maps, o->nb_stream_maps); + o->stream_maps = (StreamMap *)(grow_array(o->stream_maps, sizeof(o->stream_maps), + &o->nb_stream_maps, o->nb_stream_maps + 1)); m = &o->stream_maps[o->nb_stream_maps - 1]; m->file_index = file_idx; @@ -384,15 +388,17 @@ static int opt_map(void *optctx, const char *opt, const char *arg) static int opt_attach(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; - GROW_ARRAY(o->attachments, o->nb_attachments); + OptionsContext *o = static_cast(optctx); +// GROW_ARRAY(o->attachments, o->nb_attachments); + o->attachments = (const char **)(grow_array(o->attachments, sizeof(o->attachments), + &o->nb_attachments, o->nb_attachments + 1)); o->attachments[o->nb_attachments - 1] = arg; return 0; } static int opt_map_channel(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); int n; AVStream *st; AudioChannelMap *m; @@ -402,7 +408,9 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) if (!mapchan) return AVERROR(ENOMEM); - GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps); +// GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps); + o->audio_channel_maps = (AudioChannelMap *)(grow_array(o->audio_channel_maps, sizeof(o->audio_channel_maps), + &o->nb_audio_channel_maps, o->nb_audio_channel_maps + 1)); m = &o->audio_channel_maps[o->nb_audio_channel_maps - 1]; /* muted channel syntax */ @@ -650,7 +658,7 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); char buf[128]; int64_t recording_timestamp = parse_time_or_die(opt, arg, 0) / 1E6; struct tm time = *gmtime((time_t*)&recording_timestamp); @@ -694,11 +702,11 @@ static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int e static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st) { - char *codec_name = NULL; + /*char*/uint8_t *codec_name = NULL; MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); if (codec_name) { - AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0); + AVCodec *codec = find_codec_or_die(reinterpret_cast(codec_name), st->codecpar->codec_type, 0); st->codecpar->codec_id = codec->id; return codec; } else @@ -714,20 +722,22 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) for (i = 0; i < ic->nb_streams; i++) { AVStream *st = ic->streams[i]; AVCodecParameters *par = st->codecpar; - InputStream *ist = av_mallocz(sizeof(*ist)); - char *framerate = NULL, *hwaccel_device = NULL; - const char *hwaccel = NULL; - char *hwaccel_output_format = NULL; - char *codec_tag = NULL; + InputStream *ist = static_cast(av_mallocz(sizeof(*ist))); + /*char*/uint8_t *framerate = NULL, *hwaccel_device = NULL; + const /*char*/uint8_t *hwaccel = NULL; + /*char*/uint8_t *hwaccel_output_format = NULL; + /*char*/uint8_t *codec_tag = NULL; char *next; - char *discard_str = NULL; + /*char*/uint8_t *discard_str = NULL; const AVClass *cc = avcodec_get_class(); const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL, 0, 0); if (!ist) exit_program(1); - GROW_ARRAY(input_streams, nb_input_streams); +// GROW_ARRAY(input_streams, nb_input_streams); + input_streams = (InputStream **)(grow_array(input_streams, sizeof(input_streams), + &nb_input_streams, nb_input_streams + 1)); input_streams[nb_input_streams - 1] = ist; ist->st = st; @@ -746,7 +756,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { - uint32_t tag = strtol(codec_tag, &next, 0); + uint32_t tag = (uint32_t) strtol(reinterpret_cast(codec_tag), &next, 0); if (*next) tag = AV_RL32(codec_tag); st->codecpar->codec_tag = tag; @@ -767,7 +777,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) (o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)) ist->user_set_discard = AVDISCARD_ALL; - if (discard_str && av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard) < 0) { + if (discard_str && av_opt_eval_int(&cc, discard_opt, (const char*)discard_str, &ist->user_set_discard) < 0) { av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str); exit_program(1); @@ -809,7 +819,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st); if (framerate && av_parse_video_rate(&ist->framerate, - framerate) < 0) { + reinterpret_cast(framerate)) < 0) { av_log(NULL, AV_LOG_ERROR, "Error parsing framerate %s.\n", framerate); exit_program(1); @@ -821,25 +831,25 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st); if (hwaccel) { // The NVDEC hwaccels use a CUDA device, so remap the name here. - if (!strcmp(hwaccel, "nvdec")) - hwaccel = "cuda"; + if (!strcmp(reinterpret_cast(hwaccel), "nvdec")) + hwaccel = reinterpret_cast("cuda"); - if (!strcmp(hwaccel, "none")) + if (!strcmp(reinterpret_cast(hwaccel), "none")) ist->hwaccel_id = HWACCEL_NONE; - else if (!strcmp(hwaccel, "auto")) + else if (!strcmp(reinterpret_cast(hwaccel), "auto")) ist->hwaccel_id = HWACCEL_AUTO; else { enum AVHWDeviceType type; int i; for (i = 0; hwaccels[i].name; i++) { - if (!strcmp(hwaccels[i].name, hwaccel)) { + if (!strcmp(hwaccels[i].name, reinterpret_cast(hwaccel))) { ist->hwaccel_id = hwaccels[i].id; break; } } if (!ist->hwaccel_id) { - type = av_hwdevice_find_type_by_name(hwaccel); + type = av_hwdevice_find_type_by_name(reinterpret_cast(hwaccel)); if (type != AV_HWDEVICE_TYPE_NONE) { ist->hwaccel_id = HWACCEL_GENERIC; ist->hwaccel_device_type = type; @@ -865,7 +875,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(hwaccel_devices, str, hwaccel_device, ic, st); if (hwaccel_device) { - ist->hwaccel_device = av_strdup(hwaccel_device); + ist->hwaccel_device = av_strdup(reinterpret_cast(hwaccel_device)); if (!ist->hwaccel_device) exit_program(1); } @@ -873,7 +883,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(hwaccel_output_formats, str, hwaccel_output_format, ic, st); if (hwaccel_output_format) { - ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format); + ist->hwaccel_output_format = av_get_pix_fmt(reinterpret_cast(hwaccel_output_format)); if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) { av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output " "format: %s", hwaccel_output_format); @@ -892,13 +902,13 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) break; case AVMEDIA_TYPE_DATA: case AVMEDIA_TYPE_SUBTITLE: { - char *canvas_size = NULL; + /*char*/uint8_t *canvas_size = NULL; if(!ist->dec) ist->dec = avcodec_find_decoder(par->codec_id); MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st); MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st); if (canvas_size && - av_parse_video_size(&ist->dec_ctx->width, &ist->dec_ctx->height, canvas_size) < 0) { + av_parse_video_size(&ist->dec_ctx->width, &ist->dec_ctx->height, (const char*) canvas_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size); exit_program(1); } @@ -1003,10 +1013,10 @@ static int open_input_file(OptionsContext *o, const char *filename) int64_t timestamp; AVDictionary *unused_opts = NULL; AVDictionaryEntry *e = NULL; - char * video_codec_name = NULL; - char * audio_codec_name = NULL; - char *subtitle_codec_name = NULL; - char * data_codec_name = NULL; + /*char*/uint8_t * video_codec_name = NULL; + /*char*/uint8_t * audio_codec_name = NULL; + /*char*/uint8_t *subtitle_codec_name = NULL; + /*char*/uint8_t * data_codec_name = NULL; int scan_all_pmts_set = 0; if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { @@ -1063,14 +1073,17 @@ static int open_input_file(OptionsContext *o, const char *filename) av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { av_dict_set(&o->g->format_opts, "framerate", - o->frame_rates[o->nb_frame_rates - 1].u.str, 0); + reinterpret_cast(o->frame_rates[o->nb_frame_rates - 1].u.str), 0); } } if (o->nb_frame_sizes) { - av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0); + av_dict_set(&o->g->format_opts, "video_size", + reinterpret_cast(o->frame_sizes[o->nb_frame_sizes - 1].u.str), 0); } if (o->nb_frame_pix_fmts) - av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0); + av_dict_set(&o->g->format_opts, "pixel_format", + reinterpret_cast(o->frame_pix_fmts[o->nb_frame_pix_fmts - + 1].u.str), 0); MATCH_PER_TYPE_OPT(codec_names, str, video_codec_name, ic, "v"); MATCH_PER_TYPE_OPT(codec_names, str, audio_codec_name, ic, "a"); @@ -1078,13 +1091,13 @@ static int open_input_file(OptionsContext *o, const char *filename) MATCH_PER_TYPE_OPT(codec_names, str, data_codec_name, ic, "d"); if (video_codec_name) - ic->video_codec = find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0); + ic->video_codec = find_codec_or_die((char*)video_codec_name , AVMEDIA_TYPE_VIDEO , 0); if (audio_codec_name) - ic->audio_codec = find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0); + ic->audio_codec = find_codec_or_die((char*)audio_codec_name , AVMEDIA_TYPE_AUDIO , 0); if (subtitle_codec_name) - ic->subtitle_codec = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0); + ic->subtitle_codec = find_codec_or_die((char*)subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0); if (data_codec_name) - ic->data_codec = find_codec_or_die(data_codec_name , AVMEDIA_TYPE_DATA , 0); + ic->data_codec = find_codec_or_die((char*)data_codec_name , AVMEDIA_TYPE_DATA , 0); ic->video_codec_id = video_codec_name ? ic->video_codec->id : AV_CODEC_ID_NONE; ic->audio_codec_id = audio_codec_name ? ic->audio_codec->id : AV_CODEC_ID_NONE; @@ -1192,8 +1205,9 @@ static int open_input_file(OptionsContext *o, const char *filename) /* dump the file content */ av_dump_format(ic, nb_input_files, filename, 0); - GROW_ARRAY(input_files, nb_input_files); - f = av_mallocz(sizeof(*f)); +// GROW_ARRAY(input_files, nb_input_files); + input_files = (InputFile **) (grow_array(input_files, sizeof(input_files), &nb_input_files, nb_input_files + 1)); + f = static_cast(av_mallocz(sizeof(*f))); if (!f) exit_program(1); input_files[nb_input_files - 1] = f; @@ -1225,8 +1239,8 @@ static int open_input_file(OptionsContext *o, const char *filename) e = NULL; while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { - const AVClass *class = avcodec_get_class(); - const AVOption *option = av_opt_find(&class, e->key, NULL, 0, + const AVClass *clazz = avcodec_get_class(); + const AVOption *option = av_opt_find(&clazz, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); const AVClass *fclass = avformat_get_class(); const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, @@ -1259,7 +1273,7 @@ static int open_input_file(OptionsContext *o, const char *filename) AVStream *st = ic->streams[j]; if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1) - dump_attachment(st, o->dump_attachment[i].u.str); + dump_attachment(st, reinterpret_cast(o->dump_attachment[i].u.str)); } } @@ -1316,7 +1330,7 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) { enum AVMediaType type = ost->st->codecpar->codec_type; - char *codec_name = NULL; + /*char*/uint8_t *codec_name = NULL; if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); @@ -1332,10 +1346,10 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o avcodec_get_name(ost->st->codecpar->codec_id)); return AVERROR_ENCODER_NOT_FOUND; } - } else if (!strcmp(codec_name, "copy")) + } else if (!strcmp(reinterpret_cast(codec_name), "copy")) ost->stream_copy = 1; else { - ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); + ost->enc = find_codec_or_die(reinterpret_cast(codec_name), ost->st->codecpar->codec_type, 1); ost->st->codecpar->codec_id = ost->enc->id; } ost->encoding_needed = !ost->stream_copy; @@ -1353,8 +1367,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; - const char *bsfs = NULL, *time_base = NULL; - char *next, *codec_tag = NULL; + const /*char*/uint8_t *bsfs = NULL; + uint8_t *time_base = NULL; + char *next = NULL; + uint8_t *codec_tag = NULL; double qscale = -1; int i; @@ -1366,8 +1382,9 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (oc->nb_streams - 1 < o->nb_streamid_map) st->id = o->streamid_map[oc->nb_streams - 1]; - GROW_ARRAY(output_streams, nb_output_streams); - if (!(ost = av_mallocz(sizeof(*ost)))) +// GROW_ARRAY(output_streams, nb_output_streams); + output_streams = (OutputStream **) (grow_array(output_streams, sizeof(output_streams), &nb_output_streams, nb_output_streams + 1)); + if (!(ost = static_cast(av_mallocz(sizeof(*ost))))) exit_program(1); output_streams[nb_output_streams - 1] = ost; @@ -1399,14 +1416,15 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (ost->enc) { AVIOContext *s = NULL; - char *buf = NULL, *arg = NULL, *preset = NULL; + char *buf = NULL, *arg = NULL; + uint8_t *preset = NULL; ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); - if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { + if (preset && (!(ret = get_preset_file_2(reinterpret_cast(preset), ost->enc->name, &s)))) { do { - buf = get_line(s); + buf = reinterpret_cast(get_line(s)); if (!buf[0] || buf[0] == '#') { av_free(buf); continue; @@ -1438,7 +1456,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e MATCH_PER_STREAM_OPT(time_bases, str, time_base, oc, st); if (time_base) { AVRational q; - if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 || + if (av_parse_ratio(&q, reinterpret_cast(time_base), INT_MAX, 0, NULL) < 0 || q.num <= 0 || q.den <= 0) { av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base); exit_program(1); @@ -1449,7 +1467,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e MATCH_PER_STREAM_OPT(enc_time_bases, str, time_base, oc, st); if (time_base) { AVRational q; - if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 || + if (av_parse_ratio(&q, reinterpret_cast(time_base), INT_MAX, 0, NULL) < 0 || q.den <= 0) { av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base); exit_program(1); @@ -1475,7 +1493,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e const AVBitStreamFilter *filter; char *bsf, *bsf_options_str, *bsf_name; - bsf = av_get_token(&bsfs, ","); + bsf = av_get_token(reinterpret_cast(&bsfs), ","); if (!bsf) exit_program(1); bsf_name = av_strtok(bsf, "=", &bsf_options_str); @@ -1488,9 +1506,9 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e exit_program(1); } - ost->bsf_ctx = av_realloc_array(ost->bsf_ctx, - ost->nb_bitstream_filters + 1, - sizeof(*ost->bsf_ctx)); + ost->bsf_ctx = static_cast(av_realloc_array(ost->bsf_ctx, + ost->nb_bitstream_filters + 1, + sizeof(*ost->bsf_ctx))); if (!ost->bsf_ctx) exit_program(1); @@ -1523,7 +1541,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st); if (codec_tag) { - uint32_t tag = strtol(codec_tag, &next, 0); + uint32_t tag = (uint32_t) strtol(reinterpret_cast(codec_tag), &next, 0); if (*next) tag = AV_RL32(codec_tag); ost->st->codecpar->codec_tag = @@ -1536,7 +1554,14 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; } - MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st); + for (i = 0; i < o->nb_disposition; i++) { + char *spec = o->disposition[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->disposition = reinterpret_cast(o->disposition[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st); ost->disposition = av_strdup(ost->disposition); ost->max_muxing_queue_size = 128; @@ -1558,7 +1583,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (source_index >= 0) { ost->sync_ist = input_streams[source_index]; input_streams[source_index]->discard = 0; - input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard; + input_streams[source_index]->st->discard = static_cast(input_streams[source_index]->user_set_discard); } ost->last_mux_dts = AV_NOPTS_VALUE; @@ -1627,7 +1652,7 @@ static char *get_ost_filters(OptionsContext *o, AVFormatContext *oc, } if (ost->filters_script) - return read_file(ost->filters_script); + return reinterpret_cast(read_file(ost->filters_script)); else if (ost->filters) return av_strdup(ost->filters); @@ -1654,14 +1679,14 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in AVStream *st; OutputStream *ost; AVCodecContext *video_enc; - char *frame_rate = NULL, *frame_aspect_ratio = NULL; + /*char*/uint8_t *frame_rate = NULL, *frame_aspect_ratio = NULL; ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index); st = ost->st; video_enc = ost->enc_ctx; MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); - if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { + if (frame_rate && av_parse_video_rate(&ost->frame_rate, reinterpret_cast(frame_rate)) < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); exit_program(1); } @@ -1671,7 +1696,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st); if (frame_aspect_ratio) { AVRational q; - if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 || + if (av_parse_ratio(&q, reinterpret_cast(frame_aspect_ratio), 255, 0, NULL) < 0 || q.num <= 0 || q.den <= 0) { av_log(NULL, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio); exit_program(1); @@ -1679,22 +1704,37 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->frame_aspect_ratio = q; } - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); + int i, ret; + for (i = 0; i < o->nb_filter_scripts; i++) { + char *spec = o->filter_scripts[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->filters_script = reinterpret_cast(o->filter_scripts[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); + for (i = 0; i < o->nb_filters; i++) { + char *spec = o->filters[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->filters = reinterpret_cast(o->filters[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); if (o->nb_filters > 1) av_log(NULL, AV_LOG_ERROR, "Only '-vf %s' read, ignoring remaining -vf options: Use ',' to separate filters\n", ost->filters); if (!ost->stream_copy) { - const char *p = NULL; - char *frame_size = NULL; - char *frame_pix_fmt = NULL; - char *intra_matrix = NULL, *inter_matrix = NULL; - char *chroma_intra_matrix = NULL; + const /*char*/uint8_t *p = NULL; + /*char*/uint8_t *frame_size = NULL; + /*char*/uint8_t *frame_pix_fmt = NULL; + /*char*/uint8_t *intra_matrix = NULL, *inter_matrix = NULL; + /*char*/uint8_t *chroma_intra_matrix = NULL; int do_pass = 0; int i; MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st); - if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, frame_size) < 0) { + if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, (char *) frame_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size); exit_program(1); } @@ -1706,7 +1746,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in if (!*++frame_pix_fmt) frame_pix_fmt = NULL; } - if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == AV_PIX_FMT_NONE) { + if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt((char *) frame_pix_fmt)) == AV_PIX_FMT_NONE) { av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt); exit_program(1); } @@ -1716,42 +1756,44 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in video_enc->gop_size = 0; MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st); if (intra_matrix) { - if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) { + if (!(video_enc->intra_matrix = static_cast(av_mallocz( + sizeof(*video_enc->intra_matrix) * 64)))) { av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n"); exit_program(1); } - parse_matrix_coeffs(video_enc->intra_matrix, intra_matrix); + parse_matrix_coeffs(video_enc->intra_matrix, (const char *)intra_matrix); } MATCH_PER_STREAM_OPT(chroma_intra_matrices, str, chroma_intra_matrix, oc, st); if (chroma_intra_matrix) { - uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64); + uint16_t *p = (uint16_t *) av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64); if (!p) { av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n"); exit_program(1); } video_enc->chroma_intra_matrix = p; - parse_matrix_coeffs(p, chroma_intra_matrix); + parse_matrix_coeffs(p, reinterpret_cast(chroma_intra_matrix)); } MATCH_PER_STREAM_OPT(inter_matrices, str, inter_matrix, oc, st); if (inter_matrix) { - if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) { + if (!(video_enc->inter_matrix = static_cast(av_mallocz( + sizeof(*video_enc->inter_matrix) * 64)))) { av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for inter matrix.\n"); exit_program(1); } - parse_matrix_coeffs(video_enc->inter_matrix, inter_matrix); + parse_matrix_coeffs(video_enc->inter_matrix, reinterpret_cast(inter_matrix)); } MATCH_PER_STREAM_OPT(rc_overrides, str, p, oc, st); for (i = 0; p; i++) { int start, end, q; - int e = sscanf(p, "%d,%d,%d", &start, &end, &q); + int e = sscanf((const char*)p, "%d,%d,%d", &start, &end, &q); if (e != 3) { av_log(NULL, AV_LOG_FATAL, "error parsing rc_override\n"); exit_program(1); } video_enc->rc_override = - av_realloc_array(video_enc->rc_override, - i + 1, sizeof(RcOverride)); + static_cast(av_realloc_array(video_enc->rc_override, + i + 1, sizeof(RcOverride))); if (!video_enc->rc_override) { av_log(NULL, AV_LOG_FATAL, "Could not (re)allocate memory for rc_override.\n"); exit_program(1); @@ -1766,7 +1808,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in video_enc->rc_override[i].qscale = 0; video_enc->rc_override[i].quality_factor = -q/100.0; } - p = strchr(p, '/'); + p = reinterpret_cast(strchr((char *) (p), '/')); if (p) p++; } video_enc->rc_override_count = i; @@ -1787,7 +1829,14 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in } } - MATCH_PER_STREAM_OPT(passlogfiles, str, ost->logfile_prefix, oc, st); + for (i = 0; i < o->nb_passlogfiles; i++) { + char *spec = o->passlogfiles[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->logfile_prefix = reinterpret_cast(o->passlogfiles[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(passlogfiles, str, ost->logfile_prefix, oc, st); if (ost->logfile_prefix && !(ost->logfile_prefix = av_strdup(ost->logfile_prefix))) exit_program(1); @@ -1804,7 +1853,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); } else { if (video_enc->flags & AV_CODEC_FLAG_PASS2) { - char *logbuffer = read_file(logfilename); + char *logbuffer = reinterpret_cast(read_file(logfilename)); if (!logbuffer) { av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", @@ -1826,7 +1875,14 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in } } - MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st); + for (i = 0; i < o->nb_forced_key_frames; i++) { + char *spec = o->forced_key_frames[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->forced_keyframes = reinterpret_cast(o->forced_key_frames[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st); if (ost->forced_keyframes) ost->forced_keyframes = av_strdup(ost->forced_keyframes); @@ -1862,26 +1918,48 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in audio_enc = ost->enc_ctx; audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); + int i, ret; + for (i = 0; i < o->nb_filter_scripts; i++) { + char *spec = o->filter_scripts[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->filters_script = reinterpret_cast(o->filter_scripts[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); + for (i = 0; i < o->nb_filters; i++) { + char *spec = o->filters[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->filters = reinterpret_cast(o->filters[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); if (o->nb_filters > 1) av_log(NULL, AV_LOG_ERROR, "Only '-af %s' read, ignoring remaining -af options: Use ',' to separate filters\n", ost->filters); if (!ost->stream_copy) { - char *sample_fmt = NULL; + /*char*/uint8_t *sample_fmt = NULL; MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st); MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st); if (sample_fmt && - (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) { + (audio_enc->sample_fmt = av_get_sample_fmt((char *) sample_fmt)) == AV_SAMPLE_FMT_NONE) { av_log(NULL, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt); exit_program(1); } MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st); - MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st); + for (i = 0; i < o->nb_apad; i++) { + char *spec = o->apad[i].specifier; + if ((ret = check_stream_specifier(oc, st, spec)) > 0) + ost->apad = reinterpret_cast(o->apad[i].u.str); + else if (ret < 0) + exit_program(1); + } +// MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st); ost->apad = av_strdup(ost->apad); ost->avfilter = get_ost_filters(o, oc, ost); @@ -1954,7 +2032,7 @@ static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *o { OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT, source_index); ost->stream_copy = 1; - ost->finished = 1; + ost->finished = static_cast(1); return ost; } @@ -1973,10 +2051,10 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc, st); if (!ost->stream_copy) { - char *frame_size = NULL; + /*char*/uint8_t *frame_size = NULL; MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st); - if (frame_size && av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size) < 0) { + if (frame_size && av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, (char *) frame_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size); exit_program(1); } @@ -1988,7 +2066,7 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, /* arg format is "output-stream-index:streamid-value". */ static int opt_streamid(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); int idx; char *p; char idx_str[16]; @@ -2003,7 +2081,8 @@ static int opt_streamid(void *optctx, const char *opt, const char *arg) } *p++ = '\0'; idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1); - o->streamid_map = grow_array(o->streamid_map, sizeof(*o->streamid_map), &o->nb_streamid_map, idx+1); + o->streamid_map = static_cast(grow_array(o->streamid_map, sizeof(*o->streamid_map), + &o->nb_streamid_map, idx + 1)); o->streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); return 0; } @@ -2015,7 +2094,8 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) AVChapter **tmp; int i; - tmp = av_realloc_f(os->chapters, is->nb_chapters + os->nb_chapters, sizeof(*os->chapters)); + tmp = static_cast(av_realloc_f(os->chapters, is->nb_chapters + os->nb_chapters, + sizeof(*os->chapters))); if (!tmp) return AVERROR(ENOMEM); os->chapters = tmp; @@ -2034,7 +2114,7 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) if (rt != INT64_MAX && in_ch->start > rt + ts_off) break; - out_ch = av_mallocz(sizeof(AVChapter)); + out_ch = static_cast(av_mallocz(sizeof(AVChapter))); if (!out_ch) return AVERROR(ENOMEM); @@ -2131,8 +2211,9 @@ static int open_output_file(OptionsContext *o, const char *filename) } } - GROW_ARRAY(output_files, nb_output_files); - of = av_mallocz(sizeof(*of)); +// GROW_ARRAY(output_files, nb_output_files); + output_files = (OutputFile **) (grow_array(output_files, sizeof(output_files), &nb_output_files, nb_output_files + 1)); + of = static_cast(av_mallocz(sizeof(*of))); if (!of) exit_program(1); output_files[nb_output_files - 1] = of; @@ -2188,7 +2269,7 @@ static int open_output_file(OptionsContext *o, const char *filename) } if (!o->nb_stream_maps) { - char *subtitle_codec_name = NULL; + /*char*/uint8_t *subtitle_codec_name = NULL; /* pick the "best" stream of each type */ /* video: highest resolution */ @@ -2372,7 +2453,7 @@ loop_end: o->attachments[i]); exit_program(1); } - if (!(attachment = av_malloc(len))) { + if (!(attachment = static_cast(av_malloc(len)))) { av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n", o->attachments[i]); exit_program(1); @@ -2420,8 +2501,8 @@ loop_end: e = NULL; while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { - const AVClass *class = avcodec_get_class(); - const AVOption *option = av_opt_find(&class, e->key, NULL, 0, + const AVClass *clazz = avcodec_get_class(); + const AVOption *option = av_opt_find(&clazz, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); const AVClass *fclass = avformat_get_class(); const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, @@ -2487,7 +2568,8 @@ loop_end: count = 0; while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE) count++; - f->formats = av_mallocz_array(count + 1, sizeof(*f->formats)); + f->formats = static_cast(av_mallocz_array(count + 1, + sizeof(*f->formats))); if (!f->formats) exit_program(1); memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats)); @@ -2500,7 +2582,8 @@ loop_end: count = 0; while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE) count++; - f->formats = av_mallocz_array(count + 1, sizeof(*f->formats)); + f->formats = static_cast(av_mallocz_array(count + 1, + sizeof(*f->formats))); if (!f->formats) exit_program(1); memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats)); @@ -2511,7 +2594,8 @@ loop_end: count = 0; while (ost->enc->supported_samplerates[count]) count++; - f->sample_rates = av_mallocz_array(count + 1, sizeof(*f->sample_rates)); + f->sample_rates = static_cast(av_mallocz_array(count + 1, + sizeof(*f->sample_rates))); if (!f->sample_rates) exit_program(1); memcpy(f->sample_rates, ost->enc->supported_samplerates, @@ -2523,7 +2607,8 @@ loop_end: count = 0; while (ost->enc->channel_layouts[count]) count++; - f->channel_layouts = av_mallocz_array(count + 1, sizeof(*f->channel_layouts)); + f->channel_layouts = static_cast(av_mallocz_array(count + 1, + sizeof(*f->channel_layouts))); if (!f->channel_layouts) exit_program(1); memcpy(f->channel_layouts, ost->enc->channel_layouts, @@ -2570,7 +2655,7 @@ loop_end: /* copy metadata */ for (i = 0; i < o->nb_metadata_map; i++) { char *p; - int in_file_index = strtol(o->metadata_map[i].u.str, &p, 0); + int in_file_index = strtol(reinterpret_cast(o->metadata_map[i].u.str), &p, 0); if (in_file_index >= nb_input_files) { av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index); @@ -2623,7 +2708,7 @@ loop_end: /* process manually set programs */ for (i = 0; i < o->nb_program; i++) { - const char *p = o->program[i].u.str; + const char *p = reinterpret_cast(o->program[i].u.str); int progid = i+1; AVProgram *program; @@ -2652,7 +2737,7 @@ loop_end: program = av_new_program(oc, progid); - p = o->program[i].u.str; + p = reinterpret_cast(o->program[i].u.str); while(*p) { const char *p2 = av_get_token(&p, ":"); const char *to_dealloc = p2; @@ -2694,7 +2779,7 @@ loop_end: const char *stream_spec; int index = 0, j, ret = 0; - val = strchr(o->metadata[i].u.str, '='); + val = strchr((char *)(o->metadata[i].u.str), '='); if (!val) { av_log(NULL, AV_LOG_FATAL, "No '=' character in metadata string %s.\n", o->metadata[i].u.str); @@ -2707,7 +2792,7 @@ loop_end: for (j = 0; j < oc->nb_streams; j++) { ost = output_streams[nb_output_streams - oc->nb_streams + j]; if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) { - if (!strcmp(o->metadata[i].u.str, "rotate")) { + if (!strcmp(reinterpret_cast(o->metadata[i].u.str), "rotate")) { char *tail; double theta = av_strtod(val, &tail); if (!*tail) { @@ -2715,7 +2800,8 @@ loop_end: ost->rotate_override_value = theta; } } else { - av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0); + av_dict_set(&oc->streams[j]->metadata, + reinterpret_cast(o->metadata[i].u.str), *val ? val : NULL, 0); } } else if (ret < 0) exit_program(1); @@ -2744,7 +2830,7 @@ loop_end: av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier); exit_program(1); } - av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0); + av_dict_set(m, reinterpret_cast(o->metadata[i].u.str), *val ? val : NULL, 0); } } @@ -2753,7 +2839,7 @@ loop_end: static int opt_target(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN; static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" }; @@ -2918,19 +3004,19 @@ static int opt_vstats(void *optctx, const char *opt, const char *arg) static int opt_video_frames(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "frames:v", arg, options); } static int opt_audio_frames(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "frames:a", arg, options); } static int opt_data_frames(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "frames:d", arg, options); } @@ -2956,16 +3042,16 @@ static int opt_default_new(OptionsContext *o, const char *opt, const char *arg) static int opt_preset(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); FILE *f=NULL; char filename[1000], line[1000], tmp_line[1000]; - const char *codec_name = NULL; + const /*char*/uint8_t *codec_name = NULL; tmp_line[0] = *opt; tmp_line[1] = 0; MATCH_PER_TYPE_OPT(codec_names, str, codec_name, NULL, tmp_line); - if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) { + if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', (const char *)codec_name))) { if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){ av_log(NULL, AV_LOG_FATAL, "Please use -preset -qp 0\n"); }else @@ -3004,7 +3090,7 @@ static int opt_preset(void *optctx, const char *opt, const char *arg) static int opt_old2new(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); char *s = av_asprintf("%s:%c", opt + 1, *opt); int ret = parse_option(o, s, arg, options); av_free(s); @@ -3013,7 +3099,7 @@ static int opt_old2new(void *optctx, const char *opt, const char *arg) static int opt_bitrate(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); if(!strcmp(opt, "ab")){ av_dict_set(&o->g->codec_opts, "b:a", arg, 0); @@ -3029,7 +3115,7 @@ static int opt_bitrate(void *optctx, const char *opt, const char *arg) static int opt_qscale(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); char *s; int ret; if(!strcmp(opt, "qscale")){ @@ -3044,7 +3130,7 @@ static int opt_qscale(void *optctx, const char *opt, const char *arg) static int opt_profile(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); if(!strcmp(opt, "profile")){ av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n"); av_dict_set(&o->g->codec_opts, "profile:v", arg, 0); @@ -3056,13 +3142,13 @@ static int opt_profile(void *optctx, const char *opt, const char *arg) static int opt_video_filters(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "filter:v", arg, options); } static int opt_audio_filters(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "filter:a", arg, options); } @@ -3080,7 +3166,7 @@ static int opt_vsync(void *optctx, const char *opt, const char *arg) static int opt_timecode(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); char *tcr = av_asprintf("timecode=%s", arg); int ret = parse_option(o, "metadata:g", tcr, options); if (ret >= 0) @@ -3091,7 +3177,7 @@ static int opt_timecode(void *optctx, const char *opt, const char *arg) static int opt_channel_layout(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); char layout_str[32]; char *stream_str; char *ac_str; @@ -3103,7 +3189,7 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) av_log(NULL, AV_LOG_ERROR, "Unknown channel layout: %s\n", arg); return AVERROR(EINVAL); } - snprintf(layout_str, sizeof(layout_str), "%"PRIu64, layout); + snprintf(layout_str, sizeof(layout_str), "%" PRIu64, layout); ret = opt_default_new(o, opt, layout_str); if (ret < 0) return ret; @@ -3111,9 +3197,9 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) /* set 'ac' option based on channel layout */ channels = av_get_channel_layout_nb_channels(layout); snprintf(layout_str, sizeof(layout_str), "%d", channels); - stream_str = strchr(opt, ':'); + stream_str = strchr((char *)opt, ':'); ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0); - ac_str = av_mallocz(ac_str_size); + ac_str = static_cast(av_mallocz(ac_str_size)); if (!ac_str) return AVERROR(ENOMEM); av_strlcpy(ac_str, "ac", 3); @@ -3127,14 +3213,16 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) static int opt_audio_qscale(void *optctx, const char *opt, const char *arg) { - OptionsContext *o = optctx; + OptionsContext *o = static_cast(optctx); return parse_option(o, "q:a", arg, options); } static int opt_filter_complex(void *optctx, const char *opt, const char *arg) { - GROW_ARRAY(filtergraphs, nb_filtergraphs); - if (!(filtergraphs[nb_filtergraphs - 1] = av_mallocz(sizeof(*filtergraphs[0])))) +// GROW_ARRAY(filtergraphs, nb_filtergraphs); + filtergraphs = (FilterGraph **) (grow_array(filtergraphs, sizeof(filtergraphs), &nb_filtergraphs, nb_filtergraphs + 1)); + if (!(filtergraphs[nb_filtergraphs - 1] = static_cast(av_mallocz( + sizeof(*filtergraphs[0]))))) return AVERROR(ENOMEM); filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1; filtergraphs[nb_filtergraphs - 1]->graph_desc = av_strdup(arg); @@ -3152,11 +3240,13 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * if (!graph_desc) return AVERROR(EINVAL); - GROW_ARRAY(filtergraphs, nb_filtergraphs); - if (!(filtergraphs[nb_filtergraphs - 1] = av_mallocz(sizeof(*filtergraphs[0])))) +// GROW_ARRAY(filtergraphs, nb_filtergraphs); + filtergraphs = (FilterGraph **) (grow_array(filtergraphs, sizeof(filtergraphs), &nb_filtergraphs, nb_filtergraphs + 1)); + if (!(filtergraphs[nb_filtergraphs - 1] = static_cast(av_mallocz( + sizeof(*filtergraphs[0]))))) return AVERROR(ENOMEM); filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1; - filtergraphs[nb_filtergraphs - 1]->graph_desc = graph_desc; + filtergraphs[nb_filtergraphs - 1]->graph_desc = reinterpret_cast(graph_desc); input_stream_potentially_available = 1; @@ -3337,7 +3427,7 @@ int ffmpeg_parse_options(int argc, char **argv) fail: uninit_parse_context(&octx); if (ret < 0) { - av_strerror(ret, error, sizeof(error)); + av_strerror(ret, reinterpret_cast(error), sizeof(error)); av_log(NULL, AV_LOG_FATAL, "%s\n", error); } return ret;