aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-27 17:38:36 +0200
committerAnton Khirnov <anton@khirnov.net>2023-06-19 09:48:55 +0200
commit5293adb1a72347a2c13de1f3b0b37d51625f6985 (patch)
tree3e18915cde13c2ef55ff5e0225b598875d6415b1 /fftools/ffmpeg_filter.c
parent7d4e00ccf0b77dab1bf74320b26af968ba670394 (diff)
downloadffmpeg-5293adb1a72347a2c13de1f3b0b37d51625f6985.tar.gz
fftools/ffmpeg: attach bits_per_raw_sample information to frames
This way avoids encoders reaching into filters or decoders for this information.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ccde5b26ec..9e6883ccdd 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -45,6 +45,9 @@ typedef struct FilterGraphPriv {
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;
const char *graph_desc;
@@ -1566,7 +1569,7 @@ static int configure_filtergraph(FilterGraph *fg)
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
goto fail;
- fg->is_meta = graph_is_meta(fg->graph);
+ fgp->is_meta = graph_is_meta(fg->graph);
/* limit the lists of allowed formats to the ones selected, to
* make sure they stay the same if the filtergraph is reconfigured later */
@@ -1714,6 +1717,8 @@ int reap_filters(int flush)
filtered_frame = fgp->frame;
while (1) {
+ FrameData *fd;
+
ret = av_buffersink_get_frame_flags(filter, filtered_frame,
AV_BUFFERSINK_FLAG_NO_REQUEST);
if (ret < 0) {
@@ -1744,15 +1749,19 @@ int reap_filters(int flush)
tb.num, tb.den);
}
- if (ost->type == AVMEDIA_TYPE_VIDEO) {
- FrameData *fd = frame_data(filtered_frame);
- if (!fd) {
- av_frame_unref(filtered_frame);
- report_and_exit(AVERROR(ENOMEM));
- }
+ fd = frame_data(filtered_frame);
+ if (!fd) {
+ av_frame_unref(filtered_frame);
+ report_and_exit(AVERROR(ENOMEM));
+ }
+
+ // only use bits_per_raw_sample passed through from the decoder
+ // if the filtergraph did not touch the frame data
+ if (!fgp->is_meta)
+ fd->bits_per_raw_sample = 0;
+ if (ost->type == AVMEDIA_TYPE_VIDEO)
fd->frame_rate_filter = av_buffersink_get_frame_rate(filter);
- }
enc_frame(ost, filtered_frame);
av_frame_unref(filtered_frame);