Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/msrleenc: Constify pointers for frame->data
Date: Sun, 16 Jul 2023 17:01:46 +0200
Message-ID: <GV1P250MB073752AEA7E52E71D30BC9B68F3AA@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737BBFDA527F42111F6DBDE8F3AA@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

Encoders (usually) have no business modifying frame->data
(which need not be writable), so they should use the appropriate
pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/msrleenc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index 11f7d2a319..931e7af053 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -64,7 +64,8 @@ static void write_run(AVCodecContext *avctx, uint8_t **data, int len, int value)
     }
 }
 
-static void write_absolute(AVCodecContext *avctx, uint8_t **data, uint8_t *line, int len)
+static void write_absolute(AVCodecContext *avctx, uint8_t **data,
+                           const uint8_t *line, int len)
 {
     // writing 255 would be wasteful here due to the padding requirement
     while (len >= 254) {
@@ -136,7 +137,8 @@ static void write_yskip(AVCodecContext *avctx, uint8_t **data, int yskip)
 }
 
 // used both to encode lines in keyframes and to encode lines between deltas
-static void encode_line(AVCodecContext *avctx, uint8_t **data, uint8_t *line, int length)
+static void encode_line(AVCodecContext *avctx, uint8_t **data,
+                        const uint8_t *line, int length)
 {
     int run = 0, last = -1, absstart = 0;
     if (length == 0)
@@ -192,8 +194,8 @@ static int encode(AVCodecContext *avctx, AVPacket *pkt,
         // compare to previous frame
         int yskip = 0; // we can encode large skips using deltas
         for (int y = avctx->height-1; y >= 0; y--) {
-            uint8_t *line = &pict->data[0][y*pict->linesize[0]];
-            uint8_t *prev = &s->last_frame->data[0][y*s->last_frame->linesize[0]];
+            const uint8_t *line = &pict->data[0][y*pict->linesize[0]];
+            const uint8_t *prev = &s->last_frame->data[0][y*s->last_frame->linesize[0]];
             // we need at least 5 pixels in a row for a delta to be worthwhile
             int delta = 0, linestart = 0, encoded = 0;
             for (int x = 0; x < avctx->width; x++) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-07-16 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/msrleenc: Check allocation Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class Andreas Rheinhardt
2023-07-17 11:30   ` Tomas Härdin
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/msrleenc: Check frame allocations/references Andreas Rheinhardt
2023-07-16 15:01 ` Andreas Rheinhardt [this message]
2023-07-17 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Tomas Härdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=GV1P250MB073752AEA7E52E71D30BC9B68F3AA@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git