Skip to content

Commit 3b3c53a

Browse files
committed
fix build
1 parent 5115707 commit 3b3c53a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

jni/libmediaplayer/decoder_video.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@ bool DecoderVideo::prepare(const char *err)
2929

3030
mFrame = avcodec_alloc_frame();
3131
if (mFrame == NULL) {
32+
err = "Couldn't allocate mFrame";
3233
return false;
3334
}
3435

36+
mTempFrame = avcodec_alloc_frame();
37+
if (mTempFrame == NULL) {
38+
err = "Couldn't allocate mTempFrame";
39+
return false;
40+
}
41+
3542
if(Output::VideoDriver_getPixels(mConfig->width,
3643
mConfig->height,
3744
&pixels) != ANDROID_SURFACE_RESULT_SUCCESS) {
45+
err = "Couldn't get pixels from android surface wrapper";
3846
return false;
3947
}
4048

@@ -56,16 +64,16 @@ bool DecoderVideo::process(AVPacket *packet)
5664

5765
// Decode video frame
5866
avcodec_decode_video(mCodecCtx,
59-
mConfig->frame,
67+
mTempFrame,
6068
&completed,
6169
packet->data,
6270
packet->size);
6371

6472
if (completed) {
6573
// Convert the image from its native format to RGB
6674
sws_scale(mConfig->img_convert_ctx,
67-
mConfig->frame->data,
68-
mConfig->frame->linesize,
75+
mTempFrame->data,
76+
mTempFrame->linesize,
6977
0,
7078
mConfig->height,
7179
mFrame->data,
@@ -105,5 +113,8 @@ bool DecoderVideo::decode(void* ptr)
105113

106114
// Free the RGB image
107115
av_free(mFrame);
116+
// Free the RGB image
117+
av_free(mTempFrame);
118+
108119
return true;
109120
}

jni/libmediaplayer/decoder_video.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DecoderVideo : public IDecoder
2121
private:
2222
struct DecoderVideoConfig* mConfig;
2323
AVFrame* mFrame;
24+
AVFrame* mTempFrame;
2425
bool prepare(const char *err);
2526
bool decode(void* ptr);
2627
bool process(AVPacket *packet);

0 commit comments

Comments
 (0)