adjust free order

dev
xufuji456 3 years ago
parent 5b7b439d41
commit 12a683f45f
  1. 25
      app/src/main/cpp/video_filter.c

@ -344,7 +344,7 @@ VIDEO_PLAYER_FUNC(jint, filter, jstring filePath, jobject surface, jstring filte
} }
//is video stream or not //is video stream or not
if (packet.stream_index == video_stream_index) { if (packet.stream_index == video_stream_index) {
//对该帧进行解码 // decode frame by frame
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet); avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
if (frameFinished) { if (frameFinished) {
@ -389,22 +389,21 @@ VIDEO_PLAYER_FUNC(jint, filter, jstring filePath, jobject surface, jstring filte
end: end:
is_playing = 0; is_playing = 0;
av_free(buffer); av_free(buffer);
av_free(pFrameRGBA); av_free(out_buffer);
av_free(filter_frame); sws_freeContext(sws_ctx);
av_free(pFrame); swr_free(&audio_swr_ctx);
avcodec_close(pCodecCtx);
avformat_close_input(&pFormatCtx);
avfilter_free(buffersrc_ctx); avfilter_free(buffersrc_ctx);
avfilter_free(buffersink_ctx); avfilter_free(buffersink_ctx);
avfilter_graph_free(&filter_graph); avfilter_graph_free(&filter_graph);
avcodec_close(audioCodecCtx); avcodec_free_context(&pCodecCtx);
free(buffer); avcodec_free_context(&audioCodecCtx);
free(sws_ctx); avformat_close_input(&pFormatCtx);
free(&windowBuffer); av_free(pFrameRGBA);
free(out_buffer); av_free(filter_frame);
free(audio_swr_ctx); av_free(pFrame);
free(audio_track); free(audio_track);
free(audio_track_write_mid); free(&windowBuffer);
ANativeWindow_release(nativeWindow); ANativeWindow_release(nativeWindow);
(*env)->ReleaseStringUTFChars(env, filePath, file_name); (*env)->ReleaseStringUTFChars(env, filePath, file_name);
(*env)->ReleaseStringUTFChars(env, filterDescr, filter_descr); (*env)->ReleaseStringUTFChars(env, filterDescr, filter_descr);

Loading…
Cancel
Save