You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avfilter/scale_d3d11: cleanup return path using fail label
This commit is contained in:
@ -196,9 +196,7 @@ static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
ret = av_hwframe_get_buffer(s->hw_frames_ctx_out, out, 0);
|
ret = av_hwframe_get_buffer(s->hw_frames_ctx_out, out, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to get output frame from pool\n");
|
av_log(ctx, AV_LOG_ERROR, "Failed to get output frame from pool\n");
|
||||||
av_frame_free(&in);
|
goto fail;
|
||||||
av_frame_free(&out);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///< Configure the D3D11 video processor if not already configured
|
///< Configure the D3D11 video processor if not already configured
|
||||||
@ -215,9 +213,7 @@ static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
ret = scale_d3d11_configure_processor(s, ctx);
|
ret = scale_d3d11_configure_processor(s, ctx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to configure processor\n");
|
av_log(ctx, AV_LOG_ERROR, "Failed to configure processor\n");
|
||||||
av_frame_free(&in);
|
goto fail;
|
||||||
av_frame_free(&out);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,9 +231,8 @@ static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
s->videoDevice, (ID3D11Resource *)d3d11_texture, s->enumerator, &inputViewDesc, &inputView);
|
s->videoDevice, (ID3D11Resource *)d3d11_texture, s->enumerator, &inputViewDesc, &inputView);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to create input view: HRESULT 0x%lX\n", hr);
|
av_log(ctx, AV_LOG_ERROR, "Failed to create input view: HRESULT 0x%lX\n", hr);
|
||||||
av_frame_free(&in);
|
ret = AVERROR_EXTERNAL;
|
||||||
av_frame_free(&out);
|
goto fail;
|
||||||
return AVERROR_EXTERNAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///< Create output view for current texture
|
///< Create output view for current texture
|
||||||
@ -251,9 +246,8 @@ static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
s->videoDevice, (ID3D11Resource *)output_texture, s->enumerator, &outputViewDesc, &s->outputView);
|
s->videoDevice, (ID3D11Resource *)output_texture, s->enumerator, &outputViewDesc, &s->outputView);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to create output view: HRESULT 0x%lX\n", hr);
|
av_log(ctx, AV_LOG_ERROR, "Failed to create output view: HRESULT 0x%lX\n", hr);
|
||||||
av_frame_free(&in);
|
ret = AVERROR_EXTERNAL;
|
||||||
av_frame_free(&out);
|
goto fail;
|
||||||
return AVERROR_EXTERNAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///< Set up processing stream
|
///< Set up processing stream
|
||||||
@ -267,32 +261,23 @@ static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
hr = s->context->lpVtbl->QueryInterface(s->context, &IID_ID3D11VideoContext, (void **)&videoContext);
|
hr = s->context->lpVtbl->QueryInterface(s->context, &IID_ID3D11VideoContext, (void **)&videoContext);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to get video context: HRESULT 0x%lX\n", hr);
|
av_log(ctx, AV_LOG_ERROR, "Failed to get video context: HRESULT 0x%lX\n", hr);
|
||||||
inputView->lpVtbl->Release(inputView);
|
ret = AVERROR_EXTERNAL;
|
||||||
av_frame_free(&in);
|
goto fail;
|
||||||
av_frame_free(&out);
|
|
||||||
return AVERROR_EXTERNAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///< Process the frame
|
///< Process the frame
|
||||||
hr = videoContext->lpVtbl->VideoProcessorBlt(videoContext, s->processor, s->outputView, 0, 1, &stream);
|
hr = videoContext->lpVtbl->VideoProcessorBlt(videoContext, s->processor, s->outputView, 0, 1, &stream);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "VideoProcessorBlt failed: HRESULT 0x%lX\n", hr);
|
av_log(ctx, AV_LOG_ERROR, "VideoProcessorBlt failed: HRESULT 0x%lX\n", hr);
|
||||||
videoContext->lpVtbl->Release(videoContext);
|
ret = AVERROR_EXTERNAL;
|
||||||
inputView->lpVtbl->Release(inputView);
|
goto fail;
|
||||||
av_frame_free(&in);
|
|
||||||
av_frame_free(&out);
|
|
||||||
return AVERROR_EXTERNAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///< Set up output frame
|
///< Set up output frame
|
||||||
ret = av_frame_copy_props(out, in);
|
ret = av_frame_copy_props(out, in);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Failed to copy frame properties\n");
|
av_log(ctx, AV_LOG_ERROR, "Failed to copy frame properties\n");
|
||||||
videoContext->lpVtbl->Release(videoContext);
|
goto fail;
|
||||||
inputView->lpVtbl->Release(inputView);
|
|
||||||
av_frame_free(&in);
|
|
||||||
av_frame_free(&out);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out->data[0] = (uint8_t *)output_texture;
|
out->data[0] = (uint8_t *)output_texture;
|
||||||
@ -312,6 +297,19 @@ static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
|
|
||||||
///< Forward the frame
|
///< Forward the frame
|
||||||
return ff_filter_frame(outlink, out);
|
return ff_filter_frame(outlink, out);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (inputView)
|
||||||
|
inputView->lpVtbl->Release(inputView);
|
||||||
|
if (videoContext)
|
||||||
|
videoContext->lpVtbl->Release(videoContext);
|
||||||
|
if (s->outputView) {
|
||||||
|
s->outputView->lpVtbl->Release(s->outputView);
|
||||||
|
s->outputView = NULL;
|
||||||
|
}
|
||||||
|
av_frame_free(&in);
|
||||||
|
av_frame_free(&out);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scale_d3d11_config_props(AVFilterLink *outlink)
|
static int scale_d3d11_config_props(AVFilterLink *outlink)
|
||||||
|
Reference in New Issue
Block a user