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
d509ae5b
Commit
d509ae5b
authored
Dec 13, 2013
by
Vittorio Giovara
Committed by
Diego Biurrun
Feb 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jvdec: K&R formatting cosmetics
Signed-off-by:
Diego Biurrun
<
diego@biurrun.de
>
parent
1f097d16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
43 deletions
+49
-43
jvdec.c
libavcodec/jvdec.c
+25
-21
jvdec.c
libavformat/jvdec.c
+24
-22
No files found.
libavcodec/jvdec.c
View file @
d509ae5b
...
@@ -25,11 +25,12 @@
...
@@ -25,11 +25,12 @@
* @author Peter Ross <pross@xvid.org>
* @author Peter Ross <pross@xvid.org>
*/
*/
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "avcodec.h"
#include "dsputil.h"
#include "dsputil.h"
#include "get_bits.h"
#include "get_bits.h"
#include "internal.h"
#include "internal.h"
#include "libavutil/intreadwrite.h"
typedef
struct
JvContext
{
typedef
struct
JvContext
{
DSPContext
dsp
;
DSPContext
dsp
;
...
@@ -62,19 +63,19 @@ static inline void decode2x2(GetBitContext *gb, uint8_t *dst, int linesize)
...
@@ -62,19 +63,19 @@ static inline void decode2x2(GetBitContext *gb, uint8_t *dst, int linesize)
case
1
:
case
1
:
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
0
]
=
get_bits
(
gb
,
8
);
for
(
j
=
0
;
j
<
2
;
j
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
memset
(
dst
+
j
*
linesize
,
v
[
0
],
2
);
memset
(
dst
+
j
*
linesize
,
v
[
0
],
2
);
break
;
break
;
case
2
:
case
2
:
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
1
]
=
get_bits
(
gb
,
8
);
v
[
1
]
=
get_bits
(
gb
,
8
);
for
(
j
=
0
;
j
<
2
;
j
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
for
(
i
=
0
;
i
<
2
;
i
++
)
for
(
i
=
0
;
i
<
2
;
i
++
)
dst
[
j
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
dst
[
j
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
break
;
break
;
case
3
:
case
3
:
for
(
j
=
0
;
j
<
2
;
j
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
for
(
i
=
0
;
i
<
2
;
i
++
)
for
(
i
=
0
;
i
<
2
;
i
++
)
dst
[
j
*
linesize
+
i
]
=
get_bits
(
gb
,
8
);
dst
[
j
*
linesize
+
i
]
=
get_bits
(
gb
,
8
);
}
}
}
}
...
@@ -89,29 +90,30 @@ static inline void decode4x4(GetBitContext *gb, uint8_t *dst, int linesize)
...
@@ -89,29 +90,30 @@ static inline void decode4x4(GetBitContext *gb, uint8_t *dst, int linesize)
case
1
:
case
1
:
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
0
]
=
get_bits
(
gb
,
8
);
for
(
j
=
0
;
j
<
4
;
j
++
)
for
(
j
=
0
;
j
<
4
;
j
++
)
memset
(
dst
+
j
*
linesize
,
v
[
0
],
4
);
memset
(
dst
+
j
*
linesize
,
v
[
0
],
4
);
break
;
break
;
case
2
:
case
2
:
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
1
]
=
get_bits
(
gb
,
8
);
v
[
1
]
=
get_bits
(
gb
,
8
);
for
(
j
=
2
;
j
>=
0
;
j
-=
2
)
{
for
(
j
=
2
;
j
>=
0
;
j
-=
2
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
dst
[
j
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
dst
[
j
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
dst
[(
j
+
1
)
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
dst
[(
j
+
1
)
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
}
}
break
;
break
;
case
3
:
case
3
:
for
(
j
=
0
;
j
<
4
;
j
+=
2
)
for
(
j
=
0
;
j
<
4
;
j
+=
2
)
for
(
i
=
0
;
i
<
4
;
i
+=
2
)
for
(
i
=
0
;
i
<
4
;
i
+=
2
)
decode2x2
(
gb
,
dst
+
j
*
linesize
+
i
,
linesize
);
decode2x2
(
gb
,
dst
+
j
*
linesize
+
i
,
linesize
);
}
}
}
}
/**
/**
* Decode 8x8 block
* Decode 8x8 block
*/
*/
static
inline
void
decode8x8
(
GetBitContext
*
gb
,
uint8_t
*
dst
,
int
linesize
,
DSPContext
*
dsp
)
static
inline
void
decode8x8
(
GetBitContext
*
gb
,
uint8_t
*
dst
,
int
linesize
,
DSPContext
*
dsp
)
{
{
int
i
,
j
,
v
[
2
];
int
i
,
j
,
v
[
2
];
...
@@ -124,23 +126,22 @@ static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPC
...
@@ -124,23 +126,22 @@ static inline void decode8x8(GetBitContext *gb, uint8_t *dst, int linesize, DSPC
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
0
]
=
get_bits
(
gb
,
8
);
v
[
1
]
=
get_bits
(
gb
,
8
);
v
[
1
]
=
get_bits
(
gb
,
8
);
for
(
j
=
7
;
j
>=
0
;
j
--
)
for
(
j
=
7
;
j
>=
0
;
j
--
)
for
(
i
=
0
;
i
<
8
;
i
++
)
for
(
i
=
0
;
i
<
8
;
i
++
)
dst
[
j
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
dst
[
j
*
linesize
+
i
]
=
v
[
get_bits1
(
gb
)];
break
;
break
;
case
3
:
case
3
:
for
(
j
=
0
;
j
<
8
;
j
+=
4
)
for
(
j
=
0
;
j
<
8
;
j
+=
4
)
for
(
i
=
0
;
i
<
8
;
i
+=
4
)
for
(
i
=
0
;
i
<
8
;
i
+=
4
)
decode4x4
(
gb
,
dst
+
j
*
linesize
+
i
,
linesize
);
decode4x4
(
gb
,
dst
+
j
*
linesize
+
i
,
linesize
);
}
}
}
}
static
int
decode_frame
(
AVCodecContext
*
avctx
,
static
int
decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
AVPacket
*
avpkt
)
{
{
JvContext
*
s
=
avctx
->
priv_data
;
JvContext
*
s
=
avctx
->
priv_data
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf_end
=
buf
+
buf_size
;
const
uint8_t
*
buf_end
=
buf
+
buf_size
;
int
video_size
,
video_type
,
i
,
j
,
ret
;
int
video_size
,
video_type
,
i
,
j
,
ret
;
...
@@ -160,7 +161,8 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -160,7 +161,8 @@ static int decode_frame(AVCodecContext *avctx,
for
(
j
=
0
;
j
<
avctx
->
height
;
j
+=
8
)
for
(
j
=
0
;
j
<
avctx
->
height
;
j
+=
8
)
for
(
i
=
0
;
i
<
avctx
->
width
;
i
+=
8
)
for
(
i
=
0
;
i
<
avctx
->
width
;
i
+=
8
)
decode8x8
(
&
gb
,
s
->
frame
->
data
[
0
]
+
j
*
s
->
frame
->
linesize
[
0
]
+
i
,
decode8x8
(
&
gb
,
s
->
frame
->
data
[
0
]
+
j
*
s
->
frame
->
linesize
[
0
]
+
i
,
s
->
frame
->
linesize
[
0
],
&
s
->
dsp
);
s
->
frame
->
linesize
[
0
],
&
s
->
dsp
);
buf
+=
video_size
;
buf
+=
video_size
;
...
@@ -168,10 +170,12 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -168,10 +170,12 @@ static int decode_frame(AVCodecContext *avctx,
if
(
buf
+
1
<=
buf_end
)
{
if
(
buf
+
1
<=
buf_end
)
{
int
v
=
*
buf
++
;
int
v
=
*
buf
++
;
for
(
j
=
0
;
j
<
avctx
->
height
;
j
++
)
for
(
j
=
0
;
j
<
avctx
->
height
;
j
++
)
memset
(
s
->
frame
->
data
[
0
]
+
j
*
s
->
frame
->
linesize
[
0
],
v
,
avctx
->
width
);
memset
(
s
->
frame
->
data
[
0
]
+
j
*
s
->
frame
->
linesize
[
0
],
v
,
avctx
->
width
);
}
}
}
else
{
}
else
{
av_log
(
avctx
,
AV_LOG_WARNING
,
"unsupported frame type %i
\n
"
,
video_type
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"unsupported frame type %i
\n
"
,
video_type
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
}
}
...
@@ -188,7 +192,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -188,7 +192,7 @@ static int decode_frame(AVCodecContext *avctx,
s
->
frame
->
key_frame
=
1
;
s
->
frame
->
key_frame
=
1
;
s
->
frame
->
pict_type
=
AV_PICTURE_TYPE_I
;
s
->
frame
->
pict_type
=
AV_PICTURE_TYPE_I
;
s
->
frame
->
palette_has_changed
=
s
->
palette_has_changed
;
s
->
frame
->
palette_has_changed
=
s
->
palette_has_changed
;
s
->
palette_has_changed
=
0
;
s
->
palette_has_changed
=
0
;
memcpy
(
s
->
frame
->
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
memcpy
(
s
->
frame
->
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
if
((
ret
=
av_frame_ref
(
data
,
s
->
frame
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
s
->
frame
))
<
0
)
...
...
libavformat/jvdec.c
View file @
d509ae5b
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avformat.h"
#include "internal.h"
#include "internal.h"
...
@@ -96,17 +97,18 @@ static int read_header(AVFormatContext *s)
...
@@ -96,17 +97,18 @@ static int read_header(AVFormatContext *s)
avio_skip
(
pb
,
4
);
avio_skip
(
pb
,
4
);
ast
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
ast
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
ast
->
codec
->
codec_id
=
AV_CODEC_ID_PCM_U8
;
ast
->
codec
->
codec_id
=
AV_CODEC_ID_PCM_U8
;
ast
->
codec
->
codec_tag
=
0
;
/* no fourcc */
ast
->
codec
->
codec_tag
=
0
;
/* no fourcc */
ast
->
codec
->
sample_rate
=
avio_rl16
(
pb
);
ast
->
codec
->
sample_rate
=
avio_rl16
(
pb
);
ast
->
codec
->
channels
=
1
;
ast
->
codec
->
channels
=
1
;
ast
->
codec
->
channel_layout
=
AV_CH_LAYOUT_MONO
;
ast
->
codec
->
channel_layout
=
AV_CH_LAYOUT_MONO
;
avpriv_set_pts_info
(
ast
,
64
,
1
,
ast
->
codec
->
sample_rate
);
avpriv_set_pts_info
(
ast
,
64
,
1
,
ast
->
codec
->
sample_rate
);
avio_skip
(
pb
,
10
);
avio_skip
(
pb
,
10
);
ast
->
index_entries
=
av_malloc
(
ast
->
nb_index_entries
*
sizeof
(
*
ast
->
index_entries
));
ast
->
index_entries
=
av_malloc
(
ast
->
nb_index_entries
*
sizeof
(
*
ast
->
index_entries
));
if
(
!
ast
->
index_entries
)
if
(
!
ast
->
index_entries
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -115,18 +117,18 @@ static int read_header(AVFormatContext *s)
...
@@ -115,18 +117,18 @@ static int read_header(AVFormatContext *s)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
offset
=
0x68
+
ast
->
nb_index_entries
*
16
;
offset
=
0x68
+
ast
->
nb_index_entries
*
16
;
for
(
i
=
0
;
i
<
ast
->
nb_index_entries
;
i
++
)
{
for
(
i
=
0
;
i
<
ast
->
nb_index_entries
;
i
++
)
{
AVIndexEntry
*
e
=
ast
->
index_entries
+
i
;
AVIndexEntry
*
e
=
ast
->
index_entries
+
i
;
JVFrame
*
jvf
=
jv
->
frames
+
i
;
JVFrame
*
jvf
=
jv
->
frames
+
i
;
/* total frame size including audio, video, palette data and padding */
/* total frame size including audio, video, palette data and padding */
e
->
size
=
avio_rl32
(
pb
);
e
->
size
=
avio_rl32
(
pb
);
e
->
timestamp
=
i
;
e
->
timestamp
=
i
;
e
->
pos
=
offset
;
e
->
pos
=
offset
;
offset
+=
e
->
size
;
offset
+=
e
->
size
;
jvf
->
audio_size
=
avio_rl32
(
pb
);
jvf
->
audio_size
=
avio_rl32
(
pb
);
jvf
->
video_size
=
avio_rl32
(
pb
);
jvf
->
video_size
=
avio_rl32
(
pb
);
jvf
->
palette_size
=
avio_r8
(
pb
)
?
768
:
0
;
jvf
->
palette_size
=
avio_r8
(
pb
)
?
768
:
0
;
if
((
jvf
->
video_size
|
jvf
->
audio_size
)
&
~
0xFFFFFF
||
if
((
jvf
->
video_size
|
jvf
->
audio_size
)
&
~
0xFFFFFF
||
...
@@ -137,19 +139,19 @@ static int read_header(AVFormatContext *s)
...
@@ -137,19 +139,19 @@ static int read_header(AVFormatContext *s)
read_close
(
s
);
read_close
(
s
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
jvf
->
audio_size
=
jvf
->
audio_size
=
jvf
->
video_size
=
jvf
->
video_size
=
jvf
->
palette_size
=
0
;
jvf
->
palette_size
=
0
;
}
}
if
(
avio_r8
(
pb
))
if
(
avio_r8
(
pb
))
av_log
(
s
,
AV_LOG_WARNING
,
"unsupported audio codec
\n
"
);
av_log
(
s
,
AV_LOG_WARNING
,
"unsupported audio codec
\n
"
);
jvf
->
video_type
=
avio_r8
(
pb
);
jvf
->
video_type
=
avio_r8
(
pb
);
avio_skip
(
pb
,
1
);
avio_skip
(
pb
,
1
);
e
->
timestamp
=
jvf
->
audio_size
?
audio_pts
:
AV_NOPTS_VALUE
;
e
->
timestamp
=
jvf
->
audio_size
?
audio_pts
:
AV_NOPTS_VALUE
;
audio_pts
+=
jvf
->
audio_size
;
audio_pts
+=
jvf
->
audio_size
;
e
->
flags
=
jvf
->
video_type
!=
1
?
AVINDEX_KEYFRAME
:
0
;
e
->
flags
=
jvf
->
video_type
!=
1
?
AVINDEX_KEYFRAME
:
0
;
}
}
...
@@ -168,10 +170,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -168,10 +170,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
const
AVIndexEntry
*
e
=
ast
->
index_entries
+
jv
->
pts
;
const
AVIndexEntry
*
e
=
ast
->
index_entries
+
jv
->
pts
;
const
JVFrame
*
jvf
=
jv
->
frames
+
jv
->
pts
;
const
JVFrame
*
jvf
=
jv
->
frames
+
jv
->
pts
;
switch
(
jv
->
state
)
{
switch
(
jv
->
state
)
{
case
JV_AUDIO
:
case
JV_AUDIO
:
jv
->
state
++
;
jv
->
state
++
;
if
(
jvf
->
audio_size
)
{
if
(
jvf
->
audio_size
)
{
if
(
av_get_packet
(
s
->
pb
,
pkt
,
jvf
->
audio_size
)
<
0
)
if
(
av_get_packet
(
s
->
pb
,
pkt
,
jvf
->
audio_size
)
<
0
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
pkt
->
stream_index
=
0
;
pkt
->
stream_index
=
0
;
...
@@ -187,7 +189,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -187,7 +189,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
AV_WL32
(
pkt
->
data
,
jvf
->
video_size
);
AV_WL32
(
pkt
->
data
,
jvf
->
video_size
);
pkt
->
data
[
4
]
=
jvf
->
video_type
;
pkt
->
data
[
4
]
=
jvf
->
video_type
;
if
(
avio_read
(
pb
,
pkt
->
data
+
JV_PREAMBLE_SIZE
,
size
)
<
0
)
if
(
avio_read
(
pb
,
pkt
->
data
+
JV_PREAMBLE_SIZE
,
size
)
<
0
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
...
@@ -219,10 +221,10 @@ static int read_seek(AVFormatContext *s, int stream_index,
...
@@ -219,10 +221,10 @@ static int read_seek(AVFormatContext *s, int stream_index,
AVStream
*
ast
=
s
->
streams
[
0
];
AVStream
*
ast
=
s
->
streams
[
0
];
int
i
;
int
i
;
if
(
flags
&
(
AVSEEK_FLAG_BYTE
|
AVSEEK_FLAG_FRAME
))
if
(
flags
&
(
AVSEEK_FLAG_BYTE
|
AVSEEK_FLAG_FRAME
))
return
AVERROR
(
ENOSYS
);
return
AVERROR
(
ENOSYS
);
switch
(
stream_index
)
{
switch
(
stream_index
)
{
case
0
:
case
0
:
i
=
av_index_search_timestamp
(
ast
,
ts
,
flags
);
i
=
av_index_search_timestamp
(
ast
,
ts
,
flags
);
break
;
break
;
...
...
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