Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
b9dc0c52
Commit
b9dc0c52
authored
Jan 18, 2000
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nettoyage global. Le vlc se ferme proprement, elem_t devient dctelem_t, le
macroblock perdu a �t� retrouv�, et bien plus...
parent
f0be4ee4
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
295 additions
and
314 deletions
+295
-314
include/config.h
include/config.h
+1
-1
include/vdec_idct.h
include/vdec_idct.h
+6
-6
include/video_decoder.h.new
include/video_decoder.h.new
+5
-5
include/vpar_blocks.h
include/vpar_blocks.h
+12
-5
include/vpar_synchro.h
include/vpar_synchro.h
+1
-1
src/input/input.c.new
src/input/input.c.new
+1
-1
src/video_decoder/vdec_idct.c
src/video_decoder/vdec_idct.c
+24
-24
src/video_decoder/video_decoder.c
src/video_decoder/video_decoder.c
+14
-48
src/video_parser/video_fifo.c
src/video_parser/video_fifo.c
+40
-7
src/video_parser/video_parser.c
src/video_parser/video_parser.c
+4
-11
src/video_parser/vpar_blocks.c
src/video_parser/vpar_blocks.c
+176
-190
src/video_parser/vpar_headers.c
src/video_parser/vpar_headers.c
+11
-15
No files found.
include/config.h
View file @
b9dc0c52
...
...
@@ -45,7 +45,7 @@
/* Program version and copyright message */
#define PROGRAM_VERSION "1.0-dev"
#define COPYRIGHT_MESSAGE "VideoLAN Client v" PROGRAM_VERSION " (" __DATE__ ") - " \
PROGRAM_OPTIONS " - (c)1999 VideoLAN"
PROGRAM_OPTIONS " - (c)1999
-2000
VideoLAN"
/*******************************************************************************
* General compilation options
...
...
include/vdec_idct.h
View file @
b9dc0c52
...
...
@@ -15,9 +15,9 @@
*****************************************************************************/
#ifndef VDEC_DFT
typedef
short
elem_t
;
typedef
short
dct
elem_t
;
#else
typedef
int
elem_t
;
typedef
int
dct
elem_t
;
#endif
struct
vdec_thread_s
;
...
...
@@ -143,12 +143,12 @@ struct vdec_thread_s;
/*****************************************************************************
* Function pointers
*****************************************************************************/
typedef
void
(
*
f_idct_t
)(
struct
vdec_thread_s
*
,
elem_t
*
,
int
);
typedef
void
(
*
f_idct_t
)(
struct
vdec_thread_s
*
,
dct
elem_t
*
,
int
);
/*****************************************************************************
* Prototypes
*****************************************************************************/
void
vdec_DummyIDCT
(
struct
vdec_thread_s
*
,
elem_t
*
,
int
);
void
vdec_DummyIDCT
(
struct
vdec_thread_s
*
,
dct
elem_t
*
,
int
);
void
vdec_InitIDCT
(
struct
vdec_thread_s
*
p_vdec
);
void
vdec_SparseIDCT
(
struct
vdec_thread_s
*
,
elem_t
*
,
int
);
void
vdec_IDCT
(
struct
vdec_thread_s
*
,
elem_t
*
,
int
);
void
vdec_SparseIDCT
(
struct
vdec_thread_s
*
,
dct
elem_t
*
,
int
);
void
vdec_IDCT
(
struct
vdec_thread_s
*
,
dct
elem_t
*
,
int
);
include/video_decoder.h.new
View file @
b9dc0c52
...
...
@@ -34,7 +34,7 @@ typedef struct vdec_thread_s
// int *pi_status;
/* idct iformations */
elem_t p_pre_idct[64*64];
dct
elem_t p_pre_idct[64*64];
/* Input properties */
struct vpar_thread_s * p_vpar; /* video_parser thread */
...
...
@@ -59,7 +59,7 @@ typedef struct vdec_thread_s
/*****************************************************************************
* Function pointers
*****************************************************************************/
typedef void (*f_addb_t)( vdec_thread_t *, elem_t*, yuv_data_t*, int );
typedef void (*f_addb_t)( vdec_thread_t *,
dct
elem_t*, yuv_data_t*, int );
/*****************************************************************************
* Prototypes
...
...
@@ -69,6 +69,6 @@ struct vpar_thread_s;
/* Thread management functions */
vdec_thread_t * vdec_CreateThread ( struct vpar_thread_s *p_vpar /*, int *pi_status */ );
void vdec_DestroyThread ( vdec_thread_t *p_vdec /*, int *pi_status */ );
void vdec_AddBlock( vdec_thread_t *, elem_t*, yuv_data_t*, int );
void vdec_CopyBlock( vdec_thread_t *, elem_t*, yuv_data_t*, int );
void vdec_DummyBlock( vdec_thread_t *, elem_t*, yuv_data_t*, int );
void vdec_AddBlock( vdec_thread_t *,
dct
elem_t*, yuv_data_t*, int );
void vdec_CopyBlock( vdec_thread_t *,
dct
elem_t*, yuv_data_t*, int );
void vdec_DummyBlock( vdec_thread_t *,
dct
elem_t*, yuv_data_t*, int );
include/vpar_blocks.h
View file @
b9dc0c52
...
...
@@ -33,7 +33,7 @@ typedef struct macroblock_s
int
i_c_stride
;
/* idem, for chroma */
/* IDCT information */
elem_t
ppi_blocks
[
12
][
64
];
/* blocks */
dct
elem_t
ppi_blocks
[
12
][
64
];
/* blocks */
f_idct_t
pf_idct
[
12
];
/* sparse IDCT or not ? */
int
pi_sparse_pos
[
12
];
...
...
@@ -131,10 +131,17 @@ extern u8 pi_scan[2][64];
* Prototypes
*****************************************************************************/
void
vpar_InitCrop
(
struct
vpar_thread_s
*
p_vpar
);
void
vpar_InitMbAddrInc
(
struct
vpar_thread_s
*
p_vpar
);
void
vpar_InitPMBType
(
struct
vpar_thread_s
*
p_vpar
);
void
vpar_InitBMBType
(
struct
vpar_thread_s
*
p_vpar
);
void
vpar_InitCodedPattern
(
struct
vpar_thread_s
*
p_vpar
);
void
vpar_InitDCTTables
(
struct
vpar_thread_s
*
p_vpar
);
void
vpar_ParseMacroblock
(
struct
vpar_thread_s
*
p_vpar
,
int
*
pi_mb_address
,
int
i_mb_previous
,
int
i_mb_base
);
int
vpar_CodedPattern420
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_CodedPattern422
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_CodedPattern444
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_IMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_PMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_BMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_DMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_IMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_PMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_BMBType
(
struct
vpar_thread_s
*
p_vpar
);
int
vpar_DMBType
(
struct
vpar_thread_s
*
p_vpar
);
include/vpar_synchro.h
View file @
b9dc0c52
...
...
@@ -32,4 +32,4 @@ void vpar_SynchroTrash( struct vpar_thread_s * p_vpar, int i_coding_type,
int
i_structure
);
mtime_t
vpar_SynchroDecode
(
struct
vpar_thread_s
*
p_vpar
,
int
i_coding_type
,
int
i_structure
);
void
vpar_SynchroEnd
(
struct
vpar_thread_s
*
p_vpar
);
src/input/input.c.new
View file @
b9dc0c52
...
...
@@ -341,7 +341,7 @@ static void EndThread( input_thread_t * p_input )
{
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
v
dec_DestroyThread( (vdec
_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ );
v
par_DestroyThread( (vpar
_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ );
break;
case MPEG1_AUDIO_ES:
...
...
src/video_decoder/vdec_idct.c
View file @
b9dc0c52
...
...
@@ -44,7 +44,7 @@
* Local prototypes
*/
//extern IDCT_mmx(elem_t*);
//extern IDCT_mmx(
dct
elem_t*);
/* Our current implementation is a fast DCT, we might move to a fast DFT or
* an MMX DCT in the future. */
...
...
@@ -52,7 +52,7 @@
/*****************************************************************************
* vdec_DummyIDCT : dummy function that does nothing
*****************************************************************************/
void
vdec_DummyIDCT
(
vdec_thread_t
*
p_vdec
,
elem_t
*
p_block
,
void
vdec_DummyIDCT
(
vdec_thread_t
*
p_vdec
,
dct
elem_t
*
p_block
,
int
i_idontcare
)
{
}
...
...
@@ -66,8 +66,8 @@ void vdec_InitIDCT (vdec_thread_t * p_vdec)
{
int
i
;
elem_t
*
p_pre
=
p_vdec
->
p_pre_idct
;
memset
(
p_pre
,
0
,
64
*
64
*
sizeof
(
elem_t
)
);
dct
elem_t
*
p_pre
=
p_vdec
->
p_pre_idct
;
memset
(
p_pre
,
0
,
64
*
64
*
sizeof
(
dct
elem_t
)
);
for
(
i
=
0
;
i
<
64
;
i
++
)
{
...
...
@@ -76,7 +76,7 @@ void vdec_InitIDCT (vdec_thread_t * p_vdec)
}
}
void
vdec_SparseIDCT
(
vdec_thread_t
*
p_vdec
,
elem_t
*
p_block
,
void
vdec_SparseIDCT
(
vdec_thread_t
*
p_vdec
,
dct
elem_t
*
p_block
,
int
i_sparse_pos
)
{
short
int
val
;
...
...
@@ -135,7 +135,7 @@ void vdec_SparseIDCT (vdec_thread_t * p_vdec, elem_t * p_block,
/*****************************************************************************
* vdec_IDCT : IDCT function for normal matrices
*****************************************************************************/
void
vdec_IDCT
(
vdec_thread_t
*
p_vdec
,
elem_t
*
p_block
,
int
i_idontcare
)
void
vdec_IDCT
(
vdec_thread_t
*
p_vdec
,
dct
elem_t
*
p_block
,
int
i_idontcare
)
{
//IDCT_mmx(p_block);
#if 1
...
...
@@ -143,7 +143,7 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
s32
tmp10
,
tmp11
,
tmp12
,
tmp13
;
s32
z1
,
z2
,
z3
,
z4
,
z5
;
s32
d0
,
d1
,
d2
,
d3
,
d4
,
d5
,
d6
,
d7
;
elem_t
*
dataptr
;
dct
elem_t
*
dataptr
;
int
rowctr
;
SHIFT_TEMPS
...
...
@@ -174,7 +174,7 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
if
(
d0
)
{
/* Compute a 32 bit value to assign. */
elem_t
dcval
=
(
elem_t
)
(
d0
<<
PASS1_BITS
);
dctelem_t
dcval
=
(
dct
elem_t
)
(
d0
<<
PASS1_BITS
);
register
int
v
=
(
dcval
&
0xffff
)
|
(
dcval
<<
16
);
idataptr
[
0
]
=
v
;
...
...
@@ -727,14 +727,14 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr
[
0
]
=
(
elem_t
)
DESCALE
(
tmp10
+
tmp3
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
7
]
=
(
elem_t
)
DESCALE
(
tmp10
-
tmp3
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
1
]
=
(
elem_t
)
DESCALE
(
tmp11
+
tmp2
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
6
]
=
(
elem_t
)
DESCALE
(
tmp11
-
tmp2
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
2
]
=
(
elem_t
)
DESCALE
(
tmp12
+
tmp1
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
5
]
=
(
elem_t
)
DESCALE
(
tmp12
-
tmp1
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
3
]
=
(
elem_t
)
DESCALE
(
tmp13
+
tmp0
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
4
]
=
(
elem_t
)
DESCALE
(
tmp13
-
tmp0
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
0
]
=
(
dct
elem_t
)
DESCALE
(
tmp10
+
tmp3
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
7
]
=
(
dct
elem_t
)
DESCALE
(
tmp10
-
tmp3
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
1
]
=
(
dct
elem_t
)
DESCALE
(
tmp11
+
tmp2
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
6
]
=
(
dct
elem_t
)
DESCALE
(
tmp11
-
tmp2
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
2
]
=
(
dct
elem_t
)
DESCALE
(
tmp12
+
tmp1
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
5
]
=
(
dct
elem_t
)
DESCALE
(
tmp12
-
tmp1
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
3
]
=
(
dct
elem_t
)
DESCALE
(
tmp13
+
tmp0
,
CONST_BITS
-
PASS1_BITS
);
dataptr
[
4
]
=
(
dct
elem_t
)
DESCALE
(
tmp13
-
tmp0
,
CONST_BITS
-
PASS1_BITS
);
dataptr
+=
DCTSIZE
;
/* advance pointer to next row */
}
...
...
@@ -1294,21 +1294,21 @@ void vdec_IDCT( vdec_thread_t * p_vdec, elem_t * p_block, int i_idontcare )
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr
[
DCTSIZE
*
0
]
=
(
elem_t
)
DESCALE
(
tmp10
+
tmp3
,
dataptr
[
DCTSIZE
*
0
]
=
(
dct
elem_t
)
DESCALE
(
tmp10
+
tmp3
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
7
]
=
(
elem_t
)
DESCALE
(
tmp10
-
tmp3
,
dataptr
[
DCTSIZE
*
7
]
=
(
dct
elem_t
)
DESCALE
(
tmp10
-
tmp3
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
1
]
=
(
elem_t
)
DESCALE
(
tmp11
+
tmp2
,
dataptr
[
DCTSIZE
*
1
]
=
(
dct
elem_t
)
DESCALE
(
tmp11
+
tmp2
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
6
]
=
(
elem_t
)
DESCALE
(
tmp11
-
tmp2
,
dataptr
[
DCTSIZE
*
6
]
=
(
dct
elem_t
)
DESCALE
(
tmp11
-
tmp2
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
2
]
=
(
elem_t
)
DESCALE
(
tmp12
+
tmp1
,
dataptr
[
DCTSIZE
*
2
]
=
(
dct
elem_t
)
DESCALE
(
tmp12
+
tmp1
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
5
]
=
(
elem_t
)
DESCALE
(
tmp12
-
tmp1
,
dataptr
[
DCTSIZE
*
5
]
=
(
dct
elem_t
)
DESCALE
(
tmp12
-
tmp1
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
3
]
=
(
elem_t
)
DESCALE
(
tmp13
+
tmp0
,
dataptr
[
DCTSIZE
*
3
]
=
(
dct
elem_t
)
DESCALE
(
tmp13
+
tmp0
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
[
DCTSIZE
*
4
]
=
(
elem_t
)
DESCALE
(
tmp13
-
tmp0
,
dataptr
[
DCTSIZE
*
4
]
=
(
dct
elem_t
)
DESCALE
(
tmp13
-
tmp0
,
CONST_BITS
+
PASS1_BITS
+
3
);
dataptr
++
;
/* advance pointer to next column */
...
...
src/video_decoder/video_decoder.c
View file @
b9dc0c52
...
...
@@ -111,6 +111,11 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
/* Ask thread to kill itself */
p_vdec
->
b_die
=
1
;
/* Make sure the parser thread leaves the GetByte() function */
vlc_mutex_lock
(
&
(
p_vdec
->
p_vpar
->
vfifo
.
lock
)
);
vlc_cond_signal
(
&
(
p_vdec
->
p_vpar
->
vfifo
.
wait
)
);
vlc_mutex_unlock
(
&
(
p_vdec
->
p_vpar
->
vfifo
.
lock
)
);
/* Waiting for the decoder thread to exit */
/* Remove this as soon as the "status" flag is implemented */
...
...
@@ -128,9 +133,7 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
*******************************************************************************/
static
int
InitThread
(
vdec_thread_t
*
p_vdec
)
{
//#ifdef MPEG2_COMPLIANT
int
i_dummy
;
//#endif
intf_DbgMsg
(
"vdec debug: initializing video decoder thread %p
\n
"
,
p_vdec
);
...
...
@@ -144,7 +147,6 @@ static int InitThread( vdec_thread_t *p_vdec )
p_vdec
->
c_decoded_b_pictures
=
0
;
#endif
//#ifdef MPEG2_COMPLIANT
/* Init crop table */
p_vdec
->
pi_crop
=
p_vdec
->
pi_crop_buf
+
(
VDEC_CROPRANGE
>>
1
);
for
(
i_dummy
=
-
(
VDEC_CROPRANGE
>>
1
);
i_dummy
<
0
;
i_dummy
++
)
...
...
@@ -159,7 +161,6 @@ static int InitThread( vdec_thread_t *p_vdec )
{
p_vdec
->
pi_crop
[
i_dummy
]
=
255
;
}
//#endif
/* Mark thread as running and return */
intf_DbgMsg
(
"vdec debug: InitThread(%p) succeeded
\n
"
,
p_vdec
);
...
...
@@ -194,7 +195,7 @@ static void RunThread( vdec_thread_t *p_vdec )
while
(
(
!
p_vdec
->
b_die
)
&&
(
!
p_vdec
->
b_error
)
)
{
macroblock_t
*
p_mb
;
if
(
(
p_mb
=
vpar_GetMacroblock
(
&
p_vdec
->
p_vpar
->
vfifo
))
!=
NULL
)
{
DecodeMacroblock
(
p_vdec
,
p_mb
);
...
...
@@ -255,9 +256,9 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
* Motion Compensation (ISO/IEC 13818-2 section 7.6)
*/
(
*
p_mb
->
pf_motion
)(
p_mb
);
//#if 0
/* luminance */
for
(
i_b
=
0
;
i_b
<
4
;
i_b
++
)
for
(
i_b
=
0
;
i_b
<
4
;
i_b
++
)
{
/*
* Inverse DCT (ISO/IEC 13818-2 section Annex A)
...
...
@@ -265,29 +266,13 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
(
p_mb
->
pf_idct
[
i_b
])(
p_vdec
,
p_mb
->
ppi_blocks
[
i_b
],
p_mb
->
pi_sparse_pos
[
i_b
]
);
// if( (i_b & 2) )
/* {
int i, j;
elem_t meuh[64];
for( i = 0; i < 8; i++ )
{
for( j = 0; j < 8; j++ )
{
meuh[8*j + (7-i)] = p_mb->ppi_blocks[i_b][j + 8*i];
}
}
memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
}
*/
/*
* Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
*/
(
p_mb
->
pf_addb
[
i_b
])(
p_vdec
,
p_mb
->
ppi_blocks
[
i_b
],
p_mb
->
p_data
[
i_b
],
p_mb
->
i_addb_l_stride
);
}
//#endif
//#if 0
/* chrominance */
for
(
i_b
=
4
;
i_b
<
4
+
p_mb
->
i_chroma_nb_blocks
;
i_b
++
)
{
...
...
@@ -296,21 +281,6 @@ memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
*/
(
p_mb
->
pf_idct
[
i_b
])(
p_vdec
,
p_mb
->
ppi_blocks
[
i_b
],
p_mb
->
pi_sparse_pos
[
i_b
]
);
/*
{
int i, j;
elem_t meuh[64];
for( i = 0; i < 8; i++ )
{
for( j = 0; j < 8; j++ )
{
meuh[8*j + (7-i)] = p_mb->ppi_blocks[i_b][j + 8*i];
}
}
memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
}
*/
/*
* Adding prediction and coefficient data (ISO/IEC 13818-2 section 7.6.8)
...
...
@@ -318,7 +288,7 @@ memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
(
p_mb
->
pf_addb
[
i_b
])(
p_vdec
,
p_mb
->
ppi_blocks
[
i_b
],
p_mb
->
p_data
[
i_b
],
p_mb
->
i_addb_c_stride
);
}
//#endif
/*
* Decoding is finished, release the macroblock and free
* unneeded memory.
...
...
@@ -329,7 +299,7 @@ memcpy(p_mb->ppi_blocks[i_b], meuh, 128);
/*******************************************************************************
* vdec_AddBlock : add a block
*******************************************************************************/
void
vdec_AddBlock
(
vdec_thread_t
*
p_vdec
,
elem_t
*
p_block
,
yuv_data_t
*
p_data
,
int
i_incr
)
void
vdec_AddBlock
(
vdec_thread_t
*
p_vdec
,
dct
elem_t
*
p_block
,
yuv_data_t
*
p_data
,
int
i_incr
)
{
int
i_x
,
i_y
;
...
...
@@ -337,12 +307,8 @@ void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_dat
{
for
(
i_x
=
0
;
i_x
<
8
;
i_x
++
)
{
#ifdef MPEG2_COMPLIANT
*
p_data
=
p_vdec
->
pi_crop
[
*
p_data
+
*
p_block
++
];
p_data
++
;
#else
*
p_data
++
+=
*
p_block
++
;
#endif
}
p_data
+=
i_incr
;
}
...
...
@@ -351,7 +317,7 @@ void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_dat
/*******************************************************************************
* vdec_CopyBlock : copy a block
*******************************************************************************/
void
vdec_CopyBlock
(
vdec_thread_t
*
p_vdec
,
elem_t
*
p_block
,
yuv_data_t
*
p_data
,
int
i_incr
)
void
vdec_CopyBlock
(
vdec_thread_t
*
p_vdec
,
dct
elem_t
*
p_block
,
yuv_data_t
*
p_data
,
int
i_incr
)
{
int
i_y
;
//fprintf(stderr, "%d ", i_incr );
...
...
@@ -359,7 +325,7 @@ void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_da
for
(
i_y
=
0
;
i_y
<
8
;
i_y
++
)
{
#if 0
/* elem_t and yuv_data_t are the same */
/*
dct
elem_t and yuv_data_t are the same */
memcpy( p_data, p_block, 8*sizeof(yuv_data_t) );
p_data += i_incr+8;
p_block += 8;
...
...
@@ -380,6 +346,6 @@ void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, yuv_data_t * p_da
/*******************************************************************************
* vdec_DummyBlock : dummy function that does nothing
*******************************************************************************/
void
vdec_DummyBlock
(
vdec_thread_t
*
p_vdec
,
elem_t
*
p_block
,
yuv_data_t
*
p_data
,
int
i_incr
)
void
vdec_DummyBlock
(
vdec_thread_t
*
p_vdec
,
dct
elem_t
*
p_block
,
yuv_data_t
*
p_data
,
int
i_incr
)
{
}
src/video_parser/video_fifo.c
View file @
b9dc0c52
...
...
@@ -84,7 +84,7 @@ macroblock_t * vpar_GetMacroblock( video_fifo_t * p_fifo )
p_mb
=
VIDEO_FIFO_START
(
*
p_fifo
);
VIDEO_FIFO_INCSTART
(
*
p_fifo
);
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
return
(
p_mb
);
...
...
@@ -99,12 +99,13 @@ macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
#define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock
(
&
P_buffer
.
lock
);
if
(
P_buffer
.
i_index
==
-
1
)
while
(
P_buffer
.
i_index
==
-
1
)
{
/* No more structures available. This should not happen ! */
msleep
(
VPAR_IDLE_SLEEP
);
return
vpar_NewMacroblock
(
p_fifo
);
// return NULL;
intf_DbgMsg
(
"vpar debug: macroblock list is empty, delaying
\n
"
);
vlc_mutex_unlock
(
&
P_buffer
.
lock
);
msleep
(
VPAR_IDLE_SLEEP
);
vlc_mutex_lock
(
&
P_buffer
.
lock
);
}
p_mb
=
P_buffer
.
pp_mb_free
[
P_buffer
.
i_index
--
];
...
...
@@ -135,12 +136,16 @@ void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
*****************************************************************************/
void
vpar_ReleaseMacroblock
(
video_fifo_t
*
p_fifo
,
macroblock_t
*
p_mb
)
{
boolean_t
b_finished
;
/* Unlink picture buffer */
vlc_mutex_lock
(
&
p_mb
->
p_picture
->
lock_deccount
);
p_mb
->
p_picture
->
i_deccount
--
;
b_finished
=
(
p_mb
->
p_picture
->
i_deccount
==
1
);
vlc_mutex_unlock
(
&
p_mb
->
p_picture
->
lock_deccount
);
//fprintf(stderr, "%d ", p_mb->p_picture->i_deccount);
/* Test if it was the last block of the picture */
if
(
p_mb
->
p_picture
->
i_deccount
==
1
)
if
(
b_finished
)
{
fprintf
(
stderr
,
"Image decodee
\n
"
);
/* Mark the picture to be displayed */
...
...
@@ -159,7 +164,6 @@ fprintf(stderr, "Image decodee\n");
vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backward );
}*/
}
vlc_mutex_unlock
(
&
p_mb
->
p_picture
->
lock_deccount
);
/* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar->vbuffer
...
...
@@ -174,6 +178,35 @@ fprintf(stderr, "Image decodee\n");
*****************************************************************************/
void
vpar_DestroyMacroblock
(
video_fifo_t
*
p_fifo
,
macroblock_t
*
p_mb
)
{
boolean_t
b_finished
;
/* Unlink picture buffer */
vlc_mutex_lock
(
&
p_mb
->
p_picture
->
lock_deccount
);
p_mb
->
p_picture
->
i_deccount
--
;
b_finished
=
(
p_mb
->
p_picture
->
i_deccount
==
1
);
vlc_mutex_unlock
(
&
p_mb
->
p_picture
->
lock_deccount
);
/* Test if it was the last block of the picture */
if
(
b_finished
)
{
fprintf
(
stderr
,
"Image trashee
\n
"
);
/* Mark the picture to be displayed */
vout_DestroyPicture
(
p_fifo
->
p_vpar
->
p_vout
,
p_mb
->
p_picture
);
/* Warn Synchro for its records. */
vpar_SynchroEnd
(
p_fifo
->
p_vpar
);
/* Unlink referenced pictures */
/* if( p_mb->p_forward != NULL )
{
vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forward );
}
if( p_mb->p_backward != NULL )
{
vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backward );
}*/
}
/* Release the macroblock_t structure */
#define P_buffer p_fifo->p_vpar->vbuffer
vlc_mutex_lock
(
&
P_buffer
.
lock
);
...
...
src/video_parser/video_parser.c
View file @
b9dc0c52
...
...
@@ -175,16 +175,6 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar
->
bit_stream
.
i_byte
=
p_vpar
->
bit_stream
.
p_ts
->
i_payload_start
;
vlc_mutex_unlock
(
&
p_vpar
->
fifo
.
data_lock
);
#if 0
/* ?? */
/* Create video stream */
p_vpar->i_stream = vout_CreateStream( p_vpar->p_vout );
if( p_vpar->i_stream < 0 ) /* error */
{
return( 1 );
}
#endif
/* Initialize parsing data */
p_vpar
->
sequence
.
p_forward
=
NULL
;
p_vpar
->
sequence
.
p_backward
=
NULL
;
...
...
@@ -198,6 +188,9 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar
->
sequence
.
i_copyright_id
=
0
;
p_vpar
->
sequence
.
i_copyright_nb
=
0
;
p_vpar
->
picture
.
p_picture
=
NULL
;
p_vpar
->
picture
.
i_current_structure
=
0
;
/* Initialize other properties */
#ifdef STATS
p_vpar
->
c_loops
=
0
;
...
...
@@ -214,7 +207,7 @@ static int InitThread( vpar_thread_t *p_vpar )
/* Initialize video FIFO */
vpar_InitFIFO
(
p_vpar
);
bzero
(
p_vpar
->
p_vdec
,
NB_VDEC
*
sizeof
(
vdec_thread_t
*
)
);
/* Spawn video_decoder threads */
...
...
src/video_parser/vpar_blocks.c
View file @
b9dc0c52
...
...
@@ -42,11 +42,6 @@
/*
* Local prototypes
*/
static
__inline__
void
InitMacroblock
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
);
static
__inline__
int
MacroblockAddressIncrement
(
vpar_thread_t
*
p_vpar
);
static
__inline__
void
MacroblockModes
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
);
typedef
void
(
*
f_decode_block_t
)(
vpar_thread_t
*
,
macroblock_t
*
,
int
);
static
void
vpar_DecodeMPEG1Non
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
,
int
i_b
);
static
void
vpar_DecodeMPEG1Intra
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
,
int
i_b
);
...
...
@@ -57,7 +52,7 @@ static void vpar_DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb,
* Initialisation tables
*/
/* Table for coded_block_pattern resolution */
lookup_t
pl_coded_pattern_init_table
[
512
]
=
static
lookup_t
pl_coded_pattern_init_table
[
512
]
=
{
{
MB_ERROR
,
0
},
{
0
,
9
},
{
39
,
9
},
{
27
,
9
},
{
59
,
9
},
{
55
,
9
},
{
47
,
9
},
{
31
,
9
},
{
58
,
8
},
{
58
,
8
},
{
54
,
8
},
{
54
,
8
},
{
46
,
8
},
{
46
,
8
},
{
30
,
8
},
{
30
,
8
},
{
57
,
8
},
{
57
,
8
},
{
53
,
8
},
{
53
,
8
},
{
45
,
8
},
{
45
,
8
},
{
29
,
8
},
{
29
,
8
},
...
...
@@ -128,7 +123,7 @@ lookup_t pl_coded_pattern_init_table[512] =
*/
/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
lookup_t
pl_dct_dc_lum_init_table_1
[
32
]
=
static
lookup_t
pl_dct_dc_lum_init_table_1
[
32
]
=
{
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
0
,
3
},
{
0
,
3
},
{
0
,
3
},
{
0
,
3
},
{
3
,
3
},
{
3
,
3
},
{
3
,
3
},
{
3
,
3
},
...
...
@@ -136,7 +131,7 @@ lookup_t pl_dct_dc_lum_init_table_1[32] =
};
/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
lookup_t
pl_dct_dc_lum_init_table_2
[
32
]
=
static
lookup_t
pl_dct_dc_lum_init_table_2
[
32
]
=
{
{
7
,
6
},
{
7
,
6
},
{
7
,
6
},
{
7
,
6
},
{
7
,
6
},
{
7
,
6
},
{
7
,
6
},
{
7
,
6
},
{
8
,
7
},
{
8
,
7
},
{
8
,
7
},
{
8
,
7
},
{
9
,
8
},
{
9
,
8
},
{
10
,
9
},
{
11
,
9
},
{
MB_ERROR
,
0
},
{
MB_ERROR
,
0
},
{
MB_ERROR
,
0
},
{
MB_ERROR
,
0
},
...
...
@@ -146,7 +141,7 @@ lookup_t pl_dct_dc_lum_init_table_2[32] =
};
/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
lookup_t
pl_dct_dc_chrom_init_table_1
[
32
]
=
static
lookup_t
pl_dct_dc_chrom_init_table_1
[
32
]
=
{
{
0
,
2
},
{
0
,
2
},
{
0
,
2
},
{
0
,
2
},
{
0
,
2
},
{
0
,
2
},
{
0
,
2
},
{
0
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
...
...
@@ -154,7 +149,7 @@ lookup_t pl_dct_dc_chrom_init_table_1[32] =
};
/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
lookup_t
pl_dct_dc_chrom_init_table_2
[
32
]
=
static
lookup_t
pl_dct_dc_chrom_init_table_2
[
32
]
=
{
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
6
,
6
},
{
7
,
7
},
{
7
,
7
},
{
7
,
7
},
{
7
,
7
},
{
7
,
7
},
{
7
,
7
},
{
7
,
7
},
{
7
,
7
},
...
...
@@ -172,7 +167,7 @@ lookup_t pl_dct_dc_chrom_init_table_2[32] =
/* Table B-14, DCT coefficients table zero,
* codes 0100 ... 1xxx (used for first (DC) coefficient)
*/
dct_lookup_t
pl_DCT_tab_dc
[
12
]
=
static
dct_lookup_t
pl_DCT_tab_dc
[
12
]
=
{
{
0
,
2
,
4
},
{
2
,
1
,
4
},
{
1
,
1
,
3
},
{
1
,
1
,
3
},
{
0
,
1
,
1
},
{
0
,
1
,
1
},
{
0
,
1
,
1
},
{
0
,
1
,
1
},
...
...
@@ -182,7 +177,7 @@ dct_lookup_t pl_DCT_tab_dc[12] =
/* Table B-14, DCT coefficients table zero,
* codes 0100 ... 1xxx (used for all other coefficients)
*/
dct_lookup_t
pl_DCT_tab_ac
[
12
]
=
static
dct_lookup_t
pl_DCT_tab_ac
[
12
]
=
{
{
0
,
2
,
4
},
{
2
,
1
,
4
},
{
1
,
1
,
3
},
{
1
,
1
,
3
},
{
DCT_EOB
,
0
,
2
},
{
DCT_EOB
,
0
,
2
},
{
DCT_EOB
,
0
,
2
},
{
DCT_EOB
,
0
,
2
},
/* EOB */
...
...
@@ -192,7 +187,7 @@ dct_lookup_t pl_DCT_tab_ac[12] =
/* Table B-14, DCT coefficients table zero,
* codes 000001xx ... 00111xxx
*/
dct_lookup_t
pl_DCT_tab0
[
60
]
=
static
dct_lookup_t
pl_DCT_tab0
[
60
]
=
{
{
DCT_ESCAPE
,
0
,
6
},
{
DCT_ESCAPE
,
0
,
6
},
{
DCT_ESCAPE
,
0
,
6
},
{
DCT_ESCAPE
,
0
,
6
},
/* Escape */
...
...
@@ -215,7 +210,7 @@ dct_lookup_t pl_DCT_tab0[60] =
/* Table B-15, DCT coefficients table one,
* codes 000001xx ... 11111111
*/
dct_lookup_t
pl_DCT_tab0a
[
252
]
=
static
dct_lookup_t
pl_DCT_tab0a
[
252
]
=
{
{
65
,
0
,
6
},
{
65
,
0
,
6
},
{
65
,
0
,
6
},
{
65
,
0
,
6
},
/* Escape */
{
7
,
1
,
7
},
{
7
,
1
,
7
},
{
8
,
1
,
7
},
{
8
,
1
,
7
},
...
...
@@ -282,13 +277,10 @@ dct_lookup_t pl_DCT_tab0a[252] =
{
2
,
3
,
8
},
{
4
,
2
,
8
},
{
0
,
14
,
8
},
{
0
,
15
,
8
}
};
/* Table B-14, DCT coefficients table zero,
* codes 0000001000 ... 0000001111
*/
dct_lookup_t
pl_DCT_tab1
[
8
]
=
static
dct_lookup_t
pl_DCT_tab1
[
8
]
=
{
{
16
,
1
,
10
},
{
5
,
2
,
10
},
{
0
,
7
,
10
},
{
2
,
3
,
10
},
{
1
,
4
,
10
},
{
15
,
1
,
10
},
{
14
,
1
,
10
},
{
4
,
2
,
10
}
...
...
@@ -297,7 +289,7 @@ dct_lookup_t pl_DCT_tab1[8] =
/* Table B-15, DCT coefficients table one,
* codes 000000100x ... 000000111x
*/
dct_lookup_t
pl_DCT_tab1a
[
8
]
=
static
dct_lookup_t
pl_DCT_tab1a
[
8
]
=
{
{
5
,
2
,
9
},
{
5
,
2
,
9
},
{
14
,
1
,
9
},
{
14
,
1
,
9
},
{
2
,
4
,
10
},
{
16
,
1
,
10
},
{
15
,
1
,
9
},
{
15
,
1
,
9
}
...
...
@@ -306,7 +298,7 @@ dct_lookup_t pl_DCT_tab1a[8] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 000000010000 ... 000000011111
*/
dct_lookup_t
pl_DCT_tab2
[
16
]
=
static
dct_lookup_t
pl_DCT_tab2
[
16
]
=
{
{
0
,
11
,
12
},
{
8
,
2
,
12
},
{
4
,
3
,
12
},
{
0
,
10
,
12
},
{
2
,
4
,
12
},
{
7
,
2
,
12
},
{
21
,
1
,
12
},
{
20
,
1
,
12
},
...
...
@@ -317,7 +309,7 @@ dct_lookup_t pl_DCT_tab2[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 0000000010000 ... 0000000011111
*/
dct_lookup_t
pl_DCT_tab3
[
16
]
=
static
dct_lookup_t
pl_DCT_tab3
[
16
]
=
{
{
10
,
2
,
13
},
{
9
,
2
,
13
},
{
5
,
3
,
13
},
{
3
,
4
,
13
},
{
2
,
5
,
13
},
{
1
,
7
,
13
},
{
1
,
6
,
13
},
{
0
,
15
,
13
},
...
...
@@ -328,7 +320,7 @@ dct_lookup_t pl_DCT_tab3[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 00000000010000 ... 00000000011111
*/
dct_lookup_t
pl_DCT_tab4
[
16
]
=
static
dct_lookup_t
pl_DCT_tab4
[
16
]
=
{
{
0
,
31
,
14
},
{
0
,
30
,
14
},
{
0
,
29
,
14
},
{
0
,
28
,
14
},
{
0
,
27
,
14
},
{
0
,
26
,
14
},
{
0
,
25
,
14
},
{
0
,
24
,
14
},
...
...
@@ -339,7 +331,7 @@ dct_lookup_t pl_DCT_tab4[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 000000000010000 ... 000000000011111
*/
dct_lookup_t
pl_DCT_tab5
[
16
]
=
static
dct_lookup_t
pl_DCT_tab5
[
16
]
=
{
{
0
,
40
,
15
},
{
0
,
39
,
15
},
{
0
,
38
,
15
},
{
0
,
37
,
15
},
{
0
,
36
,
15
},
{
0
,
35
,
15
},
{
0
,
34
,
15
},
{
0
,
33
,
15
},
...
...
@@ -350,7 +342,7 @@ dct_lookup_t pl_DCT_tab5[16] =
/* Table B-14/15, DCT coefficients table zero / one,
* codes 0000000000010000 ... 0000000000011111
*/
dct_lookup_t
pl_DCT_tab6
[
16
]
=
static
dct_lookup_t
pl_DCT_tab6
[
16
]
=
{
{
1
,
18
,
16
},
{
1
,
17
,
16
},
{
1
,
16
,
16
},
{
1
,
15
,
16
},
{
6
,
3
,
16
},
{
16
,
2
,
16
},
{
15
,
2
,
16
},
{
14
,
2
,
16
},
...
...
@@ -392,7 +384,7 @@ void vpar_InitCrop( vpar_thread_t * p_vpar )
*****************************************************************************/
/* Function for filling up the lookup table for mb_addr_inc */
void
__inline__
FillMbAddrIncTable
(
vpar_thread_t
*
p_vpar
,
static
void
__inline__
FillMbAddrIncTable
(
vpar_thread_t
*
p_vpar
,
int
i_start
,
int
i_end
,
int
i_step
,
int
*
pi_value
,
int
i_length
)
{
...
...
@@ -574,6 +566,159 @@ void vpar_InitDCTTables( vpar_thread_t * p_vpar )
* Macroblock parsing functions
*/
/*****************************************************************************
* InitMacroblock : Initialize macroblock values
*****************************************************************************/
static
__inline__
void
InitMacroblock
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
)
{
static
f_chroma_motion_t
pf_chroma_motion
[
4
]
=
{
NULL
,
vdec_Motion420
,
vdec_Motion422
,
vdec_Motion444
};
p_mb
->
p_picture
=
p_vpar
->
picture
.
p_picture
;
p_mb
->
i_structure
=
p_vpar
->
picture
.
i_structure
;
p_mb
->
i_current_structure
=
p_vpar
->
picture
.
i_current_structure
;
p_mb
->
i_l_x
=
p_vpar
->
mb
.
i_l_x
;
p_mb
->
i_l_y
=
p_vpar
->
mb
.
i_l_y
;
p_mb
->
i_c_x
=
p_vpar
->
mb
.
i_c_x
;
p_mb
->
i_c_y
=
p_vpar
->
mb
.
i_c_y
;
p_mb
->
i_chroma_nb_blocks
=
p_vpar
->
sequence
.
i_chroma_nb_blocks
;
p_mb
->
pf_chroma_motion
=
pf_chroma_motion
[
p_vpar
->
sequence
.
i_chroma_format
];
p_mb
->
b_P_coding_type
=
(
p_vpar
->
picture
.
i_coding_type
==
P_CODING_TYPE
);
p_mb
->
p_forward
=
p_vpar
->
sequence
.
p_forward
;
p_mb
->
p_backward
=
p_vpar
->
sequence
.
p_backward
;
p_mb
->
i_addb_l_stride
=
p_mb
->
i_l_stride
=
p_vpar
->
picture
.
i_l_stride
;
p_mb
->
i_addb_c_stride
=
p_mb
->
i_c_stride
=
p_vpar
->
picture
.
i_c_stride
;
/* Update macroblock real position. */
p_vpar
->
mb
.
i_l_x
+=
16
;
p_vpar
->
mb
.
i_l_y
+=
(
p_vpar
->
mb
.
i_l_x
/
p_vpar
->
sequence
.
i_width
)
*
(
2
-
p_vpar
->
picture
.
b_frame_structure
)
*
16
;
p_vpar
->
mb
.
i_l_x
%=
p_vpar
->
sequence
.
i_width
;
p_vpar
->
mb
.
i_c_x
+=
p_vpar
->
sequence
.
i_chroma_mb_width
;
p_vpar
->
mb
.
i_c_y
+=
(
p_vpar
->
mb
.
i_c_x
/
p_vpar
->
sequence
.
i_chroma_width
)
*
(
2
-
p_vpar
->
picture
.
b_frame_structure
)
*
p_vpar
->
sequence
.
i_chroma_mb_height
;
p_vpar
->
mb
.
i_c_x
%=
p_vpar
->
sequence
.
i_chroma_width
;
}
/*****************************************************************************
* MacroblockAddressIncrement : Get the macroblock_address_increment field
*****************************************************************************/
static
__inline__
int
MacroblockAddressIncrement
(
vpar_thread_t
*
p_vpar
)
{
int
i_addr_inc
=
0
;
/* Index in the lookup table mb_addr_inc */
int
i_index
=
ShowBits
(
&
p_vpar
->
bit_stream
,
11
);
/* Test the presence of the escape character */
while
(
i_index
==
8
)
{
RemoveBits
(
&
p_vpar
->
bit_stream
,
11
);
i_addr_inc
+=
33
;
i_index
=
ShowBits
(
&
p_vpar
->
bit_stream
,
11
);
}
/* Affect the value from the lookup table */
i_addr_inc
+=
p_vpar
->
pl_mb_addr_inc
[
i_index
].
i_value
;
/* Dump the good number of bits */
RemoveBits
(
&
p_vpar
->
bit_stream
,
p_vpar
->
pl_mb_addr_inc
[
i_index
].
i_length
);
return
i_addr_inc
;
}
/*****************************************************************************
* MacroblockModes : Get the macroblock_modes structure
*****************************************************************************/
static
__inline__
void
MacroblockModes
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
)
{
static
f_motion_t
pf_motion
[
2
][
4
]
=
{
{
NULL
,
vdec_FieldFieldRecon
,
vdec_Field16x8Recon
,
vdec_FieldDMVRecon
},
{
NULL
,
vdec_FrameFieldRecon
,
vdec_FrameFrameRecon
,
vdec_FrameDMVRecon
}
};
static
int
ppi_mv_count
[
2
][
4
]
=
{
{
0
,
1
,
2
,
1
},
{
0
,
2
,
1
,
1
}
};
static
int
ppi_mv_format
[
2
][
4
]
=
{
{
0
,
1
,
1
,
1
},
{
0
,
1
,
2
,
1
}
};
/* Get macroblock_type. */
p_vpar
->
mb
.
i_mb_type
=
(
p_vpar
->
picture
.
pf_macroblock_type
)(
p_vpar
);
p_mb
->
i_mb_type
=
p_vpar
->
mb
.
i_mb_type
;
//fprintf( stderr, "MB type : %d\n", p_mb->i_mb_type );
/* SCALABILITY : warning, we don't know if spatial_temporal_weight_code
* has to be dropped, take care if you use scalable streams. */
/* RemoveBits( &p_vpar->bit_stream, 2 ); */
if
(
!
(
p_vpar
->
mb
.
i_mb_type
&
(
MB_MOTION_FORWARD
|
MB_MOTION_BACKWARD
))
)
{
/* If mb_type has neither MOTION_FORWARD nor MOTION_BACKWARD, this
* is useless, but also harmless. */
p_vpar
->
mb
.
i_motion_type
=
MOTION_FRAME
;
}
else
{
if
(
p_vpar
->
picture
.
i_structure
==
FRAME_STRUCTURE
&&
p_vpar
->
picture
.
b_frame_pred_frame_dct
)
{
p_vpar
->
mb
.
i_motion_type
=
MOTION_FRAME
;
}
else
{
p_vpar
->
mb
.
i_motion_type
=
GetBits
(
&
p_vpar
->
bit_stream
,
2
);
}
}
if
(
p_mb
->
b_P_coding_type
&&
!
(
p_vpar
->
mb
.
i_mb_type
&
(
MB_MOTION_FORWARD
|
MB_INTRA
))
)
{
/* Special No-MC macroblock in P pictures (7.6.3.5). */
memset
(
p_vpar
->
slice
.
pppi_pmv
,
0
,
8
*
sizeof
(
int
)
);
memset
(
p_mb
->
pppi_motion_vectors
,
0
,
8
*
sizeof
(
int
)
);
p_vpar
->
mb
.
i_motion_type
=
MOTION_FRAME
;
p_mb
->
ppi_field_select
[
0
][
0
]
=
(
p_vpar
->
picture
.
i_current_structure
==
BOTTOM_FIELD
);
}
if
(
p_vpar
->
mb
.
i_mb_type
&
MB_INTRA
)
{
/* For the intra macroblocks, we use an empty motion
* compensation function */
p_mb
->
pf_motion
=
vdec_DummyRecon
;
}
else
{
p_mb
->
pf_motion
=
pf_motion
[
p_vpar
->
picture
.
b_frame_structure
]
[
p_vpar
->
mb
.
i_motion_type
];
}
p_vpar
->
mb
.
i_mv_count
=
ppi_mv_count
[
p_vpar
->
picture
.
b_frame_structure
]
[
p_vpar
->
mb
.
i_motion_type
];
p_vpar
->
mb
.
i_mv_format
=
ppi_mv_format
[
p_vpar
->
picture
.
b_frame_structure
]
[
p_vpar
->
mb
.
i_motion_type
];
p_vpar
->
mb
.
b_dct_type
=
0
;
if
(
(
p_vpar
->
picture
.
i_structure
==
FRAME_STRUCTURE
)
&&
(
!
p_vpar
->
picture
.
b_frame_pred_frame_dct
)
&&
(
p_vpar
->
mb
.
i_mb_type
&
(
MB_PATTERN
|
MB_INTRA
))
)
{
if
(
(
p_vpar
->
mb
.
b_dct_type
=
GetBits
(
&
p_vpar
->
bit_stream
,
1
))
)
{
/* The DCT is coded on fields. Jump one line between each
* sample. */
p_mb
->
i_addb_l_stride
<<=
1
;
p_mb
->
i_addb_l_stride
+=
8
;
/* With CHROMA_420, the DCT is necessarily frame-coded. */
if
(
p_vpar
->
sequence
.
i_chroma_format
!=
CHROMA_420
)
{
p_mb
->
i_addb_c_stride
<<=
1
;
p_mb
->
i_addb_c_stride
+=
8
;
}
}
}
p_vpar
->
mb
.
b_dmv
=
p_vpar
->
mb
.
i_motion_type
==
MOTION_DMV
;
}
/*****************************************************************************
* vpar_ParseMacroblock : Parse the next macroblock
...
...
@@ -646,7 +791,7 @@ fprintf(stderr, "Skipped macroblock !\n");
if
(
p_vpar
->
picture
.
i_coding_type
==
P_CODING_TYPE
)
{
/* Reset motion vector predictors (ISO/IEC 13818-2 7.6.3.4). */
bzero
(
p_vpar
->
slice
.
pppi_pmv
,
8
*
sizeof
(
int
)
);
memset
(
p_vpar
->
slice
.
pppi_pmv
,
0
,
8
*
sizeof
(
int
)
);
}
if
(
(
p_mb
=
p_vpar
->
picture
.
pp_mb
[
i_mb_base
+
i_mb
]
=
...
...
@@ -673,7 +818,7 @@ fprintf(stderr, "Skipped macroblock !\n");
p_mb
->
ppi_field_select
[
0
][
0
]
=
p_mb
->
ppi_field_select
[
0
][
1
]
=
(
p_vpar
->
picture
.
i_current_structure
==
BOTTOM_FIELD
);
}
//fprintf(stderr, "MB1\n");
/* Get a macroblock structure. */
if
(
(
p_mb
=
p_vpar
->
picture
.
pp_mb
[
i_mb_base
+
*
pi_mb_address
]
=
vpar_NewMacroblock
(
&
p_vpar
->
vfifo
))
==
NULL
)
...
...
@@ -727,7 +872,7 @@ fprintf( stderr, "motion2 !\n" );
/*
* Effectively decode blocks.
*/
//fprintf(stderr, "MB2\n");
i_mask
=
1
<<
(
3
+
p_vpar
->
sequence
.
i_chroma_nb_blocks
);
/* luminance */
...
...
@@ -738,7 +883,7 @@ fprintf( stderr, "motion2 !\n" );
{
if
(
p_vpar
->
mb
.
i_coded_block_pattern
&
i_mask
)
{
memset
(
p_mb
->
ppi_blocks
[
i_b
],
0
,
64
*
sizeof
(
elem_t
)
);
memset
(
p_mb
->
ppi_blocks
[
i_b
],
0
,
64
*
sizeof
(
dct
elem_t
)
);
(
*
pppf_decode_block
[
p_vpar
->
sequence
.
b_mpeg2
]
[
p_vpar
->
mb
.
i_mb_type
&
MB_INTRA
])
(
p_vpar
,
p_mb
,
i_b
);
...
...
@@ -761,10 +906,6 @@ fprintf( stderr, "motion2 !\n" );
}
/* chrominance */
//fprintf(stderr, "%d ", p_mb->i_c_x
// + p_mb->i_c_y
// * (p_vpar->sequence.i_chroma_width));
p_data1
=
p_mb
->
p_picture
->
p_u
+
p_mb
->
i_c_x
+
p_mb
->
i_c_y
...
...
@@ -781,7 +922,7 @@ fprintf( stderr, "motion2 !\n" );
if
(
p_vpar
->
mb
.
i_coded_block_pattern
&
i_mask
)
{
memset
(
p_mb
->
ppi_blocks
[
i_b
],
0
,
64
*
sizeof
(
elem_t
)
);
memset
(
p_mb
->
ppi_blocks
[
i_b
],
0
,
64
*
sizeof
(
dct
elem_t
)
);
(
*
pppf_decode_block
[
p_vpar
->
sequence
.
b_mpeg2
]
[
p_vpar
->
mb
.
i_mb_type
&
MB_INTRA
])
(
p_vpar
,
p_mb
,
i_b
);
...
...
@@ -815,7 +956,7 @@ fprintf( stderr, "motion2 !\n" );
else
if
(
!
p_vpar
->
picture
.
b_concealment_mv
)
{
/* Reset MV predictors. */
bzero
(
p_vpar
->
slice
.
pppi_pmv
,
8
*
sizeof
(
int
)
);
memset
(
p_vpar
->
slice
.
pppi_pmv
,
0
,
8
*
sizeof
(
int
)
);
}
if
(
0
)
//i_count == 249)
...
...
@@ -835,161 +976,6 @@ fprintf( stderr, "motion2 !\n" );
}
}
/*****************************************************************************
* InitMacroblock : Initialize macroblock values
*****************************************************************************/
static
__inline__
void
InitMacroblock
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
)
{
static
f_chroma_motion_t
pf_chroma_motion
[
4
]
=
{
NULL
,
vdec_Motion420
,
vdec_Motion422
,
vdec_Motion444
};
p_mb
->
p_picture
=
p_vpar
->
picture
.
p_picture
;
p_mb
->
i_structure
=
p_vpar
->
picture
.
i_structure
;
p_mb
->
i_current_structure
=
p_vpar
->
picture
.
i_current_structure
;
p_mb
->
i_l_x
=
p_vpar
->
mb
.
i_l_x
;
p_mb
->
i_l_y
=
p_vpar
->
mb
.
i_l_y
;
p_mb
->
i_c_x
=
p_vpar
->
mb
.
i_c_x
;
p_mb
->
i_c_y
=
p_vpar
->
mb
.
i_c_y
;
p_mb
->
i_chroma_nb_blocks
=
p_vpar
->
sequence
.
i_chroma_nb_blocks
;
p_mb
->
pf_chroma_motion
=
pf_chroma_motion
[
p_vpar
->
sequence
.
i_chroma_format
];
p_mb
->
b_P_coding_type
=
(
p_vpar
->
picture
.
i_coding_type
==
P_CODING_TYPE
);
p_mb
->
p_forward
=
p_vpar
->
sequence
.
p_forward
;
p_mb
->
p_backward
=
p_vpar
->
sequence
.
p_backward
;
p_mb
->
i_addb_l_stride
=
p_mb
->
i_l_stride
=
p_vpar
->
picture
.
i_l_stride
;
p_mb
->
i_addb_c_stride
=
p_mb
->
i_c_stride
=
p_vpar
->
picture
.
i_c_stride
;
/* Update macroblock real position. */
p_vpar
->
mb
.
i_l_x
+=
16
;
p_vpar
->
mb
.
i_l_y
+=
(
p_vpar
->
mb
.
i_l_x
/
p_vpar
->
sequence
.
i_width
)
*
(
2
-
p_vpar
->
picture
.
b_frame_structure
)
*
16
;
p_vpar
->
mb
.
i_l_x
%=
p_vpar
->
sequence
.
i_width
;
p_vpar
->
mb
.
i_c_x
+=
p_vpar
->
sequence
.
i_chroma_mb_width
;
p_vpar
->
mb
.
i_c_y
+=
(
p_vpar
->
mb
.
i_c_x
/
p_vpar
->
sequence
.
i_chroma_width
)
*
(
2
-
p_vpar
->
picture
.
b_frame_structure
)
*
p_vpar
->
sequence
.
i_chroma_mb_height
;
p_vpar
->
mb
.
i_c_x
%=
p_vpar
->
sequence
.
i_chroma_width
;
}
/*****************************************************************************
* MacroblockAddressIncrement : Get the macroblock_address_increment field
*****************************************************************************/
static
__inline__
int
MacroblockAddressIncrement
(
vpar_thread_t
*
p_vpar
)
{
int
i_addr_inc
=
0
;
/* Index in the lookup table mb_addr_inc */
int
i_index
=
ShowBits
(
&
p_vpar
->
bit_stream
,
11
);
/* Test the presence of the escape character */
while
(
i_index
==
8
)
{
RemoveBits
(
&
p_vpar
->
bit_stream
,
11
);
i_addr_inc
+=
33
;
i_index
=
ShowBits
(
&
p_vpar
->
bit_stream
,
11
);
}
/* Affect the value from the lookup table */
i_addr_inc
+=
p_vpar
->
pl_mb_addr_inc
[
i_index
].
i_value
;
/* Dump the good number of bits */
RemoveBits
(
&
p_vpar
->
bit_stream
,
p_vpar
->
pl_mb_addr_inc
[
i_index
].
i_length
);
return
i_addr_inc
;
}
/*****************************************************************************
* MacroblockModes : Get the macroblock_modes structure
*****************************************************************************/
static
__inline__
void
MacroblockModes
(
vpar_thread_t
*
p_vpar
,
macroblock_t
*
p_mb
)
{
static
f_motion_t
pf_motion
[
2
][
4
]
=
{
{
NULL
,
vdec_FieldFieldRecon
,
vdec_Field16x8Recon
,
vdec_FieldDMVRecon
},
{
NULL
,
vdec_FrameFieldRecon
,
vdec_FrameFrameRecon
,
vdec_FrameDMVRecon
}
};
static
int
ppi_mv_count
[
2
][
4
]
=
{
{
0
,
1
,
2
,
1
},
{
0
,
2
,
1
,
1
}
};
static
int
ppi_mv_format
[
2
][
4
]
=
{
{
0
,
1
,
1
,
1
},
{
0
,
1
,
2
,
1
}
};
/* Get macroblock_type. */
p_vpar
->
mb
.
i_mb_type
=
(
p_vpar
->
picture
.
pf_macroblock_type
)(
p_vpar
);
p_mb
->
i_mb_type
=
p_vpar
->
mb
.
i_mb_type
;
//fprintf( stderr, "MB type : %d\n", p_mb->i_mb_type );
/* SCALABILITY : warning, we don't know if spatial_temporal_weight_code
* has to be dropped, take care if you use scalable streams. */
/* RemoveBits( &p_vpar->bit_stream, 2 ); */
if
(
!
(
p_vpar
->
mb
.
i_mb_type
&
(
MB_MOTION_FORWARD
|
MB_MOTION_BACKWARD
))
)
{
/* If mb_type has neither MOTION_FORWARD nor MOTION_BACKWARD, this
* is useless, but also harmless. */
p_vpar
->
mb
.
i_motion_type
=
MOTION_FRAME
;
}
else
{
if
(
p_vpar
->
picture
.
i_structure
==
FRAME_STRUCTURE
&&
p_vpar
->
picture
.
b_frame_pred_frame_dct
)
{
p_vpar
->
mb
.
i_motion_type
=
MOTION_FRAME
;
}
else
{
p_vpar
->
mb
.
i_motion_type
=
GetBits
(
&
p_vpar
->
bit_stream
,
2
);
}
}
if
(
p_mb
->
b_P_coding_type
&&
!
(
p_vpar
->
mb
.
i_mb_type
&
(
MB_MOTION_FORWARD
|
MB_INTRA
))
)
{
/* Special No-MC macroblock in P pictures (7.6.3.5). */
memset
(
p_vpar
->
slice
.
pppi_pmv
,
0
,
8
*
sizeof
(
int
)
);
memset
(
p_mb
->
pppi_motion_vectors
,
0
,
8
*
sizeof
(
int
)
);
p_vpar
->
mb
.
i_motion_type
=
MOTION_FRAME
;
p_mb
->
ppi_field_select
[
0
][
0
]
=
(
p_vpar
->
picture
.
i_current_structure
==
BOTTOM_FIELD
);
}
if
(
p_vpar
->
mb
.
i_mb_type
&
MB_INTRA
)
{
/* For the intra macroblocks, we use an empty motion
* compensation function */
p_mb
->
pf_motion
=
vdec_DummyRecon
;
}
else
{
p_mb
->
pf_motion
=
pf_motion
[
p_vpar
->
picture
.
b_frame_structure
]
[
p_vpar
->
mb
.
i_motion_type
];
}
p_vpar
->
mb
.
i_mv_count
=
ppi_mv_count
[
p_vpar
->
picture
.
b_frame_structure
]
[
p_vpar
->
mb
.
i_motion_type
];
p_vpar
->
mb
.
i_mv_format
=
ppi_mv_format
[
p_vpar
->
picture
.
b_frame_structure
]
[
p_vpar
->
mb
.
i_motion_type
];
p_vpar
->
mb
.
b_dct_type
=
0
;
if
(
(
p_vpar
->
picture
.
i_structure
==
FRAME_STRUCTURE
)
&&
(
!
p_vpar
->
picture
.
b_frame_pred_frame_dct
)
&&
(
p_vpar
->
mb
.
i_mb_type
&
(
MB_PATTERN
|
MB_INTRA
))
)
{
if
(
(
p_vpar
->
mb
.
b_dct_type
=
GetBits
(
&
p_vpar
->
bit_stream
,
1
))
)
{
/* The DCT is coded on fields. Jump one line between each
* sample. */
p_mb
->
i_addb_l_stride
<<=
1
;
p_mb
->
i_addb_l_stride
+=
8
;
/* With CHROMA_420, the DCT is necessarily frame-coded. */
if
(
p_vpar
->
sequence
.
i_chroma_format
!=
CHROMA_420
)
{
p_mb
->
i_addb_c_stride
<<=
1
;
p_mb
->
i_addb_c_stride
+=
8
;
}
}
}
p_vpar
->
mb
.
b_dmv
=
p_vpar
->
mb
.
i_motion_type
==
MOTION_DMV
;
}
/*****************************************************************************
* vpar_IMBType : macroblock_type in I pictures
*****************************************************************************/
...
...
src/video_parser/vpar_headers.c
View file @
b9dc0c52
...
...
@@ -238,8 +238,6 @@ static __inline__ void LoadMatrix( vpar_thread_t * p_vpar, quant_matrix_t * p_ma
*****************************************************************************/
static
__inline__
void
LinkMatrix
(
quant_matrix_t
*
p_matrix
,
int
*
pi_array
)
{
int
i_dummy
;
if
(
p_matrix
->
b_allocated
)
{
/* Deallocate the piece of memory. */
...
...
@@ -280,16 +278,12 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar )
switch
(
GetBits32
(
&
p_vpar
->
bit_stream
)
)
{
case
SEQUENCE_HEADER_CODE
:
fprintf
(
stderr
,
"begin sequence header
\n
"
);
SequenceHeader
(
p_vpar
);
fprintf
(
stderr
,
"end sequence header
\n
"
);
return
0
;
break
;
case
GROUP_START_CODE
:
fprintf
(
stderr
,
"begin group
\n
"
);
GroupHeader
(
p_vpar
);
fprintf
(
stderr
,
"end group
\n
"
);
return
0
;
break
;
...
...
@@ -299,7 +293,7 @@ int vpar_ParseHeader( vpar_thread_t * p_vpar )
break
;
case
SEQUENCE_END_CODE
:
fprintf
(
stderr
,
"sequence header end code
\n
"
);
intf_DbgMsg
(
"vpar debug: sequence end code received
\n
"
);
return
1
;
break
;
...
...
@@ -517,7 +511,6 @@ static void PictureHeader( vpar_thread_t * p_vpar )
int
i_structure
;
int
i_mb_address
,
i_mb_base
,
i_mb
;
elem_t
*
p_y
,
p_u
,
p_v
;
boolean_t
b_parsable
;
u32
i_dummy
;
...
...
@@ -659,7 +652,6 @@ static void PictureHeader( vpar_thread_t * p_vpar )
return
;
}
fprintf
(
stderr
,
"begin picture
\n
"
);
/* OK, now we are sure we will decode the picture. */
#define P_picture p_vpar->picture.p_picture
...
...
@@ -679,7 +671,7 @@ static void PictureHeader( vpar_thread_t * p_vpar )
p_vpar
->
b_error
=
1
;
return
;
}
bzero
(
P_picture
->
p_data
,
940032
);
/* Initialize values. */
P_picture
->
date
=
vpar_SynchroDecode
(
p_vpar
,
p_vpar
->
picture
.
i_coding_type
,
...
...
@@ -689,6 +681,9 @@ bzero( P_picture->p_data, 940032 );
p_vpar
->
picture
.
i_c_stride
=
-
8
+
(
p_vpar
->
sequence
.
i_chroma_width
<<
(
1
-
p_vpar
->
picture
.
b_frame_structure
));
P_picture
->
i_deccount
=
p_vpar
->
sequence
.
i_mb_size
;
memset
(
p_vpar
->
picture
.
pp_mb
,
0
,
MAX_MB
);
/* Update the reference pointers. */
ReferenceUpdate
(
p_vpar
,
p_vpar
->
picture
.
i_coding_type
,
P_picture
);
}
...
...
@@ -723,7 +718,7 @@ bzero( P_picture->p_data, 940032 );
<
SLICE_START_CODE_MIN
)
||
(
i_dummy
>
SLICE_START_CODE_MAX
)
)
{
intf_DbgMsg
(
"vpar debug: premature end of picture"
);
intf_DbgMsg
(
"vpar debug: premature end of picture
\n
"
);
p_vpar
->
picture
.
b_error
=
1
;
break
;
}
...
...
@@ -737,13 +732,13 @@ bzero( P_picture->p_data, 940032 );
{
/* Trash picture. */
fprintf
(
stderr
,
"Image trashee
\n
"
);
for
(
i_mb
=
0
;
p_vpar
->
picture
.
pp_mb
[
i_mb
];
i_mb
++
)
for
(
i_mb
=
1
;
p_vpar
->
picture
.
pp_mb
[
i_mb
];
i_mb
++
)
{
vpar_DestroyMacroblock
(
&
p_vpar
->
vfifo
,
p_vpar
->
picture
.
pp_mb
[
i_mb
]
);
}
vout_DestroyPicture
(
p_vpar
->
p_vout
,
p_vpar
->
picture
.
p_picture
);
ReferenceReplace
(
p_vpar
,
p_vpar
->
picture
.
i_coding_type
,
NULL
);
vout_DestroyPicture
(
p_vpar
->
p_vout
,
P_picture
);
/* Prepare context for the next picture. */
P_picture
=
NULL
;
...
...
@@ -754,8 +749,7 @@ fprintf(stderr, "Image trashee\n");
{
fprintf
(
stderr
,
"Image parsee
\n
"
);
/* Frame completely parsed. */
P_picture
->
i_deccount
=
p_vpar
->
sequence
.
i_mb_size
;
for
(
i_mb
=
0
;
i_mb
<
p_vpar
->
sequence
.
i_mb_size
;
i_mb
++
)
for
(
i_mb
=
1
;
p_vpar
->
picture
.
pp_mb
[
i_mb
];
i_mb
++
)
{
vpar_DecodeMacroblock
(
&
p_vpar
->
vfifo
,
p_vpar
->
picture
.
pp_mb
[
i_mb
]
);
}
...
...
@@ -773,7 +767,9 @@ fprintf(stderr, "Image parsee\n");
}
#endif
/* Send signal to the video_decoder. */
vlc_mutex_lock
(
&
p_vpar
->
vfifo
.
lock
);
vlc_cond_signal
(
&
p_vpar
->
vfifo
.
wait
);
vlc_mutex_unlock
(
&
p_vpar
->
vfifo
.
lock
);
/* Prepare context for the next picture. */
P_picture
=
NULL
;
...
...
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