Fix descriptor 0x0a to match newer specs. Note that this will break binary compatibility.

TODO: Update test code
parent db622d74
/***************************************************************************** /*****************************************************************************
* dr_0a.c * dr_0a.c
* (c)2001-2002 VideoLAN * (c)2001-2002 VideoLAN
* $Id: dr_0a.c,v 1.4 2003/07/25 20:20:40 fenrir Exp $ * $Id$
* *
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> * Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* *
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor) dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
{ {
dvbpsi_iso639_dr_t * p_decoded; dvbpsi_iso639_dr_t * p_decoded;
int i;
/* Check the tag */ /* Check the tag */
if(p_descriptor->i_tag != 0x0a) if(p_descriptor->i_tag != 0x0a)
...@@ -68,7 +69,7 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor) ...@@ -68,7 +69,7 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
} }
/* Decode data and check the length */ /* Decode data and check the length */
if((p_descriptor->i_length < 1) || ((p_descriptor->i_length - 1) % 3 != 0)) if((p_descriptor->i_length < 1) || (p_descriptor->i_length % 4 != 0))
{ {
DVBPSI_ERROR_ARG("dr_0a decoder", "bad length (%d)", DVBPSI_ERROR_ARG("dr_0a decoder", "bad length (%d)",
p_descriptor->i_length); p_descriptor->i_length);
...@@ -76,13 +77,15 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor) ...@@ -76,13 +77,15 @@ dvbpsi_iso639_dr_t * dvbpsi_DecodeISO639Dr(dvbpsi_descriptor_t * p_descriptor)
return NULL; return NULL;
} }
p_decoded->i_audio_type = p_descriptor->p_data[p_descriptor->i_length - 1]; p_decoded->i_code_count = p_descriptor->i_length / 4;
p_decoded->i_code_count = (p_descriptor->i_length - 1) / 3; i = 0;
if(p_decoded->i_code_count) while( i < p_decoded->i_code_count ) {
memcpy(p_decoded->i_iso_639_code, p_decoded->code[i].iso_639_code[0] = p_descriptor->p_data[i*4];
p_descriptor->p_data, p_decoded->code[i].iso_639_code[1] = p_descriptor->p_data[i*4+1];
p_descriptor->i_length - 1); p_decoded->code[i].iso_639_code[2] = p_descriptor->p_data[i*4+2];
p_decoded->code[i].i_audio_type = p_descriptor->p_data[i*4+3];
i++;
}
p_descriptor->p_decoded = (void*)p_decoded; p_descriptor->p_decoded = (void*)p_decoded;
return p_decoded; return p_decoded;
...@@ -97,17 +100,19 @@ dvbpsi_descriptor_t * dvbpsi_GenISO639Dr(dvbpsi_iso639_dr_t * p_decoded, ...@@ -97,17 +100,19 @@ dvbpsi_descriptor_t * dvbpsi_GenISO639Dr(dvbpsi_iso639_dr_t * p_decoded,
{ {
/* Create the descriptor */ /* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x0a, p_decoded->i_code_count * 3 + 1, NULL); dvbpsi_NewDescriptor(0x0a, p_decoded->i_code_count * 4, NULL);
if(p_descriptor) if(p_descriptor)
{ {
/* Encode data */ /* Encode data */
p_descriptor->p_data[p_descriptor->i_length - 1] = p_decoded->i_audio_type; int i = 0;
if(p_decoded->i_code_count) while( i < p_decoded->i_code_count ) {
memcpy(p_descriptor->p_data, p_descriptor->p_data[i*4] = p_decoded->code[i].iso_639_code[0];
p_decoded->i_iso_639_code, p_descriptor->p_data[i*4+1] = p_decoded->code[i].iso_639_code[1];
p_descriptor->i_length - 1); p_descriptor->p_data[i*4+2] = p_decoded->code[i].iso_639_code[2];
p_descriptor->p_data[i*4+3] = p_decoded->code[i].i_audio_type;
i++;
}
if(b_duplicate) if(b_duplicate)
{ {
/* Duplicate decoded data */ /* Duplicate decoded data */
......
/***************************************************************************** /*****************************************************************************
* dr_0a.h * dr_0a.h
* (c)2001-2002 VideoLAN * (c)2001-2002 VideoLAN
* $Id: dr_0a.h,v 1.2 2002/05/10 23:50:36 bozo Exp $ * $Id$
* *
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> * Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* *
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
extern "C" { extern "C" {
#endif #endif
#define DR_0A_API_VER 2
typedef uint8_t iso_639_language_code_t[3];
/***************************************************************************** /*****************************************************************************
* dvbpsi_iso639_dr_t * dvbpsi_iso639_dr_t
...@@ -58,8 +60,10 @@ typedef struct dvbpsi_iso639_dr_s ...@@ -58,8 +60,10 @@ typedef struct dvbpsi_iso639_dr_s
{ {
uint8_t i_code_count; /*!< length of the i_iso_639_code uint8_t i_code_count; /*!< length of the i_iso_639_code
array */ array */
uint8_t i_iso_639_code[252]; /*!< ISO_639_language_code */ struct {
iso_639_language_code_t iso_639_code; /*!< ISO_639_language_code */
uint8_t i_audio_type; /*!< audio_type */ uint8_t i_audio_type; /*!< audio_type */
} code[64];
} dvbpsi_iso639_dr_t; } dvbpsi_iso639_dr_t;
......
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