This commit is contained in:
2025-12-02 15:29:27 +08:00
parent c80b9fc1ea
commit 83cd56dfbb
22 changed files with 116 additions and 35 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
This directory contains files used in goanna builds from FFmpeg
(http://ffmpeg.org). The current files are from FFmpeg as of
Release 3.4.13
Release 3.4.14
All source files match their path from the library's source archive.
Currently, we only use the vp8 and vp9 portion of the library, and only on x86
+1
View File
@@ -580,6 +580,7 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr)
if (sbr->n_q > 5) {
av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
sbr->n_q = 1;
return -1;
}
+4
View File
@@ -2631,6 +2631,10 @@ typedef struct AVCodecContext {
* this callback and filled with the extra buffers if there are more
* buffers than buf[] can hold. extended_buf will be freed in
* av_frame_unref().
* Decoders will generally initialize the whole buffer before it is output
* but it can in rare error conditions happen that uninitialized data is passed
* through. \important The buffers returned by get_buffer* should thus not contain sensitive
* data.
*
* If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
* avcodec_default_get_buffer2() instead of providing buffers allocated by
+2
View File
@@ -367,6 +367,8 @@ static int check_header_mismatch(FLACParseContext *fpc,
for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS && curr != child; i++)
curr = curr->next;
av_assert0(i < FLAC_MAX_SEQUENTIAL_HEADERS);
if (header->link_penalty[i] < FLAC_HEADER_CRC_FAIL_PENALTY ||
header->link_penalty[i] == FLAC_HEADER_NOT_PENALIZED_YET) {
FLACHeaderMarker *start, *end;
+5
View File
@@ -282,6 +282,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
log = av_log2(buf);
if (log > 31 - limit) {
av_assert2(log >= k);
buf >>= log - k;
buf += (30U - log) << k;
LAST_SKIP_BITS(re, gb, 32 + k - log);
@@ -303,6 +304,8 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
/**
* read unsigned golomb rice code (jpegls).
*
* @returns -1 on error
*/
static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
int esc_len)
@@ -380,6 +383,8 @@ static inline int get_sr_golomb(GetBitContext *gb, int k, int limit,
/**
* read signed golomb rice code (flac).
*
* @returns INT_MIN on error
*/
static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit,
int esc_len)
+1 -1
View File
@@ -97,7 +97,7 @@ static inline int get_nalsize(int nal_length_size, const uint8_t *buf,
if (*buf_index >= buf_size - nal_length_size) {
// the end of the buffer is reached, refill it
return AVERROR(EAGAIN);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < nal_length_size; i++)
+15 -8
View File
@@ -536,6 +536,10 @@ static int hls_slice_header(HEVCContext *s)
if (s->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
if (sh->dependent_slice_segment_flag && !s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
s->ps.sps->ctb_height);
@@ -804,9 +808,6 @@ static int hls_slice_header(HEVCContext *s)
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
@@ -1425,7 +1426,8 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride,
if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) {
y_off >= pic_height - block_h - QPEL_EXTRA_AFTER ||
ref == s->frame) {
const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
@@ -1573,6 +1575,7 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0,
intptr_t my = av_mod_uintp2(mv->y, 2 + vshift);
intptr_t _mx = mx << (1 - hshift);
intptr_t _my = my << (1 - vshift);
int emu = src0 == s->frame->data[1] || src0 == s->frame->data[2];
x_off += mv->x >> (2 + hshift);
y_off += mv->y >> (2 + vshift);
@@ -1580,7 +1583,8 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0,
if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) {
y_off >= pic_height - block_h - EPEL_EXTRA_AFTER ||
emu) {
const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift));
int buf_offset0 = EPEL_EXTRA_BEFORE *
@@ -1819,13 +1823,13 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
if (current_mv.pred_flag & PF_L0) {
ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
if (!ref0)
if (!ref0 || !ref0->frame)
return;
hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH);
}
if (current_mv.pred_flag & PF_L1) {
ref1 = refPicList[1].ref[current_mv.ref_idx[1]];
if (!ref1)
if (!ref1 || !ref1->frame)
return;
hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH);
}
@@ -2874,8 +2878,11 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
case HEVC_NAL_RASL_N:
case HEVC_NAL_RASL_R:
ret = hls_slice_header(s);
if (ret < 0)
if (ret < 0) {
// hls_slice_header() does not cleanup on failure thus the state now is inconsistant so we cannot use it on depandant slices
s->slice_initialized = 0;
return ret;
}
if (ret == 1) {
ret = AVERROR_INVALIDDATA;
goto fail;
+4 -4
View File
@@ -69,7 +69,7 @@
#define GLOBAL(x) x
#define RIGHT_SHIFT(x, n) ((x) >> (n))
#define MULTIPLY16C16(var,const) ((var)*(const))
#define DESCALE(x,n) RIGHT_SHIFT((x) + (1 << ((n) - 1)), n)
#define DESCALE(x,n) RIGHT_SHIFT((int)(x) + (1 << ((n) - 1)), n)
/*
@@ -175,7 +175,7 @@
#if BITS_IN_JSAMPLE == 8 && CONST_BITS<=13 && PASS1_BITS<=2
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
#else
#define MULTIPLY(var,const) ((var) * (const))
#define MULTIPLY(var,const) (int)((var) * (unsigned)(const))
#endif
@@ -183,7 +183,7 @@ static av_always_inline void FUNC(row_fdct)(int16_t *data)
{
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int tmp10, tmp11, tmp12, tmp13;
int z1, z2, z3, z4, z5;
unsigned z1, z2, z3, z4, z5;
int16_t *dataptr;
int ctr;
@@ -261,7 +261,7 @@ FUNC(ff_jpeg_fdct_islow)(int16_t *data)
{
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int tmp10, tmp11, tmp12, tmp13;
int z1, z2, z3, z4, z5;
unsigned z1, z2, z3, z4, z5;
int16_t *dataptr;
int ctr;
+4 -2
View File
@@ -243,8 +243,10 @@ int ff_lpc_calc_coefs(LPCContext *s,
double av_uninit(weight);
memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));
for(j=0; j<max_order; j++)
m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];
/* Avoids initializing with an unused value when lpc_passes == 1 */
if (lpc_passes > 1)
for(j=0; j<max_order; j++)
m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];
for(; pass<lpc_passes; pass++){
avpriv_init_lls(&m[pass&1], max_order);
+1
View File
@@ -284,6 +284,7 @@ int ff_combine_frame(ParseContext *pc, int next,
}
pc->buffer = new_buffer;
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
memset(&pc->buffer[pc->index + *buf_size], 0, AV_INPUT_BUFFER_PADDING_SIZE);
pc->index += *buf_size;
return -1;
}
+6 -3
View File
@@ -372,6 +372,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
if (s->codec_id == AV_CODEC_ID_SVQ1) {
w_align = 64;
h_align = 64;
} else if (s->codec_id == AV_CODEC_ID_SNOW) {
w_align = 16;
h_align = 16;
}
break;
case AV_PIX_FMT_RGB555:
@@ -1766,9 +1769,9 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
if (sr > 0) {
/* calc from sample rate */
if (id == AV_CODEC_ID_TTA)
return 256 * sr / 245;
return 256ll * sr / 245;
else if (id == AV_CODEC_ID_DST)
return 588 * sr / 44100;
return 588ll * sr / 44100;
if (ch > 0) {
/* calc from sample rate and channels */
@@ -1878,7 +1881,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
case AV_CODEC_ID_ADPCM_IMA_WAV:
if (bps < 2 || bps > 5)
return 0;
tmp = blocks * (1LL + (ba - 4 * ch) / (bps * ch) * 8);
tmp = blocks * (1LL + (ba - 4 * ch) / (bps * ch) * 8LL);
break;
case AV_CODEC_ID_ADPCM_IMA_DK3:
tmp = blocks * (((ba - 16LL) * 2 / 3 * 4) / ch);
+10 -2
View File
@@ -191,8 +191,16 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
return AVERROR(ENOMEM);
}
#if HAVE_THREADS
pthread_mutex_init(&s->thread_data[i].lock, NULL);
pthread_cond_init(&s->thread_data[i].cond, NULL);
ret = pthread_mutex_init(&s->thread_data[i].lock, NULL);
if (ret) {
free_buffers(s);
return AVERROR(ret);
}
ret = pthread_cond_init(&s->thread_data[i].cond, NULL);
if (ret) {
free_buffers(s);
return AVERROR(ret);
}
#endif
}
+8
View File
@@ -318,7 +318,11 @@ static av_always_inline void mc_luma_unscaled(VP9TileData *td, vp9_mc_func (*mc)
// The arm/aarch64 _hv filters read one more row than what actually is
// needed, so switch to emulated edge one pixel sooner vertically
// (!!my * 5) than horizontally (!!mx * 4).
// The arm/aarch64 _h filters read one more pixel than what actually is
// needed, so switch to emulated edge if that would read beyond the bottom
// right block.
if (x < !!mx * 3 || y < !!my * 3 ||
((ARCH_AARCH64 || ARCH_ARM) && (x + !!mx * 5 > w - bw) && (y + !!my * 5 + 1 > h - bh)) ||
x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
@@ -357,7 +361,11 @@ static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func (*m
// The arm/aarch64 _hv filters read one more row than what actually is
// needed, so switch to emulated edge one pixel sooner vertically
// (!!my * 5) than horizontally (!!mx * 4).
// The arm/aarch64 _h filters read one more pixel than what actually is
// needed, so switch to emulated edge if that would read beyond the bottom
// right block.
if (x < !!mx * 3 || y < !!my * 3 ||
((ARCH_AARCH64 || ARCH_ARM) && (x + !!mx * 5 > w - bw) && (y + !!my * 5 + 1 > h - bh)) ||
x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
+4 -2
View File
@@ -451,10 +451,12 @@ int av_match_list(const char *name, const char *list, char separator)
if (k && (!p[k] || p[k] == separator))
return 1;
q = strchr(q, separator);
q += !!q;
if(q)
q++;
}
p = strchr(p, separator);
p += !!p;
if (p)
p++;
}
return 0;
+4 -2
View File
@@ -120,10 +120,12 @@ int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
}
out3:
*dst++ = v >> 10;
if (end - dst)
*dst++ = v >> 10;
v <<= 2;
out2:
*dst++ = v >> 4;
if (end - dst)
*dst++ = v >> 4;
out1:
out0:
return bits & 1 ? AVERROR_INVALIDDATA : dst - out;
+8 -2
View File
@@ -223,7 +223,10 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
if (!pool)
return NULL;
ff_mutex_init(&pool->mutex, NULL);
if (ff_mutex_init(&pool->mutex, NULL)) {
av_free(pool);
return NULL;
}
pool->size = size;
pool->opaque = opaque;
@@ -241,7 +244,10 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size))
if (!pool)
return NULL;
ff_mutex_init(&pool->mutex, NULL);
if (ff_mutex_init(&pool->mutex, NULL)) {
av_free(pool);
return NULL;
}
pool->size = size;
pool->alloc = alloc ? alloc : av_buffer_alloc;
+1 -1
View File
@@ -867,7 +867,7 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
if (log2_crop_align < min_log2_align)
return AVERROR_BUG;
if (min_log2_align < 5) {
if (min_log2_align < 5 && log2_crop_align != INT_MAX) {
frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1);
calc_cropping_offsets(offsets, frame, desc);
}
+1 -1
View File
@@ -261,7 +261,7 @@ int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enu
stride = 8LL*w;
stride += 128*8;
if ((int)w<=0 || (int)h<=0 || stride >= INT_MAX || stride*(uint64_t)(h+128) >= INT_MAX) {
if (w==0 || h==0 || w > INT32_MAX || h > INT32_MAX || stride >= INT_MAX || stride*(h + 128ULL) >= INT_MAX) {
av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
return AVERROR(EINVAL);
}
+4
View File
@@ -168,6 +168,10 @@ static av_always_inline AVRational av_inv_q(AVRational q)
* In case of infinity, the returned value is expressed as `{1, 0}` or
* `{-1, 0}` depending on the sign.
*
* In general rational numbers with |num| <= 1<<26 && |den| <= 1<<26
* can be recovered exactly from their double representation.
* (no exceptions were found within 1B random ones)
*
* @param d `double` to convert
* @param max Maximum allowed numerator and denominator
* @return `d` in AVRational form
+26 -4
View File
@@ -98,6 +98,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv,
{
AVSliceThread *ctx;
int nb_workers, i;
int ret;
#if HAVE_W32THREADS
w32thread_init();
@@ -135,16 +136,37 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv,
atomic_init(&ctx->first_job, 0);
atomic_init(&ctx->current_job, 0);
pthread_mutex_init(&ctx->done_mutex, NULL);
pthread_cond_init(&ctx->done_cond, NULL);
ret = pthread_mutex_init(&ctx->done_mutex, NULL);
if (ret) {
av_freep(&ctx->workers);
av_freep(pctx);
return AVERROR(ret);
}
ret = pthread_cond_init(&ctx->done_cond, NULL);
if (ret) {
ctx->nb_threads = main_func ? 0 : 1;
avpriv_slicethread_free(pctx);
return AVERROR(ret);
}
ctx->done = 0;
for (i = 0; i < nb_workers; i++) {
WorkerContext *w = &ctx->workers[i];
int ret;
w->ctx = ctx;
pthread_mutex_init(&w->mutex, NULL);
pthread_cond_init(&w->cond, NULL);
ret = pthread_mutex_init(&w->mutex, NULL);
if (ret) {
ctx->nb_threads = main_func ? i : i + 1;
avpriv_slicethread_free(pctx);
return AVERROR(ret);
}
ret = pthread_cond_init(&w->cond, NULL);
if (ret) {
pthread_mutex_destroy(&w->mutex);
ctx->nb_threads = main_func ? i : i + 1;
avpriv_slicethread_free(pctx);
return AVERROR(ret);
}
pthread_mutex_lock(&w->mutex);
w->done = 0;
+5 -1
View File
@@ -236,6 +236,10 @@ static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val)
/**
* Rounding-to-nearest used.
*
* @param a angle in units of (1ULL<<30)/M_PI radians
* @param s pointer to where sine in units of (1<<30) is returned
* @param c pointer to where cosine in units of (1<<30) is returned
*/
static av_unused void av_sincos_sf(int a, int *s, int *c)
{
@@ -281,7 +285,7 @@ static av_unused void av_sincos_sf(int a, int *s, int *c)
(int64_t)av_sintbl_4_sf[(idx & 0x1f) + 1] * (a & 0x7ff) +
0x400) >> 11);
*c = (int)(((int64_t)cv * ct + (int64_t)sv * st + 0x20000000) >> 30);
*c = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30);
*s = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30);
}
+1 -1
View File
@@ -173,7 +173,7 @@ static int fps_from_frame_rate(AVRational rate)
{
if (!rate.den || !rate.num)
return -1;
return (rate.num + rate.den/2) / rate.den;
return (rate.num + rate.den/2LL) / rate.den;
}
int av_timecode_check_frame_rate(AVRational rate)