我正在开发使用android NDK和FFmpeg本机库的解码器。我已经为使用Android工具的项目提供本地支持,并且我在videodecoder.cpp文件中有C代码。在该文件下面的函数给了我这个问题声明不起作用'AVPacket'
JNIEXPORT jint Java_ssrp_android_ffmpegdecoder_H264Decoder_consumeNalUnitsFromDirectBuffer(
JNIEnv* env, jobject thiz, jobject nal_units, jint num_bytes,
jlong pkt_pts) {
DecoderContext *ctx = get_ctx(env, thiz);
void *buf = NULL;
if (nal_units == NULL) {
D("Received null buffer, sending empty packet to decoder");
} else {
buf = env->GetDirectBufferAddress(nal_units);
if (buf == NULL) {
D("Error getting direct buffer address");
return -1;
}
}
AVPacket packet = {.data = (uint8_t*) buf, .size = num_bytes, .pts = pkt_pts };
int frameFinished = 0;
int res = avcodec_decode_video2(ctx->codec_ctx, ctx->src_frame,&frameFinished, &packet);
if (frameFinished)
ctx->frame_ready = 1;
return res;
}
在生产线AVPacket packet = {.data = (uint8_t*) buf, .size = num_bytes, .pts = pkt_pts };
它说,'声明没有任何效果“AVPAcket”和
在生产线int res = avcodec_decode_video2(ctx->codec_ctx, ctx->src_frame,&frameFinished, &packet);
它说Invalid arguments ' Candidates are: int avcodec_decode_video2(AVCodecContext *, AVFrame *, int *, const AVPacket *)'
你的编辑做了诡计,错误消失了。谢谢。 – ssrp