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

📄 vpar_headers.c

📁 vlc stand 0.1.99 ist sehr einfach
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * vpar_headers.c : headers parsing ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN * * Authors: * * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include "defs.h"#include <stdlib.h>                                                /* free() */#include <sys/types.h>                        /* on BSD, uio.h needs types.h */#include <sys/uio.h>                                            /* "input.h" */#include "config.h"#include "common.h"#include "threads.h"#include "mtime.h"#include "plugins.h"#include "intf_msg.h"#include "input.h"#include "decoder_fifo.h"#include "video.h"#include "video_output.h"#include "vdec_idct.h"#include "video_decoder.h"#include "vdec_motion.h"#include "vpar_blocks.h"#include "vpar_headers.h"#include "vpar_synchro.h"#include "video_parser.h"#include "video_fifo.h"/* * Function pointer */typedef void    (*f_picture_data_t)( vpar_thread_t*, int );/* * Local prototypes */static __inline__ void NextStartCode( vpar_thread_t * p_vpar );static void SequenceHeader( vpar_thread_t * p_vpar );static void GroupHeader( vpar_thread_t * p_vpar );static void PictureHeader( vpar_thread_t * p_vpar );static void ExtensionAndUserData( vpar_thread_t * p_vpar );static void QuantMatrixExtension( vpar_thread_t * p_vpar );static void SequenceScalableExtension( vpar_thread_t * p_vpar );static void SequenceDisplayExtension( vpar_thread_t * p_vpar );static void PictureDisplayExtension( vpar_thread_t * p_vpar );static void PictureSpatialScalableExtension( vpar_thread_t * p_vpar );static void PictureTemporalScalableExtension( vpar_thread_t * p_vpar );static void CopyrightExtension( vpar_thread_t * p_vpar );/* * Standard variables *//***************************************************************************** * pi_default_intra_quant : default quantization matrix *****************************************************************************/#ifndef VDEC_DFTint pi_default_intra_quant[] ={    8,  16, 19, 22, 26, 27, 29, 34,    16, 16, 22, 24, 27, 29, 34, 37,    19, 22, 26, 27, 29, 34, 34, 38,    22, 22, 26, 27, 29, 34, 37, 40,    22, 26, 27, 29, 32, 35, 40, 48,    26, 27, 29, 32, 35, 40, 48, 58,    26, 27, 29, 34, 38, 46, 56, 69,    27, 29, 35, 38, 46, 56, 69, 83};#elseint pi_default_intra_quant[] ={    2048,   5681,   6355,   6623,   6656,   5431,   4018,   2401,    5681,   7880,   10207,  10021,  9587,   8091,   6534,   3625,    6355,   10207,  11363,  10619,  9700,   8935,   6155,   3507,    6623,   9186,   10226,  9557,   8730,   8041,   6028,   3322,    5632,   9232,   9031,   8730,   8192,   7040,   5542,   3390,    5230,   7533,   7621,   7568,   7040,   6321,   5225,   3219,    3602,   5189,   5250,   5539,   5265,   5007,   4199,   2638,    1907,   2841,   3230,   3156,   3249,   3108,   2638,   1617};#endif/***************************************************************************** * pi_default_nonintra_quant : default quantization matrix *****************************************************************************/#ifndef VDEC_DFTint pi_default_nonintra_quant[] ={    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16,    16, 16, 16, 16, 16, 16, 16, 16};#elseint pi_default_nonintra_quanit[] ={    4096,   5680,   5344,   4816,   4096,   3216,   2224,   1136,    5680,   7888,   7424,   6688,   5680,   4464,   3072,   1568,    5344,   7424,   6992,   6288,   5344,   4208,   2896,   1472,    4816,   6688,   6288,   5664,   4816,   3792,   2608,   1328,    4096,   5680,   5344,   4816,   4096,   3216,   2224,   1136,    3216,   4464,   4208,   3792,   3216,   2528,   1744,   880,    2224,   3072,   2896,   2608,   2224,   1744,   1200,   608,    1136,   1568,   1472,   1328,   1136,   880,    608,    304};#endif/***************************************************************************** * pi_scan : zig-zag and alternate scan patterns *****************************************************************************/u8 pi_scan[2][64] ={    { /* Zig-Zag pattern */        0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,        12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,        35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,        58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63    },    { /* Alternate scan pattern */        0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,        41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,        51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,        53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63    }};/* * Local inline functions. *//***************************************************************************** * ReferenceUpdate : Update the reference pointers when we have a new picture *****************************************************************************/static void __inline__ ReferenceUpdate( vpar_thread_t * p_vpar,                                        int i_coding_type,                                        picture_t * p_newref ){    if( i_coding_type != B_CODING_TYPE )    {        if( p_vpar->sequence.p_forward != NULL )            vout_UnlinkPicture( p_vpar->p_vout, p_vpar->sequence.p_forward );        if( p_vpar->sequence.p_backward != NULL )        {#ifdef POLUX_SYNCHRO            vout_DatePicture( p_vpar->p_vout, p_vpar->sequence.p_backward,                              vpar_SynchroDate( p_vpar ) );#endif#ifdef SAM_SYNCHRO            vout_DatePicture( p_vpar->p_vout, p_vpar->sequence.p_backward,                              vpar_SynchroDate( p_vpar ) );#endif#ifdef MEUUH_SYNCHRO            mtime_t     date;            date = vpar_SynchroDate( p_vpar );            vout_DatePicture( p_vpar->p_vout, p_vpar->sequence.p_backward,                              date );            if( p_vpar->synchro.i_coding_type == I_CODING_TYPE )                vpar_SynchroKludge( p_vpar, date );#endif        }        p_vpar->sequence.p_forward = p_vpar->sequence.p_backward;        p_vpar->sequence.p_backward = p_newref;        if( p_newref != NULL )            vout_LinkPicture( p_vpar->p_vout, p_newref );#ifdef MEUUH_SYNCHRO        p_vpar->synchro.i_coding_type = i_coding_type;#endif    }    else if( p_newref != NULL )    {        /* Put date immediately. */        vout_DatePicture( p_vpar->p_vout, p_newref, vpar_SynchroDate(p_vpar) );    }}/***************************************************************************** * ReferenceReplace : Replace the last reference pointer when we destroy *                    a picture *****************************************************************************/static void __inline__ ReferenceReplace( vpar_thread_t * p_vpar,                                         int i_coding_type,                                         picture_t * p_newref ){    if( i_coding_type != B_CODING_TYPE )    {        if( p_vpar->sequence.p_backward != NULL )            vout_UnlinkPicture( p_vpar->p_vout, p_vpar->sequence.p_backward );        p_vpar->sequence.p_backward = p_newref;        if( p_newref != NULL )            vout_LinkPicture( p_vpar->p_vout, p_newref );    }}/***************************************************************************** * LoadMatrix : Load a quantization matrix *****************************************************************************/static __inline__ void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_matrix ){    int i_dummy;    if( !p_matrix->b_allocated )    {        /* Allocate a piece of memory to load the matrix. */        if( (p_matrix->pi_matrix = (int *)malloc( 64*sizeof(int) )) == NULL )        {            intf_ErrMsg( "vpar error: allocation error in LoadMatrix()\n" );            p_vpar->b_error = 1;            return;        }        p_matrix->b_allocated = 1;    }    for( i_dummy = 0; i_dummy < 64; i_dummy++ )    {        p_matrix->pi_matrix[pi_scan[SCAN_ZIGZAG][i_dummy]]             = GetBits( &p_vpar->bit_stream, 8 );    }#ifdef VDEC_DFT    /* Discrete Fourier Transform requires the quantization matrices to     * be normalized before using them. */    vdec_NormQuantMatrix( p_matrix->pi_matrix );#endif}/***************************************************************************** * LinkMatrix : Link a quantization matrix to another *****************************************************************************/static __inline__ void LinkMatrix( quant_matrix_t * p_matrix, int * pi_array ){    if( p_matrix->b_allocated )    {        /* Deallocate the piece of memory. */        free( p_matrix->pi_matrix );        p_matrix->b_allocated = 0;    }    p_matrix->pi_matrix = pi_array;}/* * Exported functions. *//***************************************************************************** * vpar_NextSequenceHeader : Find the next sequence header *****************************************************************************/int vpar_NextSequenceHeader( vpar_thread_t * p_vpar ){    while( !p_vpar->b_die )    {        NextStartCode( p_vpar );        if( ShowBits( &p_vpar->bit_stream, 32 ) == SEQUENCE_HEADER_CODE )            return 0;        RemoveBits( &p_vpar->bit_stream, 8 );    }    return 1;}/***************************************************************************** * vpar_ParseHeader : Parse the next header *****************************************************************************/int vpar_ParseHeader( vpar_thread_t * p_vpar ){    while( !p_vpar->b_die )    {        NextStartCode( p_vpar );        switch( GetBits32( &p_vpar->bit_stream ) )        {        case SEQUENCE_HEADER_CODE:            SequenceHeader( p_vpar );            return 0;            break;        case GROUP_START_CODE:            GroupHeader( p_vpar );            return 0;            break;        case PICTURE_START_CODE:            PictureHeader( p_vpar );            return 0;            break;        case SEQUENCE_END_CODE:            intf_DbgMsg("vpar debug: sequence end code received\n");            return 1;            break;        default:        }    }    return 0;}/* * Following functions are local *//***************************************************************************** * SequenceHeader : Parse the next sequence header *****************************************************************************/static void SequenceHeader( vpar_thread_t * p_vpar ){#define RESERVED    -1    static float r_frame_rate_table[16] =

⌨️ 快捷键说明

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