/* * Copyright (C) 2010-2011 Mamadou Diop. * * Contact: Mamadou Diop * * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. * * DOUBANGO 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 DOUBANGO. * */ /**@file tdav_codec_g711.c * @brief G.711u and G.711a (a.k.a PCMU and PCMA) codec plugins. * * @author Mamadou Diop * */ #include "tinydav/codecs/g711/tdav_codec_g711.h" #include "tinydav/codecs/g711/g711.h" /* algorithms */ #include "tsk_memory.h" #include "tsk_debug.h" /* ============ G.711u Plugin interface ================= */ #define tdav_codec_g711u_open tsk_null #define tdav_codec_g711u_close tsk_null #define tdav_codec_g711u_sdp_att_get tsk_null static tsk_size_t tdav_codec_g711u_encode(tmedia_codec_t* self, const void* in_data, tsk_size_t in_size, void** out_data, tsk_size_t* out_max_size) { register tsk_size_t i; register uint8_t* pout_data; register int16_t* pin_data; tsk_size_t out_size; if(!self || !in_data || !in_size || !out_data){ TSK_DEBUG_ERROR("Invalid parameter"); return 0; } out_size = (in_size >> 1); if(*out_max_size > 1); if(*out_max_size < out_size){ if(!(*out_data = tsk_realloc(*out_data, out_size))){ TSK_DEBUG_ERROR("Failed to allocate new buffer"); *out_max_size = 0; return 0; } *out_max_size = out_size; } pout_data = *out_data; pin_data = (int16_t*)in_data; for(i = 0; i