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
a0db7424
Commit
a0db7424
authored
Apr 28, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix buffering in qpeg in a way that allows direct rendering.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
183401b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
qpeg.c
libavcodec/qpeg.c
+17
-12
No files found.
libavcodec/qpeg.c
View file @
a0db7424
...
...
@@ -28,8 +28,7 @@
typedef
struct
QpegContext
{
AVCodecContext
*
avctx
;
AVFrame
pic
;
uint8_t
*
refdata
;
AVFrame
pic
,
ref
;
uint32_t
pal
[
256
];
}
QpegContext
;
...
...
@@ -124,9 +123,12 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size,
int
filled
=
0
;
int
orig_height
;
if
(
!
refdata
)
refdata
=
dst
;
/* copy prev frame */
for
(
i
=
0
;
i
<
height
;
i
++
)
memcpy
(
refdata
+
(
i
*
width
),
dst
+
(
i
*
stride
),
width
);
memcpy
(
dst
+
(
i
*
stride
),
refdata
+
(
i
*
stride
),
width
);
orig_height
=
height
;
height
--
;
...
...
@@ -172,10 +174,10 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size,
me_x
,
me_y
,
me_w
,
me_h
,
filled
,
height
);
else
{
/* do motion compensation */
me_plane
=
refdata
+
(
filled
+
me_x
)
+
(
height
-
me_y
)
*
width
;
me_plane
=
refdata
+
(
filled
+
me_x
)
+
(
height
-
me_y
)
*
stride
;
for
(
j
=
0
;
j
<
me_h
;
j
++
)
{
for
(
i
=
0
;
i
<
me_w
;
i
++
)
dst
[
filled
+
i
-
(
j
*
stride
)]
=
me_plane
[
i
-
(
j
*
width
)];
dst
[
filled
+
i
-
(
j
*
stride
)]
=
me_plane
[
i
-
(
j
*
stride
)];
}
}
}
...
...
@@ -254,15 +256,17 @@ static int decode_frame(AVCodecContext *avctx,
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
QpegContext
*
const
a
=
avctx
->
priv_data
;
AVFrame
*
const
p
=
(
AVFrame
*
)
&
a
->
pic
;
AVFrame
*
p
=
(
AVFrame
*
)
&
a
->
pic
;
AVFrame
*
ref
=
(
AVFrame
*
)
&
a
->
ref
;
uint8_t
*
outdata
;
int
delta
;
const
uint8_t
*
pal
=
av_packet_get_side_data
(
avpkt
,
AV_PKT_DATA_PALETTE
,
NULL
);
if
(
p
->
data
[
0
])
avctx
->
release_buffer
(
avctx
,
p
);
if
(
ref
->
data
[
0
])
avctx
->
release_buffer
(
avctx
,
ref
);
FFSWAP
(
AVFrame
,
*
ref
,
*
p
);
p
->
reference
=
0
;
p
->
reference
=
3
;
if
(
avctx
->
get_buffer
(
avctx
,
p
)
<
0
){
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
...
...
@@ -272,7 +276,7 @@ static int decode_frame(AVCodecContext *avctx,
qpeg_decode_intra
(
buf
+
0x86
,
outdata
,
buf_size
-
0x86
,
a
->
pic
.
linesize
[
0
],
avctx
->
width
,
avctx
->
height
);
}
else
{
delta
=
buf
[
0x85
];
qpeg_decode_inter
(
buf
+
0x86
,
outdata
,
buf_size
-
0x86
,
a
->
pic
.
linesize
[
0
],
avctx
->
width
,
avctx
->
height
,
delta
,
buf
+
4
,
a
->
ref
data
);
qpeg_decode_inter
(
buf
+
0x86
,
outdata
,
buf_size
-
0x86
,
a
->
pic
.
linesize
[
0
],
avctx
->
width
,
avctx
->
height
,
delta
,
buf
+
4
,
a
->
ref
.
data
[
0
]
);
}
/* make the palette available on the way out */
...
...
@@ -293,7 +297,6 @@ static av_cold int decode_init(AVCodecContext *avctx){
a
->
avctx
=
avctx
;
avctx
->
pix_fmt
=
PIX_FMT_PAL8
;
a
->
refdata
=
av_malloc
(
avctx
->
width
*
avctx
->
height
);
return
0
;
}
...
...
@@ -301,11 +304,13 @@ static av_cold int decode_init(AVCodecContext *avctx){
static
av_cold
int
decode_end
(
AVCodecContext
*
avctx
){
QpegContext
*
const
a
=
avctx
->
priv_data
;
AVFrame
*
const
p
=
(
AVFrame
*
)
&
a
->
pic
;
AVFrame
*
const
ref
=
(
AVFrame
*
)
&
a
->
ref
;
if
(
p
->
data
[
0
])
avctx
->
release_buffer
(
avctx
,
p
);
if
(
ref
->
data
[
0
])
avctx
->
release_buffer
(
avctx
,
ref
);
av_free
(
a
->
refdata
);
return
0
;
}
...
...
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