| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
#ifdef HAVE_CONFIG_H |
|---|
| 30 |
# include "config.h" |
|---|
| 31 |
#endif |
|---|
| 32 |
|
|---|
| 33 |
#include <vlc_common.h> |
|---|
| 34 |
#include <vlc_plugin.h> |
|---|
| 35 |
#include <vlc_demux.h> |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
#define HURRYUP_TEXT N_( "Hurry up" ) |
|---|
| 41 |
#define HURRYUP_LONGTEXT N_( "The demuxer will advance timestamps if the " \ |
|---|
| 42 |
"input can't keep up with the rate." ) |
|---|
| 43 |
|
|---|
| 44 |
static int Open ( vlc_object_t * ); |
|---|
| 45 |
static void Close( vlc_object_t * ); |
|---|
| 46 |
|
|---|
| 47 |
vlc_module_begin(); |
|---|
| 48 |
set_shortname( "DV" ); |
|---|
| 49 |
set_description( N_("DV (Digital Video) demuxer") ); |
|---|
| 50 |
set_capability( "demux", 3 ); |
|---|
| 51 |
set_category( CAT_INPUT ); |
|---|
| 52 |
set_subcategory( SUBCAT_INPUT_DEMUX ); |
|---|
| 53 |
add_bool( "rawdv-hurry-up", 0, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT, false ); |
|---|
| 54 |
set_callbacks( Open, Close ); |
|---|
| 55 |
add_shortcut( "rawdv" ); |
|---|
| 56 |
vlc_module_end(); |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
#define DV_PAL_FRAME_SIZE 144000 |
|---|
| 78 |
#define DV_NTSC_FRAME_SIZE 122000 |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
typedef struct { |
|---|
| 84 |
int8_t sct; |
|---|
| 85 |
int8_t dsn; |
|---|
| 86 |
int fsc; |
|---|
| 87 |
int8_t dbn; |
|---|
| 88 |
} dv_id_t; |
|---|
| 89 |
|
|---|
| 90 |
typedef struct { |
|---|
| 91 |
int dsf; |
|---|
| 92 |
int8_t apt; |
|---|
| 93 |
int tf1; |
|---|
| 94 |
int8_t ap1; |
|---|
| 95 |
int tf2; |
|---|
| 96 |
int8_t ap2; |
|---|
| 97 |
int tf3; |
|---|
| 98 |
int8_t ap3; |
|---|
| 99 |
} dv_header_t; |
|---|
| 100 |
|
|---|
| 101 |
struct demux_sys_t |
|---|
| 102 |
{ |
|---|
| 103 |
int frame_size; |
|---|
| 104 |
|
|---|
| 105 |
es_out_id_t *p_es_video; |
|---|
| 106 |
es_format_t fmt_video; |
|---|
| 107 |
|
|---|
| 108 |
es_out_id_t *p_es_audio; |
|---|
| 109 |
es_format_t fmt_audio; |
|---|
| 110 |
|
|---|
| 111 |
int i_dsf; |
|---|
| 112 |
double f_rate; |
|---|
| 113 |
int i_bitrate; |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
mtime_t i_pcr; |
|---|
| 117 |
bool b_hurry_up; |
|---|
| 118 |
}; |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
static int Demux( demux_t * ); |
|---|
| 124 |
static int Control( demux_t *, int i_query, va_list args ); |
|---|
| 125 |
|
|---|
| 126 |
static block_t *dv_extract_audio( demux_t *p_demux, |
|---|
| 127 |
block_t* p_frame_block ); |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
static int Open( vlc_object_t * p_this ) |
|---|
| 133 |
{ |
|---|
| 134 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 135 |
demux_sys_t *p_sys; |
|---|
| 136 |
|
|---|
| 137 |
const uint8_t *p_peek, *p_peek_backup; |
|---|
| 138 |
|
|---|
| 139 |
uint32_t i_dword; |
|---|
| 140 |
dv_header_t dv_header; |
|---|
| 141 |
dv_id_t dv_id; |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
if( !demux_IsPathExtension( p_demux, ".dv" ) && !p_demux->b_force ) |
|---|
| 150 |
return VLC_EGENERIC; |
|---|
| 151 |
|
|---|
| 152 |
if( stream_Peek( p_demux->s, &p_peek, DV_PAL_FRAME_SIZE ) < |
|---|
| 153 |
DV_NTSC_FRAME_SIZE ) |
|---|
| 154 |
{ |
|---|
| 155 |
|
|---|
| 156 |
msg_Err( p_demux, "cannot peek()" ); |
|---|
| 157 |
return VLC_EGENERIC; |
|---|
| 158 |
} |
|---|
| 159 |
p_peek_backup = p_peek; |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
i_dword = GetDWBE( p_peek ); p_peek += 4; |
|---|
| 163 |
dv_id.sct = i_dword >> (32 - 3); |
|---|
| 164 |
i_dword <<= 8; |
|---|
| 165 |
dv_id.dsn = i_dword >> (32 - 4); |
|---|
| 166 |
i_dword <<= 4; |
|---|
| 167 |
dv_id.fsc = i_dword >> (32 - 1); |
|---|
| 168 |
i_dword <<= 4; |
|---|
| 169 |
dv_id.dbn = i_dword >> (32 - 8); |
|---|
| 170 |
i_dword <<= 8; |
|---|
| 171 |
|
|---|
| 172 |
if( dv_id.sct != 0 ) |
|---|
| 173 |
{ |
|---|
| 174 |
msg_Warn( p_demux, "not a raw DV stream header" ); |
|---|
| 175 |
return VLC_EGENERIC; |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
dv_header.dsf = i_dword >> (32 - 1); |
|---|
| 180 |
i_dword <<= 1; |
|---|
| 181 |
if( i_dword >> (32 - 1) ) |
|---|
| 182 |
{ |
|---|
| 183 |
msg_Warn( p_demux, "incorrect bit" ); |
|---|
| 184 |
return VLC_EGENERIC; |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
i_dword = GetDWBE( p_peek ); p_peek += 4; |
|---|
| 188 |
i_dword <<= 5; |
|---|
| 189 |
dv_header.apt = i_dword >> (32 - 3); |
|---|
| 190 |
i_dword <<= 3; |
|---|
| 191 |
dv_header.tf1 = i_dword >> (32 - 1); |
|---|
| 192 |
i_dword <<= 5; |
|---|
| 193 |
dv_header.ap1 = i_dword >> (32 - 3); |
|---|
| 194 |
i_dword <<= 3; |
|---|
| 195 |
dv_header.tf2 = i_dword >> (32 - 1); |
|---|
| 196 |
i_dword <<= 5; |
|---|
| 197 |
dv_header.ap2 = i_dword >> (32 - 3); |
|---|
| 198 |
i_dword <<= 3; |
|---|
| 199 |
dv_header.tf3 = i_dword >> (32 - 1); |
|---|
| 200 |
i_dword <<= 5; |
|---|
| 201 |
dv_header.ap3 = i_dword >> (32 - 3); |
|---|
| 202 |
|
|---|
| 203 |
p_peek += 72; |
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
p_demux->pf_demux = Demux; |
|---|
| 207 |
p_demux->pf_control = Control; |
|---|
| 208 |
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); |
|---|
| 209 |
if( !p_sys ) |
|---|
| 210 |
return VLC_ENOMEM; |
|---|
| 211 |
|
|---|
| 212 |
p_sys->b_hurry_up = var_CreateGetBool( p_demux, "rawdv-hurry-up" ); |
|---|
| 213 |
msg_Dbg( p_demux, "Realtime DV Source: %s", (p_sys->b_hurry_up)?"Yes":"No" ); |
|---|
| 214 |
|
|---|
| 215 |
p_sys->i_dsf = dv_header.dsf; |
|---|
| 216 |
p_sys->frame_size = dv_header.dsf ? 12 * 150 * 80 : 10 * 150 * 80; |
|---|
| 217 |
p_sys->f_rate = dv_header.dsf ? 25 : 29.97; |
|---|
| 218 |
|
|---|
| 219 |
p_sys->i_pcr = 1; |
|---|
| 220 |
p_sys->p_es_video = NULL; |
|---|
| 221 |
p_sys->p_es_audio = NULL; |
|---|
| 222 |
|
|---|
| 223 |
p_sys->i_bitrate = 0; |
|---|
| 224 |
|
|---|
| 225 |
es_format_Init( &p_sys->fmt_video, VIDEO_ES, VLC_FOURCC('d','v','s','d') ); |
|---|
| 226 |
p_sys->fmt_video.video.i_width = 720; |
|---|
| 227 |
p_sys->fmt_video.video.i_height= dv_header.dsf ? 576 : 480;; |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
#if 0 |
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
p_input->i_bufsize = p_sys->frame_size; |
|---|
| 234 |
#endif |
|---|
| 235 |
|
|---|
| 236 |
p_sys->p_es_video = es_out_Add( p_demux->out, &p_sys->fmt_video ); |
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
p_peek = p_peek_backup + 80*6+80*16*3 + 3; |
|---|
| 240 |
if( *p_peek == 0x50 ) |
|---|
| 241 |
{ |
|---|
| 242 |
es_format_Init( &p_sys->fmt_audio, AUDIO_ES, |
|---|
| 243 |
VLC_FOURCC('a','r','a','w') ); |
|---|
| 244 |
|
|---|
| 245 |
p_sys->fmt_audio.audio.i_channels = 2; |
|---|
| 246 |
switch( (p_peek[4] >> 3) & 0x07 ) |
|---|
| 247 |
{ |
|---|
| 248 |
case 0: |
|---|
| 249 |
p_sys->fmt_audio.audio.i_rate = 48000; |
|---|
| 250 |
break; |
|---|
| 251 |
case 1: |
|---|
| 252 |
p_sys->fmt_audio.audio.i_rate = 44100; |
|---|
| 253 |
break; |
|---|
| 254 |
case 2: |
|---|
| 255 |
default: |
|---|
| 256 |
p_sys->fmt_audio.audio.i_rate = 32000; |
|---|
| 257 |
break; |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
p_sys->fmt_audio.audio.i_bitspersample = 16; |
|---|
| 262 |
|
|---|
| 263 |
p_sys->p_es_audio = es_out_Add( p_demux->out, &p_sys->fmt_audio ); |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
return VLC_SUCCESS; |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
static void Close( vlc_object_t *p_this ) |
|---|
| 273 |
{ |
|---|
| 274 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 275 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 276 |
|
|---|
| 277 |
var_Destroy( p_demux, "rawdv-hurry-up"); |
|---|
| 278 |
free( p_sys ); |
|---|
| 279 |
} |
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
static int Demux( demux_t *p_demux ) |
|---|
| 287 |
{ |
|---|
| 288 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 289 |
block_t *p_block; |
|---|
| 290 |
bool b_audio = false; |
|---|
| 291 |
|
|---|
| 292 |
if( p_sys->b_hurry_up ) |
|---|
| 293 |
{ |
|---|
| 294 |
|
|---|
| 295 |
p_sys->i_pcr = mdate() + (p_sys->i_dsf ? 120000 : 90000); |
|---|
| 296 |
} |
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr ); |
|---|
| 300 |
p_block = stream_Block( p_demux->s, p_sys->frame_size ); |
|---|
| 301 |
if( p_block == NULL ) |
|---|
| 302 |
{ |
|---|
| 303 |
|
|---|
| 304 |
return 0; |
|---|
| 305 |
} |
|---|
| 306 |
|
|---|
| 307 |
if( p_sys->p_es_audio ) |
|---|
| 308 |
{ |
|---|
| 309 |
es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, |
|---|
| 310 |
p_sys->p_es_audio, &b_audio ); |
|---|
| 311 |
} |
|---|
| 312 |
|
|---|
| 313 |
p_block->i_dts = |
|---|
| 314 |
p_block->i_pts = p_sys->i_pcr; |
|---|
| 315 |
|
|---|
| 316 |
if( b_audio ) |
|---|
| 317 |
{ |
|---|
| 318 |
block_t *p_audio_block = dv_extract_audio( p_demux, p_block ); |
|---|
| 319 |
if( p_audio_block ) |
|---|
| 320 |
{ |
|---|
| 321 |
p_audio_block->i_pts = |
|---|
| 322 |
p_audio_block->i_dts = p_sys->i_pcr; |
|---|
| 323 |
es_out_Send( p_demux->out, p_sys->p_es_audio, p_audio_block ); |
|---|
| 324 |
} |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
es_out_Send( p_demux->out, p_sys->p_es_video, p_block ); |
|---|
| 328 |
|
|---|
| 329 |
if( !p_sys->b_hurry_up ) |
|---|
| 330 |
{ |
|---|
| 331 |
p_sys->i_pcr += ( INT64_C(1000000) / p_sys->f_rate ); |
|---|
| 332 |
} |
|---|
| 333 |
|
|---|
| 334 |
return 1; |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
static int Control( demux_t *p_demux, int i_query, va_list args ) |
|---|
| 341 |
{ |
|---|
| 342 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
return demux_vaControlHelper( p_demux->s, |
|---|
| 346 |
0, -1, |
|---|
| 347 |
p_sys->frame_size * p_sys->f_rate * 8, |
|---|
| 348 |
p_sys->frame_size, i_query, args ); |
|---|
| 349 |
} |
|---|
| 350 |
|
|---|
| 351 |
static const uint16_t dv_audio_shuffle525[10][9] = { |
|---|
| 352 |
{ 0, 30, 60, 20, 50, 80, 10, 40, 70 }, |
|---|
| 353 |
{ 6, 36, 66, 26, 56, 86, 16, 46, 76 }, |
|---|
| 354 |
{ 12, 42, 72, 2, 32, 62, 22, 52, 82 }, |
|---|
| 355 |
{ 18, 48, 78, 8, 38, 68, 28, 58, 88 }, |
|---|
| 356 |
{ 24, 54, 84, 14, 44, 74, 4, 34, 64 }, |
|---|
| 357 |
|
|---|
| 358 |
{ 1, 31, 61, 21, 51, 81, 11, 41, 71 }, |
|---|
| 359 |
{ 7, 37, 67, 27, 57, 87, 17, 47, 77 }, |
|---|
| 360 |
{ 13, 43, 73, 3, 33, 63, 23, 53, 83 }, |
|---|
| 361 |
{ 19, 49, 79, 9, 39, 69, 29, 59, 89 }, |
|---|
| 362 |
{ 25, 55, 85, 15, 45, 75, 5, 35, 65 }, |
|---|
| 363 |
}; |
|---|
| 364 |
|
|---|
| 365 |
static const uint16_t dv_audio_shuffle625[12][9] = { |
|---|
| 366 |
{ 0, 36, 72, 26, 62, 98, 16, 52, 88}, |
|---|
| 367 |
{ 6, 42, 78, 32, 68, 104, 22, 58, 94}, |
|---|
| 368 |
{ 12, 48, 84, 2, 38, 74, 28, 64, 100}, |
|---|
| 369 |
{ 18, 54, 90, 8, 44, 80, 34, 70, 106}, |
|---|
| 370 |
{ 24, 60, 96, 14, 50, 86, 4, 40, 76}, |
|---|
| 371 |
{ 30, 66, 102, 20, 56, 92, 10, 46, 82}, |
|---|
| 372 |
|
|---|
| 373 |
{ 1, 37, 73, 27, 63, 99, 17, 53, 89}, |
|---|
| 374 |
{ 7, 43, 79, 33, 69, 105, 23, 59, 95}, |
|---|
| 375 |
{ 13, 49, 85, 3, 39, 75, 29, 65, 101}, |
|---|
| 376 |
{ 19, 55, 91, 9, 45, 81, 35, 71, 107}, |
|---|
| 377 |
{ 25, 61, 97, 15, 51, 87, 5, 41, 77}, |
|---|
| 378 |
{ 31, 67, 103, 21, 57, 93, 11, 47, 83}, |
|---|
| 379 |
}; |
|---|
| 380 |
|
|---|
| 381 |
static inline uint16_t dv_audio_12to16( uint16_t sample ) |
|---|
| 382 |
{ |
|---|
| 383 |
uint16_t shift, result; |
|---|
| 384 |
|
|---|
| 385 |
sample = (sample < 0x800) ? sample : sample | 0xf000; |
|---|
| 386 |
shift = (sample & 0xf00) >> 8; |
|---|
| 387 |
|
|---|
| 388 |
if (shift < 0x2 || shift > 0xd) { |
|---|
| 389 |
result = sample; |
|---|
| 390 |
} else if (shift < 0x8) { |
|---|
| 391 |
shift--; |
|---|
| 392 |
result = (sample - (256 * shift)) << shift; |
|---|
| 393 |
} else { |
|---|
| 394 |
shift = 0xe - shift; |
|---|
| 395 |
result = ((sample + ((256 * shift) + 1)) << shift) - 1; |
|---|
| 396 |
} |
|---|
| 397 |
|
|---|
| 398 |
return result; |
|---|
| 399 |
} |
|---|
| 400 |
|
|---|
| 401 |
static block_t *dv_extract_audio( demux_t *p_demux, |
|---|
| 402 |
block_t* p_frame_block ) |
|---|
| 403 |
{ |
|---|
| 404 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 405 |
block_t *p_block; |
|---|
| 406 |
uint8_t *p_frame, *p_buf; |
|---|
| 407 |
int i_audio_quant, i_samples, i_size, i_half_ch; |
|---|
| 408 |
const uint16_t (*audio_shuffle)[9]; |
|---|
| 409 |
int i, j, d, of; |
|---|
| 410 |
uint16_t lc; |
|---|
| 411 |
|
|---|
| 412 |
|
|---|
| 413 |
p_buf = p_frame_block->p_buffer + 80*6+80*16*3 + 3; |
|---|
| 414 |
if( *p_buf != 0x50 ) return NULL; |
|---|
| 415 |
|
|---|
| 416 |
i_audio_quant = p_buf[4] & 0x07; |
|---|
| 417 |
if( i_audio_quant > 1 ) |
|---|
| 418 |
{ |
|---|
| 419 |
msg_Dbg( p_demux, "unsupported quantization for DV audio"); |
|---|
| 420 |
return NULL; |
|---|
| 421 |
} |
|---|
| 422 |
|
|---|
| 423 |
i_samples = p_buf[1] & 0x3f; |
|---|
| 424 |
switch( (p_buf[4] >> 3) & 0x07 ) |
|---|
| 425 |
{ |
|---|
| 426 |
case 0: |
|---|
| 427 |
i_size = p_sys->i_dsf ? 1896 : 1580; |
|---|
| 428 |
break; |
|---|
| 429 |
case 1: |
|---|
| 430 |
i_size = p_sys->i_dsf ? 1742 : 1452; |
|---|
| 431 |
break; |
|---|
| 432 |
case 2: |
|---|
| 433 |
default: |
|---|
| 434 |
i_size = p_sys->i_dsf ? 1264 : 1053; |
|---|
| 435 |
break; |
|---|
| 436 |
} |
|---|
| 437 |
i_size = (i_size + i_samples) * 4; |
|---|
| 438 |
|
|---|
| 439 |
p_block = block_New( p_demux, i_size ); |
|---|
| 440 |
|
|---|
| 441 |
|
|---|
| 442 |
p_frame = p_frame_block->p_buffer; |
|---|
| 443 |
audio_shuffle = p_sys->i_dsf ? dv_audio_shuffle625 : dv_audio_shuffle525; |
|---|
| 444 |
i_half_ch = (p_sys->i_dsf ? 12 : 10)/2; |
|---|
| 445 |
for( i = 0; i < (p_sys->i_dsf ? 12 : 10); i++ ) |
|---|
| 446 |
{ |
|---|
| 447 |
p_frame += 6 * 80; |
|---|
| 448 |
|
|---|
| 449 |
if( i_audio_quant == 1 && i == i_half_ch ) break; |
|---|
| 450 |
|
|---|
| 451 |
for( j = 0; j < 9; j++ ) |
|---|
| 452 |
{ |
|---|
| 453 |
for( d = 8; d < 80; d += 2 ) |
|---|
| 454 |
{ |
|---|
| 455 |
if( i_audio_quant == 0 ) |
|---|
| 456 |
{ |
|---|
| 457 |
|
|---|
| 458 |
of = audio_shuffle[i][j] + (d - 8) / 2 * |
|---|
| 459 |
(p_sys->i_dsf ? 108 : 90); |
|---|
| 460 |
|
|---|
| 461 |
if( of * 2 >= i_size ) continue; |
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 |
p_block->p_buffer[of*2] = p_frame[d+1]; |
|---|
| 465 |
p_block->p_buffer[of*2+1] = p_frame[d]; |
|---|
| 466 |
|
|---|
| 467 |
if( p_block->p_buffer[of*2+1] == 0x80 && |
|---|
| 468 |
p_block->p_buffer[of*2] == 0x00 ) |
|---|
| 469 |
p_block->p_buffer[of*2+1] = 0; |
|---|
| 470 |
} |
|---|
| 471 |
else |
|---|
| 472 |
{ |
|---|
| 473 |
|
|---|
| 474 |
lc = ((uint16_t)p_frame[d] << 4) | |
|---|
| 475 |
((uint16_t)p_frame[d+2] >> 4); |
|---|
| 476 |
lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); |
|---|
| 477 |
|
|---|
| 478 |
of = audio_shuffle[i][j] + (d - 8) / 3 * |
|---|
| 479 |
(p_sys->i_dsf ? 108 : 90); |
|---|
| 480 |
if( of*2 >= i_size ) continue; |
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 |
p_block->p_buffer[of*2] = lc & 0xff; |
|---|
| 484 |
p_block->p_buffer[of*2+1] = lc >> 8; |
|---|
| 485 |
++d; |
|---|
| 486 |
} |
|---|
| 487 |
} |
|---|
| 488 |
|
|---|
| 489 |
p_frame += 16 * 80; |
|---|
| 490 |
} |
|---|
| 491 |
} |
|---|
| 492 |
|
|---|
| 493 |
return p_block; |
|---|
| 494 |
} |
|---|