1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
From: Laurent Aimar <fenrir@videolan.org>
Date: Sat, 12 Jun 2010 23:25:43 +0000 (+0200)
Subject: Fixed potential unaligned access in vaapi/dxva2 picture copy.
X-Git-Url: http://git.videolan.org/?p=vlc%2Fvlc-1.1.git;a=commitdiff_plain;h=3e949628bdd9fd17a6b43d612f70902a48d92804
Fixed potential unaligned access in vaapi/dxva2 picture copy.
It (probably) happens only when the video is non mod 16, or non mod 32
with YV12 hardware surface.
(cherry picked from commit 957409b26fea130c93c740dbb1a032b1e7624794)
Close #3606
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
---
diff --git a/modules/codec/avcodec/copy.c b/modules/codec/avcodec/copy.c
index 6bc0d82..9c9a44b 100644
--- a/modules/codec/avcodec/copy.c
+++ b/modules/codec/avcodec/copy.c
@@ -63,7 +63,6 @@
*/
static void CopyFromUswc(uint8_t *dst, size_t dst_pitch,
const uint8_t *src, size_t src_pitch,
- unsigned unaligned,
unsigned width, unsigned height,
unsigned cpu)
{
@@ -71,6 +70,7 @@ static void CopyFromUswc(uint8_t *dst, size_t dst_pitch,
ASM_SSE2(cpu, "mfence");
for (unsigned y = 0; y < height; y++) {
+ const unsigned unaligned = (intptr_t)src & 0x0f;
unsigned x;
for (x = 0; x < unaligned; x++)
@@ -237,13 +237,11 @@ static void CopyPlane(uint8_t *dst, size_t dst_pitch, const uint8_t *src, size_t
assert(hstep > 0);
for (unsigned y = 0; y < height; y += hstep) {
- const unsigned unaligned = (intptr_t)src & 0x0f;
const unsigned hblock = __MIN(hstep, height - y);
/* Copy a bunch of line into our cache */
CopyFromUswc(cache, w16,
src, src_pitch,
- unaligned,
width, hblock, cpu);
/* Copy from our cache to the destination */
@@ -270,13 +268,11 @@ static void SplitPlanes(uint8_t *dstu, size_t dstu_pitch,
assert(hstep > 0);
for (unsigned y = 0; y < height; y += hstep) {
- const unsigned unaligned = (intptr_t)src & 0x0f;
const unsigned hblock = __MIN(hstep, height - y);
/* Copy a bunch of line into our cache */
CopyFromUswc(cache, w2_16,
src, src_pitch,
- unaligned,
2*width, hblock, cpu);
/* Copy from our cache to the destination */
From: Laurent Aimar <fenrir@videolan.org>
Date: Sat, 12 Jun 2010 23:41:11 +0000 (+0200)
Subject: Workaround a potential segfault when using VAAPI/DXVA2 (close #3606).
X-Git-Url: http://git.videolan.org/?p=vlc%2Fvlc-1.1.git;a=commitdiff_plain;h=f134a12a7469c003ba95177dc23e65c70a4a5a72
Workaround a potential segfault when using VAAPI/DXVA2 (close #3606).
It seems that some avcodec decoders release frames even after being flushed.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
---
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 230010d..bc37e12 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -725,7 +725,10 @@ void EndVideoDec( decoder_t *p_dec )
if( p_sys->p_ff_pic ) av_free( p_sys->p_ff_pic );
if( p_sys->p_va )
+ {
vlc_va_Delete( p_sys->p_va );
+ p_sys->p_va = NULL;
+ }
}
/*****************************************************************************
@@ -1079,25 +1082,24 @@ static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,
if( p_sys->p_va )
{
vlc_va_Release( p_sys->p_va, p_ff_pic );
-
- /* */
- for( int i = 0; i < 4; i++ )
- p_ff_pic->data[i] = NULL;
}
else if( !p_ff_pic->opaque )
{
- avcodec_default_release_buffer( p_context, p_ff_pic );
+ /* We can end up here without the AVFrame being allocated by
+ * avcodec_default_get_buffer() if VA is used and the frame is
+ * released when the decoder is closed
+ */
+ if( p_ff_pic->type == FF_BUFFER_TYPE_INTERNAL )
+ avcodec_default_release_buffer( p_context, p_ff_pic );
}
else
{
picture_t *p_pic = (picture_t*)p_ff_pic->opaque;
decoder_UnlinkPicture( p_dec, p_pic );
-
- /* */
- for( int i = 0; i < 4; i++ )
- p_ff_pic->data[i] = NULL;
}
+ for( int i = 0; i < 4; i++ )
+ p_ff_pic->data[i] = NULL;
}
static void ffmpeg_NextPts( decoder_t *p_dec )
|