Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
ce5b7c5e
Commit
ce5b7c5e
authored
Oct 02, 2002
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sliced mode for mpeg1/2
Originally committed as revision 991 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
acf44abb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
44 deletions
+76
-44
mpeg12.c
libavcodec/mpeg12.c
+76
-44
No files found.
libavcodec/mpeg12.c
View file @
ce5b7c5e
...
...
@@ -674,39 +674,6 @@ static int mpeg_decode_mb(MpegEncContext *s,
{
int
i
,
j
,
k
,
cbp
,
val
,
code
,
mb_type
,
motion_type
;
/* skip mb handling */
if
(
s
->
mb_incr
==
0
)
{
/* read again increment */
s
->
mb_incr
=
1
;
for
(;;)
{
code
=
get_vlc2
(
&
s
->
gb
,
mbincr_vlc
.
table
,
MBINCR_VLC_BITS
,
2
);
if
(
code
<
0
)
return
1
;
/* error = end of slice */
if
(
code
>=
33
)
{
if
(
code
==
33
)
{
s
->
mb_incr
+=
33
;
}
/* otherwise, stuffing, nothing to do */
}
else
{
s
->
mb_incr
+=
code
;
break
;
}
}
}
if
(
s
->
mb_x
==-
1
/* first MB in a slice */
&&
s
->
mb_incr
>
1
){
s
->
mb_x
+=
(
s
->
mb_incr
-
1
)
%
s
->
mb_width
;
s
->
mb_y
+=
(
s
->
mb_incr
-
1
)
/
s
->
mb_width
;
s
->
mb_incr
=
1
;
}
if
(
++
s
->
mb_x
>=
s
->
mb_width
)
{
s
->
mb_x
=
0
;
if
(
s
->
mb_y
>=
(
s
->
mb_height
-
1
)){
fprintf
(
stderr
,
"slice too long
\n
"
);
return
-
1
;
}
s
->
mb_y
++
;
}
dprintf
(
"decode_mb: x=%d y=%d
\n
"
,
s
->
mb_x
,
s
->
mb_y
);
if
(
--
s
->
mb_incr
!=
0
)
{
...
...
@@ -1585,9 +1552,6 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s
->
last_dc
[
1
]
=
s
->
last_dc
[
0
];
s
->
last_dc
[
2
]
=
s
->
last_dc
[
0
];
memset
(
s
->
last_mv
,
0
,
sizeof
(
s
->
last_mv
));
s
->
mb_x
=
-
1
;
s
->
mb_y
=
start_code
;
s
->
mb_incr
=
0
;
/* start frame decoding */
if
(
s
->
first_slice
)
{
s
->
first_slice
=
0
;
...
...
@@ -1602,27 +1566,95 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
skip_bits
(
&
s
->
gb
,
8
);
}
s
->
mb_x
=
0
;
for
(;;)
{
int
code
=
get_vlc2
(
&
s
->
gb
,
mbincr_vlc
.
table
,
MBINCR_VLC_BITS
,
2
);
if
(
code
<
0
)
return
-
1
;
/* error = end of slice, but empty slice is bad or?*/
if
(
code
>=
33
)
{
if
(
code
==
33
)
{
s
->
mb_x
+=
33
;
}
/* otherwise, stuffing, nothing to do */
}
else
{
s
->
mb_x
+=
code
;
break
;
}
}
s
->
mb_y
=
start_code
;
s
->
mb_incr
=
1
;
for
(;;)
{
clear_blocks
(
s
->
block
[
0
]);
emms_c
();
ret
=
mpeg_decode_mb
(
s
,
s
->
block
);
dprintf
(
"ret=%d
\n
"
,
ret
);
if
(
ret
<
0
)
return
-
1
;
if
(
ret
==
1
)
break
;
if
(
s
->
mb_x
==
0
)
MPV_decode_mb
(
s
,
s
->
block
);
if
(
++
s
->
mb_x
>=
s
->
mb_width
)
{
if
(
avctx
->
draw_horiz_band
&&
(
s
->
num_available_buffers
>=
1
||
(
!
s
->
has_b_frames
))
)
{
UINT8
*
src_ptr
[
3
];
int
y
,
h
,
offset
;
y
=
s
->
mb_y
*
16
;
h
=
s
->
height
-
y
;
if
(
h
>
16
)
h
=
16
;
offset
=
y
*
s
->
linesize
;
if
(
s
->
pict_type
==
B_TYPE
||
(
!
s
->
has_b_frames
)){
src_ptr
[
0
]
=
s
->
current_picture
[
0
]
+
offset
;
src_ptr
[
1
]
=
s
->
current_picture
[
1
]
+
(
offset
>>
2
);
src_ptr
[
2
]
=
s
->
current_picture
[
2
]
+
(
offset
>>
2
);
}
else
{
src_ptr
[
0
]
=
s
->
last_picture
[
0
]
+
offset
;
src_ptr
[
1
]
=
s
->
last_picture
[
1
]
+
(
offset
>>
2
);
src_ptr
[
2
]
=
s
->
last_picture
[
2
]
+
(
offset
>>
2
);
}
avctx
->
draw_horiz_band
(
avctx
,
src_ptr
,
s
->
linesize
,
y
,
s
->
width
,
h
);
}
s
->
mb_x
=
0
;
s
->
mb_y
++
;
PRINT_QP
(
"%s"
,
"
\n
"
);
}
PRINT_QP
(
"%2d"
,
s
->
qscale
);
MPV_decode_mb
(
s
,
s
->
block
);
/* skip mb handling */
if
(
s
->
mb_incr
==
0
)
{
/* read again increment */
s
->
mb_incr
=
1
;
for
(;;)
{
int
code
=
get_vlc2
(
&
s
->
gb
,
mbincr_vlc
.
table
,
MBINCR_VLC_BITS
,
2
);
if
(
code
<
0
)
goto
eos
;
/* error = end of slice */
if
(
code
>=
33
)
{
if
(
code
==
33
)
{
s
->
mb_incr
+=
33
;
}
/* otherwise, stuffing, nothing to do */
}
else
{
s
->
mb_incr
+=
code
;
break
;
}
}
}
if
(
s
->
mb_y
>=
s
->
mb_height
){
fprintf
(
stderr
,
"slice too long
\n
"
);
return
-
1
;
}
}
eos:
//end of slice
emms_c
();
/* end of slice reached */
if
(
s
->
mb_x
==
(
s
->
mb_width
-
1
)
&&
s
->
mb_y
==
(
s
->
mb_height
-
1
)
)
{
if
(
/*s->mb_x == 0 &&*/
s
->
mb_y
==
s
->
mb_height
)
{
/* end of image */
UINT8
**
picture
;
...
...
@@ -1921,5 +1953,5 @@ AVCodec mpeg_decoder = {
NULL
,
mpeg_decode_end
,
mpeg_decode_frame
,
CODEC_CAP_DR1
,
CODEC_CAP_DR
AW_HORIZ_BAND
|
CODEC_CAP_DR
1
,
};
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