History

dnn: add a new interface DNNModel.get_output

for some cases (for example, super resolution), the DNN model changes the frame size which impacts the filter behavior, so the filter needs to know the out frame size at very beginning. Currently, the filter reuses DNNModule.execute_model to query the out frame size, it is not clear from interface perspective, so add a new explict interface DNNModel.get_output for such query.

Guo, Yejun committed 6 years ago

Commit e71d73b1 parent fce3e3e6 files · +185 −58Browse files

Showing the changes to libavfilter (6 of 6 files). Show all

Unified · Split

6 files
  1. libavfilter/dnn/dnn_backend_native.c +56 −10
  2. libavfilter/dnn/dnn_backend_openvino.c +56 −10
  3. libavfilter/dnn/dnn_backend_tf.c +56 −10
  4. libavfilter/dnn_interface.h +3 −0
  5. libavfilter/vf_dnn_processing.c +4 −13
  6. libavfilter/vf_sr.c +10 −15
libavfilter/dnn/dnn_backend_native.c+56−10
@@ -44,6 +44,10 @@ const AVClass dnn_native_class = { · 43 unmodified lines
44 .category = AV_CLASS_CATEGORY_FILTER,44 .category = AV_CLASS_CATEGORY_FILTER,
45};45};
46 46
47static DNNReturnType execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
48 const char **output_names, uint32_t nb_output, AVFrame *out_frame,
49 int do_ioproc);
50
47static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)51static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
48{52{
49 NativeModel *native_model = (NativeModel *)model;53 NativeModel *native_model = (NativeModel *)model;
@@ -70,6 +74,25 @@ static DNNReturnType get_input_native(void *model, DNNData *input, const char *i · 20 unmodified lines
70 return DNN_ERROR;74 return DNN_ERROR;
71}75}
72 76
77static DNNReturnType get_output_native(void *model, const char *input_name, int input_width, int input_height,
78 const char *output_name, int *output_width, int *output_height)
79{
80 DNNReturnType ret;
81 NativeModel *native_model = (NativeModel *)model;
82 AVFrame *in_frame = av_frame_alloc();
83 AVFrame *out_frame = av_frame_alloc();
84 in_frame->width = input_width;
85 in_frame->height = input_height;
86
87 ret = execute_model_native(native_model->model, input_name, in_frame, &output_name, 1, out_frame, 0);
88 *output_width = out_frame->width;
89 *output_height = out_frame->height;
90
91 av_frame_free(&out_frame);
92 av_frame_free(&in_frame);
93 return ret;
94}
95
73// Loads model and its parameters that are stored in a binary file with following structure:96// Loads model and its parameters that are stored in a binary file with following structure:
74// layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...97// layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...
75// For CONV layer: activation_function, input_num, output_num, kernel_size, kernel, biases98// For CONV layer: activation_function, input_num, output_num, kernel_size, kernel, biases
@@ -216,6 +239,7 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename, const char *optio · 140 unmodified lines
216 }239 }
217 240
218 model->get_input = &get_input_native;241 model->get_input = &get_input_native;
242 model->get_output = &get_output_native;
219 model->userdata = userdata;243 model->userdata = userdata;
220 244
221 return model;245 return model;
@@ -226,8 +250,9 @@ fail: · 4 unmodified lines
226 return NULL;250 return NULL;
227}251}
228 252
229DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,253static DNNReturnType execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
230 const char **output_names, uint32_t nb_output, AVFrame *out_frame)254 const char **output_names, uint32_t nb_output, AVFrame *out_frame,
255 int do_ioproc)
231{256{
232 NativeModel *native_model = (NativeModel *)model->model;257 NativeModel *native_model = (NativeModel *)model->model;
233 NativeContext *ctx = &native_model->ctx;258 NativeContext *ctx = &native_model->ctx;
@@ -276,10 +301,12 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *inp · 42 unmodified lines
276 input.channels = oprd->dims[3];301 input.channels = oprd->dims[3];
277 input.data = oprd->data;302 input.data = oprd->data;
278 input.dt = oprd->data_type;303 input.dt = oprd->data_type;
279 if (native_model->model->pre_proc != NULL) {304 if (do_ioproc) {
280 native_model->model->pre_proc(in_frame, &input, native_model->model->userdata);305 if (native_model->model->pre_proc != NULL) {
281 } else {306 native_model->model->pre_proc(in_frame, &input, native_model->model->userdata);
282 proc_from_frame_to_dnn(in_frame, &input, ctx);307 } else {
308 proc_from_frame_to_dnn(in_frame, &input, ctx);
309 }
283 }310 }
284 311
285 if (nb_output != 1) {312 if (nb_output != 1) {
@@ -322,21 +349,40 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *inp · 36 unmodified lines
322 output.channels = oprd->dims[3];349 output.channels = oprd->dims[3];
323 output.dt = oprd->data_type;350 output.dt = oprd->data_type;
324 351
325 if (out_frame->width != output.width || out_frame->height != output.height) {352 if (do_ioproc) {
326 out_frame->width = output.width;
327 out_frame->height = output.height;
328 } else {
329 if (native_model->model->post_proc != NULL) {353 if (native_model->model->post_proc != NULL) {
330 native_model->model->post_proc(out_frame, &output, native_model->model->userdata);354 native_model->model->post_proc(out_frame, &output, native_model->model->userdata);
331 } else {355 } else {
332 proc_from_dnn_to_frame(out_frame, &output, ctx);356 proc_from_dnn_to_frame(out_frame, &output, ctx);
333 }357 }
358 } else {
359 out_frame->width = output.width;
360 out_frame->height = output.height;
334 }361 }
335 }362 }
336 363
337 return DNN_SUCCESS;364 return DNN_SUCCESS;
338}365}
339 366
367DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
368 const char **output_names, uint32_t nb_output, AVFrame *out_frame)
369{
370 NativeModel *native_model = (NativeModel *)model->model;
371 NativeContext *ctx = &native_model->ctx;
372
373 if (!in_frame) {
374 av_log(ctx, AV_LOG_ERROR, "in frame is NULL when execute model.\n");
375 return DNN_ERROR;
376 }
377
378 if (!out_frame) {
379 av_log(ctx, AV_LOG_ERROR, "out frame is NULL when execute model.\n");
380 return DNN_ERROR;
381 }
382
383 return execute_model_native(model, input_name, in_frame, output_names, nb_output, out_frame, 1);
384}
385
340int32_t calculate_operand_dims_count(const DnnOperand *oprd)386int32_t calculate_operand_dims_count(const DnnOperand *oprd)
341{387{
342 int32_t result = 1;388 int32_t result = 1;
libavfilter/dnn/dnn_backend_openvino.c+56−10
@@ -63,6 +63,10 @@ static const AVOption dnn_openvino_options[] = { · 62 unmodified lines
63 63
64AVFILTER_DEFINE_CLASS(dnn_openvino);64AVFILTER_DEFINE_CLASS(dnn_openvino);
65 65
66static DNNReturnType execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
67 const char **output_names, uint32_t nb_output, AVFrame *out_frame,
68 int do_ioproc);
69
66static DNNDataType precision_to_datatype(precision_e precision)70static DNNDataType precision_to_datatype(precision_e precision)
67{71{
68 switch (precision)72 switch (precision)
@@ -132,6 +136,25 @@ static DNNReturnType get_input_ov(void *model, DNNData *input, const char *input · 63 unmodified lines
132 return DNN_ERROR;136 return DNN_ERROR;
133}137}
134 138
139static DNNReturnType get_output_ov(void *model, const char *input_name, int input_width, int input_height,
140 const char *output_name, int *output_width, int *output_height)
141{
142 DNNReturnType ret;
143 OVModel *ov_model = (OVModel *)model;
144 AVFrame *in_frame = av_frame_alloc();
145 AVFrame *out_frame = av_frame_alloc();
146 in_frame->width = input_width;
147 in_frame->height = input_height;
148
149 ret = execute_model_ov(ov_model->model, input_name, in_frame, &output_name, 1, out_frame, 0);
150 *output_width = out_frame->width;
151 *output_height = out_frame->height;
152
153 av_frame_free(&out_frame);
154 av_frame_free(&in_frame);
155 return ret;
156}
157
135DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, void *userdata)158DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, void *userdata)
136{159{
137 char *all_dev_names = NULL;160 char *all_dev_names = NULL;
@@ -191,6 +214,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, · 53 unmodified lines
191 214
192 model->model = (void *)ov_model;215 model->model = (void *)ov_model;
193 model->get_input = &get_input_ov;216 model->get_input = &get_input_ov;
217 model->get_output = &get_output_ov;
194 model->options = options;218 model->options = options;
195 model->userdata = userdata;219 model->userdata = userdata;
196 220
@@ -213,8 +237,9 @@ err: · 16 unmodified lines
213 return NULL;237 return NULL;
214}238}
215 239
216DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,240static DNNReturnType execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
217 const char **output_names, uint32_t nb_output, AVFrame *out_frame)241 const char **output_names, uint32_t nb_output, AVFrame *out_frame,
242 int do_ioproc)
218{243{
219 char *model_output_name = NULL;244 char *model_output_name = NULL;
220 char *all_output_names = NULL;245 char *all_output_names = NULL;
@@ -252,10 +277,12 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n · 31 unmodified lines
252 input.channels = dims.dims[1];277 input.channels = dims.dims[1];
253 input.data = blob_buffer.buffer;278 input.data = blob_buffer.buffer;
254 input.dt = precision_to_datatype(precision);279 input.dt = precision_to_datatype(precision);
255 if (ov_model->model->pre_proc != NULL) {280 if (do_ioproc) {
256 ov_model->model->pre_proc(in_frame, &input, ov_model->model->userdata);281 if (ov_model->model->pre_proc != NULL) {
257 } else {282 ov_model->model->pre_proc(in_frame, &input, ov_model->model->userdata);
258 proc_from_frame_to_dnn(in_frame, &input, ctx);283 } else {
284 proc_from_frame_to_dnn(in_frame, &input, ctx);
285 }
259 }286 }
260 ie_blob_free(&input_blob);287 ie_blob_free(&input_blob);
261 288
@@ -308,15 +335,15 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n · 46 unmodified lines
308 output.width = dims.dims[3];335 output.width = dims.dims[3];
309 output.dt = precision_to_datatype(precision);336 output.dt = precision_to_datatype(precision);
310 output.data = blob_buffer.buffer;337 output.data = blob_buffer.buffer;
311 if (out_frame->width != output.width || out_frame->height != output.height) {338 if (do_ioproc) {
312 out_frame->width = output.width;
313 out_frame->height = output.height;
314 } else {
315 if (ov_model->model->post_proc != NULL) {339 if (ov_model->model->post_proc != NULL) {
316 ov_model->model->post_proc(out_frame, &output, ov_model->model->userdata);340 ov_model->model->post_proc(out_frame, &output, ov_model->model->userdata);
317 } else {341 } else {
318 proc_from_dnn_to_frame(out_frame, &output, ctx);342 proc_from_dnn_to_frame(out_frame, &output, ctx);
319 }343 }
344 } else {
345 out_frame->width = output.width;
346 out_frame->height = output.height;
320 }347 }
321 ie_blob_free(&output_blob);348 ie_blob_free(&output_blob);
322 }349 }
@@ -324,6 +351,25 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n · 1 unmodified line
324 return DNN_SUCCESS;351 return DNN_SUCCESS;
325}352}
326 353
354DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
355 const char **output_names, uint32_t nb_output, AVFrame *out_frame)
356{
357 OVModel *ov_model = (OVModel *)model->model;
358 OVContext *ctx = &ov_model->ctx;
359
360 if (!in_frame) {
361 av_log(ctx, AV_LOG_ERROR, "in frame is NULL when execute model.\n");
362 return DNN_ERROR;
363 }
364
365 if (!out_frame) {
366 av_log(ctx, AV_LOG_ERROR, "out frame is NULL when execute model.\n");
367 return DNN_ERROR;
368 }
369
370 return execute_model_ov(model, input_name, in_frame, output_names, nb_output, out_frame, 1);
371}
372
327void ff_dnn_free_model_ov(DNNModel **model)373void ff_dnn_free_model_ov(DNNModel **model)
328{374{
329 if (*model){375 if (*model){
libavfilter/dnn/dnn_backend_tf.c+56−10
@@ -55,6 +55,10 @@ static const AVClass dnn_tensorflow_class = { · 54 unmodified lines
55 .category = AV_CLASS_CATEGORY_FILTER,55 .category = AV_CLASS_CATEGORY_FILTER,
56};56};
57 57
58static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,
59 const char **output_names, uint32_t nb_output, AVFrame *out_frame,
60 int do_ioproc);
61
58static void free_buffer(void *data, size_t length)62static void free_buffer(void *data, size_t length)
59{63{
60 av_freep(&data);64 av_freep(&data);
@@ -150,6 +154,25 @@ static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input · 89 unmodified lines
150 return DNN_SUCCESS;154 return DNN_SUCCESS;
151}155}
152 156
157static DNNReturnType get_output_tf(void *model, const char *input_name, int input_width, int input_height,
158 const char *output_name, int *output_width, int *output_height)
159{
160 DNNReturnType ret;
161 TFModel *tf_model = (TFModel *)model;
162 AVFrame *in_frame = av_frame_alloc();
163 AVFrame *out_frame = av_frame_alloc();
164 in_frame->width = input_width;
165 in_frame->height = input_height;
166
167 ret = execute_model_tf(tf_model->model, input_name, in_frame, &output_name, 1, out_frame, 0);
168 *output_width = out_frame->width;
169 *output_height = out_frame->height;
170
171 av_frame_free(&out_frame);
172 av_frame_free(&in_frame);
173 return ret;
174}
175
153static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename)176static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename)
154{177{
155 TFContext *ctx = &tf_model->ctx;178 TFContext *ctx = &tf_model->ctx;
@@ -583,14 +606,16 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, const char *options, · 427 unmodified lines
583 606
584 model->model = (void *)tf_model;607 model->model = (void *)tf_model;
585 model->get_input = &get_input_tf;608 model->get_input = &get_input_tf;
609 model->get_output = &get_output_tf;
586 model->options = options;610 model->options = options;
587 model->userdata = userdata;611 model->userdata = userdata;
588 612
589 return model;613 return model;
590}614}
591 615
592DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,616static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,
593 const char **output_names, uint32_t nb_output, AVFrame *out_frame)617 const char **output_names, uint32_t nb_output, AVFrame *out_frame,
618 int do_ioproc)
594{619{
595 TF_Output *tf_outputs;620 TF_Output *tf_outputs;
596 TFModel *tf_model = (TFModel *)model->model;621 TFModel *tf_model = (TFModel *)model->model;
@@ -618,10 +643,12 @@ DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_n · 21 unmodified lines
618 }643 }
619 input.data = (float *)TF_TensorData(input_tensor);644 input.data = (float *)TF_TensorData(input_tensor);
620 645
621 if (tf_model->model->pre_proc != NULL) {646 if (do_ioproc) {
622 tf_model->model->pre_proc(in_frame, &input, tf_model->model->userdata);647 if (tf_model->model->pre_proc != NULL) {
623 } else {648 tf_model->model->pre_proc(in_frame, &input, tf_model->model->userdata);
624 proc_from_frame_to_dnn(in_frame, &input, ctx);649 } else {
650 proc_from_frame_to_dnn(in_frame, &input, ctx);
651 }
625 }652 }
626 653
627 if (nb_output != 1) {654 if (nb_output != 1) {
@@ -673,15 +700,15 @@ DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_n · 45 unmodified lines
673 output.data = TF_TensorData(output_tensors[i]);700 output.data = TF_TensorData(output_tensors[i]);
674 output.dt = TF_TensorType(output_tensors[i]);701 output.dt = TF_TensorType(output_tensors[i]);
675 702
676 if (out_frame->width != output.width || out_frame->height != output.height) {703 if (do_ioproc) {
677 out_frame->width = output.width;
678 out_frame->height = output.height;
679 } else {
680 if (tf_model->model->post_proc != NULL) {704 if (tf_model->model->post_proc != NULL) {
681 tf_model->model->post_proc(out_frame, &output, tf_model->model->userdata);705 tf_model->model->post_proc(out_frame, &output, tf_model->model->userdata);
682 } else {706 } else {
683 proc_from_dnn_to_frame(out_frame, &output, ctx);707 proc_from_dnn_to_frame(out_frame, &output, ctx);
684 }708 }
709 } else {
710 out_frame->width = output.width;
711 out_frame->height = output.height;
685 }712 }
686 }713 }
687 714
@@ -696,6 +723,25 @@ DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_n · 8 unmodified lines
696 return DNN_SUCCESS;723 return DNN_SUCCESS;
697}724}
698 725
726DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,
727 const char **output_names, uint32_t nb_output, AVFrame *out_frame)
728{
729 TFModel *tf_model = (TFModel *)model->model;
730 TFContext *ctx = &tf_model->ctx;
731
732 if (!in_frame) {
733 av_log(ctx, AV_LOG_ERROR, "in frame is NULL when execute model.\n");
734 return DNN_ERROR;
735 }
736
737 if (!out_frame) {
738 av_log(ctx, AV_LOG_ERROR, "out frame is NULL when execute model.\n");
739 return DNN_ERROR;
740 }
741
742 return execute_model_tf(model, input_name, in_frame, output_names, nb_output, out_frame, 1);
743}
744
699void ff_dnn_free_model_tf(DNNModel **model)745void ff_dnn_free_model_tf(DNNModel **model)
700{746{
701 TFModel *tf_model;747 TFModel *tf_model;
libavfilter/dnn_interface.h+3−0
@@ -51,6 +51,9 @@ typedef struct DNNModel{ · 50 unmodified lines
51 // Gets model input information51 // Gets model input information
52 // Just reuse struct DNNData here, actually the DNNData.data field is not needed.52 // Just reuse struct DNNData here, actually the DNNData.data field is not needed.
53 DNNReturnType (*get_input)(void *model, DNNData *input, const char *input_name);53 DNNReturnType (*get_input)(void *model, DNNData *input, const char *input_name);
54 // Gets model output width/height with given input w/h
55 DNNReturnType (*get_output)(void *model, const char *input_name, int input_width, int input_height,
56 const char *output_name, int *output_width, int *output_height);
54 // set the pre process to transfer data from AVFrame to DNNData57 // set the pre process to transfer data from AVFrame to DNNData
55 // the default implementation within DNN is used if it is not provided by the filter58 // the default implementation within DNN is used if it is not provided by the filter
56 int (*pre_proc)(AVFrame *frame_in, DNNData *model_input, void *user_data);59 int (*pre_proc)(AVFrame *frame_in, DNNData *model_input, void *user_data);
libavfilter/vf_dnn_processing.c+4−13
@@ -233,24 +233,15 @@ static int config_output(AVFilterLink *outlink) · 232 unmodified lines
233 DnnProcessingContext *ctx = context->priv;233 DnnProcessingContext *ctx = context->priv;
234 DNNReturnType result;234 DNNReturnType result;
235 AVFilterLink *inlink = context->inputs[0];235 AVFilterLink *inlink = context->inputs[0];
236 AVFrame *out = NULL;
237
238 AVFrame *fake_in = ff_get_video_buffer(inlink, inlink->w, inlink->h);
239 236
240 // have a try run in case that the dnn model resize the frame237 // have a try run in case that the dnn model resize the frame
241 out = ff_get_video_buffer(inlink, inlink->w, inlink->h);238 result = ctx->model->get_output(ctx->model->model, ctx->model_inputname, inlink->w, inlink->h,
242 result = (ctx->dnn_module->execute_model)(ctx->model, ctx->model_inputname, fake_in,239 ctx->model_outputname, &outlink->w, &outlink->h);
243 (const char **)&ctx->model_outputname, 1, out);240 if (result != DNN_SUCCESS) {
244 if (result != DNN_SUCCESS){241 av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
245 av_log(ctx, AV_LOG_ERROR, "failed to execute model\n");
246 return AVERROR(EIO);242 return AVERROR(EIO);
247 }243 }
248 244
249 outlink->w = out->width;
250 outlink->h = out->height;
251
252 av_frame_free(&fake_in);
253 av_frame_free(&out);
254 prepare_uv_scale(outlink);245 prepare_uv_scale(outlink);
255 246
256 return 0;247 return 0;
libavfilter/vf_sr.c+10−15
@@ -111,23 +111,20 @@ static int config_output(AVFilterLink *outlink) · 110 unmodified lines
111 SRContext *ctx = context->priv;111 SRContext *ctx = context->priv;
112 DNNReturnType result;112 DNNReturnType result;
113 AVFilterLink *inlink = context->inputs[0];113 AVFilterLink *inlink = context->inputs[0];
114 AVFrame *out = NULL;114 int out_width, out_height;
115 const char *model_output_name = "y";
116 115
117 // have a try run in case that the dnn model resize the frame116 // have a try run in case that the dnn model resize the frame
118 AVFrame *fake_in = ff_get_video_buffer(inlink, inlink->w, inlink->h);117 result = ctx->model->get_output(ctx->model->model, "x", inlink->w, inlink->h,
119 out = ff_get_video_buffer(inlink, inlink->w, inlink->h);118 "y", &out_width, &out_height);
120 result = (ctx->dnn_module->execute_model)(ctx->model, "x", fake_in,119 if (result != DNN_SUCCESS) {
121 (const char **)&model_output_name, 1, out);120 av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
122 if (result != DNN_SUCCESS){
123 av_log(context, AV_LOG_ERROR, "failed to execute loaded model\n");
124 return AVERROR(EIO);121 return AVERROR(EIO);
125 }122 }
126 123
127 if (fake_in->width != out->width || fake_in->height != out->height) {124 if (inlink->w != out_width || inlink->h != out_height) {
128 //espcn125 //espcn
129 outlink->w = out->width;126 outlink->w = out_width;
130 outlink->h = out->height;127 outlink->h = out_height;
131 if (inlink->format != AV_PIX_FMT_GRAY8){128 if (inlink->format != AV_PIX_FMT_GRAY8){
132 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);129 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
133 int sws_src_h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);130 int sws_src_h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
@@ -141,15 +138,13 @@ static int config_output(AVFilterLink *outlink) · 7 unmodified lines
141 }138 }
142 } else {139 } else {
143 //srcnn140 //srcnn
144 outlink->w = out->width * ctx->scale_factor;141 outlink->w = out_width * ctx->scale_factor;
145 outlink->h = out->height * ctx->scale_factor;142 outlink->h = out_height * ctx->scale_factor;
146 ctx->sws_pre_scale = sws_getContext(inlink->w, inlink->h, inlink->format,143 ctx->sws_pre_scale = sws_getContext(inlink->w, inlink->h, inlink->format,
147 outlink->w, outlink->h, outlink->format,144 outlink->w, outlink->h, outlink->format,
148 SWS_BICUBIC, NULL, NULL, NULL);145 SWS_BICUBIC, NULL, NULL, NULL);
149 }146 }
150 147
151 av_frame_free(&fake_in);
152 av_frame_free(&out);
153 return 0;148 return 0;
154}149}
155 150

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t