From: John Stebbins Date: Mon, 18 Mar 2019 16:28:32 +0000 (-0600) Subject: hbavfilter: hide internals of hb_avfilter_graph_s X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8179f86c9dce3130e297c7dc3d3e7d0755a64281;p=handbrake hbavfilter: hide internals of hb_avfilter_graph_s --- diff --git a/libhb/avfilter.c b/libhb/avfilter.c index 6d69c97a8..d7fe4ea04 100644 --- a/libhb/avfilter.c +++ b/libhb/avfilter.c @@ -58,19 +58,7 @@ static int avfilter_init( hb_filter_object_t * filter, hb_filter_init_t * init ) } // Retrieve the parameters of the output filter - AVFilterLink *link = pv->graph->output->inputs[0]; - init->geometry.width = link->w; - init->geometry.height = link->h; - init->geometry.par.num = link->sample_aspect_ratio.num; - init->geometry.par.den = link->sample_aspect_ratio.den; - init->pix_fmt = link->format; - // avfilter can generate "unknown" framerates. If this happens - // just pass along the source framerate. - if (link->frame_rate.num > 0 && link->frame_rate.den > 0) - { - init->vrate.num = link->frame_rate.num; - init->vrate.den = link->frame_rate.den; - } + hb_avfilter_graph_update_init(pv->graph, init); pv->output = *init; hb_buffer_list_clear(&pv->list); @@ -109,21 +97,8 @@ static int avfilter_post_init( hb_filter_object_t * filter, hb_job_t * job ) } // Retrieve the parameters of the output filter - hb_filter_init_t * init = &pv->output; - AVFilterLink *link = pv->graph->output->inputs[0]; - *init = pv->input; - init->geometry.width = link->w; - init->geometry.height = link->h; - init->geometry.par.num = link->sample_aspect_ratio.num; - init->geometry.par.den = link->sample_aspect_ratio.den; - init->pix_fmt = link->format; - // avfilter can generate "unknown" framerates. If this happens - // just pass along the source framerate. - if (link->frame_rate.num > 0 && link->frame_rate.den > 0) - { - init->vrate.num = link->frame_rate.num; - init->vrate.den = link->frame_rate.den; - } + pv->output = pv->input; + hb_avfilter_graph_update_init(pv->graph, &pv->output); hb_buffer_list_clear(&pv->list); @@ -167,8 +142,8 @@ static hb_filter_info_t * avfilter_info(hb_filter_object_t * filter) } info->human_readable_desc[0] = 0; - char * dst = info->human_readable_desc; - char * start = pv->graph->settings; + char * dst = info->human_readable_desc; + const char * start = hb_avfilter_graph_settings(pv->graph); while (start != NULL && *start != 0) { // Find end of a filter diff --git a/libhb/avfilter_priv.h b/libhb/avfilter_priv.h index a0430fd62..8c6b0a627 100644 --- a/libhb/avfilter_priv.h +++ b/libhb/avfilter_priv.h @@ -13,17 +13,6 @@ #include "libavfilter/avfilter.h" #include "hbavfilter.h" -struct hb_avfilter_graph_s -{ - AVFilterGraph * avgraph; - AVFilterContext * last; - AVFilterContext * input; - AVFilterContext * output; - char * settings; - AVFrame * frame; - AVRational out_time_base; -}; - struct hb_filter_private_s { int initialized; diff --git a/libhb/hbavfilter.c b/libhb/hbavfilter.c index c1b789f71..a76fdf9e6 100644 --- a/libhb/hbavfilter.c +++ b/libhb/hbavfilter.c @@ -15,6 +15,17 @@ #include "hbavfilter.h" #include "avfilter_priv.h" +struct hb_avfilter_graph_s +{ + AVFilterGraph * avgraph; + AVFilterContext * last; + AVFilterContext * input; + AVFilterContext * output; + char * settings; + AVFrame * frame; + AVRational out_time_base; +}; + static AVFilterContext * append_filter( hb_avfilter_graph_t * graph, const char * name, const char * args) { @@ -157,6 +168,11 @@ fail: return NULL; } +const char * hb_avfilter_graph_settings(hb_avfilter_graph_t * graph) +{ + return graph->settings; +} + void hb_avfilter_graph_close(hb_avfilter_graph_t ** _g) { hb_avfilter_graph_t * graph = *_g; @@ -175,6 +191,25 @@ void hb_avfilter_graph_close(hb_avfilter_graph_t ** _g) *_g = NULL; } +void hb_avfilter_graph_update_init(hb_avfilter_graph_t * graph, + hb_filter_init_t * init) +{ + // Retrieve the parameters of the output filter + AVFilterLink *link = graph->output->inputs[0]; + init->geometry.width = link->w; + init->geometry.height = link->h; + init->geometry.par.num = link->sample_aspect_ratio.num; + init->geometry.par.den = link->sample_aspect_ratio.den; + init->pix_fmt = link->format; + // avfilter can generate "unknown" framerates. If this happens + // just pass along the source framerate. + if (link->frame_rate.num > 0 && link->frame_rate.den > 0) + { + init->vrate.num = link->frame_rate.num; + init->vrate.den = link->frame_rate.den; + } +} + int hb_avfilter_add_frame(hb_avfilter_graph_t * graph, AVFrame * frame) { return av_buffersrc_add_frame(graph->input, frame); diff --git a/libhb/hbavfilter.h b/libhb/hbavfilter.h index c28e87ec0..1495d3b41 100644 --- a/libhb/hbavfilter.h +++ b/libhb/hbavfilter.h @@ -14,18 +14,29 @@ typedef struct hb_avfilter_graph_s hb_avfilter_graph_t; -hb_avfilter_graph_t * hb_avfilter_graph_init(hb_value_t * settings, - hb_filter_init_t * init); -void hb_avfilter_graph_close(hb_avfilter_graph_t ** _g); +hb_avfilter_graph_t * +hb_avfilter_graph_init(hb_value_t * settings, hb_filter_init_t * init); -int hb_avfilter_add_frame(hb_avfilter_graph_t * graph, AVFrame * frame); -int hb_avfilter_get_frame(hb_avfilter_graph_t * graph, AVFrame * frame); -int hb_avfilter_add_buf(hb_avfilter_graph_t * graph, hb_buffer_t * in); -hb_buffer_t * hb_avfilter_get_buf(hb_avfilter_graph_t * graph); +void hb_avfilter_graph_close(hb_avfilter_graph_t ** _g); -void hb_avfilter_append_dict(hb_value_array_t * filters, - const char * name, hb_dict_t * settings); +const char * +hb_avfilter_graph_settings(hb_avfilter_graph_t * graph); -void hb_avfilter_combine(hb_list_t * list); +void hb_avfilter_graph_update_init(hb_avfilter_graph_t * graph, + hb_filter_init_t * init); + +int hb_avfilter_add_frame(hb_avfilter_graph_t * graph, AVFrame * frame); + +int hb_avfilter_get_frame(hb_avfilter_graph_t * graph, AVFrame * frame); + +int hb_avfilter_add_buf(hb_avfilter_graph_t * graph, hb_buffer_t * in); + +hb_buffer_t * +hb_avfilter_get_buf(hb_avfilter_graph_t * graph); + +void hb_avfilter_append_dict(hb_value_array_t * filters, + const char * name, hb_dict_t * settings); + +void hb_avfilter_combine(hb_list_t * list); #endif // HB_AVFILTER_H