diff --git a/src/video_capture/file.c b/src/video_capture/file.c index 255166248..aaa6b9af8 100644 --- a/src/video_capture/file.c +++ b/src/video_capture/file.c @@ -371,7 +371,7 @@ static bool vidcap_file_parse_fmt(struct vidcap_state_lavf_decoder *s, const cha return true; } -static AVCodecContext *vidcap_file_open_dec_ctx(AVCodec *dec, AVStream *st) { +static AVCodecContext *vidcap_file_open_dec_ctx(const AVCodec *dec, AVStream *st) { AVCodecContext *dec_ctx = avcodec_alloc_context3(dec); if (!dec_ctx) { return NULL; @@ -466,9 +466,9 @@ static int vidcap_file_init(struct vidcap_params *params, void **state) { return VIDCAP_INIT_FAIL; } - AVCodec *dec; + const AVCodec *dec = NULL; if (vidcap_params_get_flags(params) & VIDCAP_FLAG_AUDIO_ANY) { - s->audio_stream_idx = av_find_best_stream(s->fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0); + s->audio_stream_idx = av_find_best_stream(s->fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, (void *) &dec, 0); if (s->audio_stream_idx < 0 && !opportunistic_audio) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "Could not find audio stream!\n"); vidcap_file_common_cleanup(s); @@ -493,7 +493,7 @@ static int vidcap_file_init(struct vidcap_params *params, void **state) { } } - s->video_stream_idx = av_find_best_stream(s->fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0); + s->video_stream_idx = av_find_best_stream(s->fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, (void *) &dec, 0); if (s->video_stream_idx < 0) { log_msg(LOG_LEVEL_WARNING, MOD_NAME "No video stream found!\n"); vidcap_file_common_cleanup(s); diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 9d7134ffc..646a3d250 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -928,7 +928,7 @@ static bool try_open_codec(struct state_video_compress_libav *s, AVPixelFormat &pix_fmt, struct video_desc desc, codec_t ug_codec, - AVCodec *codec) + const AVCodec *codec) { // avcodec_alloc_context3 allocates context and sets default value s->codec_ctx = avcodec_alloc_context3(codec); diff --git a/src/video_decompress/libavcodec.c b/src/video_decompress/libavcodec.c index ee5536833..0f9b0fca0 100644 --- a/src/video_decompress/libavcodec.c +++ b/src/video_decompress/libavcodec.c @@ -262,7 +262,7 @@ static bool configure_with(struct state_libavcodec_decompress *s, } // construct priority list of decoders that can be used for the codec - AVCodec *codecs_available[13]; // max num of preferred decoders (10) + user supplied + default one + NULL + const AVCodec *codecs_available[13]; // max num of preferred decoders (10) + user supplied + default one + NULL memset(codecs_available, 0, sizeof codecs_available); unsigned int codec_index = 0; // first try codec specified from cmdline if any @@ -273,7 +273,7 @@ static bool configure_with(struct state_libavcodec_decompress *s, char *item, *save_ptr; while ((item = strtok_r(val, ":", &save_ptr))) { val = NULL; - AVCodec *codec = avcodec_find_decoder_by_name(item); + const AVCodec *codec = avcodec_find_decoder_by_name(item); if (codec == NULL) { log_msg(LOG_LEVEL_WARNING, "[lavd] Decoder not found: %s\n", item); } else { @@ -290,7 +290,7 @@ static bool configure_with(struct state_libavcodec_decompress *s, // then try preferred codecs const char * const *preferred_decoders_it = dec->preferred_decoders; while (*preferred_decoders_it) { - AVCodec *codec = avcodec_find_decoder_by_name(*preferred_decoders_it); + const AVCodec *codec = avcodec_find_decoder_by_name(*preferred_decoders_it); if (codec == NULL) { log_msg(LOG_LEVEL_VERBOSE, "[lavd] Decoder not available: %s\n", *preferred_decoders_it); preferred_decoders_it++; @@ -304,7 +304,7 @@ static bool configure_with(struct state_libavcodec_decompress *s, } // finally, add a default one if there are no preferred encoders or all fail if (codec_index < (sizeof codecs_available / sizeof codecs_available[0]) - 1) { - AVCodec *default_decoder = avcodec_find_decoder(dec->avcodec_id); + const AVCodec *default_decoder = avcodec_find_decoder(dec->avcodec_id); if (default_decoder == NULL) { log_msg(LOG_LEVEL_WARNING, "[lavd] No decoder found for the input codec (libavcodec perhaps compiled without any)!\n" "Use \"--param decompress= to select a different decoder than libavcodec if there is any eligibe.\n"); @@ -314,7 +314,7 @@ static bool configure_with(struct state_libavcodec_decompress *s, } // initialize the codec - use the first decoder initialization of which succeeds - AVCodec **codec_it = codecs_available; + const AVCodec **codec_it = codecs_available; while (*codec_it) { log_msg(LOG_LEVEL_VERBOSE, "[lavd] Trying decoder: %s\n", (*codec_it)->name); s->codec_ctx = avcodec_alloc_context3(*codec_it);