简体   繁体   中英

Statement has no effect 'AVPacket'

I am developing a Decoder using android NDK and FFmpeg native libraries. I have put Native Support for the project using Android Tools and I have the C code in videodecoder.cpp file. In the file the following function gives me this problem

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;
}

At the line AVPacket packet = {.data = (uint8_t*) buf, .size = num_bytes, .pts = pkt_pts };

It says that `Statement has no effect "AVPAcket" and

At the line int res = avcodec_decode_video2(ctx->codec_ctx, ctx->src_frame,&frameFinished, &packet);

It says that Invalid arguments ' Candidates are: int avcodec_decode_video2(AVCodecContext *, AVFrame *, int *, const AVPacket *)'

The Problem is

AVPacket packet = {.data = (uint8_t*) buf, .size = num_bytes, .pts = pkt_pts }

as the Compiler does not understand the type / initialization. This leads to the invalid argument error. Maybe split the line into:

AVPacket packet;
packet.data = (uint8_t*) buf;
packet.size = num_bytes;
packet.pts = pkt_pts;

This should get more clear error output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM