av(format|device): Add const to muxer packet data pointers

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>
This commit is contained in:
Andreas Rheinhardt 2022-07-04 18:08:14 +02:00
parent 417554bdd6
commit d5a0eba8a2
12 changed files with 16 additions and 15 deletions

View File

@ -86,7 +86,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
AlsaData *s = s1->priv_data; AlsaData *s = s1->priv_data;
int res; int res;
int size = pkt->size; int size = pkt->size;
uint8_t *buf = pkt->data; const uint8_t *buf = pkt->data;
size /= s->frame_size; size /= s->frame_size;
if (pkt->dts != AV_NOPTS_VALUE) if (pkt->dts != AV_NOPTS_VALUE)

View File

@ -100,7 +100,8 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt) static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
{ {
FBDevContext *fbdev = h->priv_data; FBDevContext *fbdev = h->priv_data;
uint8_t *pin, *pout; const uint8_t *pin;
uint8_t *pout;
enum AVPixelFormat fb_pix_fmt; enum AVPixelFormat fb_pix_fmt;
int disp_height; int disp_height;
int bytes_to_copy; int bytes_to_copy;

View File

@ -55,9 +55,9 @@ static int audio_write_header(AVFormatContext *s1)
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{ {
OSSAudioData *s = s1->priv_data; OSSAudioData *s = s1->priv_data;
const uint8_t *buf = pkt->data;
int len, ret; int len, ret;
int size= pkt->size; int size= pkt->size;
uint8_t *buf= pkt->data;
while (size > 0) { while (size > 0) {
len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size); len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);

View File

@ -46,7 +46,7 @@ static av_cold int audio_write_header(AVFormatContext *s1)
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{ {
SndioData *s = s1->priv_data; SndioData *s = s1->priv_data;
uint8_t *buf= pkt->data; const uint8_t *buf = pkt->data;
int size = pkt->size; int size = pkt->size;
int len, ret; int len, ret;

View File

@ -245,7 +245,7 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame)
static int dv_assemble_frame(AVFormatContext *s, static int dv_assemble_frame(AVFormatContext *s,
DVMuxContext *c, AVStream* st, 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; int i, reqasize;

View File

@ -54,7 +54,7 @@ static int gif_write_header(AVFormatContext *s)
return 0; 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; GetByteContext gb;
int x; int x;

View File

@ -62,7 +62,7 @@ typedef struct MOVIentry {
} MOVIentry; } MOVIentry;
typedef struct HintSample { typedef struct HintSample {
uint8_t *data; const uint8_t *data;
int size; int size;
int sample_number; int sample_number;
int offset; int offset;

View File

@ -96,7 +96,7 @@ static void sample_queue_free(HintSampleQueue *queue)
* not copied. sample_queue_retain should be called before pkt->data * not copied. sample_queue_retain should be called before pkt->data
* is reused/freed. * 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) int sample)
{ {
/* No need to keep track of smaller samples, since describing them /* No need to keep track of smaller samples, since describing them

View File

@ -2139,7 +2139,7 @@ static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{ {
MXFContext *mxf = s->priv_data; MXFContext *mxf = s->priv_data;
MXFStreamContext *sc = st->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; int apt, ul_index, stype, pal;
if (mxf->header_written) if (mxf->header_written)

View File

@ -197,13 +197,13 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
} }
static int ogg_buffer_data(AVFormatContext *s, AVStream *st, 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) int header)
{ {
OGGStreamContext *oggstream = st->priv_data; OGGStreamContext *oggstream = st->priv_data;
OGGContext *ogg = s->priv_data; OGGContext *ogg = s->priv_data;
int total_segments = size / 255 + 1; int total_segments = size / 255 + 1;
uint8_t *p = data; const uint8_t *p = data;
int i, segments, len, flush = 0; int i, segments, len, flush = 0;
// Handles VFR by flushing page because this frame needs to have a timestamp // Handles VFR by flushing page because this frame needs to have a timestamp

View File

@ -63,7 +63,7 @@ typedef struct IEC61937Context {
uint8_t *buffer; ///< allocated buffer, used for swap bytes uint8_t *buffer; ///< allocated buffer, used for swap bytes
int buffer_size; ///< size of allocated buffer 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 out_bytes; ///< amount of outgoing bytes
int use_preamble; ///< preamble enabled (disabled for exactly pre-padded DTS) 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); av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->buffer) if (!ctx->buffer)
return AVERROR(ENOMEM); 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); avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
} }

View File

@ -481,8 +481,8 @@ static int swf_write_video(AVFormatContext *s,
return 0; return 0;
} }
static int swf_write_audio(AVFormatContext *s, static int swf_write_audio(AVFormatContext *s, AVCodecParameters *par,
AVCodecParameters *par, uint8_t *buf, int size) const uint8_t *buf, int size)
{ {
SWFEncContext *swf = s->priv_data; SWFEncContext *swf = s->priv_data;