⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rawdv.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * rawdv.c : raw DV input module for vlc ***************************************************************************** * Copyright (C) 2001-2007 the VideoLAN team * $Id$ * * Authors: Gildas Bazin <gbazin@netcourrier.com> *          Paul Corke <paul dot corke at datatote dot co dot uk> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc_common.h>#include <vlc_plugin.h>#include <vlc_demux.h>/***************************************************************************** * Module descriptor *****************************************************************************/#define HURRYUP_TEXT N_( "Hurry up" )#define HURRYUP_LONGTEXT N_( "The demuxer will advance timestamps if the " \                "input can't keep up with the rate." )static int  Open ( vlc_object_t * );static void Close( vlc_object_t * );vlc_module_begin();    set_shortname( "DV" );    set_description( N_("DV (Digital Video) demuxer") );    set_capability( "demux", 3 );    set_category( CAT_INPUT );    set_subcategory( SUBCAT_INPUT_DEMUX );    add_bool( "rawdv-hurry-up", 0, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT, false );    set_callbacks( Open, Close );    add_shortcut( "rawdv" );vlc_module_end();/***************************************************************************** A little bit of background information (copied over from libdv glossary). - DIF block: A block of 80 bytes. This is the basic data framing unit of the       DVC tape format, analogous to sectors of hard disc. - Video Section: Each DIF sequence contains a video section, consisting of       135 DIF blocks, which are further subdivided into Video Segments. - Video Segment: A video segment consists of 5 DIF blocks, each corresponding       to a single compressed macroblock.*****************************************************************************//***************************************************************************** * Constants *****************************************************************************/#define DV_PAL_FRAME_SIZE  144000#define DV_NTSC_FRAME_SIZE 122000/***************************************************************************** * Definitions of structures used by this plugin *****************************************************************************/typedef struct {    int8_t sct;      /* Section type (header,subcode,aux,audio,video) */    int8_t dsn;      /* DIF sequence number (0-12) */    int    fsc;      /* First (0)/Second channel (1) */    int8_t dbn;      /* DIF block number (0-134) */} dv_id_t;typedef struct {    int    dsf;      /* DIF sequence flag: 525/60 (0) or 625,50 (1) */    int8_t apt;    int    tf1;    int8_t ap1;    int    tf2;    int8_t ap2;    int    tf3;    int8_t ap3;} dv_header_t;struct demux_sys_t{    int    frame_size;    es_out_id_t *p_es_video;    es_format_t  fmt_video;    es_out_id_t *p_es_audio;    es_format_t  fmt_audio;    int    i_dsf;    double f_rate;    int    i_bitrate;    /* program clock reference (in units of 90kHz) */    mtime_t i_pcr;    bool b_hurry_up;};/***************************************************************************** * Local prototypes *****************************************************************************/static int Demux( demux_t * );static int Control( demux_t *, int i_query, va_list args );static block_t *dv_extract_audio( demux_t *p_demux,                                  block_t* p_frame_block );/***************************************************************************** * Open: initializes raw DV demux structures *****************************************************************************/static int Open( vlc_object_t * p_this ){    demux_t     *p_demux = (demux_t*)p_this;    demux_sys_t *p_sys;    const uint8_t *p_peek, *p_peek_backup;    uint32_t    i_dword;    dv_header_t dv_header;    dv_id_t     dv_id;    /* It isn't easy to recognize a raw DV stream. The chances that we'll     * mistake a stream from another type for a raw DV stream are too high, so     * we'll rely on the file extension to trigger this demux. Alternatively,     * it is possible to force this demux. */    /* Check for DV file extension */    if( !demux_IsPathExtension( p_demux, ".dv" ) && !p_demux->b_force )        return VLC_EGENERIC;    if( stream_Peek( p_demux->s, &p_peek, DV_PAL_FRAME_SIZE ) <        DV_NTSC_FRAME_SIZE )    {        /* Stream too short ... */        msg_Err( p_demux, "cannot peek()" );        return VLC_EGENERIC;    }    p_peek_backup = p_peek;    /* fill in the dv_id_t structure */    i_dword = GetDWBE( p_peek ); p_peek += 4;    dv_id.sct = i_dword >> (32 - 3);    i_dword <<= 8;    dv_id.dsn = i_dword >> (32 - 4);    i_dword <<= 4;    dv_id.fsc = i_dword >> (32 - 1);    i_dword <<= 4;    dv_id.dbn = i_dword >> (32 - 8);    i_dword <<= 8;    if( dv_id.sct != 0 )    {        msg_Warn( p_demux, "not a raw DV stream header" );        return VLC_EGENERIC;    }    /* fill in the dv_header_t structure */    dv_header.dsf = i_dword >> (32 - 1);    i_dword <<= 1;    if( i_dword >> (32 - 1) ) /* incorrect bit */    {        msg_Warn( p_demux, "incorrect bit" );        return VLC_EGENERIC;    }    i_dword = GetDWBE( p_peek ); p_peek += 4;    i_dword <<= 5;    dv_header.apt = i_dword >> (32 - 3);    i_dword <<= 3;    dv_header.tf1 = i_dword >> (32 - 1);    i_dword <<= 5;    dv_header.ap1 = i_dword >> (32 - 3);    i_dword <<= 3;    dv_header.tf2 = i_dword >> (32 - 1);    i_dword <<= 5;    dv_header.ap2 = i_dword >> (32 - 3);    i_dword <<= 3;    dv_header.tf3 = i_dword >> (32 - 1);    i_dword <<= 5;    dv_header.ap3 = i_dword >> (32 - 3);    p_peek += 72;                                  /* skip rest of DIF block */    /* Set p_input field */    p_demux->pf_demux   = Demux;    p_demux->pf_control = Control;    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );    if( !p_sys )        return VLC_ENOMEM;    p_sys->b_hurry_up = var_CreateGetBool( p_demux, "rawdv-hurry-up" );    msg_Dbg( p_demux, "Realtime DV Source: %s", (p_sys->b_hurry_up)?"Yes":"No" );    p_sys->i_dsf = dv_header.dsf;    p_sys->frame_size = dv_header.dsf ? 12 * 150 * 80 : 10 * 150 * 80;    p_sys->f_rate = dv_header.dsf ? 25 : 29.97;    p_sys->i_pcr = 1;    p_sys->p_es_video = NULL;    p_sys->p_es_audio = NULL;    p_sys->i_bitrate = 0;    es_format_Init( &p_sys->fmt_video, VIDEO_ES, VLC_FOURCC('d','v','s','d') );    p_sys->fmt_video.video.i_width = 720;    p_sys->fmt_video.video.i_height= dv_header.dsf ? 576 : 480;;    /* FIXME FIXME */#if 0    /* necessary because input_SplitBuffer() will only get     * INPUT_DEFAULT_BUFSIZE bytes at a time. */    p_input->i_bufsize = p_sys->frame_size;#endif    p_sys->p_es_video = es_out_Add( p_demux->out, &p_sys->fmt_video );    /* Audio stuff */    p_peek = p_peek_backup + 80*6+80*16*3 + 3; /* beginning of AAUX pack */    if( *p_peek == 0x50 )    {        es_format_Init( &p_sys->fmt_audio, AUDIO_ES,                        VLC_FOURCC('a','r','a','w') );        p_sys->fmt_audio.audio.i_channels = 2;        switch( (p_peek[4] >> 3) & 0x07 )        {        case 0:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -