History

hwcontext_vaapi: remove duplicate formats from sw_format list

hwcontext_vaapi maps different VA fourcc to the same pix_fmt for U/V plane swap cases, however duplicate formats are not expected in sw_format list when merging formats. For example: ffmpeg -loglevel debug -init_hw_device vaapi -filter_hw_device vaapi0 \ -f lavfi -i smptebars -vf \ "hwupload=derive_device=vaapi,scale_vaapi,hwdownload,format=yuv420p" \ -vframes 1 -f null - Without this fix, an auto scaler is required for the above command Duplicate formats in ff_merge_formats detected [auto_scaler_0 @ 0x560df58f4550] Setting 'flags' to value 'bicubic' [auto_scaler_0 @ 0x560df58f4550] w:iw h:ih flags:'bicubic' interl:0 [Parsed_hwupload_0 @ 0x560df58f0ec0] auto-inserting filter 'auto_scaler_0' between the filter 'graph 0 input from stream 0:0' and the filter 'Parsed_hwupload_0'

Haihao Xiang committed 6 years ago

Commit fa3da241 parent d951eea1 file · +25 −5Browse files

Unified · Split

libavutil/hwcontext_vaapi.c+25−5
@@ -268,14 +268,24 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, · 267 unmodified lines
268 }268 }
269 269
270 for (i = j = 0; i < attr_count; i++) {270 for (i = j = 0; i < attr_count; i++) {
271 int k;
272
271 if (attr_list[i].type != VASurfaceAttribPixelFormat)273 if (attr_list[i].type != VASurfaceAttribPixelFormat)
272 continue;274 continue;
273 fourcc = attr_list[i].value.value.i;275 fourcc = attr_list[i].value.value.i;
274 pix_fmt = vaapi_pix_fmt_from_fourcc(fourcc);276 pix_fmt = vaapi_pix_fmt_from_fourcc(fourcc);
275 if (pix_fmt != AV_PIX_FMT_NONE)277
278 if (pix_fmt == AV_PIX_FMT_NONE)
279 continue;
280
281 for (k = 0; k < j; k++) {
282 if (constraints->valid_sw_formats[k] == pix_fmt)
283 break;
284 }
285
286 if (k == j)
276 constraints->valid_sw_formats[j++] = pix_fmt;287 constraints->valid_sw_formats[j++] = pix_fmt;
277 }288 }
278 av_assert0(j == pix_fmt_count);
279 constraints->valid_sw_formats[j] = AV_PIX_FMT_NONE;289 constraints->valid_sw_formats[j] = AV_PIX_FMT_NONE;
280 }290 }
281 } else {291 } else {
@@ -287,9 +297,19 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, · 5 unmodified lines
287 err = AVERROR(ENOMEM);297 err = AVERROR(ENOMEM);
288 goto fail;298 goto fail;
289 }299 }
290 for (i = 0; i < ctx->nb_formats; i++)300 for (i = j = 0; i < ctx->nb_formats; i++) {
291 constraints->valid_sw_formats[i] = ctx->formats[i].pix_fmt;301 int k;
292 constraints->valid_sw_formats[i] = AV_PIX_FMT_NONE;302
303 for (k = 0; k < j; k++) {
304 if (constraints->valid_sw_formats[k] == ctx->formats[i].pix_fmt)
305 break;
306 }
307
308 if (k == j)
309 constraints->valid_sw_formats[j++] = ctx->formats[i].pix_fmt;
310 }
311
312 constraints->valid_sw_formats[j] = AV_PIX_FMT_NONE;
293 }313 }
294 314
295 constraints->valid_hw_formats = av_malloc_array(2, sizeof(pix_fmt));315 constraints->valid_hw_formats = av_malloc_array(2, sizeof(pix_fmt));

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