-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a race condition in VAAPI CSC to YUV420P
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
- Loading branch information
1 parent
53c3cdd
commit dfb0988
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
debian/patches/0084-fix-a-race-condition-in-vaapi-csc-to-yuv420p.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Index: FFmpeg/libavutil/hwcontext_vaapi.c | ||
=================================================================== | ||
--- FFmpeg.orig/libavutil/hwcontext_vaapi.c | ||
+++ FFmpeg/libavutil/hwcontext_vaapi.c | ||
@@ -72,6 +72,7 @@ typedef struct VAAPIDevicePriv { | ||
typedef struct VAAPISurfaceFormat { | ||
enum AVPixelFormat pix_fmt; | ||
VAImageFormat image_format; | ||
+ unsigned int fourcc; | ||
} VAAPISurfaceFormat; | ||
|
||
typedef struct VAAPIDeviceContext { | ||
@@ -221,15 +222,21 @@ static int vaapi_get_image_format(AVHWDe | ||
VAImageFormat **image_format) | ||
{ | ||
VAAPIDeviceContext *ctx = hwdev->hwctx; | ||
+ const VAAPIFormatDescriptor *desc; | ||
int i; | ||
|
||
+ desc = vaapi_format_from_pix_fmt(pix_fmt); | ||
+ if (!desc || !image_format) | ||
+ goto fail; | ||
+ | ||
for (i = 0; i < ctx->nb_formats; i++) { | ||
- if (ctx->formats[i].pix_fmt == pix_fmt) { | ||
- if (image_format) | ||
- *image_format = &ctx->formats[i].image_format; | ||
+ if (ctx->formats[i].fourcc == desc->fourcc) { | ||
+ *image_format = &ctx->formats[i].image_format; | ||
return 0; | ||
} | ||
} | ||
+ | ||
+fail: | ||
return AVERROR(ENOSYS); | ||
} | ||
|
||
@@ -446,6 +453,7 @@ static int vaapi_device_init(AVHWDeviceC | ||
av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> %s.\n", | ||
fourcc, av_get_pix_fmt_name(pix_fmt)); | ||
ctx->formats[ctx->nb_formats].pix_fmt = pix_fmt; | ||
+ ctx->formats[ctx->nb_formats].fourcc = fourcc; | ||
ctx->formats[ctx->nb_formats].image_format = image_list[i]; | ||
++ctx->nb_formats; | ||
} | ||
@@ -1022,12 +1030,6 @@ static int vaapi_map_to_memory(AVHWFrame | ||
{ | ||
int err; | ||
|
||
- if (dst->format != AV_PIX_FMT_NONE) { | ||
- err = vaapi_get_image_format(hwfc->device_ctx, dst->format, NULL); | ||
- if (err < 0) | ||
- return err; | ||
- } | ||
- | ||
err = vaapi_map_frame(hwfc, dst, src, flags); | ||
if (err) | ||
return err; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters