From 99f5fef0ea5671d41fb7b737fbc3e4236542a757 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jun 2014 23:56:05 +0200 Subject: Add more const While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need. --- video/image_writer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'video/image_writer.c') diff --git a/video/image_writer.c b/video/image_writer.c index af1dab294c..f1318512b3 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -57,7 +57,7 @@ const struct image_writer_opts image_writer_opts_defaults = { #define OPT_BASE_STRUCT struct image_writer_opts const struct m_sub_options image_writer_conf = { - .opts = (m_option_t[]) { + .opts = (const m_option_t[]) { OPT_INTRANGE("jpeg-quality", jpeg_quality, 0, 0, 100), OPT_INTRANGE("jpeg-optimize", jpeg_optimize, 0, 0, 100), OPT_INTRANGE("jpeg-smooth", jpeg_smooth, 0, 0, 100), @@ -82,7 +82,7 @@ struct image_writer_ctx { struct img_writer { const char *file_ext; int (*write)(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp); - int *pixfmts; + const int *pixfmts; int lavc_codec; }; @@ -219,16 +219,16 @@ static const struct img_writer img_writers[] = { { "ppm", write_lavc, .lavc_codec = AV_CODEC_ID_PPM }, { "pgm", write_lavc, .lavc_codec = AV_CODEC_ID_PGM, - .pixfmts = (int[]) { IMGFMT_Y8, 0 }, + .pixfmts = (const int[]) { IMGFMT_Y8, 0 }, }, { "pgmyuv", write_lavc, .lavc_codec = AV_CODEC_ID_PGMYUV, - .pixfmts = (int[]) { IMGFMT_420P, 0 }, + .pixfmts = (const int[]) { IMGFMT_420P, 0 }, }, { "tga", write_lavc, .lavc_codec = AV_CODEC_ID_TARGA, - .pixfmts = (int[]) { IMGFMT_BGR24, IMGFMT_BGRA, IMGFMT_BGR15_LE, - IMGFMT_Y8, 0}, + .pixfmts = (const int[]) { IMGFMT_BGR24, IMGFMT_BGRA, IMGFMT_BGR15_LE, + IMGFMT_Y8, 0}, }, #if HAVE_JPEG { "jpg", write_jpeg }, @@ -277,7 +277,7 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts, if (writer->pixfmts) { destfmt = writer->pixfmts[0]; // default to first pixel format - for (int *fmt = writer->pixfmts; *fmt; fmt++) { + for (const int *fmt = writer->pixfmts; *fmt; fmt++) { if (*fmt == image->imgfmt) { destfmt = *fmt; break; -- cgit v1.2.3