!248 ffmpegbug修改

Merge pull request !248 from ziyugao/master
This commit is contained in:
openharmony_ci 2024-08-17 03:49:55 +00:00 committed by Gitee
commit a8dd53fbe1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 39 additions and 22 deletions

View File

@ -800,7 +800,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx,
unsigned type, const void *data, unsigned size,
unsigned mb_count)
{
void *dxva_data;
void *dxva_data = NULL;
unsigned dxva_size;
int result;
HRESULT hr = 0;
@ -822,7 +822,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx,
type, (unsigned)hr);
return -1;
}
if (size <= dxva_size) {
if (dxva_data && size <= dxva_size) {
memcpy(dxva_data, data, size);
#if CONFIG_D3D11VA

View File

@ -232,6 +232,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;
}

View File

@ -558,6 +558,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
}
goto fail;
} else {
memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
s->img_count++;
s->img_number++;
s->pts++;

View File

@ -871,8 +871,7 @@ static int w64_read_header(AVFormatContext *s)
uint8_t guid[16];
int ret;
avio_read(pb, guid, 16);
if (memcmp(guid, ff_w64_guid_riff, 16))
if (avio_read(pb, guid, 16) != 16 || memcmp(guid, ff_w64_guid_riff, 16))
return AVERROR_INVALIDDATA;
/* riff + wave + fmt + sizes */

View File

@ -227,7 +227,7 @@ av_cold int swr_init(struct SwrContext *s){
s->in_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
s->in_ch_layout.nb_channels = s->user_in_ch_count;
}
} else
} else if (av_channel_layout_check(&s->user_in_chlayout))
av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout);
if ((s->user_out_ch_count && s->user_out_ch_count != s->user_out_chlayout.nb_channels) ||
@ -240,17 +240,45 @@ av_cold int swr_init(struct SwrContext *s){
s->out_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
s->out_ch_layout.nb_channels = s->user_out_ch_count;
}
} else
} else if (av_channel_layout_check(&s->user_out_chlayout))
av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout);
if (!s->out.ch_count && !s->user_out_ch_layout)
s->out.ch_count = s->out_ch_layout.nb_channels;
if (!s-> in.ch_count && !s-> user_in_ch_layout)
s-> in.ch_count = s->in_ch_layout.nb_channels;
if (!(ret = av_channel_layout_check(&s->in_ch_layout)) || s->in_ch_layout.nb_channels > SWR_CH_MAX) {
if (ret)
av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1));
av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", ret ? l1 : "");
return AVERROR(EINVAL);
}
if (!(ret = av_channel_layout_check(&s->out_ch_layout)) || s->out_ch_layout.nb_channels > SWR_CH_MAX) {
if (ret)
av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2));
av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", ret ? l2 : "");
return AVERROR(EINVAL);
}
#else
s->out.ch_count = s-> user_out_chlayout.nb_channels;
s-> in.ch_count = s-> user_in_chlayout.nb_channels;
if (!(ret = av_channel_layout_check(&s->user_in_chlayout)) || s->user_in_chlayout.nb_channels > SWR_CH_MAX) {
if (ret)
av_channel_layout_describe(&s->user_in_chlayout, l1, sizeof(l1));
av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", ret ? l1 : "");
return AVERROR(EINVAL);
}
if (!(ret = av_channel_layout_check(&s->user_out_chlayout)) || s->user_out_chlayout.nb_channels > SWR_CH_MAX) {
if (ret)
av_channel_layout_describe(&s->user_out_chlayout, l2, sizeof(l2));
av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", ret ? l2 : "");
return AVERROR(EINVAL);
}
ret = av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout);
ret |= av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout);
if (ret < 0)
@ -261,18 +289,6 @@ av_cold int swr_init(struct SwrContext *s){
s->dither.method = s->user_dither_method;
if (!av_channel_layout_check(&s->in_ch_layout) || s->in_ch_layout.nb_channels > SWR_CH_MAX) {
av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1));
av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", l1);
av_channel_layout_uninit(&s->in_ch_layout);
}
if (!av_channel_layout_check(&s->out_ch_layout) || s->out_ch_layout.nb_channels > SWR_CH_MAX) {
av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2));
av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", l2);
av_channel_layout_uninit(&s->out_ch_layout);
}
switch(s->engine){
#if CONFIG_LIBSOXR
case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;
@ -291,9 +307,9 @@ av_cold int swr_init(struct SwrContext *s){
av_channel_layout_uninit(&s->in_ch_layout);
}
if (!s->in_ch_layout.nb_channels || s->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
if (s->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
av_channel_layout_default(&s->in_ch_layout, s->used_ch_count);
if (!s->out_ch_layout.nb_channels || s->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
if (s->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
av_channel_layout_default(&s->out_ch_layout, s->out.ch_count);
s->rematrix = av_channel_layout_compare(&s->out_ch_layout, &s->in_ch_layout) ||

View File

@ -101,9 +101,9 @@ const int *sws_getCoefficients(int colorspace)
#define PUTRGBA(dst, ysrc, asrc, i, s) \
Y = ysrc[2 * i]; \
dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \
dst[2 * i] = r[Y] + g[Y] + b[Y] + ((uint32_t)asrc[2 * i] << s); \
Y = ysrc[2 * i + 1]; \
dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s);
dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + ((uint32_t)asrc[2 * i + 1] << s);
#define PUTRGB48(dst, src, i) \
Y = src[ 2 * i]; \