]> granicus.if.org Git - handbrake/commitdiff
hbavfilter: hide internals of hb_avfilter_graph_s
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 18 Mar 2019 16:28:32 +0000 (10:28 -0600)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 8 Apr 2019 13:44:09 +0000 (07:44 -0600)
libhb/avfilter.c
libhb/avfilter_priv.h
libhb/hbavfilter.c
libhb/hbavfilter.h

index 6d69c97a8c2a0e6a2ebe5c248f4a7eb917f92c51..d7fe4ea04ea63cc41a30e8294c7ad6e74c4650bc 100644 (file)
@@ -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
index a0430fd62f7591b06046c699d99af6b9f8edfe8f..8c6b0a62734b8d6f43b96ac431357e52a53a795d 100644 (file)
 #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;
index c1b789f71372304744ebd2e7b56b2fece2263366..a76fdf9e6cf159b491215ef0ad5646561e9bb238 100644 (file)
 #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);
index c28e87ec040ac7fbb04e070750824e054eab54d8..1495d3b41b300e4288637aacb2b64e8bad251dac 100644 (file)
 
 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