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
67607e20
Commit
67607e20
authored
Mar 24, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xxan: make code independent of sizeof(AVFrame)
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
8097e5b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
23 deletions
+31
-23
xxan.c
libavcodec/xxan.c
+31
-23
No files found.
libavcodec/xxan.c
View file @
67607e20
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
typedef
struct
XanContext
{
typedef
struct
XanContext
{
AVCodecContext
*
avctx
;
AVCodecContext
*
avctx
;
AVFrame
pic
;
AVFrame
*
pic
;
uint8_t
*
y_buffer
;
uint8_t
*
y_buffer
;
uint8_t
*
scratch_buffer
;
uint8_t
*
scratch_buffer
;
...
@@ -38,6 +38,8 @@ typedef struct XanContext {
...
@@ -38,6 +38,8 @@ typedef struct XanContext {
GetByteContext
gb
;
GetByteContext
gb
;
}
XanContext
;
}
XanContext
;
static
av_cold
int
xan_decode_end
(
AVCodecContext
*
avctx
);
static
av_cold
int
xan_decode_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
xan_decode_init
(
AVCodecContext
*
avctx
)
{
{
XanContext
*
s
=
avctx
->
priv_data
;
XanContext
*
s
=
avctx
->
priv_data
;
...
@@ -57,7 +59,13 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
...
@@ -57,7 +59,13 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
s
->
scratch_buffer
=
av_malloc
(
s
->
buffer_size
+
130
);
s
->
scratch_buffer
=
av_malloc
(
s
->
buffer_size
+
130
);
if
(
!
s
->
scratch_buffer
)
{
if
(
!
s
->
scratch_buffer
)
{
av_freep
(
&
s
->
y_buffer
);
xan_decode_end
(
avctx
);
return
AVERROR
(
ENOMEM
);
}
s
->
pic
=
av_frame_alloc
();
if
(
!
s
->
pic
)
{
xan_decode_end
(
avctx
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
...
@@ -195,8 +203,8 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
...
@@ -195,8 +203,8 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
return
dec_size
;
return
dec_size
;
}
}
U
=
s
->
pic
.
data
[
1
];
U
=
s
->
pic
->
data
[
1
];
V
=
s
->
pic
.
data
[
2
];
V
=
s
->
pic
->
data
[
2
];
src
=
s
->
scratch_buffer
;
src
=
s
->
scratch_buffer
;
src_end
=
src
+
dec_size
;
src_end
=
src
+
dec_size
;
if
(
mode
)
{
if
(
mode
)
{
...
@@ -215,16 +223,16 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
...
@@ -215,16 +223,16 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
V
[
i
]
=
vval
|
(
vval
>>
5
);
V
[
i
]
=
vval
|
(
vval
>>
5
);
}
}
}
}
U
+=
s
->
pic
.
linesize
[
1
];
U
+=
s
->
pic
->
linesize
[
1
];
V
+=
s
->
pic
.
linesize
[
2
];
V
+=
s
->
pic
->
linesize
[
2
];
}
}
if
(
avctx
->
height
&
1
)
{
if
(
avctx
->
height
&
1
)
{
memcpy
(
U
,
U
-
s
->
pic
.
linesize
[
1
],
avctx
->
width
>>
1
);
memcpy
(
U
,
U
-
s
->
pic
->
linesize
[
1
],
avctx
->
width
>>
1
);
memcpy
(
V
,
V
-
s
->
pic
.
linesize
[
2
],
avctx
->
width
>>
1
);
memcpy
(
V
,
V
-
s
->
pic
->
linesize
[
2
],
avctx
->
width
>>
1
);
}
}
}
else
{
}
else
{
uint8_t
*
U2
=
U
+
s
->
pic
.
linesize
[
1
];
uint8_t
*
U2
=
U
+
s
->
pic
->
linesize
[
1
];
uint8_t
*
V2
=
V
+
s
->
pic
.
linesize
[
2
];
uint8_t
*
V2
=
V
+
s
->
pic
->
linesize
[
2
];
for
(
j
=
0
;
j
<
avctx
->
height
>>
2
;
j
++
)
{
for
(
j
=
0
;
j
<
avctx
->
height
>>
2
;
j
++
)
{
for
(
i
=
0
;
i
<
avctx
->
width
>>
1
;
i
+=
2
)
{
for
(
i
=
0
;
i
<
avctx
->
width
>>
1
;
i
+=
2
)
{
...
@@ -241,16 +249,16 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
...
@@ -241,16 +249,16 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
V
[
i
]
=
V
[
i
+
1
]
=
V2
[
i
]
=
V2
[
i
+
1
]
=
vval
|
(
vval
>>
5
);
V
[
i
]
=
V
[
i
+
1
]
=
V2
[
i
]
=
V2
[
i
+
1
]
=
vval
|
(
vval
>>
5
);
}
}
}
}
U
+=
s
->
pic
.
linesize
[
1
]
*
2
;
U
+=
s
->
pic
->
linesize
[
1
]
*
2
;
V
+=
s
->
pic
.
linesize
[
2
]
*
2
;
V
+=
s
->
pic
->
linesize
[
2
]
*
2
;
U2
+=
s
->
pic
.
linesize
[
1
]
*
2
;
U2
+=
s
->
pic
->
linesize
[
1
]
*
2
;
V2
+=
s
->
pic
.
linesize
[
2
]
*
2
;
V2
+=
s
->
pic
->
linesize
[
2
]
*
2
;
}
}
if
(
avctx
->
height
&
3
)
{
if
(
avctx
->
height
&
3
)
{
int
lines
=
((
avctx
->
height
+
1
)
>>
1
)
-
(
avctx
->
height
>>
2
)
*
2
;
int
lines
=
((
avctx
->
height
+
1
)
>>
1
)
-
(
avctx
->
height
>>
2
)
*
2
;
memcpy
(
U
,
U
-
lines
*
s
->
pic
.
linesize
[
1
],
lines
*
s
->
pic
.
linesize
[
1
]);
memcpy
(
U
,
U
-
lines
*
s
->
pic
->
linesize
[
1
],
lines
*
s
->
pic
->
linesize
[
1
]);
memcpy
(
V
,
V
-
lines
*
s
->
pic
.
linesize
[
2
],
lines
*
s
->
pic
.
linesize
[
2
]);
memcpy
(
V
,
V
-
lines
*
s
->
pic
->
linesize
[
2
],
lines
*
s
->
pic
->
linesize
[
2
]);
}
}
}
}
...
@@ -327,12 +335,12 @@ static int xan_decode_frame_type0(AVCodecContext *avctx)
...
@@ -327,12 +335,12 @@ static int xan_decode_frame_type0(AVCodecContext *avctx)
}
}
src
=
s
->
y_buffer
;
src
=
s
->
y_buffer
;
ybuf
=
s
->
pic
.
data
[
0
];
ybuf
=
s
->
pic
->
data
[
0
];
for
(
j
=
0
;
j
<
avctx
->
height
;
j
++
)
{
for
(
j
=
0
;
j
<
avctx
->
height
;
j
++
)
{
for
(
i
=
0
;
i
<
avctx
->
width
;
i
++
)
for
(
i
=
0
;
i
<
avctx
->
width
;
i
++
)
ybuf
[
i
]
=
(
src
[
i
]
<<
2
)
|
(
src
[
i
]
>>
3
);
ybuf
[
i
]
=
(
src
[
i
]
<<
2
)
|
(
src
[
i
]
>>
3
);
src
+=
avctx
->
width
;
src
+=
avctx
->
width
;
ybuf
+=
s
->
pic
.
linesize
[
0
];
ybuf
+=
s
->
pic
->
linesize
[
0
];
}
}
return
0
;
return
0
;
...
@@ -373,12 +381,12 @@ static int xan_decode_frame_type1(AVCodecContext *avctx)
...
@@ -373,12 +381,12 @@ static int xan_decode_frame_type1(AVCodecContext *avctx)
}
}
src
=
s
->
y_buffer
;
src
=
s
->
y_buffer
;
ybuf
=
s
->
pic
.
data
[
0
];
ybuf
=
s
->
pic
->
data
[
0
];
for
(
j
=
0
;
j
<
avctx
->
height
;
j
++
)
{
for
(
j
=
0
;
j
<
avctx
->
height
;
j
++
)
{
for
(
i
=
0
;
i
<
avctx
->
width
;
i
++
)
for
(
i
=
0
;
i
<
avctx
->
width
;
i
++
)
ybuf
[
i
]
=
(
src
[
i
]
<<
2
)
|
(
src
[
i
]
>>
3
);
ybuf
[
i
]
=
(
src
[
i
]
<<
2
)
|
(
src
[
i
]
>>
3
);
src
+=
avctx
->
width
;
src
+=
avctx
->
width
;
ybuf
+=
s
->
pic
.
linesize
[
0
];
ybuf
+=
s
->
pic
->
linesize
[
0
];
}
}
return
0
;
return
0
;
...
@@ -392,7 +400,7 @@ static int xan_decode_frame(AVCodecContext *avctx,
...
@@ -392,7 +400,7 @@ static int xan_decode_frame(AVCodecContext *avctx,
int
ftype
;
int
ftype
;
int
ret
;
int
ret
;
if
((
ret
=
ff_reget_buffer
(
avctx
,
&
s
->
pic
))
<
0
)
if
((
ret
=
ff_reget_buffer
(
avctx
,
s
->
pic
))
<
0
)
return
ret
;
return
ret
;
bytestream2_init
(
&
s
->
gb
,
avpkt
->
data
,
avpkt
->
size
);
bytestream2_init
(
&
s
->
gb
,
avpkt
->
data
,
avpkt
->
size
);
...
@@ -411,7 +419,7 @@ static int xan_decode_frame(AVCodecContext *avctx,
...
@@ -411,7 +419,7 @@ static int xan_decode_frame(AVCodecContext *avctx,
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
if
((
ret
=
av_frame_ref
(
data
,
&
s
->
pic
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
s
->
pic
))
<
0
)
return
ret
;
return
ret
;
*
got_frame
=
1
;
*
got_frame
=
1
;
...
@@ -423,7 +431,7 @@ static av_cold int xan_decode_end(AVCodecContext *avctx)
...
@@ -423,7 +431,7 @@ static av_cold int xan_decode_end(AVCodecContext *avctx)
{
{
XanContext
*
s
=
avctx
->
priv_data
;
XanContext
*
s
=
avctx
->
priv_data
;
av_frame_
unref
(
&
s
->
pic
);
av_frame_
free
(
&
s
->
pic
);
av_freep
(
&
s
->
y_buffer
);
av_freep
(
&
s
->
y_buffer
);
av_freep
(
&
s
->
scratch_buffer
);
av_freep
(
&
s
->
scratch_buffer
);
...
...
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