* doc/doxygen.cfg: up to date documentation configuration.

  * src/descriptor.c: doesn't copy data if none when creating a
    descriptor.
  * src/descriptors/dr_02.c, src/descriptors/dr_03.c: generators
    optimization.
  * src/descriptors/dr_04.h, src/descriptors/dr_04.c: MPEG2 "hierarchy"
    descriptor decoder and generator (not tested).
  * src/descriptors/dr_05.h, src/descriptors/dr_05.c: MPEG2
    "registration" descriptor decoder and generator (not tested).
parent dbbf06dc
......@@ -305,7 +305,7 @@ INPUT = index.doxygen \
structure.doxygen \
usage.doxygen \
newdec.doxygen \
../src ../src/tables
../src ../src/tables ../src/descriptors
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
......
......@@ -2,7 +2,7 @@
* descriptor.c: descriptors functions
*----------------------------------------------------------------------------
* (c)2001-2002 VideoLAN
* $Id: descriptor.c,v 1.4 2002/05/08 13:00:40 bozo Exp $
* $Id: descriptor.c,v 1.5 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -53,7 +53,8 @@ dvbpsi_descriptor_t* dvbpsi_NewDescriptor(uint8_t i_tag, uint8_t i_length,
{
p_descriptor->i_tag = i_tag;
p_descriptor->i_length = i_length;
memcpy(p_descriptor->p_data, p_data, i_length);
if(p_data)
memcpy(p_descriptor->p_data, p_data, i_length);
p_descriptor->p_decoded = NULL;
p_descriptor->p_next = NULL;
}
......
......@@ -4,7 +4,7 @@ pkgincludedir = $(includedir)/dvbpsi
noinst_LTLIBRARIES = lib_descriptors.la
lib_descriptors_la_SOURCES = dr_02.c dr_03.c
lib_descriptors_la_SOURCES = dr_02.c dr_03.c dr_04.c dr_05.c
pkginclude_HEADERS = dr_02.h dr_03.h
pkginclude_HEADERS = dr_02.h dr_03.h dr_04.h dr_05.h
......@@ -77,9 +77,9 @@ pkgincludedir = $(includedir)/dvbpsi
noinst_LTLIBRARIES = lib_descriptors.la
lib_descriptors_la_SOURCES = dr_02.c dr_03.c
lib_descriptors_la_SOURCES = dr_02.c dr_03.c dr_04.c dr_05.c
pkginclude_HEADERS = dr_02.h dr_03.h
pkginclude_HEADERS = dr_02.h dr_03.h dr_04.h dr_05.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../src/config.h
CONFIG_CLEAN_FILES =
......@@ -92,7 +92,7 @@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
lib_descriptors_la_LDFLAGS =
lib_descriptors_la_LIBADD =
lib_descriptors_la_OBJECTS = dr_02.lo dr_03.lo
lib_descriptors_la_OBJECTS = dr_02.lo dr_03.lo dr_04.lo dr_05.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
......@@ -107,7 +107,7 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
DEP_FILES = .deps/dr_02.P .deps/dr_03.P
DEP_FILES = .deps/dr_02.P .deps/dr_03.P .deps/dr_04.P .deps/dr_05.P
SOURCES = $(lib_descriptors_la_SOURCES)
OBJECTS = $(lib_descriptors_la_OBJECTS)
......
/*****************************************************************************
* dr_02.c
* (c)2001-2002 VideoLAN
* $Id: dr_02.c,v 1.3 2002/05/08 13:33:52 bozo Exp $
* $Id: dr_02.c,v 1.4 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -97,34 +97,31 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
int b_duplicate)
{
uint8_t data[3];
dvbpsi_descriptor_t * p_descriptor;
/* Encode data */
data[0] = 0;
if(p_decoded->b_multiple_frame_rate)
data[0] |= 0x80;
data[0] |= (p_decoded->i_frame_rate_code & 0x0f) << 3;
if(p_decoded->b_constrained_parameter)
data[0] |= 0x02;
if(p_decoded->b_still_picture)
data[0] |= 0x01;
if(p_decoded->b_mpeg2)
{
data[1] = p_decoded->i_profile_level_indication;
data[2] = 0x1f;
data[2] |= (p_decoded->i_chroma_format & 0x03) << 6;
if(p_decoded->b_frame_rate_extension)
data[2] |= 0x20;
}
/* Create the descriptor */
p_descriptor = dvbpsi_NewDescriptor(0x02, p_decoded->b_mpeg2 ? 3 : 1, data);
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x02, p_decoded->b_mpeg2 ? 3 : 1, NULL);
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0;
if(p_decoded->b_multiple_frame_rate)
p_descriptor->p_data[0] |= 0x80;
p_descriptor->p_data[0] |= (p_decoded->i_frame_rate_code & 0x0f) << 3;
if(p_decoded->b_constrained_parameter)
p_descriptor->p_data[0] |= 0x02;
if(p_decoded->b_still_picture)
p_descriptor->p_data[0] |= 0x01;
if(p_decoded->b_mpeg2)
{
p_descriptor->p_data[1] = p_decoded->i_profile_level_indication;
p_descriptor->p_data[2] = 0x1f;
p_descriptor->p_data[2] |= (p_decoded->i_chroma_format & 0x03) << 6;
if(p_decoded->b_frame_rate_extension)
p_descriptor->p_data[2] |= 0x20;
}
if(b_duplicate)
{
/* Duplicate decoded data */
......
/*****************************************************************************
* dr_03.c
* (c)2001-2002 VideoLAN
* $Id: dr_03.c,v 1.1 2002/05/08 13:33:52 bozo Exp $
* $Id: dr_03.c,v 1.2 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -85,22 +85,18 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
dvbpsi_descriptor_t * dvbpsi_GenAStreamDr(dvbpsi_astream_dr_t * p_decoded,
int b_duplicate)
{
uint8_t data;
dvbpsi_descriptor_t * p_descriptor;
/* Encode data */
data = 0x0f;
if(p_decoded->b_free_format)
data |= 0x80;
data |= (p_decoded->i_id & 0x01) << 6;
data |= (p_decoded->i_layer & 0x03) << 4;
/* Create the descriptor */
p_descriptor = dvbpsi_NewDescriptor(0x03, 1, &data);
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x03, 1, NULL);
if(p_descriptor)
{
/* Encode data */
*p_descriptor->p_data = 0x0f;
if(p_decoded->b_free_format)
*p_descriptor->p_data |= 0x80;
*p_descriptor->p_data |= (p_decoded->i_id & 0x01) << 6;
*p_descriptor->p_data |= (p_decoded->i_layer & 0x03) << 4;
if(b_duplicate)
{
/* Duplicate decoded data */
......
/*****************************************************************************
* dr_04.c
* (c)2001-2002 VideoLAN
* $Id: dr_04.c,v 1.1 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
* 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-1307, USA.
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../dvbpsi.h"
#include "../dvbpsi_private.h"
#include "../descriptor.h"
#include "dr_04.h"
/*****************************************************************************
* dvbpsi_DecodeHierarchyDr
*****************************************************************************/
dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_hierarchy_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x04)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_04 decoder", "out of memory");
return NULL;
}
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
}
p_decoded->i_h_type = p_descriptor->p_data[0] & 0x0f;
p_decoded->i_h_layer_index = p_descriptor->p_data[1] & 0x3f;
p_decoded->i_h_embedded_layer = p_descriptor->p_data[2] & 0x3f;
p_decoded->i_h_priority = p_descriptor->p_data[3] & 0x3f;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenHierarchyDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(dvbpsi_hierarchy_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x04, 4, NULL);
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = 0xf0 | p_decoded->i_h_type;
p_descriptor->p_data[1] = 0xc0 | p_decoded->i_h_layer_index;
p_descriptor->p_data[2] = 0xc0 | p_decoded->i_h_embedded_layer;
p_descriptor->p_data[3] = 0xc0 | p_decoded->i_h_priority;
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_hierarchy_dr_t * p_dup_decoded =
(dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_hierarchy_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_04.h
* (c)2001-2002 VideoLAN
* $Id: dr_04.h,v 1.1 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
* 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-1307, USA.
*
*****************************************************************************/
/*!
* \file <dr_04.h>
* \author Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* \brief Application interface for the MPEG 2 "hierarchy" descriptor
* decoder and generator.
*
* Application interface for the MPEG 2 "hierarchy" descriptor
* decoder and generator. This descriptor's definition can be found in
* ISO/IEC 13818-1 section 2.6.6.
*/
#ifndef _DVBPSI_DR_04_H_
#define _DVBPSI_DR_04_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_hierarchy_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_hierarchy_dr_s
* \brief "hierarchy" descriptor structure.
*
* This structure is used to store a decoded "hierarchy" descriptor.
* (ISO/IEC 13818-1 section 2.6.6).
*/
/*!
* \typedef struct dvbpsi_hierarchy_dr_s dvbpsi_hierarchy_dr_t
* \brief dvbpsi_hierarchy_dr_t type definition.
*/
typedef struct dvbpsi_hierarchy_dr_s
{
uint8_t i_h_type; /*!< hierarchy_type */
uint8_t i_h_layer_index; /*!< hierarchy_layer_index */
uint8_t i_h_embedded_layer; /*!< hierarchy_embedded_layer */
uint8_t i_h_priority; /*!< hierarchy_priority */
} dvbpsi_hierarchy_dr_t;
/*****************************************************************************
* dvbpsi_DecodeHierarchyDr
*****************************************************************************/
/*!
* \fn dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
* dvbpsi_descriptor_t * p_descriptor)
* \brief "hierarchy" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "hierarchy" descriptor structure which
* contains the decoded data.
*/
dvbpsi_hierarchy_dr_t* dvbpsi_DecodeHierarchyDr(
dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenHierarchyDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(
* dvbpsi_hierarchy_dr_t * p_decoded, int b_duplicate)
* \brief "hierarchy" descriptor generator.
* \param p_decoded pointer to a decoded "hierarchy" descriptor structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(dvbpsi_hierarchy_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_04.h"
#endif
/*****************************************************************************
* dr_05.c
* (c)2001-2002 VideoLAN
* $Id: dr_05.c,v 1.1 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
* 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-1307, USA.
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../dvbpsi.h"
#include "../dvbpsi_private.h"
#include "../descriptor.h"
#include "dr_05.h"
/*****************************************************************************
* dvbpsi_DecodeRegistrationDr
*****************************************************************************/
dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_registration_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x05)
{
DVBPSI_ERROR_ARG("dr_05 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
return p_descriptor->p_decoded;
/* Allocate memory */
p_decoded = (dvbpsi_registration_dr_t*)
malloc(sizeof(dvbpsi_registration_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_05 decoder", "out of memory");
return NULL;
}
/* Decode data and check the length */
if(p_descriptor->i_length < 4)
{
DVBPSI_ERROR_ARG("dr_05 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
}
p_decoded->i_format_identifier = ((uint32_t)(p_descriptor->p_data[0]) << 24)
| ((uint32_t)(p_descriptor->p_data[1]) << 16)
| ((uint32_t)(p_descriptor->p_data[2]) << 8)
| (uint32_t)(p_descriptor->p_data[3]);
p_decoded->i_additional_length = p_descriptor->i_length - 4;
if(p_decoded->i_additional_length)
memcpy(p_decoded->i_additional_info,
p_descriptor->p_data + 4,
p_decoded->i_additional_length);
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenRegistrationDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenRegistrationDr(
dvbpsi_registration_dr_t * p_decoded,
int b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x05, p_decoded->i_additional_length + 4, NULL);
if(p_descriptor)
{
/* Encode data */
p_descriptor->p_data[0] = p_decoded->i_format_identifier >> 24;
p_descriptor->p_data[1] = p_decoded->i_format_identifier >> 16;
p_descriptor->p_data[2] = p_decoded->i_format_identifier >> 8;
p_descriptor->p_data[3] = p_decoded->i_format_identifier;
if(p_decoded->i_additional_length)
memcpy(p_descriptor->p_data + 4,
p_decoded->i_additional_info,
p_decoded->i_additional_length);
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_registration_dr_t * p_dup_decoded =
(dvbpsi_registration_dr_t*)malloc(sizeof(dvbpsi_registration_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_registration_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_05.h
* (c)2001-2002 VideoLAN
* $Id: dr_05.h,v 1.1 2002/05/08 14:56:28 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
* 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-1307, USA.
*
*****************************************************************************/
/*!
* \file <dr_05.h>
* \author Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* \brief Application interface for the MPEG 2 "registration" descriptor
* decoder and generator.
*
* Application interface for the MPEG 2 "registration" descriptor
* decoder and generator. This descriptor's definition can be found in
* ISO/IEC 13818-1 section 2.6.8.
*/
#ifndef _DVBPSI_DR_05_H_
#define _DVBPSI_DR_05_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_registration_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_registration_dr_s
* \brief "registration" descriptor structure.
*
* This structure is used to store a decoded "registration" descriptor.
* (ISO/IEC 13818-1 section 2.6.8).
*/
/*!
* \typedef struct dvbpsi_registration_dr_s dvbpsi_registration_dr_t
* \brief dvbpsi_registration_dr_t type definition.
*/
typedef struct dvbpsi_registration_dr_s
{
uint32_t i_format_identifier; /*!< format_identifier */
uint8_t i_additional_length; /*!< length of the i_additional_info
array */
uint8_t i_additional_info[251]; /*!< additional_identification_info */
} dvbpsi_registration_dr_t;
/*****************************************************************************
* dvbpsi_DecodeRegistrationDr
*****************************************************************************/
/*!
* \fn dvbpsi_registration_dr_t * dvbpsi_DecodeRegistrationDr(
* dvbpsi_descriptor_t * p_descriptor)
* \brief "registration" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "registration" descriptor structure which
* contains the decoded data.
*/
dvbpsi_registration_dr_t* dvbpsi_DecodeRegistrationDr(
dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenRegistrationDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenRegistrationDr(
* dvbpsi_registration_dr_t * p_decoded, int b_duplicate)
* \brief "registration" descriptor generator.
* \param p_decoded pointer to a decoded "registration" descriptor structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenRegistrationDr(
dvbpsi_registration_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_05.h"
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment