Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
62cc8f4d
Commit
62cc8f4d
authored
9 years ago
by
Vittorio Giovara
Browse files
Options
Downloads
Patches
Plain Diff
sgienc: Port to bytestream2
parent
99f40fd0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/sgienc.c
+35
-31
35 additions, 31 deletions
libavcodec/sgienc.c
with
35 additions
and
31 deletions
libavcodec/sgienc.c
+
35
−
31
View file @
62cc8f4d
...
@@ -43,11 +43,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
...
@@ -43,11 +43,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const
AVFrame
*
frame
,
int
*
got_packet
)
const
AVFrame
*
frame
,
int
*
got_packet
)
{
{
const
AVFrame
*
const
p
=
frame
;
const
AVFrame
*
const
p
=
frame
;
uint8_t
*
offsettab
,
*
lengthtab
,
*
in_buf
,
*
encode_buf
,
*
buf
;
PutByteContext
pbc
;
uint8_t
*
in_buf
,
*
encode_buf
;
int
x
,
y
,
z
,
length
,
tablesize
,
ret
;
int
x
,
y
,
z
,
length
,
tablesize
,
ret
;
unsigned
int
width
,
height
,
depth
,
dimension
;
unsigned
int
width
,
height
,
depth
,
dimension
;
unsigned
int
bytes_per_channel
,
pixmax
,
put_be
;
unsigned
int
bytes_per_channel
,
pixmax
,
put_be
;
unsigned
char
*
end_buf
;
#if FF_API_CODED_FRAME
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
FF_DISABLE_DEPRECATION_WARNINGS
...
@@ -117,40 +117,41 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -117,40 +117,41 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error getting output packet of size %d.
\n
"
,
length
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error getting output packet of size %d.
\n
"
,
length
);
return
ret
;
return
ret
;
}
}
buf
=
pkt
->
data
;
end_buf
=
pkt
->
data
+
pkt
->
size
;
bytestream2_init_writer
(
&
pbc
,
pkt
->
data
,
pkt
->
size
)
;
/* Encode header. */
/* Encode header. */
bytestream_put_be16
(
&
buf
,
SGI_MAGIC
);
bytestream
2
_put_be16
(
&
pbc
,
SGI_MAGIC
);
bytestream_put_byte
(
&
buf
,
avctx
->
coder_type
!=
FF_CODER_TYPE_RAW
);
/* RLE 1 - VERBATIM 0*/
bytestream
2
_put_byte
(
&
pbc
,
avctx
->
coder_type
!=
FF_CODER_TYPE_RAW
);
/* RLE 1 - VERBATIM 0
*/
bytestream_put_byte
(
&
buf
,
bytes_per_channel
);
bytestream
2
_put_byte
(
&
pbc
,
bytes_per_channel
);
bytestream_put_be16
(
&
buf
,
dimension
);
bytestream
2
_put_be16
(
&
pbc
,
dimension
);
bytestream_put_be16
(
&
buf
,
width
);
bytestream
2
_put_be16
(
&
pbc
,
width
);
bytestream_put_be16
(
&
buf
,
height
);
bytestream
2
_put_be16
(
&
pbc
,
height
);
bytestream_put_be16
(
&
buf
,
depth
);
bytestream
2
_put_be16
(
&
pbc
,
depth
);
bytestream_put_be32
(
&
buf
,
0L
);
/* pixmin */
bytestream
2
_put_be32
(
&
pbc
,
0L
);
/* pixmin */
bytestream_put_be32
(
&
buf
,
pixmax
);
bytestream
2
_put_be32
(
&
pbc
,
pixmax
);
bytestream_put_be32
(
&
buf
,
0L
);
/* dummy */
bytestream
2
_put_be32
(
&
pbc
,
0L
);
/* dummy */
/* name */
/* name */
memset
(
buf
,
0
,
SGI_HEADER_SIZE
);
bytestream2_skip_p
(
&
pbc
,
80
);
buf
+=
80
;
/* colormap */
/* colormap */
bytestream_put_be32
(
&
buf
,
0L
);
bytestream
2
_put_be32
(
&
pbc
,
0L
);
/* The rest of the 512 byte header is unused. */
/* The rest of the 512 byte header is unused. */
buf
+=
404
;
bytestream2_skip_p
(
&
pbc
,
404
);
offsettab
=
buf
;
if
(
avctx
->
coder_type
!=
FF_CODER_TYPE_RAW
)
{
if
(
avctx
->
coder_type
!=
FF_CODER_TYPE_RAW
)
{
PutByteContext
taboff_pcb
,
tablen_pcb
;
/* Skip RLE offset table. */
/* Skip RLE offset table. */
b
uf
+=
tablesize
;
b
ytestream2_init_writer
(
&
taboff_pcb
,
pbc
.
buffer
,
tablesize
)
;
lengthtab
=
buf
;
bytestream2_skip_p
(
&
pbc
,
tablesize
)
;
/* Skip RLE length table. */
/* Skip RLE length table. */
buf
+=
tablesize
;
bytestream2_init_writer
(
&
tablen_pcb
,
pbc
.
buffer
,
tablesize
);
bytestream2_skip_p
(
&
pbc
,
tablesize
);
/* Make an intermediate consecutive buffer. */
/* Make an intermediate consecutive buffer. */
if
(
!
(
encode_buf
=
av_malloc
(
width
)))
if
(
!
(
encode_buf
=
av_malloc
(
width
)))
...
@@ -160,18 +161,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -160,18 +161,21 @@ FF_ENABLE_DEPRECATION_WARNINGS
in_buf
=
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
height
-
1
)
+
z
;
in_buf
=
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
height
-
1
)
+
z
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
y
=
0
;
y
<
height
;
y
++
)
{
bytestream_put_be32
(
&
offsettab
,
buf
-
pkt
->
data
);
bytestream
2
_put_be32
(
&
taboff_pcb
,
bytestream2_tell_p
(
&
pbc
)
);
for
(
x
=
0
;
x
<
width
;
x
++
)
for
(
x
=
0
;
x
<
width
;
x
++
)
encode_buf
[
x
]
=
in_buf
[
depth
*
x
];
encode_buf
[
x
]
=
in_buf
[
depth
*
x
];
if
((
length
=
ff_rle_encode
(
buf
,
end_buf
-
buf
-
1
,
encode_buf
,
1
,
width
,
0
,
0
,
0x80
,
0
))
<
1
)
{
length
=
ff_rle_encode
(
pbc
.
buffer
,
bytestream2_get_bytes_left_p
(
&
pbc
),
encode_buf
,
1
,
width
,
0
,
0
,
0x80
,
0
);
if
(
length
<
1
)
{
av_free
(
encode_buf
);
av_free
(
encode_buf
);
return
-
1
;
return
-
1
;
}
}
b
uf
+=
length
;
b
ytestream2_skip_p
(
&
pbc
,
length
)
;
bytestream_put_be32
(
&
lengthta
b
,
length
);
bytestream
2
_put_be32
(
&
tablen_pc
b
,
length
);
in_buf
-=
p
->
linesize
[
0
];
in_buf
-=
p
->
linesize
[
0
];
}
}
}
}
...
@@ -184,12 +188,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -184,12 +188,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
x
=
0
;
x
<
width
*
depth
;
x
+=
depth
)
for
(
x
=
0
;
x
<
width
*
depth
;
x
+=
depth
)
if
(
bytes_per_channel
==
1
)
if
(
bytes_per_channel
==
1
)
bytestream_put_byte
(
&
buf
,
in_buf
[
x
]);
bytestream
2
_put_byte
(
&
pbc
,
in_buf
[
x
]);
else
else
if
(
put_be
)
if
(
put_be
)
bytestream_put_be16
(
&
buf
,
((
uint16_t
*
)
in_buf
)[
x
]);
bytestream
2
_put_be16
(
&
pbc
,
((
uint16_t
*
)
in_buf
)[
x
]);
else
else
bytestream_put_le16
(
&
buf
,
((
uint16_t
*
)
in_buf
)[
x
]);
bytestream
2
_put_le16
(
&
pbc
,
((
uint16_t
*
)
in_buf
)[
x
]);
in_buf
-=
p
->
linesize
[
0
];
in_buf
-=
p
->
linesize
[
0
];
}
}
...
@@ -197,7 +201,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -197,7 +201,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
/* total length */
/* total length */
pkt
->
size
=
b
uf
-
pkt
->
data
;
pkt
->
size
=
b
ytestream2_tell_p
(
&
pbc
)
;
pkt
->
flags
|=
AV_PKT_FLAG_KEY
;
pkt
->
flags
|=
AV_PKT_FLAG_KEY
;
*
got_packet
=
1
;
*
got_packet
=
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment