summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2023-02-20 23:22:25 +0200
committerJan Ekström <jeebjp@gmail.com>2023-03-14 23:59:47 +0200
commitef7b711bede143615b9ecd04f8df1d4b780cd7bc (patch)
tree1b3136da4b05a7be5c759dcae0045be722eed9b0 /common
parent0da0acdae8e729eecfb2498ac11cb86a7fe3360d (diff)
downloadmpv-ef7b711bede143615b9ecd04f8df1d4b780cd7bc.tar.bz2
mpv-ef7b711bede143615b9ecd04f8df1d4b780cd7bc.tar.xz
common/av_common: constify mp_codec_params related getters
They should not be modifying the argument, so clearly marking it as const makes sure we don't do it in the future as well as allows for read-only optimizations.
Diffstat (limited to 'common')
-rw-r--r--common/av_common.c6
-rw-r--r--common/av_common.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/common/av_common.c b/common/av_common.c
index db31988c1b..89a647593f 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -64,7 +64,7 @@ enum AVMediaType mp_to_av_stream_type(int type)
}
}
-AVCodecParameters *mp_codec_params_to_av(struct mp_codec_params *c)
+AVCodecParameters *mp_codec_params_to_av(const struct mp_codec_params *c)
{
AVCodecParameters *avp = avcodec_parameters_alloc();
if (!avp)
@@ -125,7 +125,7 @@ error:
}
// Set avctx codec headers for decoding. Returns <0 on failure.
-int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c)
+int mp_set_avctx_codec_headers(AVCodecContext *avctx, const struct mp_codec_params *c)
{
enum AVMediaType codec_type = avctx->codec_type;
enum AVCodecID codec_id = avctx->codec_id;
@@ -145,7 +145,7 @@ int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c)
// Pick a "good" timebase, which will be used to convert double timestamps
// back to fractions for passing them through libavcodec.
-AVRational mp_get_codec_timebase(struct mp_codec_params *c)
+AVRational mp_get_codec_timebase(const struct mp_codec_params *c)
{
AVRational tb = {c->native_tb_num, c->native_tb_den};
if (tb.num < 1 || tb.den < 1) {
diff --git a/common/av_common.h b/common/av_common.h
index dd5e88e003..2c97ad19cc 100644
--- a/common/av_common.h
+++ b/common/av_common.h
@@ -33,9 +33,9 @@ struct mp_log;
int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size);
enum AVMediaType mp_to_av_stream_type(int type);
-AVCodecParameters *mp_codec_params_to_av(struct mp_codec_params *c);
-int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c);
-AVRational mp_get_codec_timebase(struct mp_codec_params *c);
+AVCodecParameters *mp_codec_params_to_av(const struct mp_codec_params *c);
+int mp_set_avctx_codec_headers(AVCodecContext *avctx, const struct mp_codec_params *c);
+AVRational mp_get_codec_timebase(const struct mp_codec_params *c);
void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb);
int64_t mp_pts_to_av(double mp_pts, AVRational *tb);
double mp_pts_from_av(int64_t av_pts, AVRational *tb);