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
d100f9e7
Commit
d100f9e7
authored
Nov 09, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flicvideo: use the AVFrame API properly.
parent
84099f51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
29 deletions
+32
-29
flicvideo.c
libavcodec/flicvideo.c
+32
-29
No files found.
libavcodec/flicvideo.c
View file @
d100f9e7
...
...
@@ -71,7 +71,7 @@
typedef
struct
FlicDecodeContext
{
AVCodecContext
*
avctx
;
AVFrame
frame
;
AVFrame
*
frame
;
unsigned
int
palette
[
256
];
int
new_palette
;
...
...
@@ -123,7 +123,10 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
return
AVERROR_INVALIDDATA
;
}
avcodec_get_frame_defaults
(
&
s
->
frame
);
s
->
frame
=
av_frame_alloc
();
if
(
!
s
->
frame
)
return
AVERROR
(
ENOMEM
);
s
->
new_palette
=
0
;
return
0
;
...
...
@@ -168,13 +171,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
bytestream2_init
(
&
g2
,
buf
,
buf_size
);
if
((
ret
=
ff_reget_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
{
if
((
ret
=
ff_reget_buffer
(
avctx
,
s
->
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"reget_buffer() failed
\n
"
);
return
ret
;
}
pixels
=
s
->
frame
.
data
[
0
];
pixel_limit
=
s
->
avctx
->
height
*
s
->
frame
.
linesize
[
0
];
pixels
=
s
->
frame
->
data
[
0
];
pixel_limit
=
s
->
avctx
->
height
*
s
->
frame
->
linesize
[
0
];
frame_size
=
bytestream2_get_le32
(
&
g2
);
bytestream2_skip
(
&
g2
,
2
);
/* skip the magic number */
num_chunks
=
bytestream2_get_le16
(
&
g2
);
...
...
@@ -248,12 +251,12 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
if
((
line_packets
&
0xC000
)
==
0xC000
)
{
// line skip opcode
line_packets
=
-
line_packets
;
y_ptr
+=
line_packets
*
s
->
frame
.
linesize
[
0
];
y_ptr
+=
line_packets
*
s
->
frame
->
linesize
[
0
];
}
else
if
((
line_packets
&
0xC000
)
==
0x4000
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Undefined opcode (%x) in DELTA_FLI
\n
"
,
line_packets
);
}
else
if
((
line_packets
&
0xC000
)
==
0x8000
)
{
// "last byte" opcode
pixel_ptr
=
y_ptr
+
s
->
frame
.
linesize
[
0
]
-
1
;
pixel_ptr
=
y_ptr
+
s
->
frame
->
linesize
[
0
]
-
1
;
CHECK_PIXEL_PTR
(
0
);
pixels
[
pixel_ptr
]
=
line_packets
&
0xff
;
}
else
{
...
...
@@ -284,7 +287,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
y_ptr
+=
s
->
frame
.
linesize
[
0
];
y_ptr
+=
s
->
frame
->
linesize
[
0
];
}
}
break
;
...
...
@@ -293,7 +296,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
/* line compressed */
starting_line
=
bytestream2_get_le16
(
&
g2
);
y_ptr
=
0
;
y_ptr
+=
starting_line
*
s
->
frame
.
linesize
[
0
];
y_ptr
+=
starting_line
*
s
->
frame
->
linesize
[
0
];
compressed_lines
=
bytestream2_get_le16
(
&
g2
);
while
(
compressed_lines
>
0
)
{
...
...
@@ -324,7 +327,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
y_ptr
+=
s
->
frame
.
linesize
[
0
];
y_ptr
+=
s
->
frame
->
linesize
[
0
];
compressed_lines
--
;
}
break
;
...
...
@@ -332,7 +335,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
case
FLI_BLACK
:
/* set the whole frame to color 0 (which is usually black) */
memset
(
pixels
,
0
,
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
);
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
);
break
;
case
FLI_BRUN
:
...
...
@@ -375,7 +378,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
y_ptr
+=
s
->
frame
.
linesize
[
0
];
y_ptr
+=
s
->
frame
->
linesize
[
0
];
}
break
;
...
...
@@ -386,8 +389,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
"bigger than image, skipping chunk
\n
"
,
chunk_size
-
6
);
bytestream2_skip
(
&
g2
,
chunk_size
-
6
);
}
else
{
for
(
y_ptr
=
0
;
y_ptr
<
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
y_ptr
+=
s
->
frame
.
linesize
[
0
])
{
for
(
y_ptr
=
0
;
y_ptr
<
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
y_ptr
+=
s
->
frame
->
linesize
[
0
])
{
bytestream2_get_buffer
(
&
g2
,
&
pixels
[
y_ptr
],
s
->
avctx
->
width
);
}
...
...
@@ -417,13 +420,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
buf_size
-
bytestream2_get_bytes_left
(
&
g2
));
/* make the palette available on the way out */
memcpy
(
s
->
frame
.
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
memcpy
(
s
->
frame
->
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
if
(
s
->
new_palette
)
{
s
->
frame
.
palette_has_changed
=
1
;
s
->
frame
->
palette_has_changed
=
1
;
s
->
new_palette
=
0
;
}
if
((
ret
=
av_frame_ref
(
data
,
&
s
->
frame
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
s
->
frame
))
<
0
)
return
ret
;
*
got_frame
=
1
;
...
...
@@ -464,13 +467,13 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
bytestream2_init
(
&
g2
,
buf
,
buf_size
);
if
((
ret
=
ff_reget_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
{
if
((
ret
=
ff_reget_buffer
(
avctx
,
s
->
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"reget_buffer() failed
\n
"
);
return
ret
;
}
pixels
=
s
->
frame
.
data
[
0
];
pixel_limit
=
s
->
avctx
->
height
*
s
->
frame
.
linesize
[
0
];
pixels
=
s
->
frame
->
data
[
0
];
pixel_limit
=
s
->
avctx
->
height
*
s
->
frame
->
linesize
[
0
];
frame_size
=
bytestream2_get_le32
(
&
g2
);
bytestream2_skip
(
&
g2
,
2
);
/* skip the magic number */
...
...
@@ -504,7 +507,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
line_packets
=
bytestream2_get_le16
(
&
g2
);
if
(
line_packets
<
0
)
{
line_packets
=
-
line_packets
;
y_ptr
+=
line_packets
*
s
->
frame
.
linesize
[
0
];
y_ptr
+=
line_packets
*
s
->
frame
->
linesize
[
0
];
}
else
{
compressed_lines
--
;
pixel_ptr
=
y_ptr
;
...
...
@@ -533,7 +536,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
}
y_ptr
+=
s
->
frame
.
linesize
[
0
];
y_ptr
+=
s
->
frame
->
linesize
[
0
];
}
}
break
;
...
...
@@ -546,7 +549,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
case
FLI_BLACK
:
/* set the whole frame to 0x0000 which is black in both 15Bpp and 16Bpp modes. */
memset
(
pixels
,
0x0000
,
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
);
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
);
break
;
case
FLI_BRUN
:
...
...
@@ -597,7 +600,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixel_ptr
+=
2
;
}
#endif
y_ptr
+=
s
->
frame
.
linesize
[
0
];
y_ptr
+=
s
->
frame
->
linesize
[
0
];
}
break
;
...
...
@@ -637,7 +640,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
}
y_ptr
+=
s
->
frame
.
linesize
[
0
];
y_ptr
+=
s
->
frame
->
linesize
[
0
];
}
break
;
...
...
@@ -650,8 +653,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
bytestream2_skip
(
&
g2
,
chunk_size
-
6
);
}
else
{
for
(
y_ptr
=
0
;
y_ptr
<
s
->
frame
.
linesize
[
0
]
*
s
->
avctx
->
height
;
y_ptr
+=
s
->
frame
.
linesize
[
0
])
{
for
(
y_ptr
=
0
;
y_ptr
<
s
->
frame
->
linesize
[
0
]
*
s
->
avctx
->
height
;
y_ptr
+=
s
->
frame
->
linesize
[
0
])
{
pixel_countdown
=
s
->
avctx
->
width
;
pixel_ptr
=
0
;
...
...
@@ -684,7 +687,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
av_log
(
avctx
,
AV_LOG_ERROR
,
"Processed FLI chunk where chunk size = %d "
\
"and final chunk ptr = %d
\n
"
,
buf_size
,
bytestream2_tell
(
&
g2
));
if
((
ret
=
av_frame_ref
(
data
,
&
s
->
frame
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
s
->
frame
))
<
0
)
return
ret
;
*
got_frame
=
1
;
...
...
@@ -733,7 +736,7 @@ static av_cold int flic_decode_end(AVCodecContext *avctx)
{
FlicDecodeContext
*
s
=
avctx
->
priv_data
;
av_frame_
unref
(
&
s
->
frame
);
av_frame_
free
(
&
s
->
frame
);
return
0
;
}
...
...
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