mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
avcodec/avfilter_amf: correct handling of AMF errors
Fix several AMF-related issues. Check the return value of amf_init_frames_context() correctly in amfdec, as it returns int rather than AMF_RESULT. Handle possible NULL surfaces returned from QueryInterface() in vf_amf_common to avoid passing invalid data to amf_amfsurface_to_avframe(). Remove FILTER_SINGLE_PIXFMT from vf_sr_amf since it must not be used together with a query formats function.
This commit is contained in:
committed by
ArazIusubov
parent
b43645b2ef
commit
4479d28103
@@ -640,9 +640,10 @@ static int amf_decode_frame(AVCodecContext *avctx, struct AVFrame *frame)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
res = ctx->decoder->pVtbl->GetProperty(ctx->decoder, AMF_VIDEO_DECODER_OUTPUT_FORMAT, &format_var);
|
||||
if (res == AMF_OK) {
|
||||
res = amf_init_frames_context(avctx, av_amf_to_av_format(format_var.int64Value), avctx->coded_width, avctx->coded_height);
|
||||
if (res != AMF_OK) {
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
int ret = amf_init_frames_context(avctx, av_amf_to_av_format(format_var.int64Value), avctx->coded_width, avctx->coded_height);
|
||||
|
||||
if (res < 0)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
@@ -101,8 +101,11 @@ int amf_filter_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||
|
||||
if (data_out) {
|
||||
AMFGuid guid = IID_AMFSurface();
|
||||
data_out->pVtbl->QueryInterface(data_out, &guid, (void**)&surface_out); // query for buffer interface
|
||||
res = data_out->pVtbl->QueryInterface(data_out, &guid, (void**)&surface_out); // query for buffer interface
|
||||
data_out->pVtbl->Release(data_out);
|
||||
AMF_RETURN_IF_FALSE(avctx, res == AMF_OK, AVERROR_UNKNOWN, "QueryInterface(IID_AMFSurface) failed with error %d\n", res);
|
||||
} else {
|
||||
return AVERROR(EAGAIN);
|
||||
}
|
||||
|
||||
out = amf_amfsurface_to_avframe(avctx, surface_out);
|
||||
|
||||
@@ -180,6 +180,5 @@ FFFilter ff_vf_sr_amf = {
|
||||
FILTER_INPUTS(amf_filter_inputs),
|
||||
FILTER_OUTPUTS(amf_filter_outputs),
|
||||
FILTER_QUERY_FUNC(&amf_filter_query_formats),
|
||||
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_AMF_SURFACE),
|
||||
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user