1 /*****************************************************************************
2 * crystalhd.c: CrystalHD decoder
3 *****************************************************************************
4 * Copyright © 2010-2011 VideoLAN
6 * Authors: Jean-Baptiste Kempf <jb@videolan.org>
7 * Narendra Sankar <nsankar@broadcom.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
39 #include <vlc_common.h>
40 #include <vlc_plugin.h>
41 #include <vlc_codec.h>
42 #include "../packetizer/h264_nal.h"
44 /* Workaround for some versions of libcrystalHD */
45 #if !defined(_WIN32) && !defined(__APPLE__)
46 # define __LINUX_USER__
50 #include <libcrystalhd/bc_dts_defs.h>
51 #include <libcrystalhd/bc_dts_types.h>
53 #if defined(HAVE_LIBCRYSTALHD_BC_DRV_IF_H) /* Win32 */
54 # include <libcrystalhd/bc_drv_if.h>
56 # define USE_DL_OPENING 1
58 # include <libcrystalhd/libcrystalhd_if.h>
61 /* On a normal Win32 build, well aren't going to ship the BCM dll
62 And forcing users to install the right dll at the right place will not work
63 Therefore, we need to dl_open and resolve the symbols */
65 # warning DLL opening mode
66 # define BC_FUNC( a ) Our ## a
67 # define BC_FUNC_PSYS( a ) p_sys->Our ## a
69 # define BC_FUNC( a ) a
70 # define BC_FUNC_PSYS( a ) a
75 /* BC pts are multiple of 100ns */
76 #define TO_BC_PTS( a ) ( a * 10 + 1 )
77 #define FROM_BC_PTS( a ) ((a - 1) /10)
79 //#define DEBUG_CRYSTALHD 1
81 /*****************************************************************************
83 *****************************************************************************/
84 static int OpenDecoder ( vlc_object_t
* );
85 static void CloseDecoder ( vlc_object_t
* );
88 set_category( CAT_INPUT
)
89 set_subcategory( SUBCAT_INPUT_VCODEC
)
90 set_description( N_("Crystal HD hardware video decoder") )
91 set_capability( "decoder", 0 )
92 set_callbacks( OpenDecoder
, CloseDecoder
)
93 add_shortcut( "crystalhd" )
96 /*****************************************************************************
98 *****************************************************************************/
99 static int DecodeBlock ( decoder_t
*p_dec
, block_t
*p_block
);
100 // static void crystal_CopyPicture ( picture_t *, BC_DTS_PROC_OUT* );
101 static int crystal_insert_sps_pps(decoder_t
*, uint8_t *, uint32_t);
103 /*****************************************************************************
104 * decoder_sys_t : CrysalHD decoder structure
105 *****************************************************************************/
108 HANDLE bcm_handle
; /* Device Handle */
110 uint8_t *p_sps_pps_buf
; /* SPS/PPS buffer */
111 size_t i_sps_pps_size
; /* SPS/PPS size */
113 uint8_t i_nal_size
; /* NAL header size */
117 BC_DTS_PROC_OUT
*proc_out
;
119 #ifdef USE_DL_OPENING
121 BC_STATUS (WINAPI
*OurDtsCloseDecoder
)( HANDLE hDevice
);
122 BC_STATUS (WINAPI
*OurDtsDeviceClose
)( HANDLE hDevice
);
123 BC_STATUS (WINAPI
*OurDtsFlushInput
)( HANDLE hDevice
, U32 Mode
);
124 BC_STATUS (WINAPI
*OurDtsStopDecoder
)( HANDLE hDevice
);
125 BC_STATUS (WINAPI
*OurDtsGetDriverStatus
)( HANDLE hDevice
,
126 BC_DTS_STATUS
*pStatus
);
127 BC_STATUS (WINAPI
*OurDtsProcInput
)( HANDLE hDevice
, U8
*pUserData
,
128 U32 ulSizeInBytes
, U64 timeStamp
, BOOL encrypted
);
129 BC_STATUS (WINAPI
*OurDtsProcOutput
)( HANDLE hDevice
, U32 milliSecWait
,
130 BC_DTS_PROC_OUT
*pOut
);
131 BC_STATUS (WINAPI
*OurDtsIsEndOfStream
)( HANDLE hDevice
, U8
* bEOS
);
135 /*****************************************************************************
136 * OpenDecoder: probe the decoder and return score
137 *****************************************************************************/
138 static int OpenDecoder( vlc_object_t
*p_this
)
140 decoder_t
*p_dec
= (decoder_t
*)p_this
;
141 decoder_sys_t
*p_sys
;
143 /* Codec specifics */
144 uint32_t i_bcm_codec_subtype
= 0;
145 switch ( p_dec
->fmt_in
.i_codec
)
148 if( p_dec
->fmt_in
.i_original_fourcc
== VLC_FOURCC( 'a', 'v', 'c', '1' ) )
149 i_bcm_codec_subtype
= BC_MSUBTYPE_AVC1
;
151 i_bcm_codec_subtype
= BC_MSUBTYPE_H264
;
154 i_bcm_codec_subtype
= BC_MSUBTYPE_VC1
;
157 i_bcm_codec_subtype
= BC_MSUBTYPE_WMV3
;
160 i_bcm_codec_subtype
= BC_MSUBTYPE_WMVA
;
163 i_bcm_codec_subtype
= BC_MSUBTYPE_MPEG2VIDEO
;
165 /* Not ready for production yet
167 i_bcm_codec_subtype = BC_MSUBTYPE_DIVX;
170 i_bcm_codec_subtype = BC_MSUBTYPE_DIVX311;
176 /* Allocate the memory needed to store the decoder's structure */
177 p_sys
= malloc( sizeof(*p_sys
) );
181 /* Fill decoder_sys_t */
182 p_dec
->p_sys
= p_sys
;
183 p_sys
->i_nal_size
= 4; // assume 4 byte start codes
184 p_sys
->i_sps_pps_size
= 0;
185 p_sys
->p_sps_pps_buf
= NULL
;
186 p_dec
->p_sys
->p_pic
= NULL
;
187 p_dec
->p_sys
->proc_out
= NULL
;
190 * We cannot link and ship BCM dll, even with LGPL license (too big)
191 * and if we don't ship it, the plugin would not work depending on the
192 * installation order => DLopen */
193 #ifdef USE_DL_OPENING
194 # define DLL_NAME "bcmDIL.dll"
196 static const TCHAR
*psz_paths
[PATHS_NB
] = {
198 TEXT("C:\\Program Files\\Broadcom\\Broadcom CrystalHD Decoder\\" DLL_NAME
),
199 TEXT("C:\\Program Files (x86)\\Broadcom\\Broadcom CrystalHD Decoder\\" DLL_NAME
),
201 for( int i
= 0; i
< PATHS_NB
; i
++ )
203 HINSTANCE p_bcm_dll
= LoadLibrary( psz_paths
[i
] );
206 p_sys
->p_bcm_dll
= p_bcm_dll
;
210 if( !p_sys
->p_bcm_dll
)
212 msg_Dbg( p_dec
, "Couldn't load the CrystalHD dll");
216 #define LOAD_SYM( a ) \
217 BC_FUNC( a ) = (void *)GetProcAddress( p_sys->p_bcm_dll, ( #a ) ); \
218 if( !BC_FUNC( a ) ) { \
219 msg_Err( p_dec, "missing symbol " # a ); return VLC_EGENERIC; }
221 #define LOAD_SYM_PSYS( a ) \
222 p_sys->BC_FUNC( a ) = (void *)GetProcAddress( p_sys->p_bcm_dll, #a ); \
223 if( !p_sys->BC_FUNC( a ) ) { \
224 msg_Err( p_dec, "missing symbol " # a ); return VLC_EGENERIC; }
226 BC_STATUS (WINAPI
*OurDtsDeviceOpen
)( HANDLE
*hDevice
, U32 mode
);
227 LOAD_SYM( DtsDeviceOpen
);
228 BC_STATUS (WINAPI
*OurDtsCrystalHDVersion
)( HANDLE hDevice
, PBC_INFO_CRYSTAL bCrystalInfo
);
229 LOAD_SYM( DtsCrystalHDVersion
);
230 BC_STATUS (WINAPI
*OurDtsSetColorSpace
)( HANDLE hDevice
, BC_OUTPUT_FORMAT Mode422
);
231 LOAD_SYM( DtsSetColorSpace
);
232 BC_STATUS (WINAPI
*OurDtsSetInputFormat
)( HANDLE hDevice
, BC_INPUT_FORMAT
*pInputFormat
);
233 LOAD_SYM( DtsSetInputFormat
);
234 BC_STATUS (WINAPI
*OurDtsOpenDecoder
)( HANDLE hDevice
, U32 StreamType
);
235 LOAD_SYM( DtsOpenDecoder
);
236 BC_STATUS (WINAPI
*OurDtsStartDecoder
)( HANDLE hDevice
);
237 LOAD_SYM( DtsStartDecoder
);
238 BC_STATUS (WINAPI
*OurDtsStartCapture
)( HANDLE hDevice
);
239 LOAD_SYM( DtsStartCapture
);
240 LOAD_SYM_PSYS( DtsCloseDecoder
);
241 LOAD_SYM_PSYS( DtsDeviceClose
);
242 LOAD_SYM_PSYS( DtsFlushInput
);
243 LOAD_SYM_PSYS( DtsStopDecoder
);
244 LOAD_SYM_PSYS( DtsGetDriverStatus
);
245 LOAD_SYM_PSYS( DtsProcInput
);
246 LOAD_SYM_PSYS( DtsProcOutput
);
247 LOAD_SYM_PSYS( DtsIsEndOfStream
);
250 #endif /* USE_DL_OPENING */
252 #ifdef DEBUG_CRYSTALHD
253 msg_Dbg( p_dec
, "Trying to open CrystalHD HW");
256 /* Get the handle for the device */
257 if( BC_FUNC(DtsDeviceOpen
)( &p_sys
->bcm_handle
,
258 (DTS_PLAYBACK_MODE
| DTS_LOAD_FILE_PLAY_FW
| DTS_SKIP_TX_CHK_CPB
) )
259 // | DTS_DFLT_RESOLUTION(vdecRESOLUTION_720p29_97) ) )
262 msg_Err( p_dec
, "Couldn't find and open the BCM CrystalHD device" );
267 #ifdef DEBUG_CRYSTALHD
268 BC_INFO_CRYSTAL info
;
269 if( BC_FUNC(DtsCrystalHDVersion
)( p_sys
->bcm_handle
, &info
) == BC_STS_SUCCESS
)
271 msg_Dbg( p_dec
, "Using CrystalHD Driver version: %i.%i.%i, "
272 "Library version: %i.%i.%i, Firmware version: %i.%i.%i",
273 info
.drvVersion
.drvRelease
, info
.drvVersion
.drvMajor
,
274 info
.drvVersion
.drvMinor
,
275 info
.dilVersion
.dilRelease
, info
.dilVersion
.dilMajor
,
276 info
.dilVersion
.dilMinor
,
277 info
.fwVersion
.fwRelease
, info
.fwVersion
.fwMajor
,
278 info
.fwVersion
.fwMinor
);
282 /* Special case for AVC1 */
283 if( i_bcm_codec_subtype
== BC_MSUBTYPE_AVC1
)
285 if( p_dec
->fmt_in
.i_extra
> 0 )
287 msg_Dbg( p_dec
, "Parsing extra infos for avc1" );
288 if( crystal_insert_sps_pps( p_dec
, (uint8_t*)p_dec
->fmt_in
.p_extra
,
289 p_dec
->fmt_in
.i_extra
) != VLC_SUCCESS
)
294 msg_Err( p_dec
, "Missing extra infos for avc1" );
299 /* Always use YUY2 color */
300 if( BC_FUNC(DtsSetColorSpace
)( p_sys
->bcm_handle
, OUTPUT_MODE422_YUY2
)
303 msg_Err( p_dec
, "Couldn't set the color space. Please report this!" );
307 /* Prepare Input for the device */
308 BC_INPUT_FORMAT p_in
;
309 memset( &p_in
, 0, sizeof(BC_INPUT_FORMAT
) );
310 p_in
.OptFlags
= 0x51; /* 0b 0 1 01 0001 */
311 p_in
.mSubtype
= i_bcm_codec_subtype
;
312 p_in
.startCodeSz
= p_sys
->i_nal_size
;
313 p_in
.pMetaData
= p_sys
->p_sps_pps_buf
;
314 p_in
.metaDataSz
= p_sys
->i_sps_pps_size
;
315 p_in
.width
= p_dec
->fmt_in
.video
.i_width
;
316 p_in
.height
= p_dec
->fmt_in
.video
.i_height
;
317 p_in
.Progressive
= true;
319 if( BC_FUNC(DtsSetInputFormat
)( p_sys
->bcm_handle
, &p_in
) != BC_STS_SUCCESS
)
321 msg_Err( p_dec
, "Couldn't set the color space. Please report this!" );
326 if( BC_FUNC(DtsOpenDecoder
)( p_sys
->bcm_handle
, BC_STREAM_TYPE_ES
)
329 msg_Err( p_dec
, "Couldn't open the CrystalHD decoder" );
334 if( BC_FUNC(DtsStartDecoder
)( p_sys
->bcm_handle
) != BC_STS_SUCCESS
)
336 msg_Err( p_dec
, "Couldn't start the decoder" );
340 if( BC_FUNC(DtsStartCapture
)( p_sys
->bcm_handle
) != BC_STS_SUCCESS
)
342 msg_Err( p_dec
, "Couldn't start the capture" );
346 /* Set output properties */
347 p_dec
->fmt_out
.i_cat
= VIDEO_ES
;
348 p_dec
->fmt_out
.i_codec
= VLC_CODEC_YUYV
;
349 p_dec
->fmt_out
.video
.i_width
= p_dec
->fmt_in
.video
.i_width
;
350 p_dec
->fmt_out
.video
.i_height
= p_dec
->fmt_in
.video
.i_height
;
353 p_dec
->pf_decode
= DecodeBlock
;
355 msg_Info( p_dec
, "Opened CrystalHD hardware with success" );
359 BC_FUNC_PSYS(DtsCloseDecoder
)( p_sys
->bcm_handle
);
361 BC_FUNC_PSYS(DtsDeviceClose
)( p_sys
->bcm_handle
);
366 /*****************************************************************************
367 * CloseDecoder: decoder destruction
368 *****************************************************************************/
369 static void CloseDecoder( vlc_object_t
*p_this
)
371 decoder_t
*p_dec
= (decoder_t
*)p_this
;
372 decoder_sys_t
*p_sys
= p_dec
->p_sys
;
374 if( BC_FUNC_PSYS(DtsFlushInput
)( p_sys
->bcm_handle
, 2 ) != BC_STS_SUCCESS
)
376 if( BC_FUNC_PSYS(DtsStopDecoder
)( p_sys
->bcm_handle
) != BC_STS_SUCCESS
)
378 if( BC_FUNC_PSYS(DtsCloseDecoder
)( p_sys
->bcm_handle
) != BC_STS_SUCCESS
)
380 if( BC_FUNC_PSYS(DtsDeviceClose
)( p_sys
->bcm_handle
) != BC_STS_SUCCESS
)
384 free( p_sys
->p_sps_pps_buf
);
385 #ifdef DEBUG_CRYSTALHD
386 msg_Dbg( p_dec
, "done cleaning up CrystalHD" );
391 static BC_STATUS
ourCallback(void *shnd
, uint32_t width
, uint32_t height
, uint32_t stride
, void *pOut
)
393 VLC_UNUSED(width
); VLC_UNUSED(height
); VLC_UNUSED(stride
);
395 decoder_t
*p_dec
= (decoder_t
*)shnd
;
396 BC_DTS_PROC_OUT
*proc_out
= p_dec
->p_sys
->proc_out
;
397 BC_DTS_PROC_OUT
*proc_in
= (BC_DTS_PROC_OUT
*)pOut
;
399 /* Direct Rendering */
400 /* Do not allocate for the second-field in the pair, in interlaced */
401 if( !(proc_in
->PicInfo
.flags
& VDEC_FLAG_INTERLACED_SRC
) ||
402 !(proc_in
->PicInfo
.flags
& VDEC_FLAG_FIELDPAIR
) )
404 if( !decoder_UpdateVideoFormat( p_dec
) )
405 p_dec
->p_sys
->p_pic
= decoder_NewPicture( p_dec
);
409 picture_t
*p_pic
= p_dec
->p_sys
->p_pic
;
414 p_pic
->b_progressive
= !(proc_in
->PicInfo
.flags
& VDEC_FLAG_INTERLACED_SRC
);
415 p_pic
->b_top_field_first
= !(proc_in
->PicInfo
.flags
& VDEC_FLAG_BOTTOM_FIRST
);
416 p_pic
->i_nb_fields
= p_pic
->b_progressive
? 1: 2;
418 /* Filling out the struct */
419 proc_out
->Ybuff
= !(proc_in
->PicInfo
.flags
& VDEC_FLAG_FIELDPAIR
) ?
420 &p_pic
->p
[0].p_pixels
[0] :
421 &p_pic
->p
[0].p_pixels
[p_pic
->p
[0].i_pitch
];
422 proc_out
->YbuffSz
= 2 * p_pic
->p
[0].i_pitch
;
423 proc_out
->StrideSz
= (proc_in
->PicInfo
.flags
& VDEC_FLAG_INTERLACED_SRC
)?
424 2 * (p_pic
->p
[0].i_pitch
/2) - p_dec
->fmt_out
.video
.i_width
:
425 p_pic
->p
[0].i_pitch
/2 - p_dec
->fmt_out
.video
.i_width
;
426 proc_out
->PoutFlags
|= BC_POUT_FLAGS_STRIDE
; /* Trust Stride info */
428 return BC_STS_SUCCESS
;
431 /****************************************************************************
432 * DecodeBlock: the whole thing
433 ****************************************************************************/
434 static int DecodeBlock( decoder_t
*p_dec
, block_t
*p_block
)
436 decoder_sys_t
*p_sys
= p_dec
->p_sys
;
438 BC_DTS_PROC_OUT proc_out
;
439 BC_DTS_STATUS driver_stat
;
441 /* First check the status of the decode to produce pictures */
442 if( BC_FUNC_PSYS(DtsGetDriverStatus
)( p_sys
->bcm_handle
, &driver_stat
) != BC_STS_SUCCESS
)
444 block_Release( p_block
);
445 return VLCDEC_SUCCESS
;
450 if( ( p_block
->i_flags
& (BLOCK_FLAG_CORRUPTED
) ) == 0 )
452 /* Valid input block, so we can send to HW to decode */
453 BC_STATUS status
= BC_FUNC_PSYS(DtsProcInput
)( p_sys
->bcm_handle
,
456 p_block
->i_pts
>= VLC_TS_INVALID
? TO_BC_PTS(p_block
->i_pts
) : 0, false );
458 block_Release( p_block
);
460 if( status
!= BC_STS_SUCCESS
)
461 return VLCDEC_SUCCESS
;
464 #ifdef DEBUG_CRYSTALHD
467 if( driver_stat
.ReadyListCount
!= 0 )
468 msg_Err( p_dec
, " Input NULL but have pictures %u", driver_stat
.ReadyListCount
);
472 if( driver_stat
.ReadyListCount
== 0 )
473 return VLCDEC_SUCCESS
;
475 /* Prepare the Output structure */
476 /* We always expect and use YUY2 */
477 memset( &proc_out
, 0, sizeof(BC_DTS_PROC_OUT
) );
478 proc_out
.PicInfo
.width
= p_dec
->fmt_out
.video
.i_width
;
479 proc_out
.PicInfo
.height
= p_dec
->fmt_out
.video
.i_height
;
480 proc_out
.PoutFlags
= BC_POUT_FLAGS_SIZE
;
481 proc_out
.AppCallBack
= ourCallback
;
482 proc_out
.hnd
= p_dec
;
483 p_sys
->proc_out
= &proc_out
;
486 BC_STATUS sts
= BC_FUNC_PSYS(DtsProcOutput
)( p_sys
->bcm_handle
, 128, &proc_out
);
487 #ifdef DEBUG_CRYSTALHD
488 if( sts
!= BC_STS_SUCCESS
)
489 msg_Err( p_dec
, "DtsProcOutput returned %i", sts
);
493 picture_t
*p_pic
= p_sys
->p_pic
;
497 if( !(proc_out
.PoutFlags
& BC_POUT_FLAGS_PIB_VALID
) )
499 msg_Dbg( p_dec
, "Invalid PIB" );
506 /* In interlaced mode, do not push the first field in the pipeline */
507 if( (proc_out
.PicInfo
.flags
& VDEC_FLAG_INTERLACED_SRC
) &&
508 !(proc_out
.PicInfo
.flags
& VDEC_FLAG_FIELDPAIR
) )
509 return VLCDEC_SUCCESS
;
511 // crystal_CopyPicture( p_pic, &proc_out );
512 p_pic
->date
= proc_out
.PicInfo
.timeStamp
> 0 ?
513 FROM_BC_PTS(proc_out
.PicInfo
.timeStamp
) : VLC_TS_INVALID
;
514 //p_pic->date += 100 * 1000;
515 #ifdef DEBUG_CRYSTALHD
516 msg_Dbg( p_dec
, "TS Output is %"PRIu64
, p_pic
->date
);
518 decoder_QueueVideo( p_dec
, p_pic
);
519 return VLCDEC_SUCCESS
;
521 case BC_STS_DEC_NOT_OPEN
:
522 case BC_STS_DEC_NOT_STARTED
:
523 msg_Err( p_dec
, "Decoder not opened or started" );
527 msg_Warn( p_dec
, "Invalid arguments. Please report" );
530 case BC_STS_FMT_CHANGE
: /* Format change */
531 /* if( !(proc_out.PoutFlags & BC_POUT_FLAGS_PIB_VALID) )
533 p_dec
->fmt_out
.video
.i_width
= proc_out
.PicInfo
.width
;
534 p_dec
->fmt_out
.video
.i_height
= proc_out
.PicInfo
.height
;
535 if( proc_out
.PicInfo
.height
== 1088 )
536 p_dec
->fmt_out
.video
.i_height
= 1080;
537 #define setAR( a, b, c ) case a: p_dec->fmt_out.video.i_sar_num = b; \
538 p_dec->fmt_out.video.i_sar_den = c; break;
539 switch( proc_out
.PicInfo
.aspect_ratio
)
541 setAR( vdecAspectRatioSquare
, 1, 1 )
542 setAR( vdecAspectRatio12_11
, 12, 11 )
543 setAR( vdecAspectRatio10_11
, 10, 11 )
544 setAR( vdecAspectRatio16_11
, 16, 11 )
545 setAR( vdecAspectRatio40_33
, 40, 33 )
546 setAR( vdecAspectRatio24_11
, 24, 11 )
547 setAR( vdecAspectRatio20_11
, 20, 11 )
548 setAR( vdecAspectRatio32_11
, 32, 11 )
549 setAR( vdecAspectRatio80_33
, 80, 33 )
550 setAR( vdecAspectRatio18_11
, 18, 11 )
551 setAR( vdecAspectRatio15_11
, 15, 11 )
552 setAR( vdecAspectRatio64_33
, 64, 33 )
553 setAR( vdecAspectRatio160_99
, 160, 99 )
554 setAR( vdecAspectRatio4_3
, 4, 3 )
555 setAR( vdecAspectRatio16_9
, 16, 9 )
556 setAR( vdecAspectRatio221_1
, 221, 1 )
560 msg_Dbg( p_dec
, "Format Change Detected [%i, %i], AR: %i/%i",
561 proc_out
.PicInfo
.width
, proc_out
.PicInfo
.height
,
562 p_dec
->fmt_out
.video
.i_sar_num
,
563 p_dec
->fmt_out
.video
.i_sar_den
);
566 /* Nothing is documented here... */
568 if( BC_FUNC_PSYS(DtsIsEndOfStream
)( p_sys
->bcm_handle
, &b_eos
)
571 msg_Dbg( p_dec
, "End of Stream" );
573 case BC_STS_TIMEOUT
: /* Timeout */
574 msg_Err( p_dec
, "ProcOutput timeout" );
576 case BC_STS_IO_XFR_ERROR
:
577 case BC_STS_IO_USER_ABORT
:
578 case BC_STS_IO_ERROR
:
579 msg_Err( p_dec
, "ProcOutput return mode not implemented. Please report" );
582 msg_Err( p_dec
, "Unknown return status. Please report %i", sts
);
586 picture_Release( p_pic
);
587 return VLCDEC_SUCCESS
;
592 * FIXME: this should not exist */
593 static void crystal_CopyPicture ( picture_t
*p_pic
, BC_DTS_PROC_OUT
* p_out
)
596 uint8_t *p_dst
, *p_dst_end
;
597 uint8_t *p_src
= p_out
->Ybuff
;
599 p_dst
= p_pic
->p
[0].p_pixels
;
600 i_dst_stride
= p_pic
->p
[0].i_pitch
;
601 p_dst_end
= p_dst
+ (i_dst_stride
* p_out
->PicInfo
.height
);
603 for( ; p_dst
< p_dst_end
; p_dst
+= i_dst_stride
, p_src
+= (p_out
->PicInfo
.width
* 2))
604 memcpy( p_dst
, p_src
, p_out
->PicInfo
.width
* 2); // Copy in bytes
608 /* Parse the SPS/PPS Metadata to feed the decoder for avc1 */
609 static int crystal_insert_sps_pps( decoder_t
*p_dec
,
613 decoder_sys_t
*p_sys
= p_dec
->p_sys
;
615 p_sys
->i_sps_pps_size
= 0;
616 p_sys
->p_sps_pps_buf
= h264_avcC_to_AnnexB_NAL( p_buf
, i_buf_size
,
617 &p_sys
->i_sps_pps_size
, &p_sys
->i_nal_size
);
619 return (p_sys
->p_sps_pps_buf
) ? VLC_SUCCESS
: VLC_EGENERIC
;