Use the init_opaque callback for the purpose.
Fix regression introduced in a5e8c41c28f. In particular, fix lavfi
device in case a conversion to the supported (packed) formats is needed.
... | ... |
@@ -181,19 +181,12 @@ int av_buffersink_poll_frame(AVFilterContext *ctx) |
181 | 181 |
|
182 | 182 |
#if CONFIG_BUFFERSINK_FILTER |
183 | 183 |
|
184 |
-static av_cold int vsink_init(AVFilterContext *ctx, const char *args) |
|
184 |
+static av_cold int vsink_init(AVFilterContext *ctx, const char *args, void *opaque) |
|
185 | 185 |
{ |
186 | 186 |
BufferSinkContext *buf = ctx->priv; |
187 |
- AVBufferSinkParams *params = NULL; |
|
187 |
+ AVBufferSinkParams *params = opaque; |
|
188 | 188 |
|
189 |
-// if(args && !strcmp(args, "opaque")) |
|
190 |
-// params = (AVBufferSinkParams *)(args+7); |
|
191 |
- |
|
192 |
- if (!params) { |
|
193 |
- av_log(ctx, AV_LOG_WARNING, |
|
194 |
- "No opaque field provided\n"); |
|
195 |
- buf->pixel_fmts = NULL; |
|
196 |
- } else { |
|
189 |
+ if (params && buf->pixel_fmts) { |
|
197 | 190 |
const int *pixel_fmts = params->pixel_fmts; |
198 | 191 |
|
199 | 192 |
buf->pixel_fmts = ff_copy_int_list(pixel_fmts); |
... | ... |
@@ -227,7 +220,7 @@ AVFilter avfilter_vsink_buffersink = { |
227 | 227 |
.name = "buffersink", |
228 | 228 |
.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."), |
229 | 229 |
.priv_size = sizeof(BufferSinkContext), |
230 |
- .init = vsink_init, |
|
230 |
+ .init_opaque = vsink_init, |
|
231 | 231 |
.uninit = vsink_uninit, |
232 | 232 |
|
233 | 233 |
.query_formats = vsink_query_formats, |
... | ... |
@@ -250,13 +243,10 @@ static int filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
250 | 250 |
return 0; |
251 | 251 |
} |
252 | 252 |
|
253 |
-static av_cold int asink_init(AVFilterContext *ctx, const char *args) |
|
253 |
+static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaque) |
|
254 | 254 |
{ |
255 | 255 |
BufferSinkContext *buf = ctx->priv; |
256 |
- AVABufferSinkParams *params = NULL; |
|
257 |
- |
|
258 |
-// if(args && !strcmp(args, "opaque")) |
|
259 |
-// params = (AVABufferSinkParams *)(args+7); |
|
256 |
+ AVABufferSinkParams *params = opaque; |
|
260 | 257 |
|
261 | 258 |
if (params && params->sample_fmts) { |
262 | 259 |
buf->sample_fmts = ff_copy_int_list (params->sample_fmts); |
... | ... |
@@ -310,7 +300,7 @@ static int asink_query_formats(AVFilterContext *ctx) |
310 | 310 |
AVFilter avfilter_asink_abuffersink = { |
311 | 311 |
.name = "abuffersink", |
312 | 312 |
.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."), |
313 |
- .init = asink_init, |
|
313 |
+ .init_opaque = asink_init, |
|
314 | 314 |
.uninit = asink_uninit, |
315 | 315 |
.priv_size = sizeof(BufferSinkContext), |
316 | 316 |
.query_formats = asink_query_formats, |