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
17b11559
Commit
17b11559
authored
Jan 18, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bethsoftvid: fix read_packet() return codes.
Use proper AVERROR codes, and return 0 for no error.
parent
f320fb89
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
bethsoftvid.c
libavformat/bethsoftvid.c
+22
-9
No files found.
libavformat/bethsoftvid.c
View file @
17b11559
...
@@ -109,6 +109,7 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
...
@@ -109,6 +109,7 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
int
bytes_copied
=
0
;
int
bytes_copied
=
0
;
int
position
;
int
position
;
unsigned
int
vidbuf_capacity
;
unsigned
int
vidbuf_capacity
;
int
ret
=
0
;
vidbuf_start
=
av_malloc
(
vidbuf_capacity
=
BUFFER_PADDING_SIZE
);
vidbuf_start
=
av_malloc
(
vidbuf_capacity
=
BUFFER_PADDING_SIZE
);
if
(
!
vidbuf_start
)
if
(
!
vidbuf_start
)
...
@@ -124,8 +125,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
...
@@ -124,8 +125,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
// set the y offset if it exists (decoder header data should be in data section)
// set the y offset if it exists (decoder header data should be in data section)
if
(
block_type
==
VIDEO_YOFF_P_FRAME
){
if
(
block_type
==
VIDEO_YOFF_P_FRAME
){
if
(
avio_read
(
pb
,
&
vidbuf_start
[
vidbuf_nbytes
],
2
)
!=
2
)
if
(
avio_read
(
pb
,
&
vidbuf_start
[
vidbuf_nbytes
],
2
)
!=
2
)
{
ret
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
}
vidbuf_nbytes
+=
2
;
vidbuf_nbytes
+=
2
;
}
}
...
@@ -141,8 +144,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
...
@@ -141,8 +144,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
if
(
block_type
==
VIDEO_I_FRAME
)
if
(
block_type
==
VIDEO_I_FRAME
)
vidbuf_start
[
vidbuf_nbytes
++
]
=
avio_r8
(
pb
);
vidbuf_start
[
vidbuf_nbytes
++
]
=
avio_r8
(
pb
);
}
else
if
(
code
){
// plain sequence
}
else
if
(
code
){
// plain sequence
if
(
avio_read
(
pb
,
&
vidbuf_start
[
vidbuf_nbytes
],
code
)
!=
code
)
if
(
avio_read
(
pb
,
&
vidbuf_start
[
vidbuf_nbytes
],
code
)
!=
code
)
{
ret
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
}
vidbuf_nbytes
+=
code
;
vidbuf_nbytes
+=
code
;
}
}
bytes_copied
+=
code
&
0x7F
;
bytes_copied
+=
code
&
0x7F
;
...
@@ -152,12 +157,14 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
...
@@ -152,12 +157,14 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
avio_seek
(
pb
,
-
1
,
SEEK_CUR
);
avio_seek
(
pb
,
-
1
,
SEEK_CUR
);
break
;
break
;
}
}
if
(
bytes_copied
>
npixels
)
if
(
bytes_copied
>
npixels
)
{
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
while
(
code
);
}
while
(
code
);
// copy data into packet
// copy data into packet
if
(
av_new_packet
(
pkt
,
vidbuf_nbytes
)
<
0
)
if
((
ret
=
av_new_packet
(
pkt
,
vidbuf_nbytes
)
)
<
0
)
goto
fail
;
goto
fail
;
memcpy
(
pkt
->
data
,
vidbuf_start
,
vidbuf_nbytes
);
memcpy
(
pkt
->
data
,
vidbuf_start
,
vidbuf_nbytes
);
av_free
(
vidbuf_start
);
av_free
(
vidbuf_start
);
...
@@ -175,10 +182,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
...
@@ -175,10 +182,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
}
}
vid
->
nframes
--
;
// used to check if all the frames were read
vid
->
nframes
--
;
// used to check if all the frames were read
return
vidbuf_nbytes
;
return
0
;
fail:
fail:
av_free
(
vidbuf_start
);
av_free
(
vidbuf_start
);
return
-
1
;
return
ret
;
}
}
static
int
vid_read_packet
(
AVFormatContext
*
s
,
static
int
vid_read_packet
(
AVFormatContext
*
s
,
...
@@ -216,9 +223,14 @@ static int vid_read_packet(AVFormatContext *s,
...
@@ -216,9 +223,14 @@ static int vid_read_packet(AVFormatContext *s,
s
->
streams
[
1
]
->
codec
->
bit_rate
=
s
->
streams
[
1
]
->
codec
->
channels
*
s
->
streams
[
1
]
->
codec
->
sample_rate
*
s
->
streams
[
1
]
->
codec
->
bits_per_coded_sample
;
s
->
streams
[
1
]
->
codec
->
bit_rate
=
s
->
streams
[
1
]
->
codec
->
channels
*
s
->
streams
[
1
]
->
codec
->
sample_rate
*
s
->
streams
[
1
]
->
codec
->
bits_per_coded_sample
;
case
AUDIO_BLOCK
:
case
AUDIO_BLOCK
:
audio_length
=
avio_rl16
(
pb
);
audio_length
=
avio_rl16
(
pb
);
ret_value
=
av_get_packet
(
pb
,
pkt
,
audio_length
);
if
((
ret_value
=
av_get_packet
(
pb
,
pkt
,
audio_length
))
!=
audio_length
)
{
if
(
ret_value
<
0
)
return
ret_value
;
av_log
(
s
,
AV_LOG_ERROR
,
"incomplete audio block
\n
"
);
return
AVERROR
(
EIO
);
}
pkt
->
stream_index
=
1
;
pkt
->
stream_index
=
1
;
return
ret_value
!=
audio_length
?
AVERROR
(
EIO
)
:
ret_value
;
return
0
;
case
VIDEO_P_FRAME
:
case
VIDEO_P_FRAME
:
case
VIDEO_YOFF_P_FRAME
:
case
VIDEO_YOFF_P_FRAME
:
...
@@ -233,7 +245,8 @@ static int vid_read_packet(AVFormatContext *s,
...
@@ -233,7 +245,8 @@ static int vid_read_packet(AVFormatContext *s,
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
default:
default:
av_log
(
s
,
AV_LOG_ERROR
,
"unknown block (character = %c, decimal = %d, hex = %x)!!!
\n
"
,
av_log
(
s
,
AV_LOG_ERROR
,
"unknown block (character = %c, decimal = %d, hex = %x)!!!
\n
"
,
block_type
,
block_type
,
block_type
);
return
-
1
;
block_type
,
block_type
,
block_type
);
return
AVERROR_INVALIDDATA
;
}
}
}
}
...
...
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