Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
136ba664
Commit
136ba664
authored
Nov 28, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cosmetics (lpcm).
parent
1f8490d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
57 deletions
+63
-57
modules/codec/lpcm.c
modules/codec/lpcm.c
+63
-57
No files found.
modules/codec/lpcm.c
View file @
136ba664
/*****************************************************************************
/*****************************************************************************
* lpcm.c: lpcm decoder/packetizer module
* lpcm.c: lpcm decoder/packetizer module
*****************************************************************************
*****************************************************************************
* Copyright (C) 1999-200
5
the VideoLAN team
* Copyright (C) 1999-200
8
the VideoLAN team
* $Id$
* $Id$
*
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Authors: Samuel Hocevar <sam@zoy.org>
...
@@ -36,6 +36,29 @@
...
@@ -36,6 +36,29 @@
#include <vlc_codec.h>
#include <vlc_codec.h>
#include <vlc_aout.h>
#include <vlc_aout.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static
int
OpenDecoder
(
vlc_object_t
*
);
static
int
OpenPacketizer
(
vlc_object_t
*
);
static
void
CloseCommon
(
vlc_object_t
*
);
vlc_module_begin
()
set_category
(
CAT_INPUT
)
set_subcategory
(
SUBCAT_INPUT_ACODEC
)
set_description
(
N_
(
"Linear PCM audio decoder"
)
)
set_capability
(
"decoder"
,
100
)
set_callbacks
(
OpenDecoder
,
CloseCommon
)
add_submodule
()
set_description
(
N_
(
"Linear PCM audio packetizer"
)
)
set_capability
(
"packetizer"
,
100
)
set_callbacks
(
OpenPacketizer
,
CloseCommon
)
vlc_module_end
()
/*****************************************************************************
/*****************************************************************************
* decoder_sys_t : lpcm decoder descriptor
* decoder_sys_t : lpcm decoder descriptor
*****************************************************************************/
*****************************************************************************/
...
@@ -49,13 +72,12 @@ struct decoder_sys_t
...
@@ -49,13 +72,12 @@ struct decoder_sys_t
*/
*/
audio_date_t
end_date
;
audio_date_t
end_date
;
/* */
unsigned
int
i_header_size
;
};
};
/*
/*
* LPCM header :
* LPCM DVD header :
* - PES header
* - private stream ID (16 bits) == 0xA0 -> not in the bitstream
*
* - frame number (8 bits)
* - frame number (8 bits)
* - unknown (16 bits) == 0x0003 ?
* - unknown (16 bits) == 0x0003 ?
* - unknown (4 bits)
* - unknown (4 bits)
...
@@ -67,69 +89,59 @@ struct decoder_sys_t
...
@@ -67,69 +89,59 @@ struct decoder_sys_t
* - start code (8 bits) == 0x80
* - start code (8 bits) == 0x80
*/
*/
#define LPCM_
HEADER_LEN 6
#define LPCM_
DVD_HEADER_LEN (6)
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
*****************************************************************************/
*****************************************************************************/
static
int
OpenDecoder
(
vlc_object_t
*
);
static
int
OpenPacketizer
(
vlc_object_t
*
);
static
void
CloseDecoder
(
vlc_object_t
*
);
static
void
*
DecodeFrame
(
decoder_t
*
,
block_t
**
);
static
void
*
DecodeFrame
(
decoder_t
*
,
block_t
**
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* OpenCommon:
*****************************************************************************/
vlc_module_begin
()
set_category
(
CAT_INPUT
)
set_subcategory
(
SUBCAT_INPUT_ACODEC
)
set_description
(
N_
(
"Linear PCM audio decoder"
)
)
set_capability
(
"decoder"
,
100
)
set_callbacks
(
OpenDecoder
,
CloseDecoder
)
add_submodule
()
set_description
(
N_
(
"Linear PCM audio packetizer"
)
)
set_capability
(
"packetizer"
,
100
)
set_callbacks
(
OpenPacketizer
,
CloseDecoder
)
vlc_module_end
()
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
*****************************************************************************/
static
int
Open
Decoder
(
vlc_object_t
*
p_this
)
static
int
Open
Common
(
vlc_object_t
*
p_this
,
bool
b_packetizer
)
{
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_sys_t
*
p_sys
;
decoder_sys_t
*
p_sys
;
if
(
p_dec
->
fmt_in
.
i_codec
!=
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'm'
)
switch
(
p_dec
->
fmt_in
.
i_codec
)
&&
p_dec
->
fmt_in
.
i_codec
!=
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'b'
)
)
{
{
case
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'm'
):
case
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'b'
):
break
;
default:
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
/* Allocate the memory needed to store the decoder's structure */
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
if
(
(
p_dec
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
/* Misc init */
/* Misc init */
p_sys
->
b_packetizer
=
false
;
p_sys
->
b_packetizer
=
b_packetizer
;
p_sys
->
i_header_size
=
LPCM_DVD_HEADER_LEN
;
aout_DateSet
(
&
p_sys
->
end_date
,
0
);
aout_DateSet
(
&
p_sys
->
end_date
,
0
);
/* Set output properties */
/* Set output properties */
p_dec
->
fmt_out
.
i_cat
=
AUDIO_ES
;
p_dec
->
fmt_out
.
i_cat
=
AUDIO_ES
;
if
(
p_dec
->
fmt_out
.
audio
.
i_bitspersample
==
24
)
if
(
b_packetizer
)
{
{
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
'
s'
,
'2'
,
'4'
,
'b
'
);
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
'
l'
,
'p'
,
'c'
,
'm
'
);
}
}
else
else
{
{
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
's'
,
'1'
,
'6'
,
'b'
);
switch
(
p_dec
->
fmt_out
.
audio
.
i_bitspersample
)
p_dec
->
fmt_out
.
audio
.
i_bitspersample
=
16
;
{
case
24
:
case
20
:
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
's'
,
'2'
,
'4'
,
'b'
);
break
;
default:
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
's'
,
'1'
,
'6'
,
'b'
);
p_dec
->
fmt_out
.
audio
.
i_bitspersample
=
16
;
break
;
}
}
}
/* Set callback */
/* Set callback */
...
@@ -140,20 +152,13 @@ static int OpenDecoder( vlc_object_t *p_this )
...
@@ -140,20 +152,13 @@ static int OpenDecoder( vlc_object_t *p_this )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
OpenDecoder
(
vlc_object_t
*
p_this
)
{
return
OpenCommon
(
p_this
,
false
);
}
static
int
OpenPacketizer
(
vlc_object_t
*
p_this
)
static
int
OpenPacketizer
(
vlc_object_t
*
p_this
)
{
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
return
OpenCommon
(
p_this
,
true
);
int
i_ret
=
OpenDecoder
(
p_this
);
if
(
i_ret
!=
VLC_SUCCESS
)
return
i_ret
;
p_dec
->
p_sys
->
b_packetizer
=
true
;
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'm'
);
return
i_ret
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -188,7 +193,7 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
...
@@ -188,7 +193,7 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
return
NULL
;
return
NULL
;
}
}
if
(
p_block
->
i_buffer
<=
LPCM_HEADER_LEN
)
if
(
p_block
->
i_buffer
<=
p_sys
->
i_header_size
)
{
{
msg_Err
(
p_dec
,
"frame is too short"
);
msg_Err
(
p_dec
,
"frame is too short"
);
block_Release
(
p_block
);
block_Release
(
p_block
);
...
@@ -294,7 +299,7 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
...
@@ -294,7 +299,7 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
p_dec
->
fmt_out
.
audio
.
i_physical_channels
p_dec
->
fmt_out
.
audio
.
i_physical_channels
=
i_original_channels
&
AOUT_CHAN_PHYSMASK
;
=
i_original_channels
&
AOUT_CHAN_PHYSMASK
;
i_frame_length
=
(
p_block
->
i_buffer
-
LPCM_HEADER_LEN
)
/
i_frame_length
=
(
p_block
->
i_buffer
-
p_sys
->
i_header_size
)
/
p_dec
->
fmt_out
.
audio
.
i_channels
*
8
/
i_bitspersample
;
p_dec
->
fmt_out
.
audio
.
i_channels
*
8
/
i_bitspersample
;
if
(
p_sys
->
b_packetizer
)
if
(
p_sys
->
b_packetizer
)
...
@@ -318,8 +323,8 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
...
@@ -318,8 +323,8 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
p_aout_buffer
->
end_date
=
p_aout_buffer
->
end_date
=
aout_DateIncrement
(
&
p_sys
->
end_date
,
i_frame_length
);
aout_DateIncrement
(
&
p_sys
->
end_date
,
i_frame_length
);
p_block
->
p_buffer
+=
LPCM_HEADER_LEN
;
p_block
->
p_buffer
+=
p_sys
->
i_header_size
;
p_block
->
i_buffer
-=
LPCM_HEADER_LEN
;
p_block
->
i_buffer
-=
p_sys
->
i_header_size
;
/* 20/24 bits LPCM use special packing */
/* 20/24 bits LPCM use special packing */
if
(
i_bitspersample
==
24
)
if
(
i_bitspersample
==
24
)
...
@@ -390,10 +395,11 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
...
@@ -390,10 +395,11 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
}
}
/*****************************************************************************
/*****************************************************************************
* Close
Decoder
: lpcm decoder destruction
* Close
Common
: lpcm decoder destruction
*****************************************************************************/
*****************************************************************************/
static
void
Close
Decoder
(
vlc_object_t
*
p_this
)
static
void
Close
Common
(
vlc_object_t
*
p_this
)
{
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
free
(
p_dec
->
p_sys
);
free
(
p_dec
->
p_sys
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment