* src/descriptors/dr_02.h, src/descriptors/dr_02.c: fixed a typo and

    a little optimization.
  * src/descriptors/dr_03.h, src/descriptors/dr_03.c: MPEG2 "audio
    stream" descriptor decoder and generator (not tested).
parent 3fa924f5
......@@ -4,7 +4,7 @@ pkgincludedir = $(includedir)/dvbpsi
noinst_LTLIBRARIES = lib_descriptors.la
lib_descriptors_la_SOURCES = dr_02.c
lib_descriptors_la_SOURCES = dr_02.c dr_03.c
pkginclude_HEADERS = dr_02.h
pkginclude_HEADERS = dr_02.h dr_03.h
......@@ -77,9 +77,9 @@ pkgincludedir = $(includedir)/dvbpsi
noinst_LTLIBRARIES = lib_descriptors.la
lib_descriptors_la_SOURCES = dr_02.c
lib_descriptors_la_SOURCES = dr_02.c dr_03.c
pkginclude_HEADERS = dr_02.h
pkginclude_HEADERS = dr_02.h dr_03.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
lib_descriptors_la_OBJECTS = dr_02.lo dr_03.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
DEP_FILES = .deps/dr_02.P .deps/dr_03.P
SOURCES = $(lib_descriptors_la_SOURCES)
OBJECTS = $(lib_descriptors_la_OBJECTS)
......
/*****************************************************************************
* dr_02.c
* (c)2001-2002 VideoLAN
* $Id: dr_02.c,v 1.2 2002/05/08 13:11:41 bozo Exp $
* $Id: dr_02.c,v 1.3 2002/05/08 13:33:52 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -135,8 +135,6 @@ dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
else
p_descriptor->p_decoded = NULL;
}
return p_descriptor;
......
/*****************************************************************************
* dr_02.h
* (c)2001-2002 VideoLAN
* $Id: dr_02.h,v 1.1 2002/05/08 13:00:40 bozo Exp $
* $Id: dr_02.h,v 1.2 2002/05/08 13:33:52 bozo Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -79,7 +79,7 @@ typedef struct dvbpsi_vstream_dr_s
* \brief "video stream" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "video stream" descriptor structure which
* contain the decoded data.
* contains the decoded data.
*/
dvbpsi_vstream_dr_t* dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor);
......@@ -94,7 +94,7 @@ dvbpsi_vstream_dr_t* dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor);
* \param p_decoded pointer to a decoded "video stream" 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 contain encoded data.
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
int b_duplicate);
......
/*****************************************************************************
* dr_03.c
* (c)2001-2002 VideoLAN
* $Id: dr_03.c,v 1.1 2002/05/08 13:33:52 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_03.h"
/*****************************************************************************
* dvbpsi_DecodeAStreamDr
*****************************************************************************/
dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
{
dvbpsi_astream_dr_t * p_decoded;
/* Check the tag */
if(p_descriptor->i_tag != 0x03)
{
DVBPSI_ERROR_ARG("dr_03 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_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_03 decoder", "out of memory");
return NULL;
}
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
}
p_decoded->b_free_format = (p_descriptor->p_data[0] & 0x80) ? 1 : 0;
p_decoded->i_id = (p_descriptor->p_data[0] & 0x40) >> 6;
p_decoded->i_layer = (p_descriptor->p_data[0] & 0x30) >> 4;
p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded;
}
/*****************************************************************************
* dvbpsi_GenAStreamDr
*****************************************************************************/
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);
if(p_descriptor)
{
if(b_duplicate)
{
/* Duplicate decoded data */
dvbpsi_astream_dr_t * p_dup_decoded =
(dvbpsi_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t));
if(p_dup_decoded)
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_astream_dr_t));
p_descriptor->p_decoded = (void*)p_dup_decoded;
}
}
return p_descriptor;
}
/*****************************************************************************
* dr_03.h
* (c)2001-2002 VideoLAN
* $Id: dr_03.h,v 1.1 2002/05/08 13:33:52 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_03.h>
* \author Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* \brief Application interface for the MPEG 2 "audio stream" descriptor
* decoder and generator.
*
* Application interface for the MPEG 2 "audio stream" descriptor
* decoder and generator. This descriptor's definition can be found in
* ISO/IEC 13818-1 section 2.6.4.
*/
#ifndef _DVBPSI_DR_03_H_
#define _DVBPSI_DR_03_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_astream_dr_t
*****************************************************************************/
/*!
* \struct dvbpsi_astream_dr_s
* \brief "audio stream" descriptor structure.
*
* This structure is used to store a decoded "audio stream" descriptor.
* (ISO/IEC 13818-1 section 2.6.4).
*/
/*!
* \typedef struct dvbpsi_astream_dr_s dvbpsi_astream_dr_t
* \brief dvbpsi_astream_dr_t type definition.
*/
typedef struct dvbpsi_astream_dr_s
{
int b_free_format; /*!< free_format_flag */
uint8_t i_id; /*!< ID */
uint8_t i_layer; /*!< layer */
} dvbpsi_astream_dr_t;
/*****************************************************************************
* dvbpsi_DecodeAStreamDr
*****************************************************************************/
/*!
* \fn dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(
* dvbpsi_descriptor_t * p_descriptor)
* \brief "audio stream" descriptor decoder.
* \param p_descriptor pointer to the descriptor structure
* \return a pointer to a new "audio stream" descriptor structure which
* contains the decoded data.
*/
dvbpsi_astream_dr_t* dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor);
/*****************************************************************************
* dvbpsi_GenAStreamDr
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenAStreamDr(
* dvbpsi_astream_dr_t * p_decoded, int b_duplicate)
* \brief "audio stream" descriptor generator.
* \param p_decoded pointer to a decoded "video stream" 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_GenAStreamDr(dvbpsi_astream_dr_t * p_decoded,
int b_duplicate);
#ifdef __cplusplus
};
#endif
#else
#error "Multiple inclusions of dr_03.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