/*****************************************************************************
+ * crystalhd.c: CrystalHD decoder
+ *****************************************************************************
* Copyright © 2010-2011 VideoLAN
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
* Narendra Sankar <nsankar@broadcom.com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
+#include "h264_nal.h"
/* Workaround for some versions of libcrystalHD */
#if !defined(_WIN32) && !defined(__APPLE__)
};
for( int i = 0; i < PATHS_NB; i++ )
{
- HINSTANCE p_bcm_dll = LoadLibrary( psz_paths[i] );
+ HINSTANCE p_bcm_dll = LoadLibraryA( psz_paths[i] );
if( p_bcm_dll )
{
p_sys->p_bcm_dll = p_bcm_dll;
}
#define LOAD_SYM( a ) \
- BC_FUNC( a ) = (void *)GetProcAddress( p_sys->p_bcm_dll, TEXT( #a ) ); \
+ BC_FUNC( a ) = (void *)GetProcAddress( p_sys->p_bcm_dll, ( #a ) ); \
if( !BC_FUNC( a ) ) { \
msg_Err( p_dec, "missing symbol " # a ); return VLC_EGENERIC; }
break;
}
if( p_pic )
- decoder_DeletePicture( p_dec, p_pic );
+ picture_Release( p_pic );
return NULL;
}
p_dst_end = p_dst + (i_dst_stride * p_out->PicInfo.height);
for( ; p_dst < p_dst_end; p_dst += i_dst_stride, p_src += (p_out->PicInfo.width * 2))
- vlc_memcpy( p_dst, p_src, p_out->PicInfo.width * 2); // Copy in bytes
+ memcpy( p_dst, p_src, p_out->PicInfo.width * 2); // Copy in bytes
}
#endif
uint32_t i_buf_size)
{
decoder_sys_t *p_sys = p_dec->p_sys;
- int i_profile;
- uint32_t i_data_size = i_buf_size, i_nal_size;
- unsigned int i_loop_end;
+ int ret;
p_sys->i_sps_pps_size = 0;
if( !p_sys->p_sps_pps_buf )
return VLC_ENOMEM;
- /* */
- if( i_data_size < 7 )
- {
- msg_Err( p_dec, "Input Metadata too small" );
- goto error;
- }
-
- /* Read infos in first 6 bytes */
- i_profile = (p_buf[1] << 16) | (p_buf[2] << 8) | p_buf[3];
- p_sys->i_nal_size = (p_buf[4] & 0x03) + 1;
- p_buf += 5;
- i_data_size -= 5;
-
- for ( unsigned int j = 0; j < 2; j++ )
- {
- /* First time is SPS, Second is PPS */
- if( i_data_size < 1 )
- {
- msg_Err( p_dec, "PPS too small after processing SPS/PPS %u",
- i_data_size );
- goto error;
- }
- i_loop_end = p_buf[0] & (j == 0 ? 0x1f : 0xff);
- p_buf++; i_data_size--;
-
- for ( unsigned int i = 0; i < i_loop_end; i++)
- {
- if( i_data_size < 2 )
- {
- msg_Err( p_dec, "SPS is too small %u", i_data_size );
- goto error;
- }
-
- i_nal_size = (p_buf[0] << 8) | p_buf[1];
- p_buf += 2;
- i_data_size -= 2;
-
- if( i_data_size < i_nal_size )
- {
- msg_Err( p_dec, "SPS size does not match NAL specified size %u",
- i_data_size );
- goto error;
- }
-
- p_sys->p_sps_pps_buf[p_sys->i_sps_pps_size++] = 0;
- p_sys->p_sps_pps_buf[p_sys->i_sps_pps_size++] = 0;
- p_sys->p_sps_pps_buf[p_sys->i_sps_pps_size++] = 0;
- p_sys->p_sps_pps_buf[p_sys->i_sps_pps_size++] = 1;
+ ret = convert_sps_pps( p_dec, p_buf, i_buf_size, p_sys->p_sps_pps_buf,
+ p_dec->fmt_in.i_extra * 2, &p_sys->i_sps_pps_size,
+ &p_sys->i_nal_size );
+ if( !ret )
+ return ret;
- memcpy( p_sys->p_sps_pps_buf + p_sys->i_sps_pps_size, p_buf, i_nal_size );
- p_sys->i_sps_pps_size += i_nal_size;
-
- p_buf += i_nal_size;
- i_data_size -= i_nal_size;
- }
- }
-
- return VLC_SUCCESS;
-
-error:
free( p_sys->p_sps_pps_buf );
p_sys->p_sps_pps_buf = NULL;
- return VLC_ENOMEM;
+ return ret;
}