• 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);

  • 相关阅读:
    Metinfo 5.x 管理员密码重置漏洞
    【CVE-2018-11116】openwrt rpcd 配置文件错误导致访问控制失效
    openwrt-rpcd服务ACL配置错误风险分析
    黑客基础知识
    渗透测试(漏洞利用)
    Niagara物联网框架机制二(笔记)
    基于kali linux无线网络渗透测试
    渗透测试(漏洞扫描)
    Workbench热水泵系统
    Niagara物联网框架机制一(笔记)
  • 原文地址:https://www.cnblogs.com/lidabo/p/15905170.html
Copyright © 2020-2023  润新知