Feature: use bool instead of jboolean

pull/221/head
xufuji456 2 years ago
parent 91f614f07a
commit 4640f82fe5
  1. 56
      app/src/main/cpp/video_filter.c

@ -1,23 +1,26 @@
// //
// Created by frank on 2018/6/4. // Created by frank on 2018/6/4.
// //
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include "libavcodec/avcodec.h" #include "libavcodec/avcodec.h"
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
#include "libswscale/swscale.h" #include "libswscale/swscale.h"
#include <android/native_window.h> #include "libavutil/imgutils.h"
#include <android/native_window_jni.h> #include "libavfilter/buffersink.h"
#include <stdio.h> #include "libavfilter/buffersrc.h"
#include <unistd.h> #include "libavfilter/avfiltergraph.h"
#include <libavutil/imgutils.h> #include "libavutil/opt.h"
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavfilter/avfiltergraph.h>
#include <libavutil/opt.h>
#include "libswresample/swresample.h" #include "libswresample/swresample.h"
#include "ffmpeg_jni_define.h" #include "ffmpeg_jni_define.h"
#define TAG "VideoFilter" #define TAG "VideoFilter"
#define ENABLE_MEDIACODEC 0
AVFormatContext *pFormatCtx; AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx; AVCodecContext *pCodecCtx;
@ -32,20 +35,22 @@ AVFrame *filter_frame;
struct SwsContext *sws_ctx; struct SwsContext *sws_ctx;
int video_stream_index = -1; int video_stream_index = -1;
#define MAX_AUDIO_FRAME_SIZE 48000 * 4 int pos;
jmethodID audio_track_write_mid; int got_frame;
int out_channel_nb;
uint8_t *out_buffer; uint8_t *out_buffer;
jobject audio_track; jobject audio_track;
bool playAudio = true;
SwrContext *audio_swr_ctx; SwrContext *audio_swr_ctx;
int out_channel_nb;
enum AVSampleFormat out_sample_fmt;
int audio_stream_index = -1; int audio_stream_index = -1;
int got_frame;
AVCodecContext *audioCodecCtx; AVCodecContext *audioCodecCtx;
jboolean playAudio = JNI_TRUE; jmethodID audio_track_write_mid;
int pos; enum AVSampleFormat out_sample_fmt;
char* filters[] = {"lutyuv='u=128:v=128'",
#define MAX_AUDIO_FRAME_SIZE (48000 * 4)
const char* filters[] = {"lutyuv='u=128:v=128'",
"hue='h=60:s=-3'", "hue='h=60:s=-3'",
"edgedetect=low=0.1:high=0.4", "edgedetect=low=0.1:high=0.4",
"drawgrid=w=iw/3:h=ih/3:t=2:c=white@0.5", "drawgrid=w=iw/3:h=ih/3:t=2:c=white@0.5",
@ -56,11 +61,10 @@ char* filters[] = {"lutyuv='u=128:v=128'",
"rotate=180*PI/180", "rotate=180*PI/180",
"unsharp"}; "unsharp"};
//init filter
int init_filters(const char *filters_descr, AVRational time_base, AVCodecContext *codecCtx, int init_filters(const char *filters_descr, AVRational time_base, AVCodecContext *codecCtx,
AVFilterGraph **graph, AVFilterContext **src, AVFilterContext **sink) { AVFilterGraph **graph, AVFilterContext **src, AVFilterContext **sink) {
char args[512]; char args[512];
int ret = 0; int ret;
AVFilterContext *buffersrc_ctx; AVFilterContext *buffersrc_ctx;
AVFilterContext *buffersink_ctx; AVFilterContext *buffersink_ctx;
const AVFilter *buffersrc = avfilter_get_by_name("buffer"); const AVFilter *buffersrc = avfilter_get_by_name("buffer");
@ -151,17 +155,7 @@ int open_input(JNIEnv *env, const char *file_name, jobject surface) {
} }
pCodecCtx = pFormatCtx->streams[video_stream_index]->codec; pCodecCtx = pFormatCtx->streams[video_stream_index]->codec;
AVCodec *pCodec; AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (ENABLE_MEDIACODEC && pCodecCtx->codec_id == AV_CODEC_ID_H264) {
// note: Some devices will bring blurred screen, when using mediacodec
pCodec = avcodec_find_decoder_by_name("h264_mediacodec");
if (pCodec == NULL) {
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
}
LOGE(TAG, "codec name=%s", pCodec->name);
} else {
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
}
if (pCodec == NULL) { if (pCodec == NULL) {
LOGE(TAG, "couldn't find Codec."); LOGE(TAG, "couldn't find Codec.");
return -1; return -1;

Loading…
Cancel
Save