File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,20 @@ bool DecoderVideo::prepare(const char *err)
29
29
30
30
mFrame = avcodec_alloc_frame ();
31
31
if (mFrame == NULL ) {
32
+ err = " Couldn't allocate mFrame" ;
32
33
return false ;
33
34
}
34
35
36
+ mTempFrame = avcodec_alloc_frame ();
37
+ if (mTempFrame == NULL ) {
38
+ err = " Couldn't allocate mTempFrame" ;
39
+ return false ;
40
+ }
41
+
35
42
if (Output::VideoDriver_getPixels (mConfig ->width ,
36
43
mConfig ->height ,
37
44
&pixels) != ANDROID_SURFACE_RESULT_SUCCESS) {
45
+ err = " Couldn't get pixels from android surface wrapper" ;
38
46
return false ;
39
47
}
40
48
@@ -56,16 +64,16 @@ bool DecoderVideo::process(AVPacket *packet)
56
64
57
65
// Decode video frame
58
66
avcodec_decode_video (mCodecCtx ,
59
- mConfig -> frame ,
67
+ mTempFrame ,
60
68
&completed,
61
69
packet->data ,
62
70
packet->size );
63
71
64
72
if (completed) {
65
73
// Convert the image from its native format to RGB
66
74
sws_scale (mConfig ->img_convert_ctx ,
67
- mConfig -> frame -> data ,
68
- mConfig -> frame -> linesize ,
75
+ mTempFrame -> data ,
76
+ mTempFrame -> linesize ,
69
77
0 ,
70
78
mConfig ->height ,
71
79
mFrame ->data ,
@@ -105,5 +113,8 @@ bool DecoderVideo::decode(void* ptr)
105
113
106
114
// Free the RGB image
107
115
av_free (mFrame );
116
+ // Free the RGB image
117
+ av_free (mTempFrame );
118
+
108
119
return true ;
109
120
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class DecoderVideo : public IDecoder
21
21
private:
22
22
struct DecoderVideoConfig * mConfig ;
23
23
AVFrame* mFrame ;
24
+ AVFrame* mTempFrame ;
24
25
bool prepare (const char *err);
25
26
bool decode (void * ptr);
26
27
bool process (AVPacket *packet);
You can’t perform that action at this time.
0 commit comments