Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>tags/n2.8
@@ -1732,7 +1732,7 @@ static int transcode_init(void) | |||||
av_assert0(ist && !ost->filter); | av_assert0(ist && !ost->filter); | ||||
extra_size = (uint64_t)dec_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; | |||||
extra_size = (uint64_t)dec_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE; | |||||
if (extra_size > INT_MAX) { | if (extra_size > INT_MAX) { | ||||
return AVERROR(EINVAL); | return AVERROR(EINVAL); | ||||
@@ -226,7 +226,7 @@ static void audio_decode_example(const char *outfilename, const char *filename) | |||||
AVCodecContext *c= NULL; | AVCodecContext *c= NULL; | ||||
int len; | int len; | ||||
FILE *f, *outfile; | FILE *f, *outfile; | ||||
uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
AVPacket avpkt; | AVPacket avpkt; | ||||
AVFrame *decoded_frame = NULL; | AVFrame *decoded_frame = NULL; | ||||
@@ -459,14 +459,14 @@ static void video_decode_example(const char *outfilename, const char *filename) | |||||
int frame, got_picture, len; | int frame, got_picture, len; | ||||
FILE *f; | FILE *f; | ||||
AVFrame *picture; | AVFrame *picture; | ||||
uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
char buf[1024]; | char buf[1024]; | ||||
AVPacket avpkt; | AVPacket avpkt; | ||||
av_init_packet(&avpkt); | av_init_packet(&avpkt); | ||||
/* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */ | /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */ | ||||
memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
printf("Video decoding\n"); | printf("Video decoding\n"); | ||||
@@ -405,7 +405,7 @@ int main(int argc, char **argv) | |||||
decoder_ctx->codec_id = AV_CODEC_ID_H264; | decoder_ctx->codec_id = AV_CODEC_ID_H264; | ||||
if (video_st->codec->extradata_size) { | if (video_st->codec->extradata_size) { | ||||
decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size + | decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!decoder_ctx->extradata) { | if (!decoder_ctx->extradata) { | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
goto finish; | goto finish; | ||||
@@ -446,13 +446,13 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length) | |||||
} | } | ||||
av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, | av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, | ||||
bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
bitstream_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!f->bitstream_buffer) | if (!f->bitstream_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
f->bbdsp.bswap_buf(f->bitstream_buffer, (const uint32_t *) (buf + extra), | f->bbdsp.bswap_buf(f->bitstream_buffer, (const uint32_t *) (buf + extra), | ||||
bitstream_size / 4); | bitstream_size / 4); | ||||
memset((uint8_t*)f->bitstream_buffer + bitstream_size, | memset((uint8_t*)f->bitstream_buffer + bitstream_size, | ||||
0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
init_get_bits(&f->gb, f->bitstream_buffer, 8 * bitstream_size); | init_get_bits(&f->gb, f->bitstream_buffer, 8 * bitstream_size); | ||||
wordstream_offset = extra + bitstream_size; | wordstream_offset = extra + bitstream_size; | ||||
@@ -769,13 +769,13 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length) | |||||
prestream_size = length + buf - prestream; | prestream_size = length + buf - prestream; | ||||
av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, | av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, | ||||
prestream_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
prestream_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!f->bitstream_buffer) | if (!f->bitstream_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
f->bbdsp.bswap_buf(f->bitstream_buffer, (const uint32_t *) prestream, | f->bbdsp.bswap_buf(f->bitstream_buffer, (const uint32_t *) prestream, | ||||
prestream_size / 4); | prestream_size / 4); | ||||
memset((uint8_t*)f->bitstream_buffer + prestream_size, | memset((uint8_t*)f->bitstream_buffer + prestream_size, | ||||
0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
init_get_bits(&f->pre_gb, f->bitstream_buffer, 8 * prestream_size); | init_get_bits(&f->pre_gb, f->bitstream_buffer, 8 * prestream_size); | ||||
f->last_dc = 0 * 128 * 8 * 8; | f->last_dc = 0 * 128 * 8 * 8; | ||||
@@ -849,7 +849,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, | |||||
cfrm = &f->cfrm[i]; | cfrm = &f->cfrm[i]; | ||||
cfrm->data = av_fast_realloc(cfrm->data, &cfrm->allocated_size, | cfrm->data = av_fast_realloc(cfrm->data, &cfrm->allocated_size, | ||||
cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
cfrm->size + data_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
// explicit check needed as memcpy below might not catch a NULL | // explicit check needed as memcpy below might not catch a NULL | ||||
if (!cfrm->data) { | if (!cfrm->data) { | ||||
av_log(f->avctx, AV_LOG_ERROR, "realloc failure"); | av_log(f->avctx, AV_LOG_ERROR, "realloc failure"); | ||||
@@ -209,7 +209,7 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx) | |||||
} | } | ||||
/* set up extradata */ | /* set up extradata */ | ||||
if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) { | |||||
if (!(avctx->extradata = av_mallocz(8 * 4 + AV_INPUT_BUFFER_PADDING_SIZE))) { | |||||
av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n"); | av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n"); | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
} | } | ||||
@@ -88,7 +88,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc, | |||||
buf += get_bits_count(&gb)/8; | buf += get_bits_count(&gb)/8; | ||||
} | } | ||||
avctx->extradata_size = 2 + pce_size; | avctx->extradata_size = 2 + pce_size; | ||||
avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -34,7 +34,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, | |||||
int size; | int size; | ||||
union { | union { | ||||
uint64_t u64; | uint64_t u64; | ||||
uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
uint8_t u8[8 + AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
} tmp; | } tmp; | ||||
tmp.u64 = av_be2ne64(state); | tmp.u64 = av_be2ne64(state); | ||||
@@ -2969,7 +2969,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, | |||||
if (new_extradata) { | if (new_extradata) { | ||||
av_free(avctx->extradata); | av_free(avctx->extradata); | ||||
avctx->extradata = av_mallocz(new_extradata_size + | avctx->extradata = av_mallocz(new_extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
avctx->extradata_size = new_extradata_size; | avctx->extradata_size = new_extradata_size; | ||||
@@ -3089,14 +3089,14 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, | |||||
if (avctx->extradata_size < esize) { | if (avctx->extradata_size < esize) { | ||||
av_free(avctx->extradata); | av_free(avctx->extradata); | ||||
avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_malloc(esize + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
} | } | ||||
avctx->extradata_size = esize; | avctx->extradata_size = esize; | ||||
memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); | memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); | ||||
memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(avctx->extradata+esize, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
} | } | ||||
skip_bits_long(gb, bits_consumed); | skip_bits_long(gb, bits_consumed); | ||||
@@ -711,7 +711,7 @@ static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s) | |||||
int ch; | int ch; | ||||
FF_ALLOCZ_OR_GOTO(avctx, s->buffer.samples, 3 * 1024 * s->channels * sizeof(s->buffer.samples[0]), alloc_fail); | FF_ALLOCZ_OR_GOTO(avctx, s->buffer.samples, 3 * 1024 * s->channels * sizeof(s->buffer.samples[0]), alloc_fail); | ||||
FF_ALLOCZ_OR_GOTO(avctx, s->cpe, sizeof(ChannelElement) * s->chan_map[0], alloc_fail); | FF_ALLOCZ_OR_GOTO(avctx, s->cpe, sizeof(ChannelElement) * s->chan_map[0], alloc_fail); | ||||
FF_ALLOCZ_OR_GOTO(avctx, avctx->extradata, 5 + FF_INPUT_BUFFER_PADDING_SIZE, alloc_fail); | |||||
FF_ALLOCZ_OR_GOTO(avctx, avctx->extradata, 5 + AV_INPUT_BUFFER_PADDING_SIZE, alloc_fail); | |||||
for(ch = 0; ch < s->channels; ch++) | for(ch = 0; ch < s->channels; ch++) | ||||
s->planar_samples[ch] = s->buffer.samples + 3 * 1024 * ch; | s->planar_samples[ch] = s->buffer.samples + 3 * 1024 * ch; | ||||
@@ -150,7 +150,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, | |||||
int err; | int err; | ||||
union { | union { | ||||
uint64_t u64; | uint64_t u64; | ||||
uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
uint8_t u8[8 + AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
} tmp = { av_be2ne64(state) }; | } tmp = { av_be2ne64(state) }; | ||||
AC3HeaderInfo hdr; | AC3HeaderInfo hdr; | ||||
GetBitContext gbc; | GetBitContext gbc; | ||||
@@ -217,7 +217,7 @@ typedef struct AC3DecodeContext { | |||||
DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients | DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients | ||||
DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing | DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing | ||||
DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing | DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing | ||||
DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread | |||||
DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread | |||||
///@} | ///@} | ||||
} AC3DecodeContext; | } AC3DecodeContext; | ||||
@@ -111,7 +111,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) | |||||
avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / | avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / | ||||
avctx->channels + 2; | avctx->channels + 2; | ||||
avctx->block_align = BLKSIZE; | avctx->block_align = BLKSIZE; | ||||
if (!(avctx->extradata = av_malloc(32 + FF_INPUT_BUFFER_PADDING_SIZE))) | |||||
if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE))) | |||||
goto error; | goto error; | ||||
avctx->extradata_size = 32; | avctx->extradata_size = 32; | ||||
extradata = avctx->extradata; | extradata = avctx->extradata; | ||||
@@ -519,7 +519,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) | |||||
avctx->channels, | avctx->channels, | ||||
avctx->bits_per_raw_sample); | avctx->bits_per_raw_sample); | ||||
avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
goto error; | goto error; | ||||
@@ -223,7 +223,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
if (!pkt->data && | if (!pkt->data && | ||||
(ret = av_new_packet(pkt, a->mb_height * a->mb_width * MAX_MB_SIZE + | (ret = av_new_packet(pkt, a->mb_height * a->mb_width * MAX_MB_SIZE + | ||||
FF_MIN_BUFFER_SIZE)) < 0) { | |||||
AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -879,7 +879,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) | |||||
return AVERROR(EINVAL); | return AVERROR(EINVAL); | ||||
q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) + | q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!q->decoded_bytes_buffer) | if (!q->decoded_bytes_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -535,15 +535,24 @@ typedef struct AVCodecDescriptor { | |||||
* Note: If the first 23 bits of the additional bytes are not 0, then damaged | * Note: If the first 23 bits of the additional bytes are not 0, then damaged | ||||
* MPEG bitstreams could cause overread and segfault. | * MPEG bitstreams could cause overread and segfault. | ||||
*/ | */ | ||||
#define FF_INPUT_BUFFER_PADDING_SIZE 8 | |||||
#define AV_INPUT_BUFFER_PADDING_SIZE 8 | |||||
/** | /** | ||||
* @ingroup lavc_encoding | * @ingroup lavc_encoding | ||||
* minimum encoding buffer size | * minimum encoding buffer size | ||||
* Used to avoid some checks during header writing. | * Used to avoid some checks during header writing. | ||||
*/ | */ | ||||
#define FF_MIN_BUFFER_SIZE 16384 | |||||
#define AV_INPUT_BUFFER_MIN_SIZE 16384 | |||||
/** | |||||
* @deprecated use AV_INPUT_BUFFER_PADDING_SIZE instead | |||||
*/ | |||||
#define FF_INPUT_BUFFER_PADDING_SIZE 8 | |||||
/** | |||||
* @deprecated use AV_INPUT_BUFFER_MIN_SIZE instead | |||||
*/ | |||||
#define FF_MIN_BUFFER_SIZE 16384 | |||||
/** | /** | ||||
* @ingroup lavc_encoding | * @ingroup lavc_encoding | ||||
@@ -1362,7 +1371,7 @@ typedef struct AVCodecContext { | |||||
* mjpeg: Huffman tables | * mjpeg: Huffman tables | ||||
* rv10: additional flags | * rv10: additional flags | ||||
* mpeg4: global headers (they can be in the bitstream or here) | * mpeg4: global headers (they can be in the bitstream or here) | ||||
* The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger | |||||
* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger | |||||
* than extradata_size to avoid prolems if it is read with the bitstream reader. | * than extradata_size to avoid prolems if it is read with the bitstream reader. | ||||
* The bytewise contents of extradata must not depend on the architecture or CPU endianness. | * The bytewise contents of extradata must not depend on the architecture or CPU endianness. | ||||
* - encoding: Set/allocated/freed by libavcodec. | * - encoding: Set/allocated/freed by libavcodec. | ||||
@@ -3627,7 +3636,7 @@ int av_grow_packet(AVPacket *pkt, int grow_by); | |||||
* function returns successfully, the data is owned by the underlying AVBuffer. | * function returns successfully, the data is owned by the underlying AVBuffer. | ||||
* The caller may not access the data through other means. | * The caller may not access the data through other means. | ||||
* @param size size of data in bytes, without the padding. I.e. the full buffer | * @param size size of data in bytes, without the padding. I.e. the full buffer | ||||
* size is assumed to be size + FF_INPUT_BUFFER_PADDING_SIZE. | |||||
* size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. | |||||
* | * | ||||
* @return 0 on success, a negative AVERROR on error | * @return 0 on success, a negative AVERROR on error | ||||
*/ | */ | ||||
@@ -3843,7 +3852,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, | |||||
* returning samples. It is safe to flush even those decoders that are not | * returning samples. It is safe to flush even those decoders that are not | ||||
* marked with AV_CODEC_CAP_DELAY, then no samples will be returned. | * marked with AV_CODEC_CAP_DELAY, then no samples will be returned. | ||||
* | * | ||||
* @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE | |||||
* @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE | |||||
* larger than the actual read bytes because some optimized bitstream | * larger than the actual read bytes because some optimized bitstream | ||||
* readers read 32 or 64 bits at once and could read over the end. | * readers read 32 or 64 bits at once and could read over the end. | ||||
* | * | ||||
@@ -3883,7 +3892,7 @@ int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, | |||||
* Some decoders may support multiple frames in a single AVPacket, such | * Some decoders may support multiple frames in a single AVPacket, such | ||||
* decoders would then just decode the first frame. | * decoders would then just decode the first frame. | ||||
* | * | ||||
* @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than | |||||
* @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than | |||||
* the actual read bytes because some optimized bitstream readers read 32 or 64 | * the actual read bytes because some optimized bitstream readers read 32 or 64 | ||||
* bits at once and could read over the end. | * bits at once and could read over the end. | ||||
* | * | ||||
@@ -4612,7 +4621,7 @@ AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f); | |||||
* Allocate a buffer with padding, reusing the given one if large enough. | * Allocate a buffer with padding, reusing the given one if large enough. | ||||
* | * | ||||
* Same behaviour av_fast_malloc but the buffer has additional | * Same behaviour av_fast_malloc but the buffer has additional | ||||
* FF_INPUT_PADDING_SIZE at the end which will always memset to 0. | |||||
* AV_INPUT_PADDING_SIZE at the end which will always memset to 0. | |||||
* | * | ||||
*/ | */ | ||||
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); | void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); | ||||
@@ -66,14 +66,14 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||
static int packet_alloc(AVBufferRef **buf, int size) | static int packet_alloc(AVBufferRef **buf, int size) | ||||
{ | { | ||||
int ret; | int ret; | ||||
if ((unsigned)size >= (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE) | |||||
if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE) | |||||
return AVERROR(EINVAL); | return AVERROR(EINVAL); | ||||
ret = av_buffer_realloc(buf, size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
ret = av_buffer_realloc(buf, size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (ret < 0) | if (ret < 0) | ||||
return ret; | return ret; | ||||
memset((*buf)->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -103,20 +103,20 @@ void av_shrink_packet(AVPacket *pkt, int size) | |||||
if (pkt->size <= size) | if (pkt->size <= size) | ||||
return; | return; | ||||
pkt->size = size; | pkt->size = size; | ||||
memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
} | } | ||||
int av_grow_packet(AVPacket *pkt, int grow_by) | int av_grow_packet(AVPacket *pkt, int grow_by) | ||||
{ | { | ||||
int new_size; | int new_size; | ||||
av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE); | |||||
av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!pkt->size) | if (!pkt->size) | ||||
return av_new_packet(pkt, grow_by); | return av_new_packet(pkt, grow_by); | ||||
if ((unsigned)grow_by > | if ((unsigned)grow_by > | ||||
INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE)) | |||||
INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE)) | |||||
return -1; | return -1; | ||||
new_size = pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE; | |||||
new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE; | |||||
if (pkt->buf) { | if (pkt->buf) { | ||||
int ret = av_buffer_realloc(&pkt->buf, new_size); | int ret = av_buffer_realloc(&pkt->buf, new_size); | ||||
if (ret < 0) | if (ret < 0) | ||||
@@ -134,17 +134,17 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||
} | } | ||||
pkt->data = pkt->buf->data; | pkt->data = pkt->buf->data; | ||||
pkt->size += grow_by; | pkt->size += grow_by; | ||||
memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
return 0; | return 0; | ||||
} | } | ||||
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size) | int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size) | ||||
{ | { | ||||
if (size >= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) | |||||
if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) | |||||
return AVERROR(EINVAL); | return AVERROR(EINVAL); | ||||
pkt->buf = av_buffer_create(data, size + FF_INPUT_BUFFER_PADDING_SIZE, | |||||
pkt->buf = av_buffer_create(data, size + AV_INPUT_BUFFER_PADDING_SIZE, | |||||
av_buffer_default_free, NULL, 0); | av_buffer_default_free, NULL, 0); | ||||
if (!pkt->buf) | if (!pkt->buf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -172,9 +172,9 @@ do { \ | |||||
void *data; \ | void *data; \ | ||||
if (padding) { \ | if (padding) { \ | ||||
if ((unsigned)(size) > \ | if ((unsigned)(size) > \ | ||||
(unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \ | |||||
(unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \ | |||||
goto failed_alloc; \ | goto failed_alloc; \ | ||||
ALLOC(data, size + FF_INPUT_BUFFER_PADDING_SIZE); \ | |||||
ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \ | |||||
} else { \ | } else { \ | ||||
ALLOC(data, size); \ | ALLOC(data, size); \ | ||||
} \ | } \ | ||||
@@ -183,7 +183,7 @@ do { \ | |||||
memcpy(data, src, size); \ | memcpy(data, src, size); \ | ||||
if (padding) \ | if (padding) \ | ||||
memset((uint8_t *)data + size, 0, \ | memset((uint8_t *)data + size, 0, \ | ||||
FF_INPUT_BUFFER_PADDING_SIZE); \ | |||||
AV_INPUT_BUFFER_PADDING_SIZE); \ | |||||
dst = data; \ | dst = data; \ | ||||
} while (0) | } while (0) | ||||
@@ -266,7 +266,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, | |||||
if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data)) | if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data)) | ||||
return NULL; | return NULL; | ||||
if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) | |||||
if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) | |||||
return NULL; | return NULL; | ||||
pkt->side_data = av_realloc(pkt->side_data, | pkt->side_data = av_realloc(pkt->side_data, | ||||
@@ -274,7 +274,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, | |||||
if (!pkt->side_data) | if (!pkt->side_data) | ||||
return NULL; | return NULL; | ||||
pkt->side_data[elems].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
pkt->side_data[elems].data = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!pkt->side_data[elems].data) | if (!pkt->side_data[elems].data) | ||||
return NULL; | return NULL; | ||||
pkt->side_data[elems].size = size; | pkt->side_data[elems].size = size; | ||||
@@ -302,7 +302,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, | |||||
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); | av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); | ||||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
} | } | ||||
buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
buf = av_realloc(s->packet_buffer, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!buf) | if (!buf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
s->packet_buffer = buf; | s->packet_buffer = buf; | ||||
@@ -263,7 +263,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, | |||||
if (encoding) { | if (encoding) { | ||||
av_fast_padded_malloc(&c->new_video, &c->new_video_size, | av_fast_padded_malloc(&c->new_video, &c->new_video_size, | ||||
h * w + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
h * w + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!c->new_video) | if (!c->new_video) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
if (c->bpp == 8) | if (c->bpp == 8) | ||||
@@ -1213,11 +1213,11 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) | |||||
/* Pad the databuffer with: | /* Pad the databuffer with: | ||||
DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), | DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), | ||||
FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ | |||||
AV_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ | |||||
q->decoded_bytes_buffer = | q->decoded_bytes_buffer = | ||||
av_mallocz(avctx->block_align | av_mallocz(avctx->block_align | ||||
+ DECODE_BYTES_PAD1(avctx->block_align) | + DECODE_BYTES_PAD1(avctx->block_align) | ||||
+ FF_INPUT_BUFFER_PADDING_SIZE); | |||||
+ AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!q->decoded_bytes_buffer) | if (!q->decoded_bytes_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -113,7 +113,7 @@ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, | |||||
int *sample_rate, int *framesize) | int *sample_rate, int *framesize) | ||||
{ | { | ||||
GetBitContext gb; | GetBitContext gb; | ||||
uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 }; | |||||
uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; | |||||
int ret, sample_blocks, sr_code; | int ret, sample_blocks, sr_code; | ||||
if (buf_size < 12) | if (buf_size < 12) | ||||
@@ -65,7 +65,7 @@ typedef struct DssSpContext { | |||||
int pulse_dec_mode; | int pulse_dec_mode; | ||||
DECLARE_ALIGNED(16, uint8_t, bits)[DSS_SP_FRAME_SIZE + | DECLARE_ALIGNED(16, uint8_t, bits)[DSS_SP_FRAME_SIZE + | ||||
FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
} DssSpContext; | } DssSpContext; | ||||
/* | /* | ||||
@@ -36,12 +36,12 @@ static int dump_extradata(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, | |||||
/*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ | /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ | ||||
int size= buf_size + avctx->extradata_size; | int size= buf_size + avctx->extradata_size; | ||||
*poutbuf_size= size; | *poutbuf_size= size; | ||||
*poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf= av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); | memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); | ||||
memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
return 1; | return 1; | ||||
} | } | ||||
} | } | ||||
@@ -167,8 +167,8 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) | |||||
GetBitContext gb; | GetBitContext gb; | ||||
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; | BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; | ||||
LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]); | LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]); | ||||
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ | |||||
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ | |||||
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ | |||||
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ | |||||
const int log2_blocksize = 3; | const int log2_blocksize = 3; | ||||
int is_field_mode[5]; | int is_field_mode[5]; | ||||
@@ -940,7 +940,7 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * | if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * | ||||
((8 * 2 + 1 + 1) * 4) / 8 + | ((8 * 2 + 1 + 1) * 4) / 8 + | ||||
FF_MIN_BUFFER_SIZE)) < 0) { | |||||
AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -294,10 +294,10 @@ static int jpg_decode_data(JPGContext *c, int width, int height, | |||||
const int ridx = swapuv ? 2 : 0; | const int ridx = swapuv ? 2 : 0; | ||||
if ((ret = av_reallocp(&c->buf, | if ((ret = av_reallocp(&c->buf, | ||||
src_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) | |||||
src_size + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) | |||||
return ret; | return ret; | ||||
jpg_unescape(src, src_size, c->buf, &unesc_size); | jpg_unescape(src, src_size, c->buf, &unesc_size); | ||||
memset(c->buf + unesc_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(c->buf + unesc_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
init_get_bits(&gb, c->buf, unesc_size * 8); | init_get_bits(&gb, c->buf, unesc_size * 8); | ||||
width = FFALIGN(width, 16); | width = FFALIGN(width, 16); | ||||
@@ -1170,7 +1170,7 @@ static int g2m_init_buffers(G2MContext *c) | |||||
c->synth_tile = av_mallocz(c->tile_stride * aligned_height); | c->synth_tile = av_mallocz(c->tile_stride * aligned_height); | ||||
c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height); | c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height); | ||||
c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height + | c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
c->kempf_flags = av_mallocz(c->tile_width * aligned_height); | c->kempf_flags = av_mallocz(c->tile_width * aligned_height); | ||||
if (!c->synth_tile || !c->jpeg_tile || | if (!c->synth_tile || !c->jpeg_tile || | ||||
!c->kempf_buf || !c->kempf_flags) | !c->kempf_buf || !c->kempf_flags) | ||||
@@ -367,7 +367,7 @@ static inline int check_marker(GetBitContext *s, const char *msg) | |||||
/** | /** | ||||
* Initialize GetBitContext. | * Initialize GetBitContext. | ||||
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes | |||||
* @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes | |||||
* larger than the actual read bits because some optimized bitstream | * larger than the actual read bits because some optimized bitstream | ||||
* readers read 32 or 64 bit at once and could read over the end | * readers read 32 or 64 bit at once and could read over the end | ||||
* @param bit_size the size of the buffer in bits | * @param bit_size the size of the buffer in bits | ||||
@@ -400,7 +400,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, | |||||
/** | /** | ||||
* Initialize GetBitContext. | * Initialize GetBitContext. | ||||
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes | |||||
* @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes | |||||
* larger than the actual read bits because some optimized bitstream | * larger than the actual read bits because some optimized bitstream | ||||
* readers read 32 or 64 bit at once and could read over the end | * readers read 32 or 64 bit at once and could read over the end | ||||
* @param byte_size the size of the buffer in bytes | * @param byte_size the size of the buffer in bytes | ||||
@@ -153,7 +153,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
uint8_t *outbuf_ptr, *end; | uint8_t *outbuf_ptr, *end; | ||||
int ret; | int ret; | ||||
if ((ret = ff_alloc_packet(pkt, avctx->width*avctx->height*7/5 + FF_MIN_BUFFER_SIZE)) < 0) { | |||||
if ((ret = ff_alloc_packet(pkt, avctx->width*avctx->height*7/5 + AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -275,7 +275,7 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, H264SliceContext *sl, | |||||
} | } | ||||
av_fast_malloc(&sl->rbsp_buffer, &sl->rbsp_buffer_size, | av_fast_malloc(&sl->rbsp_buffer, &sl->rbsp_buffer_size, | ||||
length + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
length + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
dst = sl->rbsp_buffer; | dst = sl->rbsp_buffer; | ||||
if (!dst) | if (!dst) | ||||
@@ -304,7 +304,7 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, H264SliceContext *sl, | |||||
dst[di++] = src[si++]; | dst[di++] = src[si++]; | ||||
nsc: | nsc: | ||||
memset(dst + di, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
*dst_length = di; | *dst_length = di; | ||||
*consumed = si + 1; // +1 for the header | *consumed = si + 1; // +1 for the header | ||||
@@ -41,7 +41,7 @@ static int alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, | |||||
*poutbuf_size += sps_pps_size + in_size + nal_header_size; | *poutbuf_size += sps_pps_size + in_size + nal_header_size; | ||||
if ((err = av_reallocp(poutbuf, | if ((err = av_reallocp(poutbuf, | ||||
*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) { | |||||
*poutbuf_size + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { | |||||
*poutbuf_size = 0; | *poutbuf_size = 0; | ||||
return err; | return err; | ||||
} | } | ||||
@@ -109,7 +109,7 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding) | |||||
} | } | ||||
if (out) | if (out) | ||||
memset(out + total_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(out + total_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!sps_seen) | if (!sps_seen) | ||||
av_log(avctx, AV_LOG_WARNING, | av_log(avctx, AV_LOG_WARNING, | ||||
@@ -150,7 +150,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, | |||||
/* retrieve sps and pps NAL units from extradata */ | /* retrieve sps and pps NAL units from extradata */ | ||||
if (!ctx->extradata_parsed) { | if (!ctx->extradata_parsed) { | ||||
ret = h264_extradata_to_annexb(avctx, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
ret = h264_extradata_to_annexb(avctx, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (ret < 0) | if (ret < 0) | ||||
return ret; | return ret; | ||||
ctx->length_size = ret; | ctx->length_size = ret; | ||||
@@ -67,18 +67,18 @@ static int hevc_extradata_to_annexb(AVCodecContext *avctx) | |||||
for (j = 0; j < cnt; j++) { | for (j = 0; j < cnt; j++) { | ||||
int nalu_len = bytestream2_get_be16(&gb); | int nalu_len = bytestream2_get_be16(&gb); | ||||
if (4 + FF_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { | |||||
if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { | |||||
ret = AVERROR_INVALIDDATA; | ret = AVERROR_INVALIDDATA; | ||||
goto fail; | goto fail; | ||||
} | } | ||||
ret = av_reallocp(&new_extradata, new_extradata_size + nalu_len + 4 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
ret = av_reallocp(&new_extradata, new_extradata_size + nalu_len + 4 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (ret < 0) | if (ret < 0) | ||||
goto fail; | goto fail; | ||||
AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode | AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode | ||||
bytestream2_get_buffer(&gb, new_extradata + new_extradata_size + 4, nalu_len); | bytestream2_get_buffer(&gb, new_extradata + new_extradata_size + 4, nalu_len); | ||||
new_extradata_size += 4 + nalu_len; | new_extradata_size += 4 + nalu_len; | ||||
memset(new_extradata + new_extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(new_extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
} | } | ||||
} | } | ||||
@@ -89,7 +89,7 @@ int ff_hevc_extract_rbsp(const uint8_t *src, int length, | |||||
} | } | ||||
av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, | av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, | ||||
length + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
length + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!nal->rbsp_buffer) | if (!nal->rbsp_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -119,7 +119,7 @@ int ff_hevc_extract_rbsp(const uint8_t *src, int length, | |||||
dst[di++] = src[si++]; | dst[di++] = src[si++]; | ||||
nsc: | nsc: | ||||
memset(dst + di, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
nal->data = dst; | nal->data = dst; | ||||
nal->size = di; | nal->size = di; | ||||
@@ -35,14 +35,14 @@ | |||||
#include "thread.h" | #include "thread.h" | ||||
#define classic_shift_luma_table_size 42 | #define classic_shift_luma_table_size 42 | ||||
static const unsigned char classic_shift_luma[classic_shift_luma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = { | |||||
static const unsigned char classic_shift_luma[classic_shift_luma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = { | |||||
34, 36, 35, 69, 135, 232, 9, 16, 10, 24, 11, 23, 12, 16, 13, 10, | 34, 36, 35, 69, 135, 232, 9, 16, 10, 24, 11, 23, 12, 16, 13, 10, | ||||
14, 8, 15, 8, 16, 8, 17, 20, 16, 10, 207, 206, 205, 236, 11, 8, | 14, 8, 15, 8, 16, 8, 17, 20, 16, 10, 207, 206, 205, 236, 11, 8, | ||||
10, 21, 9, 23, 8, 8, 199, 70, 69, 68, 0 | 10, 21, 9, 23, 8, 8, 199, 70, 69, 68, 0 | ||||
}; | }; | ||||
#define classic_shift_chroma_table_size 59 | #define classic_shift_chroma_table_size 59 | ||||
static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = { | |||||
static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = { | |||||
66, 36, 37, 38, 39, 40, 41, 75, 76, 77, 110, 239, 144, 81, 82, 83, | 66, 36, 37, 38, 39, 40, 41, 75, 76, 77, 110, 239, 144, 81, 82, 83, | ||||
84, 85, 118, 183, 56, 57, 88, 89, 56, 89, 154, 57, 58, 57, 26, 141, | 84, 85, 118, 183, 56, 57, 88, 89, 56, 89, 154, 57, 58, 57, 26, 141, | ||||
57, 56, 58, 57, 58, 57, 184, 119, 214, 245, 116, 83, 82, 49, 80, 79, | 57, 56, 58, 57, 58, 57, 184, 119, 214, 245, 116, 83, 82, 49, 80, 79, | ||||
@@ -511,11 +511,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, | |||||
av_fast_malloc(&s->bitstream_buffer, | av_fast_malloc(&s->bitstream_buffer, | ||||
&s->bitstream_buffer_size, | &s->bitstream_buffer_size, | ||||
buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!s->bitstream_buffer) | if (!s->bitstream_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memset(s->bitstream_buffer + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(s->bitstream_buffer + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
s->bdsp.bswap_buf((uint32_t *) s->bitstream_buffer, | s->bdsp.bswap_buf((uint32_t *) s->bitstream_buffer, | ||||
(const uint32_t *) buf, buf_size / 4); | (const uint32_t *) buf, buf_size / 4); | ||||
@@ -453,7 +453,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
int i, j, size = 0, ret; | int i, j, size = 0, ret; | ||||
if (!pkt->data && | if (!pkt->data && | ||||
(ret = av_new_packet(pkt, width * height * 3 * 4 + FF_MIN_BUFFER_SIZE)) < 0) { | |||||
(ret = av_new_packet(pkt, width * height * 3 * 4 + AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error allocating output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error allocating output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -172,7 +172,7 @@ static av_cold int decode_init(AVCodecContext *avctx) | |||||
if ((err = av_image_check_size(avctx->width, avctx->height, 0, avctx))) | if ((err = av_image_check_size(avctx->width, avctx->height, 0, avctx))) | ||||
return err; | return err; | ||||
s->planesize = FFALIGN(avctx->width, 16) >> 3; // Align plane size in bits to word-boundary | s->planesize = FFALIGN(avctx->width, 16) >> 3; // Align plane size in bits to word-boundary | ||||
s->planebuf = av_malloc(s->planesize + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
s->planebuf = av_malloc(s->planesize + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!s->planebuf) | if (!s->planebuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -997,7 +997,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, | |||||
IMCContext *q = avctx->priv_data; | IMCContext *q = avctx->priv_data; | ||||
LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + FF_INPUT_BUFFER_PADDING_SIZE) / 2]); | |||||
LOCAL_ALIGNED_16(uint16_t, buf16, [(IMC_BLOCK_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / 2]); | |||||
if (buf_size < IMC_BLOCK_SIZE * avctx->channels) { | if (buf_size < IMC_BLOCK_SIZE * avctx->channels) { | ||||
av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); | av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); | ||||
@@ -42,7 +42,7 @@ static int imx_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx | |||||
return 0; | return 0; | ||||
} | } | ||||
*poutbuf = av_malloc(buf_size + 20 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf = av_malloc(buf_size + 20 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
poutbufp = *poutbuf; | poutbufp = *poutbuf; | ||||
@@ -157,7 +157,7 @@ int avpriv_unlock_avformat(void); | |||||
* This value was chosen such that every bit of the buffer is | * This value was chosen such that every bit of the buffer is | ||||
* addressable by a 32-bit signed integer as used by get_bits. | * addressable by a 32-bit signed integer as used by get_bits. | ||||
*/ | */ | ||||
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE) | |||||
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) | |||||
/** | /** | ||||
* Check AVPacket size and/or allocate data. | * Check AVPacket size and/or allocate data. | ||||
@@ -268,7 +268,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, | |||||
comps = 3; | comps = 3; | ||||
if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 + | if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 + | ||||
FF_MIN_BUFFER_SIZE)) < 0) { | |||||
AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -54,7 +54,7 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data, | |||||
} | } | ||||
mrk = AV_RB32(input); | mrk = AV_RB32(input); | ||||
if (mrk != DCA_SYNCWORD_CORE_BE && mrk != DCA_SYNCWORD_SUBSTREAM) { | if (mrk != DCA_SYNCWORD_CORE_BE && mrk != DCA_SYNCWORD_SUBSTREAM) { | ||||
s->buffer = av_fast_realloc(s->buffer, &s->buffer_size, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
s->buffer = av_fast_realloc(s->buffer, &s->buffer_size, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!s->buffer) | if (!s->buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -139,7 +139,7 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx) | |||||
if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer, | if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer, | ||||
&decoder_specific_info_size)) { | &decoder_specific_info_size)) { | ||||
avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_malloc(decoder_specific_info_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
goto error; | goto error; | ||||
@@ -292,7 +292,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) | |||||
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { | if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { | ||||
avctx->extradata_size = info.confSize; | avctx->extradata_size = info.confSize; | ||||
avctx->extradata = av_mallocz(avctx->extradata_size + | avctx->extradata = av_mallocz(avctx->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
goto error; | goto error; | ||||
@@ -143,7 +143,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) | |||||
(*s->encoder)->EncodeParameterSets(s->encoder, &fbi); | (*s->encoder)->EncodeParameterSets(s->encoder, &fbi); | ||||
for (i = 0; i < fbi.sLayerInfo[0].iNalCount; i++) | for (i = 0; i < fbi.sLayerInfo[0].iNalCount; i++) | ||||
size += fbi.sLayerInfo[0].pNalLengthInByte[i]; | size += fbi.sLayerInfo[0].pNalLengthInByte[i]; | ||||
avctx->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
err = AVERROR(ENOMEM); | err = AVERROR(ENOMEM); | ||||
goto fail; | goto fail; | ||||
@@ -262,7 +262,7 @@ static int av_cold libopus_encode_init(AVCodecContext *avctx) | |||||
} | } | ||||
header_size = 19 + (avctx->channels > 2 ? 2 + avctx->channels : 0); | header_size = 19 + (avctx->channels > 2 ? 2 + avctx->channels : 0); | ||||
avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_malloc(header_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
av_log(avctx, AV_LOG_ERROR, "Failed to allocate extradata.\n"); | av_log(avctx, AV_LOG_ERROR, "Failed to allocate extradata.\n"); | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
@@ -244,7 +244,7 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
header_data = speex_header_to_packet(&s->header, &header_size); | header_data = speex_header_to_packet(&s->header, &header_size); | ||||
/* allocate extradata */ | /* allocate extradata */ | ||||
avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_malloc(header_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
speex_header_free(header_data); | speex_header_free(header_data); | ||||
speex_encoder_destroy(s->enc_state); | speex_encoder_destroy(s->enc_state); | ||||
@@ -105,7 +105,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) | |||||
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { | if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { | ||||
avctx->extradata_size = 2; | avctx->extradata_size = 2; | ||||
avctx->extradata = av_mallocz(avctx->extradata_size + | avctx->extradata = av_mallocz(avctx->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
goto error; | goto error; | ||||
@@ -206,7 +206,7 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) | |||||
xiph_len(header_comm.bytes) + | xiph_len(header_comm.bytes) + | ||||
header_code.bytes; | header_code.bytes; | ||||
p = avctx->extradata = av_malloc(avctx->extradata_size + | p = avctx->extradata = av_malloc(avctx->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!p) { | if (!p) { | ||||
ret = AVERROR(ENOMEM); | ret = AVERROR(ENOMEM); | ||||
goto error; | goto error; | ||||
@@ -225,7 +225,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) | |||||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
} | } | ||||
avctx->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
av_log(avctx, AV_LOG_ERROR, | av_log(avctx, AV_LOG_ERROR, | ||||
"Cannot allocate HEVC header of size %d.\n", avctx->extradata_size); | "Cannot allocate HEVC header of size %d.\n", avctx->extradata_size); | ||||
@@ -81,7 +81,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, | |||||
{ | { | ||||
XavsContext *x4 = ctx->priv_data; | XavsContext *x4 = ctx->priv_data; | ||||
uint8_t *p; | uint8_t *p; | ||||
int i, s, ret, size = x4->sei_size + FF_MIN_BUFFER_SIZE; | |||||
int i, s, ret, size = x4->sei_size + AV_INPUT_BUFFER_MIN_SIZE; | |||||
if (!nnal) | if (!nnal) | ||||
return 0; | return 0; | ||||
@@ -688,7 +688,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
xvid_enc_stats_t xvid_enc_stats = { 0 }; | xvid_enc_stats_t xvid_enc_stats = { 0 }; | ||||
if (!user_packet && | if (!user_packet && | ||||
(ret = av_new_packet(pkt, mb_width * mb_height * MAX_MB_BYTES + FF_MIN_BUFFER_SIZE)) < 0) { | |||||
(ret = av_new_packet(pkt, mb_width * mb_height * MAX_MB_BYTES + AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -211,7 +211,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
const int height = avctx->height; | const int height = avctx->height; | ||||
const int mb_width = (width + s->hsample[0] - 1) / s->hsample[0]; | const int mb_width = (width + s->hsample[0] - 1) / s->hsample[0]; | ||||
const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0]; | const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0]; | ||||
int max_pkt_size = FF_MIN_BUFFER_SIZE; | |||||
int max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE; | |||||
int ret, header_bits; | int ret, header_bits; | ||||
if (avctx->pix_fmt == AV_PIX_FMT_BGR24) | if (avctx->pix_fmt == AV_PIX_FMT_BGR24) | ||||
@@ -181,7 +181,7 @@ static int decode_frame(AVCodecContext *avctx, | |||||
frame.f->pict_type = AV_PICTURE_TYPE_I; | frame.f->pict_type = AV_PICTURE_TYPE_I; | ||||
frame.f->key_frame = 1; | frame.f->key_frame = 1; | ||||
av_fast_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
av_fast_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!a->bitstream_buffer) | if (!a->bitstream_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
for (i = 0; i < buf_size; i += 2) { | for (i = 0; i < buf_size; i += 2) { | ||||
@@ -44,7 +44,7 @@ static int mjpega_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *av | |||||
} | } | ||||
*poutbuf_size = 0; | *poutbuf_size = 0; | ||||
*poutbuf = av_malloc(buf_size + 44 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf = av_malloc(buf_size + 44 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
poutbufp = *poutbuf; | poutbufp = *poutbuf; | ||||
@@ -1422,7 +1422,7 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s, | |||||
*unescaped_buf_ptr = s->buffer; | *unescaped_buf_ptr = s->buffer; | ||||
*unescaped_buf_size = dst - s->buffer; | *unescaped_buf_size = dst - s->buffer; | ||||
memset(s->buffer + *unescaped_buf_size, 0, | memset(s->buffer + *unescaped_buf_size, 0, | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %td bytes\n", | av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %td bytes\n", | ||||
(buf_end - *buf_ptr) - (dst - s->buffer)); | (buf_end - *buf_ptr) - (dst - s->buffer)); | ||||
@@ -1465,7 +1465,7 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s, | |||||
*unescaped_buf_ptr = dst; | *unescaped_buf_ptr = dst; | ||||
*unescaped_buf_size = (bit_count + 7) >> 3; | *unescaped_buf_size = (bit_count + 7) >> 3; | ||||
memset(s->buffer + *unescaped_buf_size, 0, | memset(s->buffer + *unescaped_buf_size, 0, | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
} else { | } else { | ||||
*unescaped_buf_ptr = *buf_ptr; | *unescaped_buf_ptr = *buf_ptr; | ||||
*unescaped_buf_size = buf_end - *buf_ptr; | *unescaped_buf_size = buf_end - *buf_ptr; | ||||
@@ -274,14 +274,14 @@ static int mp_decode_frame(AVCodecContext *avctx, | |||||
} | } | ||||
/* le32 bitstream msb first */ | /* le32 bitstream msb first */ | ||||
av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!mp->bswapbuf) | if (!mp->bswapbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
mp->bdsp.bswap_buf((uint32_t *) mp->bswapbuf, (const uint32_t *) buf, | mp->bdsp.bswap_buf((uint32_t *) mp->bswapbuf, (const uint32_t *) buf, | ||||
buf_size / 4); | buf_size / 4); | ||||
if (buf_size & 3) | if (buf_size & 3) | ||||
memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3); | memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3); | ||||
memset(mp->bswapbuf + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(mp->bswapbuf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
init_get_bits(&gb, mp->bswapbuf, buf_size * 8); | init_get_bits(&gb, mp->bswapbuf, buf_size * 8); | ||||
memset(mp->changes_map, 0, avctx->width * avctx->height); | memset(mp->changes_map, 0, avctx->width * avctx->height); | ||||
@@ -28,7 +28,7 @@ static int text2movsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, co | |||||
const uint8_t *buf, int buf_size, int keyframe){ | const uint8_t *buf, int buf_size, int keyframe){ | ||||
if (buf_size > 0xffff) return 0; | if (buf_size > 0xffff) return 0; | ||||
*poutbuf_size = buf_size + 2; | *poutbuf_size = buf_size + 2; | ||||
*poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf = av_malloc(*poutbuf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
AV_WB16(*poutbuf, buf_size); | AV_WB16(*poutbuf, buf_size); | ||||
@@ -47,7 +47,7 @@ static int mov2textsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, co | |||||
const uint8_t *buf, int buf_size, int keyframe){ | const uint8_t *buf, int buf_size, int keyframe){ | ||||
if (buf_size < 2) return 0; | if (buf_size < 2) return 0; | ||||
*poutbuf_size = FFMIN(buf_size - 2, AV_RB16(buf)); | *poutbuf_size = FFMIN(buf_size - 2, AV_RB16(buf)); | ||||
*poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf = av_malloc(*poutbuf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(*poutbuf, buf + 2, *poutbuf_size); | memcpy(*poutbuf, buf + 2, *poutbuf_size); | ||||
@@ -2516,7 +2516,7 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) | |||||
av_fast_malloc(&s->bitstream_buffer, | av_fast_malloc(&s->bitstream_buffer, | ||||
&s->allocated_bitstream_buffer_size, | &s->allocated_bitstream_buffer_size, | ||||
buf_size - current_pos + | buf_size - current_pos + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!s->bitstream_buffer) | if (!s->bitstream_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(s->bitstream_buffer, buf + current_pos, | memcpy(s->bitstream_buffer, buf + current_pos, | ||||
@@ -544,7 +544,7 @@ do {\ | |||||
if (s1->bitstream_buffer) { | if (s1->bitstream_buffer) { | ||||
if (s1->bitstream_buffer_size + | if (s1->bitstream_buffer_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) | |||||
AV_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) | |||||
av_fast_malloc(&s->bitstream_buffer, | av_fast_malloc(&s->bitstream_buffer, | ||||
&s->allocated_bitstream_buffer_size, | &s->allocated_bitstream_buffer_size, | ||||
s1->allocated_bitstream_buffer_size); | s1->allocated_bitstream_buffer_size); | ||||
@@ -552,7 +552,7 @@ do {\ | |||||
memcpy(s->bitstream_buffer, s1->bitstream_buffer, | memcpy(s->bitstream_buffer, s1->bitstream_buffer, | ||||
s1->bitstream_buffer_size); | s1->bitstream_buffer_size); | ||||
memset(s->bitstream_buffer + s->bitstream_buffer_size, 0, | memset(s->bitstream_buffer + s->bitstream_buffer_size, 0, | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
} | } | ||||
// linesize dependend scratch buffer allocation | // linesize dependend scratch buffer allocation | ||||
@@ -476,7 +476,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, | |||||
Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r; | Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r; | ||||
int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask); | int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask); | ||||
av_assert0(FF_INPUT_BUFFER_PADDING_SIZE >= | |||||
av_assert0(AV_INPUT_BUFFER_PADDING_SIZE >= | |||||
ARITH2_PADDING + (MIN_CACHE_BITS + 7) / 8); | ARITH2_PADDING + (MIN_CACHE_BITS + 7) / 8); | ||||
init_get_bits(&gb, buf, buf_size * 8); | init_get_bits(&gb, buf, buf_size * 8); | ||||
@@ -32,10 +32,10 @@ static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const ch | |||||
int amount= args ? atoi(args) : (*state % 10001+1); | int amount= args ? atoi(args) : (*state % 10001+1); | ||||
int i; | int i; | ||||
*poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf= av_malloc(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(*poutbuf, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memcpy(*poutbuf, buf, buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
for(i=0; i<buf_size; i++){ | for(i=0; i<buf_size; i++){ | ||||
(*state) += (*poutbuf)[i] + 1; | (*state) += (*poutbuf)[i] + 1; | ||||
if(*state % amount == 0) | if(*state % amount == 0) | ||||
@@ -128,7 +128,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, | |||||
avctx->height = c->height = height; | avctx->height = c->height = height; | ||||
ptr = av_fast_realloc(c->decomp_buf, &c->decomp_size, | ptr = av_fast_realloc(c->decomp_buf, &c->decomp_size, | ||||
c->height * c->width * 3 / 2 + | c->height * c->width * 3 / 2 + | ||||
FF_INPUT_BUFFER_PADDING_SIZE + | |||||
AV_INPUT_BUFFER_PADDING_SIZE + | |||||
RTJPEG_HEADER_SIZE); | RTJPEG_HEADER_SIZE); | ||||
if (!ptr) { | if (!ptr) { | ||||
av_log(avctx, AV_LOG_ERROR, | av_log(avctx, AV_LOG_ERROR, | ||||
@@ -202,7 +202,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, | |||||
buf = &buf[12]; | buf = &buf[12]; | ||||
buf_size -= 12; | buf_size -= 12; | ||||
if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { | if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { | ||||
int outlen = c->decomp_size - FF_INPUT_BUFFER_PADDING_SIZE; | |||||
int outlen = c->decomp_size - AV_INPUT_BUFFER_PADDING_SIZE; | |||||
int inlen = buf_size; | int inlen = buf_size; | ||||
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) { | if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) { | ||||
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); | ||||
@@ -747,7 +747,7 @@ static int nvenc_setup_extradata(AVCodecContext *avctx) | |||||
NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; | NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; | ||||
int ret; | int ret; | ||||
avctx->extradata = av_mallocz(EXTRADATA_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_mallocz(EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -203,7 +203,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) | |||||
memset(((uint8_t *) dest->obj) + size, 0, pad); \ | memset(((uint8_t *) dest->obj) + size, 0, pad); \ | ||||
} | } | ||||
alloc_and_copy_or_fail(extradata, src->extradata_size, | alloc_and_copy_or_fail(extradata, src->extradata_size, | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0); | alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0); | ||||
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0); | alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0); | ||||
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0); | alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0); | ||||
@@ -126,7 +126,7 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, | |||||
int64_t pts, int64_t dts, int64_t pos) | int64_t pts, int64_t dts, int64_t pos) | ||||
{ | { | ||||
int index, i; | int index, i; | ||||
uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) { | if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) { | ||||
s->next_frame_offset = | s->next_frame_offset = | ||||
@@ -195,13 +195,13 @@ int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, | |||||
int size = buf_size + avctx->extradata_size; | int size = buf_size + avctx->extradata_size; | ||||
*poutbuf_size = size; | *poutbuf_size = size; | ||||
*poutbuf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
*poutbuf = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!*poutbuf) | if (!*poutbuf) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); | memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); | ||||
memcpy(*poutbuf + avctx->extradata_size, buf, | memcpy(*poutbuf + avctx->extradata_size, buf, | ||||
buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
return 1; | return 1; | ||||
} | } | ||||
} | } | ||||
@@ -243,7 +243,7 @@ int ff_combine_frame(ParseContext *pc, int next, | |||||
if (next == END_NOT_FOUND) { | if (next == END_NOT_FOUND) { | ||||
void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, | void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, | ||||
*buf_size + pc->index + | *buf_size + pc->index + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!new_buffer) | if (!new_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -260,14 +260,14 @@ int ff_combine_frame(ParseContext *pc, int next, | |||||
if (pc->index) { | if (pc->index) { | ||||
void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, | void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, | ||||
next + pc->index + | next + pc->index + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!new_buffer) | if (!new_buffer) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
pc->buffer = new_buffer; | pc->buffer = new_buffer; | ||||
if (next > -FF_INPUT_BUFFER_PADDING_SIZE) | |||||
if (next > -AV_INPUT_BUFFER_PADDING_SIZE) | |||||
memcpy(&pc->buffer[pc->index], *buf, | memcpy(&pc->buffer[pc->index], *buf, | ||||
next + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
next + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
pc->index = 0; | pc->index = 0; | ||||
*buf = pc->buffer; | *buf = pc->buffer; | ||||
} | } | ||||
@@ -297,7 +297,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
enc_row_size = deflateBound(&s->zstream, row_size); | enc_row_size = deflateBound(&s->zstream, row_size); | ||||
max_packet_size = avctx->height * (enc_row_size + | max_packet_size = avctx->height * (enc_row_size + | ||||
((enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) * 12) | ((enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) * 12) | ||||
+ FF_MIN_BUFFER_SIZE; | |||||
+ AV_INPUT_BUFFER_MIN_SIZE; | |||||
if (!pkt->data && | if (!pkt->data && | ||||
(ret = av_new_packet(pkt, max_packet_size)) < 0) { | (ret = av_new_packet(pkt, max_packet_size)) < 0) { | ||||
av_log(avctx, AV_LOG_ERROR, "Could not allocate output packet of size %d.\n", | av_log(avctx, AV_LOG_ERROR, "Could not allocate output packet of size %d.\n", | ||||
@@ -55,7 +55,7 @@ retry: | |||||
goto retry; | goto retry; | ||||
} | } | ||||
#if 0 | #if 0 | ||||
if (pc->index && pc->index * 2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index) { | |||||
if (pc->index && pc->index * 2 + AV_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index) { | |||||
memcpy(pc->buffer + pc->index, buf, pc->index); | memcpy(pc->buffer + pc->index, buf, pc->index); | ||||
pc->index += pc->index; | pc->index += pc->index; | ||||
buf += pc->index; | buf += pc->index; | ||||
@@ -948,7 +948,7 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||
pkt_size = ctx->frame_size_upper_bound; | pkt_size = ctx->frame_size_upper_bound; | ||||
if ((ret = ff_alloc_packet(pkt, pkt_size + FF_MIN_BUFFER_SIZE)) < 0) { | |||||
if ((ret = ff_alloc_packet(pkt, pkt_size + AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -341,7 +341,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, | |||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
if (avctx->extradata) { | if (avctx->extradata) { | ||||
q->avctx_internal->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
q->avctx_internal->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!q->avctx_internal->extradata) | if (!q->avctx_internal->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -177,7 +177,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) | |||||
} | } | ||||
avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * extradata.PPSBufSize + | avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * extradata.PPSBufSize + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -185,7 +185,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) | |||||
if (need_pps) | if (need_pps) | ||||
memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize); | memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize); | ||||
avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize; | avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize; | ||||
memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -140,7 +140,7 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) | |||||
} | } | ||||
vps_size = bytestream2_tell_p(&pbc); | vps_size = bytestream2_tell_p(&pbc); | ||||
new_extradata = av_mallocz(vps_size + avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
new_extradata = av_mallocz(vps_size + avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!new_extradata) | if (!new_extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(new_extradata, vps_buf, vps_size); | memcpy(new_extradata, vps_buf, vps_size); | ||||
@@ -431,7 +431,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data, | |||||
void *tmp_ptr; | void *tmp_ptr; | ||||
s->max_framesize = 1024; // should hopefully be enough for the first header | s->max_framesize = 1024; // should hopefully be enough for the first header | ||||
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, | tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, | ||||
s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!tmp_ptr) { | if (!tmp_ptr) { | ||||
av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); | av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -33,7 +33,7 @@ int ff_startcode_find_candidate_c(const uint8_t *buf, int size) | |||||
int i = 0; | int i = 0; | ||||
#if HAVE_FAST_UNALIGNED | #if HAVE_FAST_UNALIGNED | ||||
/* we check i < size instead of i + 3 / 7 because it is | /* we check i < size instead of i + 3 / 7 because it is | ||||
* simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE | |||||
* simpler and there must be AV_INPUT_BUFFER_PADDING_SIZE | |||||
* bytes at the end. | * bytes at the end. | ||||
*/ | */ | ||||
#if HAVE_FAST_64BIT | #if HAVE_FAST_64BIT | ||||
@@ -586,7 +586,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
if (!pkt->data && | if (!pkt->data && | ||||
(ret = av_new_packet(pkt, s->y_block_width * s->y_block_height * | (ret = av_new_packet(pkt, s->y_block_width * s->y_block_height * | ||||
MAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE)) < 0) { | |||||
MAX_MB_BYTES * 3 + AV_INPUT_BUFFER_MIN_SIZE)) < 0) { | |||||
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -141,7 +141,7 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride, | |||||
{ | { | ||||
int i, ret = 0; | int i, ret = 0; | ||||
uint8_t *src2 = av_malloc((unsigned)size + | uint8_t *src2 = av_malloc((unsigned)size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!src2) { | if (!src2) { | ||||
av_log(s->avctx, AV_LOG_ERROR, | av_log(s->avctx, AV_LOG_ERROR, | ||||
@@ -159,7 +159,7 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride, | |||||
for (i = 0; i < size; i++) | for (i = 0; i < size; i++) | ||||
src2[i] = ff_reverse[src[i]]; | src2[i] = ff_reverse[src[i]]; | ||||
} | } | ||||
memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(src2 + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, | ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, | ||||
s->compr, s->fax_opts); | s->compr, s->fax_opts); | ||||
av_free(src2); | av_free(src2); | ||||
@@ -309,7 +309,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
strips = (s->height - 1) / s->rps + 1; | strips = (s->height - 1) / s->rps + 1; | ||||
packet_size = avctx->height * ((avctx->width * s->bpp + 7) >> 3) * 2 + | packet_size = avctx->height * ((avctx->width * s->bpp + 7) >> 3) * 2 + | ||||
avctx->height * 4 + FF_MIN_BUFFER_SIZE; | |||||
avctx->height * 4 + AV_INPUT_BUFFER_MIN_SIZE; | |||||
if (!pkt->data && | if (!pkt->data && | ||||
(ret = av_new_packet(pkt, packet_size)) < 0) { | (ret = av_new_packet(pkt, packet_size)) < 0) { | ||||
@@ -856,7 +856,7 @@ static int decode_frame(AVCodecContext *avctx, | |||||
int i, t, ret; | int i, t, ret; | ||||
uint8_t *swbuf; | uint8_t *swbuf; | ||||
swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
swbuf = av_malloc(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!swbuf) { | if (!swbuf) { | ||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -59,14 +59,14 @@ static void *avformat_mutex; | |||||
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) | void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) | ||||
{ | { | ||||
void **p = ptr; | void **p = ptr; | ||||
if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { | |||||
if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { | |||||
av_freep(p); | av_freep(p); | ||||
*size = 0; | *size = 0; | ||||
return; | return; | ||||
} | } | ||||
av_fast_malloc(p, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
av_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (*size) | if (*size) | ||||
memset((uint8_t *)*p + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset((uint8_t *)*p + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
} | } | ||||
/* encoder management */ | /* encoder management */ | ||||
@@ -1324,7 +1324,7 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||
int ff_alloc_packet(AVPacket *avpkt, int size) | int ff_alloc_packet(AVPacket *avpkt, int size) | ||||
{ | { | ||||
if (size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) | |||||
if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) | |||||
return AVERROR(EINVAL); | return AVERROR(EINVAL); | ||||
if (avpkt->data) { | if (avpkt->data) { | ||||
@@ -142,7 +142,7 @@ static int decode_plane(UtvideoContext *c, int plane_no, | |||||
memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, | memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, | ||||
slice_size); | slice_size); | ||||
memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(c->slice_bits + slice_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
c->bdsp.bswap_buf((uint32_t *) c->slice_bits, | c->bdsp.bswap_buf((uint32_t *) c->slice_bits, | ||||
(uint32_t *) c->slice_bits, | (uint32_t *) c->slice_bits, | ||||
(slice_data_end - slice_data_start + 3) >> 2); | (slice_data_end - slice_data_start + 3) >> 2); | ||||
@@ -388,7 +388,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, | |||||
} | } | ||||
av_fast_malloc(&c->slice_bits, &c->slice_bits_size, | av_fast_malloc(&c->slice_bits, &c->slice_bits_size, | ||||
max_slice_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
max_slice_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!c->slice_bits) { | if (!c->slice_bits) { | ||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | ||||
@@ -157,7 +157,7 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx) | |||||
avctx->extradata_size = 16; | avctx->extradata_size = 16; | ||||
avctx->extradata = av_mallocz(avctx->extradata_size + | avctx->extradata = av_mallocz(avctx->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) { | if (!avctx->extradata) { | ||||
av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n"); | av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n"); | ||||
@@ -167,7 +167,7 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx) | |||||
for (i = 0; i < c->planes; i++) { | for (i = 0; i < c->planes; i++) { | ||||
c->slice_buffer[i] = av_malloc(c->slice_stride * (avctx->height + 2) + | c->slice_buffer[i] = av_malloc(c->slice_stride * (avctx->height + 2) + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!c->slice_buffer[i]) { | if (!c->slice_buffer[i]) { | ||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n"); | av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n"); | ||||
utvideo_encode_close(avctx); | utvideo_encode_close(avctx); | ||||
@@ -547,7 +547,7 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
bytestream2_init_writer(&pb, dst, pkt->size); | bytestream2_init_writer(&pb, dst, pkt->size); | ||||
av_fast_malloc(&c->slice_bits, &c->slice_bits_size, | av_fast_malloc(&c->slice_bits, &c->slice_bits_size, | ||||
width * height + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
width * height + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!c->slice_bits) { | if (!c->slice_bits) { | ||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n"); | av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n"); | ||||
@@ -461,7 +461,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) | |||||
return -1; | return -1; | ||||
} | } | ||||
buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
buf2 = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
start = find_next_marker(start, end); // in WVC1 extradata first byte is its size, but can be 0 in mkv | start = find_next_marker(start, end); // in WVC1 extradata first byte is its size, but can be 0 in mkv | ||||
next = start; | next = start; | ||||
for (; next < end; start = next) { | for (; next < end; start = next) { | ||||
@@ -612,7 +612,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, | |||||
//for advanced profile we may need to parse and unescape data | //for advanced profile we may need to parse and unescape data | ||||
if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { | if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { | ||||
int buf_size2 = 0; | int buf_size2 = 0; | ||||
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
buf2 = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (IS_MARKER(AV_RB32(buf))) { /* frame starts with marker and needs to be parsed */ | if (IS_MARKER(AV_RB32(buf))) { /* frame starts with marker and needs to be parsed */ | ||||
const uint8_t *start, *end, *next; | const uint8_t *start, *end, *next; | ||||
@@ -635,7 +635,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, | |||||
if (!tmp) | if (!tmp) | ||||
goto err; | goto err; | ||||
slices = tmp; | slices = tmp; | ||||
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
slices[n_slices].buf = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!slices[n_slices].buf) | if (!slices[n_slices].buf) | ||||
goto err; | goto err; | ||||
buf_size3 = vc1_unescape_buffer(start + 4, size, | buf_size3 = vc1_unescape_buffer(start + 4, size, | ||||
@@ -660,7 +660,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, | |||||
if (!tmp) | if (!tmp) | ||||
goto err; | goto err; | ||||
slices = tmp; | slices = tmp; | ||||
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
slices[n_slices].buf = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!slices[n_slices].buf) | if (!slices[n_slices].buf) | ||||
goto err; | goto err; | ||||
buf_size3 = vc1_unescape_buffer(start + 4, size, | buf_size3 = vc1_unescape_buffer(start + 4, size, | ||||
@@ -686,7 +686,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, | |||||
if (!tmp) | if (!tmp) | ||||
goto err; | goto err; | ||||
slices = tmp; | slices = tmp; | ||||
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
slices[n_slices].buf = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!slices[n_slices].buf) | if (!slices[n_slices].buf) | ||||
goto err; | goto err; | ||||
buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf); | buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf); | ||||
@@ -446,7 +446,7 @@ static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) | |||||
const int max_bits = 1 + 23 + 8 + 1; | const int max_bits = 1 + 23 + 8 + 1; | ||||
const int left_bits = get_bits_left(&s->gb_extra_bits); | const int left_bits = get_bits_left(&s->gb_extra_bits); | ||||
if (left_bits + 8 * FF_INPUT_BUFFER_PADDING_SIZE < max_bits) | |||||
if (left_bits + 8 * AV_INPUT_BUFFER_PADDING_SIZE < max_bits) | |||||
return 0.0; | return 0.0; | ||||
} | } | ||||
@@ -120,7 +120,7 @@ typedef struct WMACodecContext { | |||||
/* output buffer for one frame and the last for IMDCT windowing */ | /* output buffer for one frame and the last for IMDCT windowing */ | ||||
DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]; | DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]; | ||||
/* last frame info */ | /* last frame info */ | ||||
uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; /* padding added */ | |||||
uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; /* padding added */ | |||||
int last_bitoffset; | int last_bitoffset; | ||||
int last_superframe_len; | int last_superframe_len; | ||||
float noise_table[NOISE_TAB_SIZE]; | float noise_table[NOISE_TAB_SIZE]; | ||||
@@ -853,7 +853,7 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, | |||||
} | } | ||||
if (len > 0) | if (len > 0) | ||||
*q++ = (get_bits) (&s->gb, len) << (8 - len); | *q++ = (get_bits) (&s->gb, len) << (8 - len); | ||||
memset(q, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |||||
/* XXX: bit_offset bits into last frame */ | /* XXX: bit_offset bits into last frame */ | ||||
init_get_bits(&s->gb, s->last_superframe, | init_get_bits(&s->gb, s->last_superframe, | ||||
@@ -69,7 +69,7 @@ typedef struct WmallDecodeCtx { | |||||
/* generic decoder variables */ | /* generic decoder variables */ | ||||
AVCodecContext *avctx; | AVCodecContext *avctx; | ||||
AVFrame *frame; | AVFrame *frame; | ||||
uint8_t frame_data[MAX_FRAMESIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< compressed frame data | |||||
uint8_t frame_data[MAX_FRAMESIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< compressed frame data | |||||
PutBitContext pb; ///< context for filling the frame_data buffer | PutBitContext pb; ///< context for filling the frame_data buffer | ||||
/* frame size dependent frame information (set during initialization) */ | /* frame size dependent frame information (set during initialization) */ | ||||
@@ -173,7 +173,7 @@ typedef struct WMAProDecodeCtx { | |||||
AVCodecContext* avctx; ///< codec context for av_log | AVCodecContext* avctx; ///< codec context for av_log | ||||
AVFloatDSPContext fdsp; | AVFloatDSPContext fdsp; | ||||
uint8_t frame_data[MAX_FRAMESIZE + | uint8_t frame_data[MAX_FRAMESIZE + | ||||
FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data | |||||
AV_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data | |||||
PutBitContext pb; ///< context for filling the frame_data buffer | PutBitContext pb; ///< context for filling the frame_data buffer | ||||
FFTContext mdct_ctx[WMAPRO_BLOCK_SIZES]; ///< MDCT context per block size | FFTContext mdct_ctx[WMAPRO_BLOCK_SIZES]; ///< MDCT context per block size | ||||
DECLARE_ALIGNED(32, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer | DECLARE_ALIGNED(32, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer | ||||
@@ -205,7 +205,7 @@ typedef struct WMAVoiceContext { | |||||
///< to #wmavoice_decode_packet() (since | ///< to #wmavoice_decode_packet() (since | ||||
///< they're part of the previous superframe) | ///< they're part of the previous superframe) | ||||
uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + FF_INPUT_BUFFER_PADDING_SIZE]; | |||||
uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + AV_INPUT_BUFFER_PADDING_SIZE]; | |||||
///< cache for superframe data split over | ///< cache for superframe data split over | ||||
///< multiple packets | ///< multiple packets | ||||
int sframe_cache_size; ///< set to >0 if we have data from an | int sframe_cache_size; ///< set to >0 if we have data from an | ||||
@@ -75,7 +75,7 @@ static int decode_frame(AVCodecContext *avctx, | |||||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
} | } | ||||
rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
rbuf = av_malloc(buf_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!rbuf) { | if (!rbuf) { | ||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -392,7 +392,7 @@ static int vfw_read_header(AVFormatContext *s) | |||||
codec->codec_id = AV_CODEC_ID_RAWVIDEO; | codec->codec_id = AV_CODEC_ID_RAWVIDEO; | ||||
if(biCompression == BI_RGB) { | if(biCompression == BI_RGB) { | ||||
codec->bits_per_coded_sample = biBitCount; | codec->bits_per_coded_sample = biBitCount; | ||||
codec->extradata = av_malloc(9 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (codec->extradata) { | if (codec->extradata) { | ||||
codec->extradata_size = 9; | codec->extradata_size = 9; | ||||
memcpy(codec->extradata, "BottomUp", 9); | memcpy(codec->extradata, "BottomUp", 9); | ||||
@@ -227,7 +227,7 @@ static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt) | |||||
xcb_shm_get_image_reply_t *img; | xcb_shm_get_image_reply_t *img; | ||||
xcb_drawable_t drawable = c->screen->root; | xcb_drawable_t drawable = c->screen->root; | ||||
uint8_t *data; | uint8_t *data; | ||||
int size = c->frame_size + FF_INPUT_BUFFER_PADDING_SIZE; | |||||
int size = c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE; | |||||
int id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); | int id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); | ||||
xcb_generic_error_t *e = NULL; | xcb_generic_error_t *e = NULL; | ||||
@@ -111,7 +111,7 @@ static int parse_vtrk(AVFormatContext *s, | |||||
st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | st->codec->codec_type = AVMEDIA_TYPE_VIDEO; | ||||
st->codec->codec_id = AV_CODEC_ID_4XM; | st->codec->codec_id = AV_CODEC_ID_4XM; | ||||
st->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
st->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) | if (!st->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
st->codec->extradata_size = 4; | st->codec->extradata_size = 4; | ||||
@@ -76,7 +76,7 @@ static int adx_read_header(AVFormatContext *s) | |||||
c->header_size = avio_rb16(s->pb) + 4; | c->header_size = avio_rb16(s->pb) + 4; | ||||
avio_seek(s->pb, -4, SEEK_CUR); | avio_seek(s->pb, -4, SEEK_CUR); | ||||
avctx->extradata = av_mallocz(c->header_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_mallocz(c->header_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
if (avio_read(s->pb, avctx->extradata, c->header_size) < c->header_size) { | if (avio_read(s->pb, avctx->extradata, c->header_size) < c->header_size) { | ||||
@@ -259,7 +259,7 @@ static int aiff_read_header(AVFormatContext *s) | |||||
case MKTAG('w', 'a', 'v', 'e'): | case MKTAG('w', 'a', 'v', 'e'): | ||||
if ((uint64_t)size > (1<<30)) | if ((uint64_t)size > (1<<30)) | ||||
return -1; | return -1; | ||||
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) | if (!st->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
st->codec->extradata_size = size; | st->codec->extradata_size = size; | ||||
@@ -133,7 +133,7 @@ static int read_header(AVFormatContext *s) | |||||
/* color cycling and palette data */ | /* color cycling and palette data */ | ||||
st->codec->extradata_size = 16*8 + 4*256; | st->codec->extradata_size = 16*8 + 4*256; | ||||
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) { | if (!st->codec->extradata) { | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
} | } | ||||
@@ -53,7 +53,7 @@ static int apc_read_header(AVFormatContext *s) | |||||
st->codec->extradata_size = 2 * 4; | st->codec->extradata_size = 2 * 4; | ||||
st->codec->extradata = av_malloc(st->codec->extradata_size + | st->codec->extradata = av_malloc(st->codec->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) | if (!st->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -57,7 +57,7 @@ static int ape_tag_read_field(AVFormatContext *s) | |||||
av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key); | av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key); | ||||
return -1; | return -1; | ||||
} | } | ||||
if (size > INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { | |||||
if (size > INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { | |||||
av_log(s, AV_LOG_ERROR, "APE tag size too large.\n"); | av_log(s, AV_LOG_ERROR, "APE tag size too large.\n"); | ||||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
} | } | ||||
@@ -94,7 +94,7 @@ static int ape_tag_read_field(AVFormatContext *s) | |||||
st->attached_pic.stream_index = st->index; | st->attached_pic.stream_index = st->index; | ||||
st->attached_pic.flags |= AV_PKT_FLAG_KEY; | st->attached_pic.flags |= AV_PKT_FLAG_KEY; | ||||
} else { | } else { | ||||
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
st->codec->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) | if (!st->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
if (avio_read(pb, st->codec->extradata, size) != size) { | if (avio_read(pb, st->codec->extradata, size) != size) { | ||||
@@ -674,12 +674,12 @@ static int parse_video_info(AVIOContext *pb, AVStream *st) | |||||
int ret; | int ret; | ||||
st->codec->extradata_size = size - BMP_HEADER_SIZE; | st->codec->extradata_size = size - BMP_HEADER_SIZE; | ||||
if (!(st->codec->extradata = av_malloc(st->codec->extradata_size + | if (!(st->codec->extradata = av_malloc(st->codec->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE))) { | |||||
AV_INPUT_BUFFER_PADDING_SIZE))) { | |||||
st->codec->extradata_size = 0; | st->codec->extradata_size = 0; | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
} | } | ||||
memset(st->codec->extradata + st->codec->extradata_size , 0, | memset(st->codec->extradata + st->codec->extradata_size , 0, | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if ((ret = avio_read(pb, st->codec->extradata, | if ((ret = avio_read(pb, st->codec->extradata, | ||||
st->codec->extradata_size)) < 0) | st->codec->extradata_size)) < 0) | ||||
return ret; | return ret; | ||||
@@ -625,7 +625,7 @@ static int avi_read_header(AVFormatContext *s) | |||||
if (size > 10 * 4 && size < (1 << 30)) { | if (size > 10 * 4 && size < (1 << 30)) { | ||||
st->codec->extradata_size = size - 10 * 4; | st->codec->extradata_size = size - 10 * 4; | ||||
st->codec->extradata = av_malloc(st->codec->extradata_size + | st->codec->extradata = av_malloc(st->codec->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) { | if (!st->codec->extradata) { | ||||
st->codec->extradata_size = 0; | st->codec->extradata_size = 0; | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
@@ -696,7 +696,7 @@ static int avi_read_header(AVFormatContext *s) | |||||
st->codec->extradata_size += 9; | st->codec->extradata_size += 9; | ||||
if ((ret = av_reallocp(&st->codec->extradata, | if ((ret = av_reallocp(&st->codec->extradata, | ||||
st->codec->extradata_size + | st->codec->extradata_size + | ||||
FF_INPUT_BUFFER_PADDING_SIZE)) < 0) { | |||||
AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { | |||||
st->codec->extradata_size = 0; | st->codec->extradata_size = 0; | ||||
return ret; | return ret; | ||||
} else | } else | ||||
@@ -396,7 +396,7 @@ int avio_open_dyn_buf(AVIOContext **s); | |||||
/** | /** | ||||
* Return the written size and a pointer to the buffer. The buffer | * Return the written size and a pointer to the buffer. The buffer | ||||
* must be freed with av_free(). | * must be freed with av_free(). | ||||
* Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. | |||||
* Padding of AV_INPUT_BUFFER_PADDING_SIZE is added to the buffer. | |||||
* | * | ||||
* @param s IO context | * @param s IO context | ||||
* @param pbuffer pointer to a byte buffer | * @param pbuffer pointer to a byte buffer | ||||
@@ -983,7 +983,7 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) | |||||
{ | { | ||||
DynBuffer *d; | DynBuffer *d; | ||||
int size; | int size; | ||||
static const char padbuf[FF_INPUT_BUFFER_PADDING_SIZE] = {0}; | |||||
static const char padbuf[AV_INPUT_BUFFER_PADDING_SIZE] = {0}; | |||||
int padding = 0; | int padding = 0; | ||||
if (!s) { | if (!s) { | ||||
@@ -994,7 +994,7 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) | |||||
/* don't attempt to pad fixed-size packet buffers */ | /* don't attempt to pad fixed-size packet buffers */ | ||||
if (!s->max_packet_size) { | if (!s->max_packet_size) { | ||||
avio_write(s, padbuf, sizeof(padbuf)); | avio_write(s, padbuf, sizeof(padbuf)); | ||||
padding = FF_INPUT_BUFFER_PADDING_SIZE; | |||||
padding = AV_INPUT_BUFFER_PADDING_SIZE; | |||||
} | } | ||||
avio_flush(s); | avio_flush(s); | ||||
@@ -120,7 +120,7 @@ static int read_header(AVFormatContext *s) | |||||
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; | vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; | ||||
vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO; | vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO; | ||||
vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
vst->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!vst->codec->extradata) | if (!vst->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
vst->codec->extradata_size = 4; | vst->codec->extradata_size = 4; | ||||
@@ -156,7 +156,7 @@ static int read_header(AVFormatContext *s) | |||||
ast->codec->channels = 1; | ast->codec->channels = 1; | ||||
ast->codec->channel_layout = AV_CH_LAYOUT_MONO; | ast->codec->channel_layout = AV_CH_LAYOUT_MONO; | ||||
} | } | ||||
ast->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
ast->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!ast->codec->extradata) | if (!ast->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
ast->codec->extradata_size = 4; | ast->codec->extradata_size = 4; | ||||