📄 real.c
字号:
((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset; memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy ); } p += i_copy; if( (h&0xc0) != 0x80 ) { break; }#if 0 if( tk->p_frame ) { /* append data */ int i_ck = ((uint32_t*)tk->p_frame->p_buffer)[1]++; if( (h&0xc0) == 0x80 ) { /* last fragment */ i_copy = i_offset; i_offset = i_len - i_offset; ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset; memcpy( &tk->p_frame->p_buffer[i_offset+ 8], p, i_copy ); p += i_copy; if( p_sys->i_pcr < tk->p_frame->i_dts ) { p_sys->i_pcr = tk->p_frame->i_dts; es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_pcr ); } es_out_Send( p_demux->out, tk->p_es, tk->p_frame ); tk->i_frame = 0; tk->p_frame = NULL; continue; } ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[i_ck] = i_offset; memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy ); break; } if( (h&0xc0) != 0x00 ) { block_t *p_frame; /* not fragmented */ if( !( p_frame = block_New( p_demux, i_copy + 8 + 8 ) ) ) { return -1; } p_frame->i_dts = i_pts; p_frame->i_pts = i_pts; ((uint32_t*)p_frame->p_buffer)[0] = i_copy; ((uint32_t*)p_frame->p_buffer)[1] = 1; ((uint32_t*)(p_frame->p_buffer+i_copy+8))[0] = 0; memcpy( &p_frame->p_buffer[8], p, i_copy ); p += i_copy; if( p_sys->i_pcr < p_frame->i_dts ) { p_sys->i_pcr = p_frame->i_dts; es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_pcr ); } es_out_Send( p_demux->out, tk->p_es, p_frame ); } else { /* First fragment */ tk->i_frame = i_len; if( !( tk->p_frame = block_New( p_demux, i_len + 8 + 1000) ) ) { return -1; } memset( &tk->p_frame->p_buffer[8], 0, i_len ); tk->p_frame->i_dts = i_pts; tk->p_frame->i_pts = i_pts; ((uint32_t*)tk->p_frame->p_buffer)[0] = i_len; /* len */ ((uint32_t*)tk->p_frame->p_buffer)[1] = 1; /* chunk counts */ ((uint32_t*)(tk->p_frame->p_buffer+i_len+8))[0] = i_offset; memcpy( &tk->p_frame->p_buffer[i_offset + 8], p, i_copy ); break; }#endif } } else if( tk->fmt.i_cat == AUDIO_ES && b_selected ) { /* Set PCR */ if( p_sys->i_pcr < i_pts ) { p_sys->i_pcr = i_pts; es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_pcr ); } if( tk->fmt.i_codec == VLC_FOURCC( 'm', 'p', '4', 'a' ) ) { int i_sub = (p_sys->buffer[1] >> 4)&0x0f; uint8_t *p_sub = &p_sys->buffer[2+2*i_sub]; int i; for( i = 0; i < i_sub; i++ ) { int i_sub_size = GetWBE( &p_sys->buffer[2+i*2]); block_t *p_block = block_New( p_demux, i_sub_size ); if( p_block ) { memcpy( p_block->p_buffer, p_sub, i_sub_size ); p_sub += i_sub_size; p_block->i_dts = p_block->i_pts = ( i == 0 ? i_pts : 0 ); es_out_Send( p_demux->out, tk->p_es, p_block ); } } } else if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) || tk->fmt.i_codec == VLC_FOURCC('2','8','_','8') ) { uint8_t *p_buf = p_sys->buffer; int y = tk->i_subpacket / (tk->i_frame_size /tk->i_subpacket_size); int i_index, i; /* Sanity check */ if( i_flags & 2 ) y = tk->i_subpacket = 0; if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) ) for( i = 0; i < tk->i_frame_size / tk->i_subpacket_size; i++ ) { block_t *p_block = block_New( p_demux, tk->i_subpacket_size ); memcpy( p_block->p_buffer, p_buf, tk->i_subpacket_size ); p_buf += tk->i_subpacket_size; i_index = tk->i_subpacket_h * i + ((tk->i_subpacket_h + 1) / 2) * (y&1) + (y>>1); p_block->i_dts = p_block->i_pts = i_pts; tk->p_subpackets[i_index] = p_block; tk->i_subpacket++; } if( tk->fmt.i_codec == VLC_FOURCC('2','8','_','8') ) for( i = 0; i < tk->i_subpacket_h / 2; i++ ) { block_t *p_block = block_New( p_demux, tk->i_coded_frame_size); memcpy( p_block->p_buffer, p_buf, tk->i_coded_frame_size ); p_buf += tk->i_coded_frame_size; i_index = (i * 2 * tk->i_frame_size) / tk->i_coded_frame_size + y; p_block->i_dts = p_block->i_pts = i_pts; tk->p_subpackets[i_index] = p_block; tk->i_subpacket++; } while( tk->i_out_subpacket != tk->i_subpackets && tk->p_subpackets[tk->i_out_subpacket] ) { block_t *p_block = tk->p_subpackets[tk->i_out_subpacket]; tk->p_subpackets[tk->i_out_subpacket] = 0; if( tk->i_out_subpacket ) p_block->i_dts = p_block->i_pts = 0; es_out_Send( p_demux->out, tk->p_es, p_block ); tk->i_out_subpacket++; } if( tk->i_subpacket == tk->i_subpackets && tk->i_out_subpacket != tk->i_subpackets ) { msg_Warn( p_demux, "i_subpacket != i_out_subpacket, " "this shouldn't happen" ); } if( tk->i_subpacket == tk->i_subpackets ) { tk->i_subpacket = 0; tk->i_out_subpacket = 0; } } else { block_t *p_block = block_New( p_demux, i_size ); if( tk->fmt.i_codec == VLC_FOURCC( 'a', '5', '2', ' ' ) ) { uint8_t *src = p_sys->buffer; uint8_t *dst = p_block->p_buffer; /* byte swap data */ while( dst < &p_block->p_buffer[i_size- 1]) { *dst++ = src[1]; *dst++ = src[0]; src += 2; } } else { memcpy( p_block->p_buffer, p_sys->buffer, i_size ); } p_block->i_dts = p_block->i_pts = i_pts; es_out_Send( p_demux->out, tk->p_es, p_block ); } } return 1;}/***************************************************************************** * Control: *****************************************************************************/static int Control( demux_t *p_demux, int i_query, va_list args ){ demux_sys_t *p_sys = p_demux->p_sys;#if 0 double f, *pf; int64_t i64;#endif int64_t *pi64; switch( i_query ) {#if 0 case DEMUX_GET_POSITION: pf = (double*) va_arg( args, double* ); i64 = stream_Size( p_demux->s ); if( i64 > 0 ) { *pf = (double)stream_Tell( p_demux->s ) / (double)i64; } else { *pf = 0.0; } return VLC_SUCCESS; case DEMUX_SET_POSITION: f = (double) va_arg( args, double ); i64 = stream_Size( p_demux->s ); es_out_Control( p_demux->out, ES_OUT_RESET_PCR ); return stream_Seek( p_demux->s, (int64_t)(i64 * f) ); case DEMUX_GET_TIME: pi64 = (int64_t*)va_arg( args, int64_t * ); if( p_sys->i_mux_rate > 0 ) { *pi64 = (int64_t)1000000 * ( stream_Tell( p_demux->s ) / 50 ) / p_sys->i_mux_rate; return VLC_SUCCESS; } *pi64 = 0; return VLC_EGENERIC;#endif case DEMUX_GET_LENGTH: pi64 = (int64_t*)va_arg( args, int64_t * ); /* the commented following lines are fen's implementation, which doesn't seem to * work for one reason or another -- FK */ /*if( p_sys->i_mux_rate > 0 ) { *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate; return VLC_SUCCESS; }*/ if( p_sys->i_our_duration > 0 ) { /* our stored duration is in ms, so... */ *pi64 = (int64_t)1000 * p_sys->i_our_duration; return VLC_SUCCESS; } *pi64 = 0; return VLC_EGENERIC; case DEMUX_GET_META: { vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** ); *pp_meta = p_sys->p_meta; return VLC_SUCCESS; } case DEMUX_SET_TIME: case DEMUX_GET_FPS: default: return VLC_EGENERIC; } return VLC_EGENERIC;}/***************************************************************************** * HeaderRead: *****************************************************************************/static int HeaderRead( demux_t *p_demux ){ demux_sys_t *p_sys = p_demux->p_sys; uint8_t header[100]; /* FIXME */ uint32_t i_id; uint32_t i_size; int64_t i_skip; int i_version; p_sys->p_meta = vlc_meta_New(); for( ;; ) { /* Read the header */ if( stream_Read( p_demux->s, header, 10 ) < 10 ) { return VLC_EGENERIC; } i_id = VLC_FOURCC( header[0], header[1], header[2], header[3] ); i_size = GetDWBE( &header[4] ); i_version = GetWBE( &header[8] ); msg_Dbg( p_demux, "object %4.4s size=%d version=%d", (char*)&i_id, i_size, i_version ); if( (i_size < 10) && (i_id != VLC_FOURCC('D','A','T','A')) ) { msg_Dbg( p_demux, "invalid size for object %4.4s", (char*)&i_id ); return VLC_EGENERIC; } i_skip = i_size - 10; if( i_id == VLC_FOURCC('.','R','M','F') ) { if( stream_Read( p_demux->s, header, 8 ) < 8 ) return VLC_EGENERIC; msg_Dbg( p_demux, " - file version=0x%x num headers=%d", GetDWBE( &header[0] ), GetDWBE( &header[4] ) ); i_skip -= 8; } else if( i_id == VLC_FOURCC('P','R','O','P') ) { int i_flags; if( stream_Read(p_demux->s, header, 40) < 40 ) return VLC_EGENERIC; msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d", GetDWBE(&header[0]), GetDWBE(&header[4]) ); msg_Dbg( p_demux, " - max packet size=%d avg bitrate=%d", GetDWBE(&header[8]), GetDWBE(&header[12]) ); msg_Dbg( p_demux, " - packets count=%d", GetDWBE(&header[16]) ); msg_Dbg( p_demux, " - duration=%d ms", GetDWBE(&header[20]) ); msg_Dbg( p_demux, " - preroll=%d ms", GetDWBE(&header[24]) ); msg_Dbg( p_demux, " - index offset=%d", GetDWBE(&header[28]) ); msg_Dbg( p_demux, " - data offset=%d", GetDWBE(&header[32]) ); msg_Dbg( p_demux, " - num streams=%d", GetWBE(&header[36]) ); /* set the duration for export in control */ p_sys->i_our_duration = (int)GetDWBE(&header[20]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -