Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
afa1617b
Commit
afa1617b
authored
Dec 17, 2012
by
Peter Ross
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SGI RLE 8-bit decoder
Signed-off-by:
Peter Ross
<
pross@xvid.org
>
parent
2e59142f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
160 additions
and
0 deletions
+160
-0
Changelog
Changelog
+1
-0
general.texi
doc/general.texi
+1
-0
Makefile
libavcodec/Makefile
+1
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
codec_desc.c
libavcodec/codec_desc.c
+7
-0
sgirledec.c
libavcodec/sgirledec.c
+148
-0
No files found.
Changelog
View file @
afa1617b
...
@@ -42,6 +42,7 @@ version <next>:
...
@@ -42,6 +42,7 @@ version <next>:
- JSON captions for TED talks decoding support
- JSON captions for TED talks decoding support
- SOX Resampler support in libswresample
- SOX Resampler support in libswresample
- aselect filter
- aselect filter
- SGI RLE 8-bit decoder
version 1.0:
version 1.0:
...
...
doc/general.texi
View file @
afa1617b
...
@@ -664,6 +664,7 @@ following image formats are supported:
...
@@ -664,6 +664,7 @@ following image formats are supported:
@tab Texture dictionaries used by the Renderware Engine.
@tab Texture dictionaries used by the Renderware Engine.
@item RL2 video @tab @tab X
@item RL2 video @tab @tab X
@tab used in some games by Entertainment Software Partners
@tab used in some games by Entertainment Software Partners
@item SGI RLE 8-bit @tab @tab X
@item Sierra VMD video @tab @tab X
@item Sierra VMD video @tab @tab X
@tab Used in Sierra VMD files.
@tab Used in Sierra VMD files.
@item Smacker video @tab @tab X
@item Smacker video @tab @tab X
...
...
libavcodec/Makefile
View file @
afa1617b
...
@@ -376,6 +376,7 @@ OBJS-$(CONFIG_S302M_DECODER) += s302m.o
...
@@ -376,6 +376,7 @@ OBJS-$(CONFIG_S302M_DECODER) += s302m.o
OBJS-$(CONFIG_SANM_DECODER)
+=
sanm.o
OBJS-$(CONFIG_SANM_DECODER)
+=
sanm.o
OBJS-$(CONFIG_SGI_DECODER)
+=
sgidec.o
OBJS-$(CONFIG_SGI_DECODER)
+=
sgidec.o
OBJS-$(CONFIG_SGI_ENCODER)
+=
sgienc.o
rle.o
OBJS-$(CONFIG_SGI_ENCODER)
+=
sgienc.o
rle.o
OBJS-$(CONFIG_SGIRLE_DECODER)
+=
sgirledec.o
OBJS-$(CONFIG_SHORTEN_DECODER)
+=
shorten.o
OBJS-$(CONFIG_SHORTEN_DECODER)
+=
shorten.o
OBJS-$(CONFIG_SIPR_DECODER)
+=
sipr.o
acelp_pitch_delay.o
\
OBJS-$(CONFIG_SIPR_DECODER)
+=
sipr.o
acelp_pitch_delay.o
\
celp_math.o
acelp_vectors.o
\
celp_math.o
acelp_vectors.o
\
...
...
libavcodec/allcodecs.c
View file @
afa1617b
...
@@ -215,6 +215,7 @@ void avcodec_register_all(void)
...
@@ -215,6 +215,7 @@ void avcodec_register_all(void)
REGISTER_DECODER
(
S302M
,
s302m
);
REGISTER_DECODER
(
S302M
,
s302m
);
REGISTER_DECODER
(
SANM
,
sanm
);
REGISTER_DECODER
(
SANM
,
sanm
);
REGISTER_ENCDEC
(
SGI
,
sgi
);
REGISTER_ENCDEC
(
SGI
,
sgi
);
REGISTER_DECODER
(
SGIRLE
,
sgirle
);
REGISTER_DECODER
(
SMACKER
,
smacker
);
REGISTER_DECODER
(
SMACKER
,
smacker
);
REGISTER_DECODER
(
SMC
,
smc
);
REGISTER_DECODER
(
SMC
,
smc
);
REGISTER_ENCDEC
(
SNOW
,
snow
);
REGISTER_ENCDEC
(
SNOW
,
snow
);
...
...
libavcodec/avcodec.h
View file @
afa1617b
...
@@ -285,6 +285,7 @@ enum AVCodecID {
...
@@ -285,6 +285,7 @@ enum AVCodecID {
AV_CODEC_ID_AVRN
=
MKBETAG
(
'A'
,
'V'
,
'R'
,
'n'
),
AV_CODEC_ID_AVRN
=
MKBETAG
(
'A'
,
'V'
,
'R'
,
'n'
),
AV_CODEC_ID_CPIA
=
MKBETAG
(
'C'
,
'P'
,
'I'
,
'A'
),
AV_CODEC_ID_CPIA
=
MKBETAG
(
'C'
,
'P'
,
'I'
,
'A'
),
AV_CODEC_ID_XFACE
=
MKBETAG
(
'X'
,
'F'
,
'A'
,
'C'
),
AV_CODEC_ID_XFACE
=
MKBETAG
(
'X'
,
'F'
,
'A'
,
'C'
),
AV_CODEC_ID_SGIRLE
=
MKBETAG
(
'S'
,
'G'
,
'I'
,
'R'
),
/* various PCM "codecs" */
/* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO
=
0x10000
,
///< A dummy id pointing at the start of audio codecs
AV_CODEC_ID_FIRST_AUDIO
=
0x10000
,
///< A dummy id pointing at the start of audio codecs
...
...
libavcodec/codec_desc.c
View file @
afa1617b
...
@@ -751,6 +751,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
...
@@ -751,6 +751,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SGI image"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SGI image"
),
.
props
=
AV_CODEC_PROP_INTRA_ONLY
|
AV_CODEC_PROP_LOSSY
,
.
props
=
AV_CODEC_PROP_INTRA_ONLY
|
AV_CODEC_PROP_LOSSY
,
},
},
{
.
id
=
AV_CODEC_ID_SGIRLE
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
name
=
"sgirle"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SGI RLE 8-bit"
),
.
props
=
AV_CODEC_PROP_INTRA_ONLY
|
AV_CODEC_PROP_LOSSLESS
,
},
{
{
.
id
=
AV_CODEC_ID_C93
,
.
id
=
AV_CODEC_ID_C93
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
...
...
libavcodec/sgirledec.c
0 → 100644
View file @
afa1617b
/*
* SGI RLE 8-bit decoder
* Copyright (c) 2012 Peter Ross
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* SGI RLE 8-bit decoder
*/
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "bytestream.h"
static
av_cold
int
sgirle_decode_init
(
AVCodecContext
*
avctx
)
{
avctx
->
pix_fmt
=
AV_PIX_FMT_BGR8
;
avctx
->
coded_frame
=
avcodec_alloc_frame
();
if
(
!
avctx
->
coded_frame
)
return
AVERROR
(
ENOMEM
);
return
0
;
}
/**
* Convert SGI RGB332 pixel into PIX_FMT_BGR8
* SGI RGB332 is packed RGB 3:3:2, 8bpp, (msb)3R 2B 3G(lsb)
*/
#define RGB332_TO_BGR8(x) (((x << 3) & 0xC0) | ((x << 3) & 0x38) | ((x >> 5) & 7))
static
av_always_inline
void
memcpy_rgb332_to_bgr8
(
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
size
)
{
int
i
;
for
(
i
=
0
;
i
<
size
;
i
++
)
dst
[
i
]
=
RGB332_TO_BGR8
(
src
[
i
]);
}
/**
* @param[out] dst Destination buffer
* @param[in] src Source buffer
* @param src_size Source buffer size (bytes)
* @param width Width of destination buffer (pixels)
* @param height Height of destination buffer (pixels)
* @param linesize Line size of destination buffer (bytes)
* @return <0 on error
*/
static
int
decode_sgirle8
(
AVCodecContext
*
avctx
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
src_size
,
int
width
,
int
height
,
int
linesize
)
{
const
uint8_t
*
src_end
=
src
+
src_size
;
int
x
=
0
,
y
=
0
;
#define INC_XY(n) \
x += n; \
if (x >= width) { \
y++; \
if (y >= height) \
return 0; \
x = 0; \
}
while
(
src_end
-
src
>=
2
)
{
uint8_t
v
=
*
src
++
;
if
(
v
>
0
&&
v
<
0xC0
)
{
do
{
int
length
=
FFMIN
(
v
,
width
-
x
);
memset
(
dst
+
y
*
linesize
+
x
,
RGB332_TO_BGR8
(
*
src
),
length
);
INC_XY
(
length
);
v
-=
length
;
}
while
(
v
>
0
);
src
++
;
}
else
if
(
v
>=
0xC1
)
{
v
-=
0xC0
;
do
{
int
length
=
FFMIN3
(
v
,
width
-
x
,
src_end
-
src
);
if
(
src_end
-
src
<
length
)
break
;
memcpy_rgb332_to_bgr8
(
dst
+
y
*
linesize
+
x
,
src
,
length
);
INC_XY
(
length
);
src
+=
length
;
v
-=
length
;
}
while
(
v
>
0
);
}
else
{
av_log_ask_for_sample
(
avctx
,
"unknown opcode
\n
"
);
return
AVERROR_PATCHWELCOME
;
}
}
return
0
;
}
static
int
sgirle_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
{
AVFrame
*
frame
=
avctx
->
coded_frame
;
int
ret
;
frame
->
reference
=
3
;
frame
->
buffer_hints
=
FF_BUFFER_HINTS_VALID
|
FF_BUFFER_HINTS_PRESERVE
|
FF_BUFFER_HINTS_REUSABLE
|
FF_BUFFER_HINTS_READABLE
;
ret
=
avctx
->
reget_buffer
(
avctx
,
frame
);
if
(
ret
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"reget_buffer() failed
\n
"
);
return
ret
;
}
ret
=
decode_sgirle8
(
avctx
,
frame
->
data
[
0
],
avpkt
->
data
,
avpkt
->
size
,
avctx
->
width
,
avctx
->
height
,
frame
->
linesize
[
0
]);
if
(
ret
<
0
)
return
ret
;
*
got_frame
=
1
;
*
(
AVFrame
*
)
data
=
*
frame
;
return
avpkt
->
size
;
}
static
av_cold
int
sgirle_decode_end
(
AVCodecContext
*
avctx
)
{
if
(
avctx
->
coded_frame
->
data
[
0
])
avctx
->
release_buffer
(
avctx
,
avctx
->
coded_frame
);
av_freep
(
&
avctx
->
coded_frame
);
return
0
;
}
AVCodec
ff_sgirle_decoder
=
{
.
name
=
"sgirle"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
id
=
AV_CODEC_ID_SGIRLE
,
.
init
=
sgirle_decode_init
,
.
close
=
sgirle_decode_end
,
.
decode
=
sgirle_decode_frame
,
.
capabilities
=
CODEC_CAP_DR1
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SGI RLE 8-bit"
),
};
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