On 31/03/17 20:31, Anton Khirnov wrote:
> Quoting Mark Thompson (2017-03-05 00:57:41)
>> Also refactor a little and improve error messages to make failure
>> cases easier to understand.
>> ---
>> libavfilter/vf_hwmap.c | 67
>> +++++++++++++++++++++++++++++++++++++++-----------
>> 1 file changed, 52 insertions(+), 15 deletions(-)
>>
>> diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c
>> index 11595bd6c..6e890dae3 100644
>> --- a/libavfilter/vf_hwmap.c
>> +++ b/libavfilter/vf_hwmap.c
>> @@ -34,6 +34,7 @@ typedef struct HWMapContext {
>> AVBufferRef *hwframes_ref;
>>
>> int mode;
>> + char *derive_device_type;
>> int map_backwards;
>> } HWMapContext;
>>
>> @@ -52,6 +53,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
>> HWMapContext *ctx = avctx->priv;
>> AVFilterLink *inlink = avctx->inputs[0];
>> AVHWFramesContext *hwfc;
>> + AVBufferRef *device;
>> const AVPixFmtDescriptor *desc;
>> int err;
>>
>> @@ -59,30 +61,61 @@ static int hwmap_config_output(AVFilterLink *outlink)
>> av_get_pix_fmt_name(inlink->format),
>> av_get_pix_fmt_name(outlink->format));
>>
>> + av_buffer_unref(&ctx->hwframes_ref);
>> + av_buffer_unref(&ctx->hwdevice_ref);
>
> maybe just call uninit() from both here and the fail block
Sure.
>> +
>> + device = avctx->hw_device_ctx;
>> +
>> if (inlink->hw_frames_ctx) {
>> hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
>>
>> + if (ctx->derive_device_type) {
>> + enum AVHWDeviceType type;
>> +
>> + type = av_hwdevice_find_type_by_name(ctx->derive_device_type);
>> + if (type == -1) {
>
> TYPE_NONE?
Oops, leftover from before NONE existed.
> Why are we even keeping hwdevice_ref in the context here? Seems it's not
> used outside of hwmap_config_output().
Hmm, yes. It holds the derived device, but we don't actually need that because
the frames context holds the necessary reference. I'll remove it.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel