From patchwork Thu Jan 31 20:43:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 11933 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 1EBC944C501 for ; Thu, 31 Jan 2019 22:43:03 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 37D3168ACE4; Thu, 31 Jan 2019 22:42:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f181.google.com (mail-it1-f181.google.com [209.85.166.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4662C68ACDB for ; Thu, 31 Jan 2019 22:42:44 +0200 (EET) Received: by mail-it1-f181.google.com with SMTP id p197so6538775itp.0 for ; Thu, 31 Jan 2019 12:43:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=yItYk1+0Wn4p8HcphiSX3JddKQIOnOQLxH4pASHZtDg=; b=mIl8PnRZGV6UWGGx5PnYqtaouLWAUbKnRrN/2jCgaK6YwQ9EF/OR4UgxYxVhBdpc4S o5MXg1M6sEyGtocMHq7DZap34GUTtYiukg+Ori84+88/948IN1c+4ifFKX9BBaNPSgMe TQE5vL7d91P/K+AyDO7a3b53h3mkNEu6cfYJR6IVJwoqnLL5/Hgbz0ABTCSgYVgQdEUN AGC7ovPLR09WWQ7+qLrBV9fW0E3FBTQH0rYcfQcm6aE40a4d1bhPKmq91YriNL3hWlkf ms9ZKXqQYUIyUhi3ZB3u/tTfnhN7Uk25TdwWUdKn0hIQre3ge3HGg1jW1CwfIWsmNB+s Vz/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=yItYk1+0Wn4p8HcphiSX3JddKQIOnOQLxH4pASHZtDg=; b=k4Wme76IdzjgktGfEuBLYQTZkn1zMkcj2+hjXEmaducSxOzVgz5mOWuHgYGHTidz+3 hlgF1brQ/gL72YClfoQ/fnP+nMY+Om6OJcdxxY00+HRUUp6bDrx6ZsLif5ZLj42yqQQc Bz8X4jEbfC0kuOb1Z4TnmEpCUoUo78h5OTk6uWEGDJE0YnXiRZUzFY4LIsZpeGrM3uJh GVOThIOe3vJEv0okUpM63nlLKSHerni5P0iNFnwPwsHRjz3MiVGM+iNAJsWcpCyqmbln HXLf+MOjxC7vjRQKvHsJgcYRejI1/Vht1XCUhYkUw8gsiaQ6fvykJEs2GEv5TW+WC3hK M08Q== X-Gm-Message-State: AJcUukeJ/S5IZYHnNW6bl70i/BcV4xawfUgNgNlWHztn0kqyfaYrL8FU VE/mD46uGHMXk/aULpPMK+34B4NpcHiQsuA6leOeKg== X-Google-Smtp-Source: ALg8bN7sSHsrjmQ8rJvNwJk1bRjs3xeY1j5VbCTGZ/qHZNEqrdPu3FWkFZHGpwk4lifLFHes86syu48ZPEDeC4XXWgM= X-Received: by 2002:a24:100d:: with SMTP id 13mr19474724ity.58.1548967384503; Thu, 31 Jan 2019 12:43:04 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:5f11:0:0:0:0:0 with HTTP; Thu, 31 Jan 2019 12:43:03 -0800 (PST) From: Carl Eugen Hoyos Date: Thu, 31 Jan 2019 21:43:03 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavf:Constify AVInputFormat pointer 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi! Attached patch persistently uses "const" for AVInputFormat pointer after the next version bump. Please comment, Carl Eugen From 95fc17cc1a82ea6d2e9e96932e145cc2b4c210b6 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 31 Jan 2019 21:40:58 +0100 Subject: [PATCH] lavf: Constify AVInputFormat pointer. --- libavformat/allformats.c | 6 +++++- libavformat/avformat.h | 32 +++++++++++++++++++++++++++++++- libavformat/dashdec.c | 3 +++ libavformat/hls.c | 3 +++ libavformat/img2dec.c | 2 +- libavformat/mpeg.c | 3 +++ libavformat/rtpdec_asf.c | 3 +++ libavformat/sapdec.c | 3 +++ libavformat/utils.c | 11 ++++++++--- libavformat/version.h | 3 +++ 10 files changed, 63 insertions(+), 6 deletions(-) diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 0684498..01c4c14 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -583,7 +583,11 @@ AVInputFormat *av_iformat_next(const AVInputFormat *f) ff_thread_once(&av_format_next_init, av_format_init_next); if (f) - return f->next; + return +#if !FF_API_AVINPUTFORMAT + (AVInputFormat *) +#endif + f->next; else { void *opaque = NULL; return (AVInputFormat *)av_demuxer_iterate(&opaque); diff --git a/libavformat/avformat.h b/libavformat/avformat.h index fdaffa5..7c4ec8f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -676,7 +676,10 @@ typedef struct AVInputFormat { * New public fields should be added right above. ***************************************************************** */ - struct AVInputFormat *next; +#if !FF_API_AVINPUTFORMAT + const +#endif +struct AVInputFormat *next; /** * Raw demuxers store their codec ID here. @@ -1346,6 +1349,9 @@ typedef struct AVFormatContext { * * Demuxing only, set by avformat_open_input(). */ +#if !FF_API_AVINPUTFORMAT + const +#endif struct AVInputFormat *iformat; /** @@ -2222,6 +2228,9 @@ int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oforma /** * Find AVInputFormat based on the short name of the input format. */ +#if !FF_API_AVINPUTFORMAT +const +#endif AVInputFormat *av_find_input_format(const char *short_name); /** @@ -2231,6 +2240,9 @@ AVInputFormat *av_find_input_format(const char *short_name); * @param is_opened Whether the file is already opened; determines whether * demuxers with or without AVFMT_NOFILE are probed. */ +#if !FF_API_AVINPUTFORMAT +const +#endif AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); /** @@ -2245,6 +2257,9 @@ AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended * to retry with a larger probe buffer. */ +#if !FF_API_AVINPUTFORMAT +const +#endif AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max); /** @@ -2254,6 +2269,9 @@ AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score * demuxers with or without AVFMT_NOFILE are probed. * @param score_ret The score of the best detection. */ +#if !FF_API_AVINPUTFORMAT +const +#endif AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret); /** @@ -2272,14 +2290,22 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score * the maximal score is AVPROBE_SCORE_MAX * AVERROR code otherwise */ +#if FF_API_AVINPUTFORMAT int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, +#else +int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, +#endif const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size); /** * Like av_probe_input_buffer2() but returns 0 on success */ +#if FF_API_AVINPUTFORMAT int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, +#else +int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, +#endif const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size); @@ -2302,7 +2328,11 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, * * @note If you want to use custom IO, preallocate the format context and set its pb field. */ +#if FF_API_AVINPUTFORMAT int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options); +#else +int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options); +#endif attribute_deprecated int av_demuxer_open(AVFormatContext *ic); diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index f4f4e93..ad9cdb1 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1851,6 +1851,9 @@ static void close_demux_for_component(struct representation *pls) static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls) { DASHContext *c = s->priv_data; +#if !FF_API_AVINPUTFORMAT + const +#endif AVInputFormat *in_fmt = NULL; AVDictionary *in_fmt_opts = NULL; uint8_t *avio_ctx_buffer = NULL; diff --git a/libavformat/hls.c b/libavformat/hls.c index 8975a87..1b7ac4b 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1868,6 +1868,9 @@ static int hls_read_header(AVFormatContext *s) /* Open the demuxer for each playlist */ for (i = 0; i < c->n_playlists; i++) { struct playlist *pls = c->playlists[i]; +#if !FF_API_AVINPUTFORMAT + const +#endif AVInputFormat *in_fmt = NULL; if (!(pls->ctx = avformat_alloc_context())) { diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index e82b1df..71d8aa3b 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -424,7 +424,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) if (par->codec_id == AV_CODEC_ID_NONE) { AVProbeData pd = { 0 }; - AVInputFormat *ifmt; + const AVInputFormat *ifmt; uint8_t header[PROBE_BUF_MIN + AVPROBE_PADDING_SIZE]; int ret; int score = 0; diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index d4369b4..cbfebf6 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -722,6 +722,9 @@ static int vobsub_read_header(AVFormatContext *s) int stream_id = -1; char id[64] = {0}; char alt[MAX_LINE_SIZE] = {0}; +#if !FF_API_AVINPUTFORMAT + const +#endif AVInputFormat *iformat; if (!vobsub->sub_name) { diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 54ffef6..69805b0 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -106,6 +106,9 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) AVDictionary *opts = NULL; int len = strlen(p) * 6 / 8; char *buf = av_mallocz(len); +#if !FF_API_AVINPUTFORMAT + const +#endif AVInputFormat *iformat; if (!buf) diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 7a6c8bf..5103ab2 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -68,6 +68,9 @@ static int sap_read_header(AVFormatContext *s) uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; int port; int ret, i; +#if !FF_API_AVINPUTFORMAT + const +#endif AVInputFormat* infmt; if (!ff_network_init()) diff --git a/libavformat/utils.c b/libavformat/utils.c index 7afef54..4837ef3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -357,7 +357,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, { 0 } }; int score; - AVInputFormat *fmt = av_probe_input_format3(pd, 1, &score); + const AVInputFormat *fmt = av_probe_input_format3(pd, 1, &score); if (fmt) { int i; @@ -535,7 +535,12 @@ FF_ENABLE_DEPRECATION_WARNINGS int avformat_open_input(AVFormatContext **ps, const char *filename, - AVInputFormat *fmt, AVDictionary **options) +#if FF_API_AVINPUTFORMAT + AVInputFormat *fmt, +#else + const AVInputFormat *fmt, +#endif + AVDictionary **options) { AVFormatContext *s = *ps; int i, ret = 0; @@ -2163,7 +2168,7 @@ static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t * int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags) { - AVInputFormat *avif = s->iformat; + const AVInputFormat *avif = s->iformat; int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; int64_t ts_min, ts_max, ts; int index; diff --git a/libavformat/version.h b/libavformat/version.h index 4408eca..6915be0 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -103,6 +103,9 @@ #ifndef FF_API_LAVF_MP4A_LATM #define FF_API_LAVF_MP4A_LATM (LIBAVFORMAT_VERSION_MAJOR < 59) #endif +#ifndef FF_API_AVINPUTFORMAT +#define FF_API_AVINPUTFORMAT (LIBAVFORMAT_VERSION_MAJOR < 59) +#endif #ifndef FF_API_R_FRAME_RATE -- 1.7.10.4