History

fftools/ffmpeg_filter: reinitialize the filterchain if downmix metadata changed between frames

James Almer committed 1 year ago

Commit 4f9afbb1 parent 6a282cd1 file · +28 −1Browse files

Unified · Split

fftools/ffmpeg_filter.c+28−1
@@ -30,6 +30,7 @@ · 29 unmodified lines
30#include "libavutil/avstring.h"30#include "libavutil/avstring.h"
31#include "libavutil/bprint.h"31#include "libavutil/bprint.h"
32#include "libavutil/channel_layout.h"32#include "libavutil/channel_layout.h"
33#include "libavutil/downmix_info.h"
33#include "libavutil/mem.h"34#include "libavutil/mem.h"
34#include "libavutil/opt.h"35#include "libavutil/opt.h"
35#include "libavutil/pixdesc.h"36#include "libavutil/pixdesc.h"
@@ -150,6 +151,9 @@ typedef struct InputFilterPriv { · 114 unmodified lines
150 int displaymatrix_applied;151 int displaymatrix_applied;
151 int32_t displaymatrix[9];152 int32_t displaymatrix[9];
152 153
154 int downmixinfo_present;
155 AVDownmixInfo downmixinfo;
156
153 struct {157 struct {
154 AVFrame *frame;158 AVFrame *frame;
155 159
@@ -2119,6 +2123,19 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr · 1963 unmodified lines
2119 memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix));2123 memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix));
2120 ifp->displaymatrix_present = !!sd;2124 ifp->displaymatrix_present = !!sd;
2121 2125
2126 /* Copy downmix related side data to InputFilterPriv so it may be propagated
2127 * to the filter chain even though it's not "global", as filters like aresample
2128 * require this information during init and not when remixing a frame */
2129 sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO);
2130 if (sd) {
2131 ret = av_frame_side_data_clone(&ifp->side_data,
2132 &ifp->nb_side_data, sd, 0);
2133 if (ret < 0)
2134 return ret;
2135 memcpy(&ifp->downmixinfo, sd->data, sizeof(ifp->downmixinfo));
2136 }
2137 ifp->downmixinfo_present = !!sd;
2138
2122 return 0;2139 return 0;
2123}2140}
2124 2141
@@ -2832,7 +2849,8 @@ enum ReinitReason { · 707 unmodified lines
2832 VIDEO_CHANGED = (1 << 0),2849 VIDEO_CHANGED = (1 << 0),
2833 AUDIO_CHANGED = (1 << 1),2850 AUDIO_CHANGED = (1 << 1),
2834 MATRIX_CHANGED = (1 << 2),2851 MATRIX_CHANGED = (1 << 2),
2835 HWACCEL_CHANGED = (1 << 3)2852 DOWNMIX_CHANGED = (1 << 3),
2853 HWACCEL_CHANGED = (1 << 4)
2836};2854};
2837 2855
2838static const char *unknown_if_null(const char *str)2856static const char *unknown_if_null(const char *str)
@@ -2873,6 +2891,13 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, · 34 unmodified lines
2873 } else if (ifp->displaymatrix_present)2891 } else if (ifp->displaymatrix_present)
2874 need_reinit |= MATRIX_CHANGED;2892 need_reinit |= MATRIX_CHANGED;
2875 2893
2894 if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO)) {
2895 if (!ifp->downmixinfo_present ||
2896 memcmp(sd->data, &ifp->downmixinfo, sizeof(ifp->downmixinfo)))
2897 need_reinit |= DOWNMIX_CHANGED;
2898 } else if (ifp->downmixinfo_present)
2899 need_reinit |= DOWNMIX_CHANGED;
2900
2876 if (!(ifp->opts.flags & IFILTER_FLAG_REINIT) && fgt->graph)2901 if (!(ifp->opts.flags & IFILTER_FLAG_REINIT) && fgt->graph)
2877 need_reinit = 0;2902 need_reinit = 0;
2878 2903
@@ -2927,6 +2952,8 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, · 48 unmodified lines
2927 }2952 }
2928 if (need_reinit & MATRIX_CHANGED)2953 if (need_reinit & MATRIX_CHANGED)
2929 av_bprintf(&reason, "display matrix changed, ");2954 av_bprintf(&reason, "display matrix changed, ");
2955 if (need_reinit & DOWNMIX_CHANGED)
2956 av_bprintf(&reason, "downmix medatata changed, ");
2930 if (need_reinit & HWACCEL_CHANGED)2957 if (need_reinit & HWACCEL_CHANGED)
2931 av_bprintf(&reason, "hwaccel changed, ");2958 av_bprintf(&reason, "hwaccel changed, ");
2932 if (reason.len > 1)2959 if (reason.len > 1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t