Hi <div><br></div><div>I have some questions in the code below. Also is there any way to multithread a filter?</div><div><br></div><div><div>struct deinterlacer::implementation</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>std::shared_ptr<AVFilterGraph><span class="Apple-tab-span" style="white-space:pre">        </span>graph_;</div>
<div><br></div><div>        // Do I need to free the filter context somehow?</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>AVFilterContext*<span class="Apple-tab-span" style="white-space:pre">                    </span>video_in_filter_;  </div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>AVFilterContext*<span class="Apple-tab-span" style="white-space:pre">                    </span>video_out_filter_;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">  </span>implementation(size_t width, size_t height, PixelFormat pix_fmt)</div>
<div><span class="Apple-tab-span" style="white-space:pre">              </span>: graph_(avfilter_graph_alloc(), avfilter_graph_free)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{<span class="Apple-tab-span" style="white-space:pre">           </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>     // What is this "buffer" filter and why do I need to configure it with time_base?</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>    snprintf(args, sizeof(args), "%d:%d:%d:%d:%d", width, height, pix_fmt, video_dec->time_base.num, video_dec->time_base.den);<span class="Apple-tab-span" style="white-space:pre">     </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>    avfilter_graph_create_filter(&video_in_filter_, avfilter_get_by_name("buffer"), "src", args, NULL, filter_graph);<span class="Apple-tab-span" style="white-space:pre">       </span></div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>    // Can yadif be at the end of the filter or do I need to add some form of "sink"?</div><div>            // Where will the check that the yadif filter supports the pix_fmt provided to "buffer" or not?</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>    avfilter_graph_create_filter(&video_out_filter_, avfilter_get_by_name("yadif"), "out", NULL, NULL, filter_graph);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>    // I hope this is correct?</div><div>        <span class="Apple-tab-span" style="white-space:pre">       </span>avfilter_graph_add_filter(filter_graph_, video_in_filter_);</div>
<div><span class="Apple-tab-span" style="white-space:pre">              </span>avfilter_graph_add_filter(filter_graph_, video_out_filter_);</div><div><span class="Apple-tab-span" style="white-space:pre">         </span></div><div><span class="Apple-tab-span" style="white-space:pre">             </span>// Is this required?</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>    avfilter_graph_config(filter_graph, NULL);</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>std::shared_ptr<AVFrame> execute(const std::shared_ptr<AVFrame>& frame)</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>// Not sure why this is the "out" link?</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>AVFilterLink* out = video_out_filter->inputs[0];</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">             </span>// Will this make a copy of the frame? Or do I need to store it in  a buffer in order to guarantee it is not freed while the filter is working on it?</div>
<div><span class="Apple-tab-span" style="white-space:pre">              </span>av_vsrc_buffer_add_frame(video_in_filter, frame, 0);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>// Do I need to get all the frames poll_frame says exists, or can I just take one?</div>
<div><span class="Apple-tab-span" style="white-space:pre">              </span>if(avfilter_poll_frame(out) > 0)</div><div><span class="Apple-tab-span" style="white-space:pre">                  </span>avfilter_request_frame(out); </div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">              </span>// Where is my resulting frame?</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>}</div><div>};</div></div>