dr_43.c | dr_43.c | |||
---|---|---|---|---|
/************************************************************************** *** | /************************************************************************** *** | |||
* dr_43.c | * dr_43.c | |||
* Copyright (C) 2001-2010 VideoLAN | * Copyright (C) 2001-2011 VideoLAN | |||
* $Id$ | * $Id$ | |||
* | * | |||
* Authors: Johann Hanne | * Authors: Johann Hanne | |||
* | * | |||
* This library is free software; you can redistribute it and/or | * This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | * License as published by the Free Software Foundation; either | |||
* version 2.1 of the License, or (at your option) any later version. | * version 2.1 of the License, or (at your option) any later version. | |||
* | * | |||
* This library is distributed in the hope that it will be useful, | * This library is distributed in the hope that it will be useful, | |||
skipping to change at line 28 | skipping to change at line 28 | |||
* You should have received a copy of the GNU Lesser General Public | * You should have received a copy of the GNU Lesser General Public | |||
* License along with this library; if not, write to the Free Software | * License along with this library; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 1 USA | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 1 USA | |||
* | * | |||
************************************************************************** ***/ | ************************************************************************** ***/ | |||
#include "config.h" | #include "config.h" | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <stdbool.h> | ||||
#include <string.h> | #include <string.h> | |||
#if defined(HAVE_INTTYPES_H) | #if defined(HAVE_INTTYPES_H) | |||
#include <inttypes.h> | #include <inttypes.h> | |||
#elif defined(HAVE_STDINT_H) | #elif defined(HAVE_STDINT_H) | |||
#include <stdint.h> | #include <stdint.h> | |||
#endif | #endif | |||
#include "../dvbpsi.h" | #include "../dvbpsi.h" | |||
#include "../dvbpsi_private.h" | #include "../dvbpsi_private.h" | |||
#include "../descriptor.h" | #include "../descriptor.h" | |||
#include "dr_43.h" | #include "dr_43.h" | |||
/************************************************************************** *** | /************************************************************************** *** | |||
* dvbpsi_DecodeSatDelivSysDr | * dvbpsi_DecodeSatDelivSysDr | |||
************************************************************************** ***/ | ************************************************************************** ***/ | |||
dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr( | dvbpsi_sat_deliv_sys_dr_t * dvbpsi_DecodeSatDelivSysDr( | |||
dvbpsi_descriptor_t * p_descriptor) | dvbpsi_descriptor_t * p_descriptor) | |||
{ | { | |||
dvbpsi_sat_deliv_sys_dr_t * p_decoded; | dvbpsi_sat_deliv_sys_dr_t * p_decoded; | |||
/* Check the tag */ | /* Check the tag */ | |||
if(p_descriptor->i_tag != 0x43) | if (!dvbpsi_CanDecodeAsDescriptor(p_descriptor, 0x43)) | |||
{ | return NULL; | |||
DVBPSI_ERROR_ARG("dr_43 decoder", "bad tag (0x%x)", p_descriptor->i_tag | ||||
); | /* Don't decode twice */ | |||
return NULL; | if (dvbpsi_IsDescriptorDecoded(p_descriptor)) | |||
} | return p_descriptor->p_decoded; | |||
/* Don't decode twice */ | /* Allocate memory */ | |||
if(p_descriptor->p_decoded) | p_decoded = (dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_ | |||
return p_descriptor->p_decoded; | sys_dr_t)); | |||
if (!p_decoded) | ||||
/* Allocate memory */ | return NULL; | |||
p_decoded = | ||||
(dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_sys_dr_t | /* Decode data */ | |||
)); | p_decoded->i_frequency = (uint32_t)(p_descriptor->p_data[0] < | |||
if(!p_decoded) | < 24) | |||
{ | | (uint32_t)(p_descriptor->p_data[1] < | |||
DVBPSI_ERROR("dr_43 decoder", "out of memory"); | < 16) | |||
return NULL; | | (uint32_t)(p_descriptor->p_data[2] < | |||
} | < 8) | |||
| (uint32_t)(p_descriptor->p_data[3]); | ||||
/* Decode data */ | p_decoded->i_orbital_position = (uint16_t)(p_descriptor->p_data[4] < | |||
p_decoded->i_frequency = (uint32_t)(p_descriptor->p_data[0] << | < 8) | |||
24) | | (uint16_t)(p_descriptor->p_data[5]); | |||
| (uint32_t)(p_descriptor->p_data[1] << | p_decoded->i_west_east_flag = (p_descriptor->p_data[6] >> 7) & 0x0 | |||
16) | 1; | |||
| (uint32_t)(p_descriptor->p_data[2] << | p_decoded->i_polarization = (p_descriptor->p_data[6] >> 5) & 0x0 | |||
8) | 3; | |||
| (uint32_t)(p_descriptor->p_data[3]); | p_decoded->i_roll_off = (p_descriptor->p_data[6] >> 3) & 0x0 | |||
p_decoded->i_orbital_position = (uint16_t)(p_descriptor->p_data[4] << | 3; | |||
8) | p_decoded->i_modulation_system = (p_descriptor->p_data[6] >> 2) & 0x0 | |||
| (uint16_t)(p_descriptor->p_data[5]); | 1; | |||
p_decoded->i_west_east_flag = (p_descriptor->p_data[6] >> 7) & 0x01; | p_decoded->i_modulation_type = p_descriptor->p_data[6] & 0x03; | |||
p_decoded->i_polarization = (p_descriptor->p_data[6] >> 5) & 0x03; | p_decoded->i_symbol_rate = (uint32_t)(p_descriptor->p_data[7] < | |||
p_decoded->i_roll_off = (p_descriptor->p_data[6] >> 3) & 0x03; | < 20) | |||
p_decoded->i_modulation_system = (p_descriptor->p_data[6] >> 2) & 0x01; | | (uint32_t)(p_descriptor->p_data[8] < | |||
p_decoded->i_modulation_type = p_descriptor->p_data[6] & 0x03; | < 12) | |||
p_decoded->i_symbol_rate = (uint32_t)(p_descriptor->p_data[7] << | | (uint32_t)(p_descriptor->p_data[9] < | |||
20) | < 4) | |||
| (uint32_t)(p_descriptor->p_data[8] << | | (uint32_t)((p_descriptor->p_data[10] | |||
12) | >> 4) & 0x0f); | |||
| (uint32_t)(p_descriptor->p_data[9] << | p_decoded->i_fec_inner = p_descriptor->p_data[10] & 0x0f; | |||
4) | ||||
| (uint32_t)((p_descriptor->p_data[10] > | ||||
> 4) & 0x0f); | ||||
p_decoded->i_fec_inner = p_descriptor->p_data[10] & 0x0f; | ||||
p_descriptor->p_decoded = (void*)p_decoded; | p_descriptor->p_decoded = (void*)p_decoded; | |||
return p_decoded; | return p_decoded; | |||
} | } | |||
/************************************************************************** *** | /************************************************************************** *** | |||
* dvbpsi_GenSatDelivSysDr | * dvbpsi_GenSatDelivSysDr | |||
************************************************************************** ***/ | ************************************************************************** ***/ | |||
dvbpsi_descriptor_t * dvbpsi_GenSatDelivSysDr( | dvbpsi_descriptor_t * dvbpsi_GenSatDelivSysDr( | |||
dvbpsi_sat_deliv_sys_dr_t * p_decod ed, | dvbpsi_sat_deliv_sys_dr_t * p_decod ed, | |||
int b_duplicate) | bool b_duplicate) | |||
{ | { | |||
/* Create the descriptor */ | /* Create the descriptor */ | |||
dvbpsi_descriptor_t * p_descriptor = | dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x43, 11, NUL | |||
dvbpsi_NewDescriptor(0x43, 11, NULL); | L); | |||
if (!p_descriptor) | ||||
return NULL; | ||||
if(p_descriptor) | ||||
{ | ||||
/* Encode data */ | /* Encode data */ | |||
p_descriptor->p_data[0] = (p_decoded->i_frequency >> 24) & 0 | p_descriptor->p_data[0] = (p_decoded->i_frequency >> 24) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[1] = (p_decoded->i_frequency >> 16) & 0 | p_descriptor->p_data[1] = (p_decoded->i_frequency >> 16) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[2] = (p_decoded->i_frequency >> 8) & 0 | p_descriptor->p_data[2] = (p_decoded->i_frequency >> 8) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[3] = p_decoded->i_frequency & 0 | p_descriptor->p_data[3] = p_decoded->i_frequency & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[4] = (p_decoded->i_orbital_position >> 8) & 0 | p_descriptor->p_data[4] = (p_decoded->i_orbital_position >> 8) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[5] = p_decoded->i_orbital_position & 0 | p_descriptor->p_data[5] = p_decoded->i_orbital_position & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[6] = ((p_decoded->i_west_east_flag & 0 | p_descriptor->p_data[6] = ((p_decoded->i_west_east_flag & 0x01 | |||
x01) << 7) | ) << 7) | |||
| ((p_decoded->i_polarization & 0 | | ((p_decoded->i_polarization & 0x03 | |||
x03) << 5) | ) << 5) | |||
| ((p_decoded->i_roll_off & 0 | | ((p_decoded->i_roll_off & 0x03 | |||
x03) << 3) | ) << 3) | |||
| ((p_decoded->i_modulation_system & 0 | | ((p_decoded->i_modulation_system & 0x01 | |||
x01) << 2) | ) << 2) | |||
| (p_decoded->i_modulation_type & 0 | | (p_decoded->i_modulation_type & 0x03 | |||
x03); | ); | |||
p_descriptor->p_data[7] = (p_decoded->i_symbol_rate >> 20) & 0 | p_descriptor->p_data[7] = (p_decoded->i_symbol_rate >> 20) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[8] = (p_decoded->i_symbol_rate >> 12) & 0 | p_descriptor->p_data[8] = (p_decoded->i_symbol_rate >> 12) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[9] = (p_decoded->i_symbol_rate >> 4) & 0 | p_descriptor->p_data[9] = (p_decoded->i_symbol_rate >> 4) & 0xff | |||
xff; | ; | |||
p_descriptor->p_data[10] = ((p_decoded->i_symbol_rate << 4) & 0 | p_descriptor->p_data[10] = ((p_decoded->i_symbol_rate << 4) & 0xf0 | |||
xf0) | ) | |||
| (p_decoded->i_fec_inner & 0 | | (p_decoded->i_fec_inner & 0x0f | |||
x0f); | ); | |||
if(b_duplicate) | if (b_duplicate) | |||
{ | { | |||
/* Duplicate decoded data */ | /* Duplicate decoded data */ | |||
dvbpsi_sat_deliv_sys_dr_t * p_dup_decoded = | p_descriptor->p_decoded = | |||
(dvbpsi_sat_deliv_sys_dr_t*)malloc(sizeof(dvbpsi_sat_deliv_sys_dr_t | dvbpsi_DuplicateDecodedDescriptor(p_decoded, | |||
)); | sizeof(dvbpsi_sat_deliv_s | |||
if(p_dup_decoded) | ys_dr_t)); | |||
memcpy(p_dup_decoded, p_decoded, sizeof(dvbpsi_sat_deliv_sys_dr_t)) | ||||
; | ||||
p_descriptor->p_decoded = (void*)p_dup_decoded; | ||||
} | } | |||
} | ||||
return p_descriptor; | return p_descriptor; | |||
} | } | |||
End of changes. 13 change blocks. | ||||
100 lines changed or deleted | 92 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |