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
4e33582a
Commit
4e33582a
authored
Mar 18, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tscc2: allocate AVFrame properly.
parent
20a8ee30
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
16 deletions
+22
-16
tscc2.c
libavcodec/tscc2.c
+22
-16
No files found.
libavcodec/tscc2.c
View file @
4e33582a
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
typedef
struct
TSCC2Context
{
typedef
struct
TSCC2Context
{
AVCodecContext
*
avctx
;
AVCodecContext
*
avctx
;
AVFrame
pic
;
AVFrame
*
pic
;
int
mb_width
,
mb_height
;
int
mb_width
,
mb_height
;
uint8_t
*
slice_quants
;
uint8_t
*
slice_quants
;
int
quant
[
2
];
int
quant
[
2
];
...
@@ -200,9 +200,9 @@ static int tscc2_decode_slice(TSCC2Context *c, int mb_y,
...
@@ -200,9 +200,9 @@ static int tscc2_decode_slice(TSCC2Context *c, int mb_y,
if
(
q
==
0
||
q
==
3
)
// skip block
if
(
q
==
0
||
q
==
3
)
// skip block
continue
;
continue
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
off
=
mb_x
*
16
+
mb_y
*
8
*
c
->
pic
.
linesize
[
i
];
off
=
mb_x
*
16
+
mb_y
*
8
*
c
->
pic
->
linesize
[
i
];
ret
=
tscc2_decode_mb
(
c
,
c
->
q
[
q
-
1
],
c
->
quant
[
q
-
1
]
-
2
,
ret
=
tscc2_decode_mb
(
c
,
c
->
q
[
q
-
1
],
c
->
quant
[
q
-
1
]
-
2
,
c
->
pic
.
data
[
i
]
+
off
,
c
->
pic
.
linesize
[
i
],
i
);
c
->
pic
->
data
[
i
]
+
off
,
c
->
pic
->
linesize
[
i
],
i
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
}
}
...
@@ -230,14 +230,14 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -230,14 +230,14 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
if
((
ret
=
ff_reget_buffer
(
avctx
,
&
c
->
pic
))
<
0
)
{
if
((
ret
=
ff_reget_buffer
(
avctx
,
c
->
pic
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"reget_buffer() failed
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"reget_buffer() failed
\n
"
);
return
ret
;
return
ret
;
}
}
if
(
frame_type
==
0
)
{
if
(
frame_type
==
0
)
{
*
got_frame
=
1
;
*
got_frame
=
1
;
if
((
ret
=
av_frame_ref
(
data
,
&
c
->
pic
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
c
->
pic
))
<
0
)
return
ret
;
return
ret
;
return
buf_size
;
return
buf_size
;
...
@@ -322,13 +322,24 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -322,13 +322,24 @@ static int tscc2_decode_frame(AVCodecContext *avctx, void *data,
}
}
*
got_frame
=
1
;
*
got_frame
=
1
;
if
((
ret
=
av_frame_ref
(
data
,
&
c
->
pic
))
<
0
)
if
((
ret
=
av_frame_ref
(
data
,
c
->
pic
))
<
0
)
return
ret
;
return
ret
;
/* always report that the buffer was completely consumed */
/* always report that the buffer was completely consumed */
return
buf_size
;
return
buf_size
;
}
}
static
av_cold
int
tscc2_decode_end
(
AVCodecContext
*
avctx
)
{
TSCC2Context
*
const
c
=
avctx
->
priv_data
;
av_frame_free
(
&
c
->
pic
);
av_freep
(
&
c
->
slice_quants
);
free_vlcs
(
c
);
return
0
;
}
static
av_cold
int
tscc2_decode_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
tscc2_decode_init
(
AVCodecContext
*
avctx
)
{
{
TSCC2Context
*
const
c
=
avctx
->
priv_data
;
TSCC2Context
*
const
c
=
avctx
->
priv_data
;
...
@@ -352,16 +363,11 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx)
...
@@ -352,16 +363,11 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
return
0
;
c
->
pic
=
av_frame_alloc
();
}
if
(
!
c
->
pic
)
{
tscc2_decode_end
(
avctx
);
static
av_cold
int
tscc2_decode_end
(
AVCodecContext
*
avctx
)
return
AVERROR
(
ENOMEM
);
{
}
TSCC2Context
*
const
c
=
avctx
->
priv_data
;
av_frame_unref
(
&
c
->
pic
);
av_freep
(
&
c
->
slice_quants
);
free_vlcs
(
c
);
return
0
;
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