You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
fftools/ffmpeg_filter: make FilterGraphPriv private again
As the name implies, it's a struct meant to be internal and private to the filter handling code. If a field is required in other modules, then it can be moved to the public facing struct, which is done in this commit. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@ -39,6 +39,7 @@
|
|||||||
#include "libavfilter/avfilter.h"
|
#include "libavfilter/avfilter.h"
|
||||||
|
|
||||||
#include "libavutil/avutil.h"
|
#include "libavutil/avutil.h"
|
||||||
|
#include "libavutil/bprint.h"
|
||||||
#include "libavutil/dict.h"
|
#include "libavutil/dict.h"
|
||||||
#include "libavutil/eval.h"
|
#include "libavutil/eval.h"
|
||||||
#include "libavutil/fifo.h"
|
#include "libavutil/fifo.h"
|
||||||
@ -381,6 +382,9 @@ typedef struct FilterGraph {
|
|||||||
int nb_inputs;
|
int nb_inputs;
|
||||||
OutputFilter **outputs;
|
OutputFilter **outputs;
|
||||||
int nb_outputs;
|
int nb_outputs;
|
||||||
|
|
||||||
|
const char *graph_desc;
|
||||||
|
struct AVBPrint graph_print_buf;
|
||||||
} FilterGraph;
|
} FilterGraph;
|
||||||
|
|
||||||
enum DecoderFlags {
|
enum DecoderFlags {
|
||||||
|
@ -44,6 +44,42 @@
|
|||||||
// FIXME private header, used for mid_pred()
|
// FIXME private header, used for mid_pred()
|
||||||
#include "libavcodec/mathops.h"
|
#include "libavcodec/mathops.h"
|
||||||
|
|
||||||
|
typedef struct FilterGraphPriv {
|
||||||
|
FilterGraph fg;
|
||||||
|
|
||||||
|
// name used for logging
|
||||||
|
char log_name[32];
|
||||||
|
|
||||||
|
int is_simple;
|
||||||
|
// true when the filtergraph contains only meta filters
|
||||||
|
// that do not modify the frame data
|
||||||
|
int is_meta;
|
||||||
|
// source filters are present in the graph
|
||||||
|
int have_sources;
|
||||||
|
int disable_conversions;
|
||||||
|
|
||||||
|
unsigned nb_outputs_done;
|
||||||
|
|
||||||
|
int nb_threads;
|
||||||
|
|
||||||
|
// frame for temporarily holding output from the filtergraph
|
||||||
|
AVFrame *frame;
|
||||||
|
// frame for sending output to the encoder
|
||||||
|
AVFrame *frame_enc;
|
||||||
|
|
||||||
|
Scheduler *sch;
|
||||||
|
unsigned sch_idx;
|
||||||
|
} FilterGraphPriv;
|
||||||
|
|
||||||
|
static FilterGraphPriv *fgp_from_fg(FilterGraph *fg)
|
||||||
|
{
|
||||||
|
return (FilterGraphPriv*)fg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg)
|
||||||
|
{
|
||||||
|
return (const FilterGraphPriv*)fg;
|
||||||
|
}
|
||||||
|
|
||||||
// data that is local to the filter thread and not visible outside of it
|
// data that is local to the filter thread and not visible outside of it
|
||||||
typedef struct FilterGraphThread {
|
typedef struct FilterGraphThread {
|
||||||
@ -856,7 +892,7 @@ void fg_free(FilterGraph **pfg)
|
|||||||
av_freep(&fg->outputs[j]);
|
av_freep(&fg->outputs[j]);
|
||||||
}
|
}
|
||||||
av_freep(&fg->outputs);
|
av_freep(&fg->outputs);
|
||||||
av_freep(&fgp->graph_desc);
|
av_freep(&fg->graph_desc);
|
||||||
|
|
||||||
av_frame_free(&fgp->frame);
|
av_frame_free(&fgp->frame);
|
||||||
av_frame_free(&fgp->frame_enc);
|
av_frame_free(&fgp->frame_enc);
|
||||||
@ -909,7 +945,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fg->class = &fg_class;
|
fg->class = &fg_class;
|
||||||
fgp->graph_desc = graph_desc;
|
fg->graph_desc = graph_desc;
|
||||||
fgp->disable_conversions = !auto_conversion_filters;
|
fgp->disable_conversions = !auto_conversion_filters;
|
||||||
fgp->nb_threads = -1;
|
fgp->nb_threads = -1;
|
||||||
fgp->sch = sch;
|
fgp->sch = sch;
|
||||||
@ -928,7 +964,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
|
|||||||
return AVERROR(ENOMEM);;
|
return AVERROR(ENOMEM);;
|
||||||
graph->nb_threads = 1;
|
graph->nb_threads = 1;
|
||||||
|
|
||||||
ret = graph_parse(fg, graph, fgp->graph_desc, &inputs, &outputs,
|
ret = graph_parse(fg, graph, fg->graph_desc, &inputs, &outputs,
|
||||||
hw_device_for_filter());
|
hw_device_for_filter());
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -1070,7 +1106,6 @@ int fg_create_simple(FilterGraph **pfg,
|
|||||||
|
|
||||||
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
|
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
|
||||||
{
|
{
|
||||||
FilterGraphPriv *fgp = fgp_from_fg(fg);
|
|
||||||
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
|
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
|
||||||
InputStream *ist = NULL;
|
InputStream *ist = NULL;
|
||||||
enum AVMediaType type = ifp->type;
|
enum AVMediaType type = ifp->type;
|
||||||
@ -1086,7 +1121,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
|
|||||||
dec_idx = strtol(ifp->linklabel + 4, &p, 0);
|
dec_idx = strtol(ifp->linklabel + 4, &p, 0);
|
||||||
if (dec_idx < 0 || dec_idx >= nb_decoders) {
|
if (dec_idx < 0 || dec_idx >= nb_decoders) {
|
||||||
av_log(fg, AV_LOG_ERROR, "Invalid decoder index %d in filtergraph description %s\n",
|
av_log(fg, AV_LOG_ERROR, "Invalid decoder index %d in filtergraph description %s\n",
|
||||||
dec_idx, fgp->graph_desc);
|
dec_idx, fg->graph_desc);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,7 +1172,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
|
|||||||
file_idx = strtol(ifp->linklabel, &p, 0);
|
file_idx = strtol(ifp->linklabel, &p, 0);
|
||||||
if (file_idx < 0 || file_idx >= nb_input_files) {
|
if (file_idx < 0 || file_idx >= nb_input_files) {
|
||||||
av_log(fg, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n",
|
av_log(fg, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n",
|
||||||
file_idx, fgp->graph_desc);
|
file_idx, fg->graph_desc);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
s = input_files[file_idx]->ctx;
|
s = input_files[file_idx]->ctx;
|
||||||
@ -1171,7 +1206,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
|
|||||||
stream_specifier_uninit(&ss);
|
stream_specifier_uninit(&ss);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
av_log(fg, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
|
av_log(fg, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
|
||||||
"matches no streams.\n", p, fgp->graph_desc);
|
"matches no streams.\n", p, fg->graph_desc);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
ist = input_files[file_idx]->streams[st->index];
|
ist = input_files[file_idx]->streams[st->index];
|
||||||
@ -1733,7 +1768,7 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
|
|||||||
AVFilterInOut *inputs, *outputs, *cur;
|
AVFilterInOut *inputs, *outputs, *cur;
|
||||||
int ret = AVERROR_BUG, i, simple = filtergraph_is_simple(fg);
|
int ret = AVERROR_BUG, i, simple = filtergraph_is_simple(fg);
|
||||||
int have_input_eof = 0;
|
int have_input_eof = 0;
|
||||||
const char *graph_desc = fgp->graph_desc;
|
const char *graph_desc = fg->graph_desc;
|
||||||
|
|
||||||
cleanup_filtergraph(fg, fgt);
|
cleanup_filtergraph(fg, fgt);
|
||||||
fgt->graph = avfilter_graph_alloc();
|
fgt->graph = avfilter_graph_alloc();
|
||||||
|
@ -37,48 +37,6 @@
|
|||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/downmix_info.h"
|
#include "libavutil/downmix_info.h"
|
||||||
|
|
||||||
typedef struct FilterGraphPriv {
|
|
||||||
FilterGraph fg;
|
|
||||||
|
|
||||||
// name used for logging
|
|
||||||
char log_name[32];
|
|
||||||
|
|
||||||
int is_simple;
|
|
||||||
// true when the filtergraph contains only meta filters
|
|
||||||
// that do not modify the frame data
|
|
||||||
int is_meta;
|
|
||||||
// source filters are present in the graph
|
|
||||||
int have_sources;
|
|
||||||
int disable_conversions;
|
|
||||||
|
|
||||||
unsigned nb_outputs_done;
|
|
||||||
|
|
||||||
const char *graph_desc;
|
|
||||||
|
|
||||||
int nb_threads;
|
|
||||||
|
|
||||||
// frame for temporarily holding output from the filtergraph
|
|
||||||
AVFrame *frame;
|
|
||||||
// frame for sending output to the encoder
|
|
||||||
AVFrame *frame_enc;
|
|
||||||
|
|
||||||
Scheduler *sch;
|
|
||||||
unsigned sch_idx;
|
|
||||||
|
|
||||||
AVBPrint graph_print_buf;
|
|
||||||
|
|
||||||
} FilterGraphPriv;
|
|
||||||
|
|
||||||
static inline FilterGraphPriv *fgp_from_fg(FilterGraph *fg)
|
|
||||||
{
|
|
||||||
return (FilterGraphPriv*)fg;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg)
|
|
||||||
{
|
|
||||||
return (const FilterGraphPriv*)fg;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct InputFilterPriv {
|
typedef struct InputFilterPriv {
|
||||||
InputFilter ifilter;
|
InputFilter ifilter;
|
||||||
|
|
||||||
|
@ -479,14 +479,13 @@ static void init_sections(void)
|
|||||||
static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AVFilterGraph *graph)
|
static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AVFilterGraph *graph)
|
||||||
{
|
{
|
||||||
AVTextFormatContext *tfc = gpc->tfc;
|
AVTextFormatContext *tfc = gpc->tfc;
|
||||||
FilterGraphPriv *fgp = fgp_from_fg(fg);
|
|
||||||
AVDictionary *input_map = NULL;
|
AVDictionary *input_map = NULL;
|
||||||
AVDictionary *output_map = NULL;
|
AVDictionary *output_map = NULL;
|
||||||
|
|
||||||
print_int("graph_index", fg->index);
|
print_int("graph_index", fg->index);
|
||||||
print_fmt("name", "Graph %d.%d", gpc->id_prefix_num, fg->index);
|
print_fmt("name", "Graph %d.%d", gpc->id_prefix_num, fg->index);
|
||||||
print_fmt("id", "Graph_%d_%d", gpc->id_prefix_num, fg->index);
|
print_fmt("id", "Graph_%d_%d", gpc->id_prefix_num, fg->index);
|
||||||
print_str("description", fgp->graph_desc);
|
print_str("description", fg->graph_desc);
|
||||||
|
|
||||||
print_section_header_id(gpc, SECTION_ID_GRAPH_INPUTS, "Input_File", 0);
|
print_section_header_id(gpc, SECTION_ID_GRAPH_INPUTS, "Input_File", 0);
|
||||||
|
|
||||||
@ -557,7 +556,7 @@ static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AV
|
|||||||
|
|
||||||
if (gpc->is_diagram) {
|
if (gpc->is_diagram) {
|
||||||
print_fmt("name", "Graph %d.%d", gpc->id_prefix_num, fg->index);
|
print_fmt("name", "Graph %d.%d", gpc->id_prefix_num, fg->index);
|
||||||
print_str("description", fgp->graph_desc);
|
print_str("description", fg->graph_desc);
|
||||||
print_str("id", sec_ctx.context_id);
|
print_str("id", sec_ctx.context_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,11 +966,10 @@ int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph)
|
|||||||
{
|
{
|
||||||
GraphPrintContext *gpc = NULL;
|
GraphPrintContext *gpc = NULL;
|
||||||
AVTextFormatContext *tfc;
|
AVTextFormatContext *tfc;
|
||||||
FilterGraphPriv *fgp = fgp_from_fg(fg);
|
AVBPrint *target_buf = &fg->graph_print_buf;
|
||||||
AVBPrint *target_buf = &fgp->graph_print_buf;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!fg || !fgp) {
|
if (!fg) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Invalid filter graph provided\n");
|
av_log(NULL, AV_LOG_ERROR, "Invalid filter graph provided\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
@ -1035,8 +1033,7 @@ static int print_filtergraphs_priv(FilterGraph **graphs, int nb_graphs, InputFil
|
|||||||
avtext_print_section_header(tfc, NULL, SECTION_ID_FILTERGRAPHS);
|
avtext_print_section_header(tfc, NULL, SECTION_ID_FILTERGRAPHS);
|
||||||
|
|
||||||
for (int i = 0; i < nb_graphs; i++) {
|
for (int i = 0; i < nb_graphs; i++) {
|
||||||
FilterGraphPriv *fgp = fgp_from_fg(graphs[i]);
|
AVBPrint *graph_buf = &graphs[i]->graph_print_buf;
|
||||||
AVBPrint *graph_buf = &fgp->graph_print_buf;
|
|
||||||
|
|
||||||
if (graph_buf->len > 0) {
|
if (graph_buf->len > 0) {
|
||||||
avtext_print_section_header(tfc, NULL, SECTION_ID_FILTERGRAPH);
|
avtext_print_section_header(tfc, NULL, SECTION_ID_FILTERGRAPH);
|
||||||
@ -1053,8 +1050,7 @@ static int print_filtergraphs_priv(FilterGraph **graphs, int nb_graphs, InputFil
|
|||||||
OutputStream *ost = of->streams[i];
|
OutputStream *ost = of->streams[i];
|
||||||
|
|
||||||
if (ost->fg_simple) {
|
if (ost->fg_simple) {
|
||||||
FilterGraphPriv *fgp = fgp_from_fg(ost->fg_simple);
|
AVBPrint *graph_buf = &ost->fg_simple->graph_print_buf;
|
||||||
AVBPrint *graph_buf = &fgp->graph_print_buf;
|
|
||||||
|
|
||||||
if (graph_buf->len > 0) {
|
if (graph_buf->len > 0) {
|
||||||
avtext_print_section_header(tfc, NULL, SECTION_ID_FILTERGRAPH);
|
avtext_print_section_header(tfc, NULL, SECTION_ID_FILTERGRAPH);
|
||||||
|
Reference in New Issue
Block a user