Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] av(format|device): Add const to muxer packet data pointers
@ 2022-07-04 19:14 Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 2/4] avcodec: " Andreas Rheinhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-07-04 19:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The packets given to muxers need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavdevice/alsa_enc.c   | 2 +-
 libavdevice/fbdev_enc.c  | 3 ++-
 libavdevice/oss_enc.c    | 2 +-
 libavdevice/sndio_enc.c  | 2 +-
 libavformat/dvenc.c      | 2 +-
 libavformat/gif.c        | 2 +-
 libavformat/movenc.h     | 2 +-
 libavformat/movenchint.c | 2 +-
 libavformat/mxfenc.c     | 2 +-
 libavformat/oggenc.c     | 4 ++--
 libavformat/spdifenc.c   | 4 ++--
 libavformat/swfenc.c     | 4 ++--
 12 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c
index 3d6bccdc2a..ac09e33c49 100644
--- a/libavdevice/alsa_enc.c
+++ b/libavdevice/alsa_enc.c
@@ -86,7 +86,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
     AlsaData *s = s1->priv_data;
     int res;
     int size     = pkt->size;
-    uint8_t *buf = pkt->data;
+    const uint8_t *buf = pkt->data;
 
     size /= s->frame_size;
     if (pkt->dts != AV_NOPTS_VALUE)
diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c
index 898a630aa1..84ec6733ff 100644
--- a/libavdevice/fbdev_enc.c
+++ b/libavdevice/fbdev_enc.c
@@ -100,7 +100,8 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
 static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
 {
     FBDevContext *fbdev = h->priv_data;
-    uint8_t *pin, *pout;
+    const uint8_t *pin;
+    uint8_t *pout;
     enum AVPixelFormat fb_pix_fmt;
     int disp_height;
     int bytes_to_copy;
diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c
index d6a512a264..704f434c53 100644
--- a/libavdevice/oss_enc.c
+++ b/libavdevice/oss_enc.c
@@ -55,9 +55,9 @@ static int audio_write_header(AVFormatContext *s1)
 static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
 {
     OSSAudioData *s = s1->priv_data;
+    const uint8_t *buf = pkt->data;
     int len, ret;
     int size= pkt->size;
-    uint8_t *buf= pkt->data;
 
     while (size > 0) {
         len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
diff --git a/libavdevice/sndio_enc.c b/libavdevice/sndio_enc.c
index a595438d8a..0cf58fdc6a 100644
--- a/libavdevice/sndio_enc.c
+++ b/libavdevice/sndio_enc.c
@@ -46,7 +46,7 @@ static av_cold int audio_write_header(AVFormatContext *s1)
 static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
 {
     SndioData *s = s1->priv_data;
-    uint8_t *buf= pkt->data;
+    const uint8_t *buf = pkt->data;
     int size = pkt->size;
     int len, ret;
 
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 1917c00694..7ef9692302 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -245,7 +245,7 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame)
 
 static int dv_assemble_frame(AVFormatContext *s,
                              DVMuxContext *c, AVStream* st,
-                             uint8_t* data, int data_size, uint8_t** frame)
+                             const uint8_t *data, int data_size, uint8_t **frame)
 {
     int i, reqasize;
 
diff --git a/libavformat/gif.c b/libavformat/gif.c
index cba87d3eae..b52ff4dd39 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -54,7 +54,7 @@ static int gif_write_header(AVFormatContext *s)
     return 0;
 }
 
-static int gif_parse_packet(AVFormatContext *s, uint8_t *data, int size)
+static int gif_parse_packet(AVFormatContext *s, const uint8_t *data, int size)
 {
     GetByteContext gb;
     int x;
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index e4550f7900..c6b3313deb 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -62,7 +62,7 @@ typedef struct MOVIentry {
 } MOVIentry;
 
 typedef struct HintSample {
-    uint8_t *data;
+    const uint8_t *data;
     int size;
     int sample_number;
     int offset;
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index aaaaa3ac7b..0169341189 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -96,7 +96,7 @@ static void sample_queue_free(HintSampleQueue *queue)
  * not copied. sample_queue_retain should be called before pkt->data
  * is reused/freed.
  */
-static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
+static void sample_queue_push(HintSampleQueue *queue, const uint8_t *data, int size,
                               int sample)
 {
     /* No need to keep track of smaller samples, since describing them
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 2d08dd6d40..9a9acbfa08 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2139,7 +2139,7 @@ static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt)
 {
     MXFContext *mxf = s->priv_data;
     MXFStreamContext *sc = st->priv_data;
-    uint8_t *vs_pack, *vsc_pack;
+    const uint8_t *vs_pack, *vsc_pack;
     int apt, ul_index, stype, pal;
 
     if (mxf->header_written)
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 016047f616..ae0705ba54 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -197,13 +197,13 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
 }
 
 static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
-                           uint8_t *data, unsigned size, int64_t granule,
+                           const uint8_t *data, unsigned size, int64_t granule,
                            int header)
 {
     OGGStreamContext *oggstream = st->priv_data;
     OGGContext *ogg = s->priv_data;
     int total_segments = size / 255 + 1;
-    uint8_t *p = data;
+    const uint8_t *p = data;
     int i, segments, len, flush = 0;
 
     // Handles VFR by flushing page because this frame needs to have a timestamp
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index 0a634e4232..7b8e231cff 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -63,7 +63,7 @@ typedef struct IEC61937Context {
     uint8_t *buffer;                ///< allocated buffer, used for swap bytes
     int buffer_size;                ///< size of allocated buffer
 
-    uint8_t *out_buf;               ///< pointer to the outgoing data before byte-swapping
+    const uint8_t *out_buf;         ///< pointer to the outgoing data before byte-swapping
     int out_bytes;                  ///< amount of outgoing bytes
 
     int use_preamble;               ///< preamble enabled (disabled for exactly pre-padded DTS)
@@ -657,7 +657,7 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
         av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
         if (!ctx->buffer)
             return AVERROR(ENOMEM);
-        ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
+        ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (const uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
         avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
     }
 
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 2c8c034c42..75b892087f 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -481,8 +481,8 @@ static int swf_write_video(AVFormatContext *s,
     return 0;
 }
 
-static int swf_write_audio(AVFormatContext *s,
-                           AVCodecParameters *par, uint8_t *buf, int size)
+static int swf_write_audio(AVFormatContext *s, AVCodecParameters *par,
+                           const uint8_t *buf, int size)
 {
     SWFEncContext *swf = s->priv_data;
 
-- 
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/4] avcodec: Add const to muxer packet data pointers
  2022-07-04 19:14 [FFmpeg-devel] [PATCH 1/4] av(format|device): Add const to muxer packet data pointers Andreas Rheinhardt
@ 2022-07-04 19:15 ` Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 3/4] fftools/ffprobe: Add const to AVPacket " Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 4/4] avformat/movenc: Ensure packet is writable before modifying it Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-07-04 19:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The packets given to decoder need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/cpia.c                | 4 ++--
 libavcodec/dfpwmdec.c            | 3 ++-
 libavcodec/hnm4video.c           | 8 ++++----
 libavcodec/libcodec2.c           | 2 +-
 libavcodec/libvpxdec.c           | 2 +-
 libavcodec/libzvbi-teletextdec.c | 2 +-
 libavcodec/pafvideo.c            | 2 +-
 libavcodec/pixlet.c              | 4 ++--
 libavcodec/webp.c                | 8 ++++----
 libavcodec/yop.c                 | 6 +++---
 10 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
index 2f4ad1fb5b..fcf2621e61 100644
--- a/libavcodec/cpia.c
+++ b/libavcodec/cpia.c
@@ -54,8 +54,8 @@ static int cpia_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
     CpiaContext* const cpia = avctx->priv_data;
     int i,j,ret;
 
-    uint8_t* const header = avpkt->data;
-    uint8_t* src;
+    const uint8_t *const header = avpkt->data;
+    const uint8_t *src;
     int src_size;
     uint16_t linelength;
     uint8_t skip;
diff --git a/libavcodec/dfpwmdec.c b/libavcodec/dfpwmdec.c
index 77c6d2cb18..d013d4c215 100644
--- a/libavcodec/dfpwmdec.c
+++ b/libavcodec/dfpwmdec.c
@@ -38,7 +38,8 @@ typedef struct {
 // DFPWM codec from https://github.com/ChenThread/dfpwm/blob/master/1a/
 // Licensed in the public domain
 
-static void au_decompress(DFPWMState *state, int fs, int len, uint8_t *outbuf, uint8_t *inbuf)
+static void au_decompress(DFPWMState *state, int fs, int len,
+                          uint8_t *outbuf, const uint8_t *inbuf)
 {
     unsigned d;
     for (int i = 0; i < len; i++) {
diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c
index 9eb9f3a694..1326d5f872 100644
--- a/libavcodec/hnm4video.c
+++ b/libavcodec/hnm4video.c
@@ -64,7 +64,7 @@ static int getbit(GetByteContext *gb, uint32_t *bitbuf, int *bits)
     return ret;
 }
 
-static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src,
+static void unpack_intraframe(AVCodecContext *avctx, const uint8_t *src,
                               uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
@@ -147,7 +147,7 @@ static void copy_processed_frame(AVCodecContext *avctx, AVFrame *frame)
     }
 }
 
-static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t size)
+static int decode_interframe_v4(AVCodecContext *avctx, const uint8_t *src, uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
     GetByteContext gb;
@@ -276,7 +276,7 @@ static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t si
     return 0;
 }
 
-static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
+static void decode_interframe_v4a(AVCodecContext *avctx, const uint8_t *src,
                                   uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
@@ -355,7 +355,7 @@ static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
     }
 }
 
-static void hnm_update_palette(AVCodecContext *avctx, uint8_t *src,
+static void hnm_update_palette(AVCodecContext *avctx, const uint8_t *src,
                                uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c
index 9064b823ee..abb1130e80 100644
--- a/libavcodec/libcodec2.c
+++ b/libavcodec/libcodec2.c
@@ -135,7 +135,7 @@ static int libcodec2_decode(AVCodecContext *avctx, AVFrame *frame,
 {
     LibCodec2Context *c2 = avctx->priv_data;
     int ret, nframes, i;
-    uint8_t *input;
+    const uint8_t *input;
     int16_t *output;
 
     nframes           = pkt->size / avctx->block_align;
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index ef690a7093..0b279e7eda 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -199,7 +199,7 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img,
 }
 
 static int decode_frame(AVCodecContext *avctx, vpx_codec_ctx_t *decoder,
-                        uint8_t *data, uint32_t data_sz)
+                        const uint8_t *data, uint32_t data_sz)
 {
     if (vpx_codec_decode(decoder, data, data_sz, NULL, 0) != VPX_CODEC_OK) {
         const char *error  = vpx_codec_error(decoder);
diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c
index 92466cc11e..514e76f1b6 100644
--- a/libavcodec/libzvbi-teletextdec.c
+++ b/libavcodec/libzvbi-teletextdec.c
@@ -581,7 +581,7 @@ static void handler(vbi_event *ev, void *user_data)
     vbi_unref_page(&page);
 }
 
-static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size)
+static int slice_to_vbi_lines(TeletextContext *ctx, const uint8_t *buf, int size)
 {
     int lines = 0;
     while (size >= 2 && lines < MAX_SLICES) {
diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c
index a0bd22e8fd..60cdd34add 100644
--- a/libavcodec/pafvideo.c
+++ b/libavcodec/pafvideo.c
@@ -159,7 +159,7 @@ static void set_src_position(PAFVideoDecContext *c,
     *pend = c->frame[page] + c->frame_size;
 }
 
-static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
+static int decode_0(PAFVideoDecContext *c, const uint8_t *pkt, uint8_t code)
 {
     uint32_t opcode_size, offset;
     uint8_t *dst, *dend, mask = 0, color = 0;
diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index 18a6587257..3174f30e91 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -198,7 +198,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size,
     return get_bits_count(bc) >> 3;
 }
 
-static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
+static int read_high_coeffs(AVCodecContext *avctx, const uint8_t *src, int16_t *dst,
                             int size, int c, int a, int d,
                             int width, ptrdiff_t stride)
 {
@@ -313,7 +313,7 @@ static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
     return get_bits_count(bc) >> 3;
 }
 
-static int read_highpass(AVCodecContext *avctx, uint8_t *ptr,
+static int read_highpass(AVCodecContext *avctx, const uint8_t *ptr,
                          int plane, AVFrame *frame)
 {
     PixletContext *ctx = avctx->priv_data;
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 1b5e943a6e..9c041d9528 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -200,7 +200,7 @@ typedef struct WebPContext {
     int has_alpha;                      /* has a separate alpha chunk */
     enum AlphaCompression alpha_compression; /* compression type for alpha chunk */
     enum AlphaFilter alpha_filter;      /* filtering method for alpha chunk */
-    uint8_t *alpha_data;                /* alpha chunk data */
+    const uint8_t *alpha_data;          /* alpha chunk data */
     int alpha_data_size;                /* alpha chunk data size */
     int has_exif;                       /* set after an EXIF chunk has been processed */
     int has_iccp;                       /* set after an ICCP chunk has been processed */
@@ -1084,7 +1084,7 @@ static void update_canvas_size(AVCodecContext *avctx, int w, int h)
 }
 
 static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
-                                     int *got_frame, uint8_t *data_start,
+                                     int *got_frame, const uint8_t *data_start,
                                      unsigned int data_size, int is_alpha_chunk)
 {
     WebPContext *s = avctx->priv_data;
@@ -1240,7 +1240,7 @@ static void alpha_inverse_prediction(AVFrame *frame, enum AlphaFilter m)
 }
 
 static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
-                                  uint8_t *data_start,
+                                  const uint8_t *data_start,
                                   unsigned int data_size)
 {
     WebPContext *s = avctx->priv_data;
@@ -1293,7 +1293,7 @@ static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
 }
 
 static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
-                                  int *got_frame, uint8_t *data_start,
+                                  int *got_frame, const uint8_t *data_start,
                                   unsigned int data_size)
 {
     WebPContext *s = avctx->priv_data;
diff --git a/libavcodec/yop.c b/libavcodec/yop.c
index 5befbb072e..7a11ca77b8 100644
--- a/libavcodec/yop.c
+++ b/libavcodec/yop.c
@@ -40,9 +40,9 @@ typedef struct YopDecContext {
     int first_color[2];
     int frame_data_length;
 
-    uint8_t *low_nibble;
-    uint8_t *srcptr;
-    uint8_t *src_end;
+    const uint8_t *low_nibble;
+    const uint8_t *srcptr;
+    const uint8_t *src_end;
     uint8_t *dstptr;
     uint8_t *dstbuf;
 } YopDecContext;
-- 
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 3/4] fftools/ffprobe: Add const to AVPacket data pointers
  2022-07-04 19:14 [FFmpeg-devel] [PATCH 1/4] av(format|device): Add const to muxer packet data pointers Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 2/4] avcodec: " Andreas Rheinhardt
@ 2022-07-04 19:15 ` Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 4/4] avformat/movenc: Ensure packet is writable before modifying it Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-07-04 19:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

These packets need not be writable (and are not modified by us),
so it is best to access them via const uint8_t*.

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

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 5020ba484c..2f110efcb7 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -901,7 +901,7 @@ static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, in
 }
 
 static void writer_print_data(WriterContext *wctx, const char *name,
-                              uint8_t *data, int size)
+                              const uint8_t *data, int size)
 {
     AVBPrint bp;
     int offset = 0, l, i;
@@ -929,7 +929,7 @@ static void writer_print_data(WriterContext *wctx, const char *name,
 }
 
 static void writer_print_data_hash(WriterContext *wctx, const char *name,
-                                   uint8_t *data, int size)
+                                   const uint8_t *data, int size)
 {
     char *p, buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };
 
-- 
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 4/4] avformat/movenc: Ensure packet is writable before modifying it
  2022-07-04 19:14 [FFmpeg-devel] [PATCH 1/4] av(format|device): Add const to muxer packet data pointers Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 2/4] avcodec: " Andreas Rheinhardt
  2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 3/4] fftools/ffprobe: Add const to AVPacket " Andreas Rheinhardt
@ 2022-07-04 19:15 ` Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-07-04 19:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Fixes e.g.

ffmpeg -i fate-suite/h264/bbc2.sample.h264 -c:v rawvideo -map 0:v -frames:v 10 -pix_fmt gray8 -f tee "first.mov|second.mov"

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/movenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a4dace7c1d..5608afde42 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6513,6 +6513,9 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
             } else if (trk->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
                        (trk->par->format == AV_PIX_FMT_GRAY8 ||
                        trk->par->format == AV_PIX_FMT_MONOBLACK)) {
+                ret = av_packet_make_writable(pkt);
+                if (ret < 0)
+                    goto fail;
                 for (i = 0; i < pkt->size; i++)
                     pkt->data[i] = ~pkt->data[i];
             }
-- 
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-04 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 19:14 [FFmpeg-devel] [PATCH 1/4] av(format|device): Add const to muxer packet data pointers Andreas Rheinhardt
2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 2/4] avcodec: " Andreas Rheinhardt
2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 3/4] fftools/ffprobe: Add const to AVPacket " Andreas Rheinhardt
2022-07-04 19:15 ` [FFmpeg-devel] [PATCH 4/4] avformat/movenc: Ensure packet is writable before modifying it Andreas Rheinhardt

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