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
71c37898
Commit
71c37898
authored
Aug 21, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qtrle: make code independent of sizeof(AVFrame)
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
5c9d44d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
26 deletions
+28
-26
qtrle.c
libavcodec/qtrle.c
+28
-26
No files found.
libavcodec/qtrle.c
View file @
71c37898
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
typedef
struct
QtrleContext
{
typedef
struct
QtrleContext
{
AVCodecContext
*
avctx
;
AVCodecContext
*
avctx
;
AVFrame
frame
;
AVFrame
*
frame
;
GetByteContext
g
;
GetByteContext
g
;
uint32_t
pal
[
256
];
uint32_t
pal
[
256
];
...
@@ -58,10 +58,10 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
...
@@ -58,10 +58,10 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
{
{
int
rle_code
;
int
rle_code
;
int
pixel_ptr
;
int
pixel_ptr
;
int
row_inc
=
s
->
frame
.
linesize
[
0
];
int
row_inc
=
s
->
frame
->
linesize
[
0
];
uint8_t
pi0
,
pi1
;
/* 2 8-pixel values */
uint8_t
pi0
,
pi1
;
/* 2 8-pixel values */
uint8_t
*
rgb
=
s
->
frame
.
data
[
0
];
uint8_t
*
rgb
=
s
->
frame
->
data
[
0
];
int
pixel_limit
=
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
int
pixel_limit
=
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
int
skip
;
int
skip
;
/* skip & 0x80 appears to mean 'start a new line', which can be interpreted
/* skip & 0x80 appears to mean 'start a new line', which can be interpreted
* as 'go to next line' during the decoding of a frame but is 'go to first
* as 'go to next line' during the decoding of a frame but is 'go to first
...
@@ -121,10 +121,10 @@ static inline void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr,
...
@@ -121,10 +121,10 @@ static inline void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr,
{
{
int
rle_code
,
i
;
int
rle_code
,
i
;
int
pixel_ptr
;
int
pixel_ptr
;
int
row_inc
=
s
->
frame
.
linesize
[
0
];
int
row_inc
=
s
->
frame
->
linesize
[
0
];
uint8_t
pi
[
16
];
/* 16 palette indices */
uint8_t
pi
[
16
];
/* 16 palette indices */
uint8_t
*
rgb
=
s
->
frame
.
data
[
0
];
uint8_t
*
rgb
=
s
->
frame
->
data
[
0
];
int
pixel_limit
=
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
int
pixel_limit
=
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
int
num_pixels
=
(
bpp
==
4
)
?
8
:
16
;
int
num_pixels
=
(
bpp
==
4
)
?
8
:
16
;
while
(
lines_to_change
--
)
{
while
(
lines_to_change
--
)
{
...
@@ -177,10 +177,10 @@ static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
...
@@ -177,10 +177,10 @@ static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
{
{
int
rle_code
;
int
rle_code
;
int
pixel_ptr
;
int
pixel_ptr
;
int
row_inc
=
s
->
frame
.
linesize
[
0
];
int
row_inc
=
s
->
frame
->
linesize
[
0
];
uint8_t
pi1
,
pi2
,
pi3
,
pi4
;
/* 4 palette indexes */
uint8_t
pi1
,
pi2
,
pi3
,
pi4
;
/* 4 palette indexes */
uint8_t
*
rgb
=
s
->
frame
.
data
[
0
];
uint8_t
*
rgb
=
s
->
frame
->
data
[
0
];
int
pixel_limit
=
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
int
pixel_limit
=
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
while
(
lines_to_change
--
)
{
while
(
lines_to_change
--
)
{
pixel_ptr
=
row_ptr
+
(
4
*
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
));
pixel_ptr
=
row_ptr
+
(
4
*
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
));
...
@@ -226,10 +226,10 @@ static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change
...
@@ -226,10 +226,10 @@ static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change
{
{
int
rle_code
;
int
rle_code
;
int
pixel_ptr
;
int
pixel_ptr
;
int
row_inc
=
s
->
frame
.
linesize
[
0
];
int
row_inc
=
s
->
frame
->
linesize
[
0
];
uint16_t
rgb16
;
uint16_t
rgb16
;
uint8_t
*
rgb
=
s
->
frame
.
data
[
0
];
uint8_t
*
rgb
=
s
->
frame
->
data
[
0
];
int
pixel_limit
=
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
int
pixel_limit
=
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
while
(
lines_to_change
--
)
{
while
(
lines_to_change
--
)
{
pixel_ptr
=
row_ptr
+
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
)
*
2
;
pixel_ptr
=
row_ptr
+
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
)
*
2
;
...
@@ -270,10 +270,10 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change
...
@@ -270,10 +270,10 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change
{
{
int
rle_code
;
int
rle_code
;
int
pixel_ptr
;
int
pixel_ptr
;
int
row_inc
=
s
->
frame
.
linesize
[
0
];
int
row_inc
=
s
->
frame
->
linesize
[
0
];
uint8_t
r
,
g
,
b
;
uint8_t
r
,
g
,
b
;
uint8_t
*
rgb
=
s
->
frame
.
data
[
0
];
uint8_t
*
rgb
=
s
->
frame
->
data
[
0
];
int
pixel_limit
=
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
int
pixel_limit
=
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
while
(
lines_to_change
--
)
{
while
(
lines_to_change
--
)
{
pixel_ptr
=
row_ptr
+
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
)
*
3
;
pixel_ptr
=
row_ptr
+
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
)
*
3
;
...
@@ -317,10 +317,10 @@ static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change
...
@@ -317,10 +317,10 @@ static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change
{
{
int
rle_code
;
int
rle_code
;
int
pixel_ptr
;
int
pixel_ptr
;
int
row_inc
=
s
->
frame
.
linesize
[
0
];
int
row_inc
=
s
->
frame
->
linesize
[
0
];
unsigned
int
argb
;
unsigned
int
argb
;
uint8_t
*
rgb
=
s
->
frame
.
data
[
0
];
uint8_t
*
rgb
=
s
->
frame
->
data
[
0
];
int
pixel_limit
=
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
int
pixel_limit
=
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
while
(
lines_to_change
--
)
{
while
(
lines_to_change
--
)
{
pixel_ptr
=
row_ptr
+
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
)
*
4
;
pixel_ptr
=
row_ptr
+
(
bytestream2_get_byte
(
&
s
->
g
)
-
1
)
*
4
;
...
@@ -395,7 +395,9 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx)
...
@@ -395,7 +395,9 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
avcodec_get_frame_defaults
(
&
s
->
frame
);
s
->
frame
=
av_frame_alloc
();
if
(
!
s
->
frame
)
return
AVERROR
(
ENOMEM
);
return
0
;
return
0
;
}
}
...
@@ -411,7 +413,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
...
@@ -411,7 +413,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
int
ret
;
int
ret
;
bytestream2_init
(
&
s
->
g
,
avpkt
->
data
,
avpkt
->
size
);
bytestream2_init
(
&
s
->
g
,
avpkt
->
data
,
avpkt
->
size
);
if
((
ret
=
ff_reget_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
if
((
ret
=
ff_reget_buffer
(
avctx
,
s
->
frame
))
<
0
)
return
ret
;
return
ret
;
/* check if this frame is even supposed to change */
/* check if this frame is even supposed to change */
...
@@ -438,7 +440,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
...
@@ -438,7 +440,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
start_line
=
0
;
start_line
=
0
;
height
=
s
->
avctx
->
height
;
height
=
s
->
avctx
->
height
;
}
}
row_ptr
=
s
->
frame
.
linesize
[
0
]
*
start_line
;
row_ptr
=
s
->
frame
->
linesize
[
0
]
*
start_line
;
switch
(
avctx
->
bits_per_coded_sample
)
{
switch
(
avctx
->
bits_per_coded_sample
)
{
case
1
:
case
1
:
...
@@ -486,16 +488,16 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
...
@@ -486,16 +488,16 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
const
uint8_t
*
pal
=
av_packet_get_side_data
(
avpkt
,
AV_PKT_DATA_PALETTE
,
NULL
);
const
uint8_t
*
pal
=
av_packet_get_side_data
(
avpkt
,
AV_PKT_DATA_PALETTE
,
NULL
);
if
(
pal
)
{
if
(
pal
)
{
s
->
frame
.
palette_has_changed
=
1
;
s
->
frame
->
palette_has_changed
=
1
;
memcpy
(
s
->
pal
,
pal
,
AVPALETTE_SIZE
);
memcpy
(
s
->
pal
,
pal
,
AVPALETTE_SIZE
);
}
}
/* make the palette available on the way out */
/* make the palette available on the way out */
memcpy
(
s
->
frame
.
data
[
1
],
s
->
pal
,
AVPALETTE_SIZE
);
memcpy
(
s
->
frame
->
data
[
1
],
s
->
pal
,
AVPALETTE_SIZE
);
}
}
done:
done:
if
((
ret
=
av_frame_ref
(
data
,
&
s
->
frame
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
s
->
frame
))
<
0
)
return
ret
;
return
ret
;
*
got_frame
=
1
;
*
got_frame
=
1
;
...
@@ -507,7 +509,7 @@ static av_cold int qtrle_decode_end(AVCodecContext *avctx)
...
@@ -507,7 +509,7 @@ static av_cold int qtrle_decode_end(AVCodecContext *avctx)
{
{
QtrleContext
*
s
=
avctx
->
priv_data
;
QtrleContext
*
s
=
avctx
->
priv_data
;
av_frame_
unref
(
&
s
->
frame
);
av_frame_
free
(
&
s
->
frame
);
return
0
;
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