vlc代码分析(4)——mpgv的demux

2023-05-16

Mpgv.c 是对mpeg vedio的解码部分,从demux开始,到sample到输出。其中,核心部分是函数ParseMPEGBlock。
两种数据格式:video_format 是video的meta_data,block是实际的数据

Code Path:
Open()----->
Modules/demux/Mpgv.c

1)set function point. p_sys is main structure
p_demux->pf_demux  = Demux;
p_demux->pf_control= Control;
p_demux->p_sys     = p_sys = malloc( sizeof( demux_sys_t ) );

2)create demux object
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER );

3)create packetizer
decoder_t  p_packetizer

struct decoder_t
{
    VLC_COMMON_MEMBERS

    /* Module properties */
    module_t *          p_module;
    decoder_sys_t *     p_sys;

    /* Input format ie from demuxer (XXX: a lot of field could be invalid) */
    es_format_t         fmt_in;

    /* Output format of decoder/packetizer */
    es_format_t         fmt_out;

    /* Some decoders only accept packetized data (ie. not truncated) */
    vlc_bool_t          b_need_packetized;

    /* Tell the decoder if it is allowed to drop frames */
    vlc_bool_t          b_pace_control;

    picture_t *         ( * pf_decode_video )( decoder_t *, block_t ** );
    aout_buffer_t *     ( * pf_decode_audio )( decoder_t *, block_t ** );
    subpicture_t *      ( * pf_decode_sub)   ( decoder_t *, block_t ** );
    block_t *           ( * pf_packetize )   ( decoder_t *, block_t ** );
    ... ...
}

4) es_format_Init( &p_sys->p_packetizer->fmt_in, VIDEO_ES,
                    VLC_FOURCC( 'm', 'p', 'g', 'v' ) );
                  
5) p_sys->p_packetizer->p_module =
        module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 );
       
Demux()----->
Modules/demux/Mpgv.c       
1)get a whole package
if( ( p_block_in = stream_Block( p_demux->s, MPGV_PACKET_SIZE ) ) == NULL )

2)packetize it, demux it
 while( (p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, &p_block_in )) )
    {
        p_sys->b_start = VLC_FALSE;

        while( p_block_out )
        {
            block_t *p_next = p_block_out->p_next;

            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts );

            p_block_out->p_next = NULL;
            //send to next filter to handle it
            es_out_Send( p_demux->out, p_sys->p_es, p_block_out );
            p_block_out = p_next;
        }
    }
pf_packetize() is make stream to package and parse it

pf_packetize() -->
/Packetizer/mpegvideo.c
static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
decoder_sys_t *p_sys = p_dec->p_sys;
while( 1 )
    {
        switch( p_sys->i_state )
        {
        case STATE_NOSYNC:
       
        case STATE_NEXT_SYNC:
         /* Get the new fragment and set the pts/dts */
         p_pic = block_New( p_dec, p_sys->i_offset );
         block_BytestreamFlush( &p_sys->bytestream );
         if( !( p_pic = ParseMPEGBlock( p_dec, p_pic ) ) )
            {
                p_sys->i_state = STATE_NOSYNC;
                break;
            }
        
        }
       
    }

ParseMPEGBlock()-->
/Packetizer/mpegvideo.c
parse data to get something

es_out_Control() and es_out_Send() call next filter to transfer pictures

/include/Vlc_es.h
/**
 * ES definition
 */
struct es_format_t
{
    int             i_cat;
    vlc_fourcc_t    i_codec;

    int             i_id;       /* -1: let the core mark the right id
                                   >=0: valid id */
    int             i_group;    /* -1 : standalone
                                   >= 0 then a "group" (program) is created
                                        for each value */
    int             i_priority; /*  -2 : mean not selectable by the users
                                    -1 : mean not selected by default even
                                        when no other stream
                                    >=0: priority */
    char            *psz_language;
    char            *psz_description;

    audio_format_t audio;
    video_format_t video;
    subs_format_t  subs;

    unsigned int   i_bitrate;

    vlc_bool_t     b_packetized; /* wether the data is packetized
                                    (ie. not truncated) */
    int     i_extra;
    void    *p_extra;

};
/include/Vlc_common.h
/**
 * The vlc_fourcc_t type.
 *
 * See http://www.webartz.com/fourcc/ for a very detailed list.
 */
typedef uint32_t vlc_fourcc_t;

/include/Vlc_es.h
struct audio_format_t
{
    vlc_fourcc_t i_format;                          /**< audio format fourcc */
    unsigned int i_rate;                              /**< audio sample-rate */

    /* Describes the channels configuration of the samples (ie. number of
     * channels which are available in the buffer, and positions). */
    uint32_t     i_physical_channels;

    /* Describes from which original channels, before downmixing, the
     * buffer is derived. */
    uint32_t     i_original_channels;

    /* Optional - for A/52, SPDIF and DTS types : */
    /* Bytes used by one compressed frame, depends on bitrate. */
    unsigned int i_bytes_per_frame;

    /* Number of sampleframes contained in one compressed frame. */
    unsigned int i_frame_length;
    /* Please note that it may be completely arbitrary - buffers are not
     * obliged to contain a integral number of so-called "frames". It's
     * just here for the division :
     * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
     */

    /* FIXME ? (used by the codecs) */
    int i_channels;
    int i_blockalign;
    int i_bitspersample;
};

/**
 * video format description
 */
struct video_format_t
{
    vlc_fourcc_t i_chroma;                               /**< picture chroma */
    unsigned int i_aspect;                                 /**< aspect ratio */

    unsigned int i_width;                                 /**< picture width */
    unsigned int i_height;                               /**< picture height */
    unsigned int i_x_offset;               /**< start offset of visible area */
    unsigned int i_y_offset;               /**< start offset of visible area */
    unsigned int i_visible_width;                 /**< width of visible area */
    unsigned int i_visible_height;               /**< height of visible area */

    unsigned int i_bits_per_pixel;             /**< number of bits per pixel */

    unsigned int i_sar_num;                   /**< sample/pixel aspect ratio */
    unsigned int i_sar_den;

    unsigned int i_frame_rate;                     /**< frame rate numerator */
    unsigned int i_frame_rate_base;              /**< frame rate denominator */

    int i_rmask, i_gmask, i_bmask;          /**< color masks for RGB chroma */
    video_palette_t *p_palette;              /**< video palette from demuxer */
};

/include/Vlc_block.h
struct block_t
{
    block_t     *p_next;
    block_t     *p_prev;

    uint32_t    i_flags;

    mtime_t     i_pts;
    mtime_t     i_dts;
    mtime_t     i_length;

    int         i_samples; /* Used for audio */
    int         i_rate;

    int         i_buffer;
    uint8_t     *p_buffer;

    /* This way the block_Release can be overloaded
     * Don't mess with it now, if you need it the ask on ML
     */
    void        (*pf_release)   ( block_t * );

    /* It's an object that should be valid as long as the block_t is valid */
    /* It should become a true block manager to reduce malloc/free */
    vlc_object_t    *p_manager;

    /* Following fields are private, user should never touch it */
    /* XXX never touch that OK !!! the first that access that will
     * have cvs account removed ;) XXX */
    block_sys_t *p_sys;
}; 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

vlc代码分析(4)——mpgv的demux 的相关文章

  • C#编写的基于VLC的播放器

    首先看一下最终的程序效果 实现的功能 1 打开播放的音视频文件 1 菜单栏 文件 gt 打开 2 工具栏 下面 打开 3 播放器右键 gt 打开 2 暂停 继续播放 停止音视频文件 3 进度条和右下角文本框显示播放进度 4 拖动进度条对视频
  • 使用 Live555 搭建流媒体服务器

    搭建环境为Centos 7 2 64bit 一 安装gcc编译器 yum install gcc c 二 安装live555 wget http www live555 com liveMedia public live555 latest
  • Windows下Python加载VLC的方法

    从网上看到一篇文章 Python 流媒体播放器 基于VLC 其中提到windows下开发VLC需要首先安装VLC 否则就需要设置环境变量PYTHON VLC MODULE PATH 但是我尝试了一下 没有成功 但是 这篇文章给了我一个思路
  • 深入解析Invoke and BeginInvoke, 同步与异步解析

    Invoke and BeginInvoke 本文后面的源代码分析在我的博客园博客 就是此链接 在 Invoke 或者 BeginInvoke 的使用中无一例外地使用了委托 Delegate 至于委托的本质请参考我的另一随笔 对 net事件
  • Vlc.DotNet播放本地文件时的路径编码

    在播放本地媒体文件时 VLC会对文件路径进行编码 将中文字符编码为utf 8 在程序中也需要如此 否则不能正常播放 C 中可以用 System Web HttpUtility UrlEncode string System Text Enc
  • 基于VLC的Unity视频播放器(一)

    思路来自 http blog csdn net yechen2320374 article details 52226294 using System using System Text using System Runtime Inter
  • 使用vlc显示海康网络摄像机的视频

    通过博主的另外一篇博客https blog csdn net u014552102 article details 86700057 配置完海康网络摄像机后 我们就可以使用vlc显示摄像机的视频了 在下图所示的浏览器页面中 我们可以知道摄像
  • VLC在Android中的使用以及vlc中options的参数

    options 中的参数 我在csdn中找过很多篇文章了 有的文章一个参数也没写 有的写的都是关于缓存的 还有的写了几个 也没说明是什么意思 然后只能跑到csdn下载文档查看 为了方便网友们的使用 这里就简单写一下我是怎么使用的 后面会附上
  • vlc mac python绑定没有视频输出

    我正在使用 vlc python 绑定来播放视频 然后我得到了这些错误 0x3d0c58 main window error corrupt module Applications VLC app Contents MacOS plugin
  • libvlc 流屏幕的一部分

    我想使用 vlc 库流式传输屏幕的一部分 我写了一个小例子 include
  • vlcj:: 无法在 64 位操作系统中加载库“libvlc”

    我使用的是 64 位操作系统 Windows 7 并且我有 32 位 VLC 版本 1 1 8 我已经添加了这些库jna jar platform jar vlcj 1 1 5 1 jar 我无法使用 jVlc 进行流式传输 public
  • 使用 Gstreamer 提供 RTSP 流,寻求工作示例

    我们正在尝试让 Gstreamer 在 DM368 Leopardboard 上运行 我们已成功说服它创建测试视频 videotestsrc 对其进行编码并将其转储到文件中 有效的管道是 gst launch v videotestsrc
  • VLC 和 MJPEG 解码器流式传输(标头无效)

    我正在制作一个包含视频流的 WinRT 应用程序 现在我以 VLC 作为流媒体服务器和 MJPEGDecoder 库结束 http mjpeg codeplex com http mjpeg codeplex com 在客户端上解码视频 但
  • 从 vlcj 播放器数组中播放视频

    我正在尝试播放以字符串形式提供的 MRL 列表中的视频 问题是 当我尝试运行该类时 面板列表显示带有按钮 只有一个面板工作 但播放按钮不起作用 其他面板也不起作用 尽管我故意留下了停止按钮 因为我没有向它们添加动作侦听器 我想要实现的是 当
  • VLC 流至 MP4 WEBM 和 Flash

    我正在尝试将视频从 IP 摄像机流式传输到我的 WordPress 网站 我希望我的流可以通过常见设备 Windows Mac Android 和 IOS 访问 目前我正在使用 VLC 进行流式传输 但我只能使用 flash 流 但我想做
  • 使用 VLC 托管无限视频循环流

    我想通过 WIFI 网络从带有 VLC 播放器的电脑向智能手机提供视频流以进行回归测试 视频在智能手机上播放完毕后应自动重新开始 我目前使用 rtsp 作为协议和循环选项 但这不是强制性的 问题是 每次视频重新启动时 都需要进行新的 rts
  • MobileVLCKit 编译时失败

    我正在尝试在我的应用程序中使用适用于 iOS 的 MobileVLCKit 我按照 给出的步骤进行操作构建 iOS 框架 https wiki videolan org VLCKit 我已在 Xcode 5 中将部署目标设置为 iOS 7
  • libVLCSharp 无法创建 MediaList

    我正在玩 libVLCSharp 发现了一个有线行为 实际上 我创建媒体并使用 MediaPlayer 播放它没有任何问题 但是 当我尝试从 MediaList 创建媒体时 它会中断并显示以下消息 无法在本机端执行实例化 确保你 在您的系统
  • 有没有办法获得 LibVlc 加载的缓冲区百分比?

    我目前正在制作一个城市网络摄像头应用程序 它使用 libVlc 来显示来自城市网络摄像头的 rtsp 流 我的问题是 是否可以获得流的实际加载状态 我想展示给用户 我可以在 Android Studio runLog 中看到存在某种缓冲 但
  • 如何在最新的 VLC 版本上通过命令行设置音量?

    我一直在尝试在 Ubuntu 上通过终端设置 VLC 2 2 1 中的音量 但没有成功 参数 volume不存在了 Warning option volume no longer exists 并且我在帮助中找不到任何包含 卷 的内容 文档

随机推荐

  • 微信客服对接-唯一客服系统文档中心

    微信客服官方网址为 xff1a https kf weixin qq com xff0c 可以在微信内 外各个场景中接入微信客服 xff0c 提供一致的咨询体验 xff0c 企业可通过API接口回复消息 xff0c 做好客户服务 微信客服或
  • 访客接入-唯一客服系统文档中心

    网站可以通过多种方式接入客服系统 xff0c 直接跳转链接 xff0c 或者在页面右下角弹窗 访客链接 可以在自己的网站接入 xff0c 访客独立链接 xff0c 入口形式可以完全自己写 xff0c 只是跳转链接 例如下面的访客链接 htt
  • 知识库AI机器人客服(基于ChatGPT3.5)对接-唯一客服系统文档中心

    此功能是利用chatgpt训练企业知识开发个性化客服系统 xff0c 可以上传自有数据 xff0c 基于向量数据库与OpenAI Embedding xff0c 以及OpenAI chat completions接口 xff0c 实现的基于
  • AX7A200教程(6): 串口接收图片数据,通过hdmi接口输出显示

    本章节主要使用uart接收图片数据 xff0c 然后通过ddr3缓存 xff0c 最后通过hdmi接口显示输出 xff0c 功能框图如下图所示 uart接收的图片数据位1024 768 3分辨率大小的数据 xff0c 一共2359296个字
  • ROS 程序初读一(gps_driver)

    先来看到 launch 文件夹 xff0c 有三个 launch 文件 xff0c 也不知道从哪看起 xff0c 就从第一个看看先 第一个文件为 gps data get launch xff0c 内容如下 lt launch gt lt
  • 什么是SLO?

    Short term Liquidity Operation即短期流动性调节工具 SLO以7天期以内短期回购为主 xff0c 遇节假日可适当延长操作期限 xff0c 采用市场化利率招标方式开展操作 SLO原则上在公开市场常规操作的间歇期使用
  • 21.6.7爬虫日志

    一 爬虫的目的 采集数据 xff0c 为软件服务 xff01 xff01 那么数据从那儿来 xff1f 都是从生活中来的 xff01 xff01 1 手工采集 可以采集数据 xff0c 但是操作效率低下 2 内部数据 公司内部数据 xff0
  • 什么是自贸区?什么是离岸债券?

    1 自由贸易区 中国自由贸易区是指在国境内关外设立的 xff0c 以优惠税收和海关特殊监管政策 为主要手段 xff0c 以贸易自由化便利化为主要目的的多功能经济性特区 自由贸易区有两个本质上存在差异很大的概念 xff1a 一个是FTA xf
  • 什么是SLO?

    SLO xff1a 短期流动性调节工具 xff08 Short termLiquidityOperations xff09 每周二 周四 xff0c 央行一般都会进行公开市场操作 xff0c 目前最主要的是回购操作 回购操作又分成两种 xf
  • strcpy、strncpy与memcpy的区别与使用方法

    strcpy strncpy 与memcpy 的区别与使用方法 strcpy strncpy memcpy这三个C语言函数我们在主机代码编写中会很频繁的使用到 xff0c 但是三个函数的区别 使用时该注意什么还是有必要说下的 本文参考 C
  • C语言:存取结构体成员的点运算符(.)和箭头运算符(->)的区别

    一直以为这两个是没有什么区别的 xff0c 可以相互替换 xff0c 今天又翻了一下 C语言核心技术 xff0c 明白了其中的奥妙 相同点 xff1a 两个都是二元操作符 xff0c 其右操作符是成员的名称 不同点 xff1a 点操作符左边
  • DB2 命令行中如何执行sql脚本

    原文链接 xff1a http space itpub net 8231934 viewspace 584635 db2 61 gt connect to dbName user xxx using password db2 61 gt s
  • 性能测试知多少 --并发用户数与TPS之间的关系

    1 背景 在做性能测试的时候 xff0c 很多人都用并发用户数来衡量系统的性能 xff0c 觉得系统能支撑的并发用户数越多 xff0c 系统的性能就越好 xff1b 对TPS不是非常理解 xff0c 也根本不知道它们之间的关系 xff0c
  • ubuntu编译 opencv undefined referece to `cv::imread()`

    Ubuntu下编译一个C 43 43 文件 xff0c C 43 43 源程序中使用了opencv xff0c opencv的安装没有问题 xff0c 但是在编译的过程中出现如下错误 xff1a undefined reference to
  • 基于深度学习的3D pose estimation总结(包括几篇2D pose estimation)

    一 任务描述 给定一幅图或者是一段视频 xff0c 人体姿态估计就是恢复出其中的人体关节点位置的过程 二 挑战和难点 1 人体肢体运动较为灵活 xff1b 2 视角的变化 xff1b 3 附着物的变化 xff08 比如遮挡 xff0c 衣物
  • STM32的空闲中断

    最近发现了STM32的USART的空闲中断非常的舒爽 xff0c 但是在前期配置的时候会出现一些小问题导致没有办法进入终中断或者是一直空闲中断 xff0c 现将它记下来 xff0c 给各位和自己留一个参考 xff1a 1 不进入中断 我是这
  • Github上最受欢迎的7个开源AI机器学习框架

    在过去的几年中 xff0c 人工智能正在占领技术的许多领域 来自不同背景的开发人员最终意识到了AI为他们带来的机遇 xff0c 而不管他们的需求如何 在今天的文章中 xff0c 我们列出了7种最佳的开源AI 机器学习系统和框架 1 Tens
  • ubuntu更换shell

    ubuntu更换shell zsh配置 span class token comment 安装zsh span span class token function sudo span span class token function ap
  • 网络调试助手NetAssist的使用

    一 使用场景 xff1a 项目定制需求 xff1a 前端的车载终端把gps 报警信息 报警图片 其他检测数据发往约定的第三方服务器 xff0c 车载终端通过公网 xff08 SIM拨号或者有线网 xff09 以udp或者tcp连接服务器 x
  • vlc代码分析(4)——mpgv的demux

    Mpgv c 是对mpeg vedio的解码部分 xff0c 从demux开始 xff0c 到sample到输出 其中 xff0c 核心部分是函数ParseMPEGBlock 两种数据格式 xff1a video format 是video