Skip to content

Commit

Permalink
hbavfilter: hide internals of hb_avfilter_graph_s
Browse files Browse the repository at this point in the history
  • Loading branch information
jstebbins committed Apr 8, 2019
1 parent 1613985 commit 8179f86
Showing 4 changed files with 61 additions and 51 deletions.
35 changes: 5 additions & 30 deletions libhb/avfilter.c
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions libhb/avfilter_priv.h
Original file line number Diff line number Diff line change
@@ -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;
35 changes: 35 additions & 0 deletions libhb/hbavfilter.c
Original file line number Diff line number Diff line change
@@ -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 @@ hb_avfilter_graph_init(hb_value_t * settings, hb_filter_init_t * init)
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);
31 changes: 21 additions & 10 deletions libhb/hbavfilter.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8179f86

Please sign in to comment.