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
4956dc88
Commit
4956dc88
authored
Feb 18, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/cdxl: add support for raw videos with chunky format
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
98a0053d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
+39
-7
cdxl.c
libavcodec/cdxl.c
+33
-5
cdxl.c
libavformat/cdxl.c
+6
-2
No files found.
libavcodec/cdxl.c
View file @
4956dc88
...
...
@@ -30,6 +30,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"
...
...
@@ -107,6 +108,17 @@ static void bitline2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
}
}
static
void
chunky2chunky
(
CDXLVideoContext
*
c
,
int
linesize
,
uint8_t
*
out
)
{
GetByteContext
gb
;
int
y
;
bytestream2_init
(
&
gb
,
c
->
video
,
c
->
video_size
);
for
(
y
=
0
;
y
<
c
->
avctx
->
height
;
y
++
)
{
bytestream2_get_buffer
(
&
gb
,
out
+
linesize
*
y
,
c
->
avctx
->
width
*
3
);
}
}
static
void
import_format
(
CDXLVideoContext
*
c
,
int
linesize
,
uint8_t
*
out
)
{
memset
(
out
,
0
,
linesize
*
c
->
avctx
->
height
);
...
...
@@ -118,6 +130,9 @@ static void import_format(CDXLVideoContext *c, int linesize, uint8_t *out)
case
BIT_LINE
:
bitline2chunky
(
c
,
linesize
,
out
);
break
;
case
CHUNKY
:
chunky2chunky
(
c
,
linesize
,
out
);
break
;
}
}
...
...
@@ -130,6 +145,11 @@ static void cdxl_decode_rgb(CDXLVideoContext *c, AVFrame *frame)
import_format
(
c
,
frame
->
linesize
[
0
],
frame
->
data
[
0
]);
}
static
void
cdxl_decode_raw
(
CDXLVideoContext
*
c
,
AVFrame
*
frame
)
{
import_format
(
c
,
frame
->
linesize
[
0
],
frame
->
data
[
0
]);
}
static
void
cdxl_decode_ham6
(
CDXLVideoContext
*
c
,
AVFrame
*
frame
)
{
AVCodecContext
*
avctx
=
c
->
avctx
;
...
...
@@ -242,7 +262,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
return
AVERROR_INVALIDDATA
;
if
(
c
->
bpp
<
1
)
return
AVERROR_INVALIDDATA
;
if
(
c
->
format
!=
BIT_PLANAR
&&
c
->
format
!=
BIT_LINE
)
{
if
(
c
->
format
!=
BIT_PLANAR
&&
c
->
format
!=
BIT_LINE
&&
c
->
format
!=
CHUNKY
)
{
avpriv_request_sample
(
avctx
,
"Pixel format 0x%0x"
,
c
->
format
);
return
AVERROR_PATCHWELCOME
;
}
...
...
@@ -250,6 +270,9 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
if
((
ret
=
ff_set_dimensions
(
avctx
,
w
,
h
))
<
0
)
return
ret
;
if
(
c
->
format
==
CHUNKY
)
aligned_width
=
avctx
->
width
;
else
aligned_width
=
FFALIGN
(
c
->
avctx
->
width
,
16
);
c
->
padded_bits
=
aligned_width
-
c
->
avctx
->
width
;
if
(
c
->
video_size
<
aligned_width
*
avctx
->
height
*
c
->
bpp
/
8
)
...
...
@@ -260,9 +283,12 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
if
(
c
->
palette_size
!=
(
1
<<
(
c
->
bpp
-
1
)))
return
AVERROR_INVALIDDATA
;
avctx
->
pix_fmt
=
AV_PIX_FMT_BGR24
;
}
else
if
(
!
encoding
&&
c
->
bpp
==
24
&&
c
->
format
==
CHUNKY
&&
!
c
->
palette_size
)
{
avctx
->
pix_fmt
=
AV_PIX_FMT_RGB24
;
}
else
{
avpriv_request_sample
(
avctx
,
"Encoding %d
and bpp %d
"
,
encoding
,
c
->
bpp
);
avpriv_request_sample
(
avctx
,
"Encoding %d
, bpp %d and format 0x%x
"
,
encoding
,
c
->
bpp
,
c
->
format
);
return
AVERROR_PATCHWELCOME
;
}
...
...
@@ -279,8 +305,10 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
cdxl_decode_ham8
(
c
,
p
);
else
cdxl_decode_ham6
(
c
,
p
);
}
else
{
}
else
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_PAL8
)
{
cdxl_decode_rgb
(
c
,
p
);
}
else
{
cdxl_decode_raw
(
c
,
p
);
}
*
got_frame
=
1
;
...
...
libavformat/cdxl.c
View file @
4956dc88
...
...
@@ -111,7 +111,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
uint32_t
current_size
,
video_size
,
image_size
;
uint16_t
audio_size
,
palette_size
,
width
,
height
;
int64_t
pos
;
int
frames
,
ret
;
int
f
ormat
,
f
rames
,
ret
;
if
(
avio_feof
(
pb
))
return
AVERROR_EOF
;
...
...
@@ -125,6 +125,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
return
AVERROR_INVALIDDATA
;
}
format
=
cdxl
->
header
[
1
]
&
0xE0
;
current_size
=
AV_RB32
(
&
cdxl
->
header
[
2
]);
width
=
AV_RB16
(
&
cdxl
->
header
[
14
]);
height
=
AV_RB16
(
&
cdxl
->
header
[
16
]);
...
...
@@ -132,6 +133,9 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
audio_size
=
AV_RB16
(
&
cdxl
->
header
[
22
]);
if
(
FFALIGN
(
width
,
16
)
*
(
uint64_t
)
height
*
cdxl
->
header
[
19
]
>
INT_MAX
)
return
AVERROR_INVALIDDATA
;
if
(
format
==
0x20
)
image_size
=
width
*
height
*
cdxl
->
header
[
19
]
/
8
;
else
image_size
=
FFALIGN
(
width
,
16
)
*
height
*
cdxl
->
header
[
19
]
/
8
;
video_size
=
palette_size
+
image_size
;
...
...
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