[FFmpeg-devel] [PATCH v5 06/12] avfilter/avfilter: Handle subtitle frames
Soft Works
softworkz at hotmail.com
Sun Sep 12 06:21:48 EEST 2021
Signed-off-by: softworkz <softworkz at hotmail.com>
---
libavfilter/avfilter.c | 8 +++++---
libavfilter/avfiltergraph.c | 5 +++++
libavfilter/formats.c | 14 ++++++++++++++
libavfilter/formats.h | 3 +++
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index a04f8ed62f..961e55e7b4 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -56,7 +56,8 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end)
ref->linesize[0], ref->linesize[1], ref->linesize[2], ref->linesize[3],
ref->pts, ref->pkt_pos);
- if (ref->width) {
+ switch(ref->type) {
+ case AVMEDIA_TYPE_VIDEO:
ff_tlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
ref->sample_aspect_ratio.num, ref->sample_aspect_ratio.den,
ref->width, ref->height,
@@ -64,12 +65,13 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end)
ref->top_field_first ? 'T' : 'B', /* Top / Bottom */
ref->key_frame,
av_get_picture_type_char(ref->pict_type));
- }
- if (ref->nb_samples) {
+ break;
+ case AVMEDIA_TYPE_AUDIO:
ff_tlog(ctx, " cl:%"PRId64"d n:%d r:%d",
ref->channel_layout,
ref->nb_samples,
ref->sample_rate);
+ break;
}
ff_tlog(ctx, "]%s", end ? "\n" : "");
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 45b028cd9c..7a5a4ea419 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -314,6 +314,8 @@ static int filter_link_check_formats(void *log, AVFilterLink *link, AVFilterForm
return ret;
break;
+ case AVMEDIA_TYPE_SUBTITLE:
+ return 0;
default:
av_assert0(!"reached");
}
@@ -444,6 +446,9 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx)
if (!link)
continue;
+ if (link->type == AVMEDIA_TYPE_SUBTITLE)
+ continue;
+
neg = ff_filter_get_negotiation(link);
av_assert0(neg);
for (neg_step = 1; neg_step < neg->nb_mergers; neg_step++) {
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 1bf7d36195..704774d763 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcodec/avcodec.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
@@ -430,6 +431,12 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
return 0;
}
+int ff_add_subtitle_type(AVFilterFormats **avff, int64_t fmt)
+{
+ ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats);
+ return 0;
+}
+
AVFilterFormats *ff_all_formats(enum AVMediaType type)
{
AVFilterFormats *ret = NULL;
@@ -447,6 +454,13 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type)
return NULL;
fmt++;
}
+ } else if (type == AVMEDIA_TYPE_SUBTITLE) {
+ if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_BITMAP) < 0)
+ return NULL;
+ if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_ASS) < 0)
+ return NULL;
+ if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_TEXT) < 0)
+ return NULL;
}
return ret;
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 471cb42bc4..25ae511fc1 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -180,6 +180,9 @@ int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts);
av_warn_unused_result
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout);
+av_warn_unused_result
+int ff_add_subtitle_type(AVFilterFormats **avff, int64_t fmt);
+
/**
* Add *ref as a new reference to f.
*/
--
2.30.2.windows.1
More information about the ffmpeg-devel
mailing list