• avcodec_decode_video2使用参数picture注意点


    一句话:解码时,当AVCodecContext的refcounted_frames字段为0,则frame的分配与释放由ffmpeg内部本身控制。ide

    那么使用是要注意不要破坏picture的数据指针。this

    依据:spa

    AVCodecContext
    指针

        /**
         * If non-zero, the decoded audio and video frames returned from
         * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
         * and are valid indefinitely. The caller must free them with
         * av_frame_unref() when they are not needed anymore.
         * Otherwise, the decoded frames must not be freed by the caller and are
         * only valid until the next decode call.
         *
         * - encoding: unused
         * - decoding: set by the caller before avcodec_open2().
         */
        int refcounted_frames;
    code

     * @param[out] picture The AVFrame in which the decoded video frame will be stored.
     *             Use av_frame_alloc() to get an AVFrame. The codec will
     *             allocate memory for the actual bitmap by calling the
     *             AVCodecContext.get_buffer2() callback.
     *             When AVCodecContext.refcounted_frames is set to 1, the frame is
     *             reference counted and the returned reference belongs to the
     *             caller. The caller must release the frame using av_frame_unref()
     *             when the frame is no longer needed. The caller may safely write
     *             to the frame if av_frame_is_writable() returns 1.
     *             When AVCodecContext.refcounted_frames is set to 0, the returned
     *             reference belongs to the decoder and is valid only until the
     *             next call to this function or until closing or flushing the
     *             decoder. The caller may not write to it.
    get

    int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
                             int *got_picture_ptr,
                             const AVPacket *avpkt);

  • 相关阅读:
    Java判断一个字符是数字或字母
    java数组和字符串相互转换
    java 字符串截取的三种方法
    Templates && Algorithms
    挖坑——未完成题目列表QwQ
    作业_2018.08.25
    BZOJ1008 [HNOI2008]越狱 (快速幂,组合)
    UR #3 核聚变反应强度( gcd )
    A Super Hero
    NOIP2015 pj
  • 原文地址:https://www.cnblogs.com/lidabo/p/15905170.html
Copyright © 2020-2023  润新知