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
a3b53ff0
Commit
a3b53ff0
authored
Aug 22, 2013
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mov: Refactor video specific parsing in mov_parse_stsd_video
parent
bf985625
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
107 deletions
+108
-107
mov.c
libavformat/mov.c
+108
-107
No files found.
libavformat/mov.c
View file @
a3b53ff0
...
...
@@ -1100,68 +1100,13 @@ static int mov_codec_id(AVStream *st, uint32_t format)
return
id
;
}
int
ff_mov_read_stsd_entries
(
MOVContext
*
c
,
AVIOContext
*
pb
,
int
entries
)
static
void
mov_parse_stsd_video
(
MOVContext
*
c
,
AVIOContext
*
pb
,
AVStream
*
st
,
MOVStreamContext
*
sc
)
{
AVStream
*
st
;
MOVStreamContext
*
sc
;
int
j
,
pseudo_stream_id
;
if
(
c
->
fc
->
nb_streams
<
1
)
return
0
;
st
=
c
->
fc
->
streams
[
c
->
fc
->
nb_streams
-
1
];
sc
=
st
->
priv_data
;
for
(
pseudo_stream_id
=
0
;
pseudo_stream_id
<
entries
&&
!
pb
->
eof_reached
;
pseudo_stream_id
++
)
{
//Parsing Sample description table
enum
AVCodecID
id
;
int
dref_id
=
1
;
MOVAtom
a
=
{
AV_RL32
(
"stsd"
)
};
int64_t
start_pos
=
avio_tell
(
pb
);
uint32_t
size
=
avio_rb32
(
pb
);
/* size */
uint32_t
format
=
avio_rl32
(
pb
);
/* data format */
if
(
size
>=
16
)
{
avio_rb32
(
pb
);
/* reserved */
avio_rb16
(
pb
);
/* reserved */
dref_id
=
avio_rb16
(
pb
);
}
else
{
av_log
(
c
->
fc
,
AV_LOG_ERROR
,
"invalid size %d in stsd
\n
"
,
size
);
return
AVERROR_INVALIDDATA
;
}
if
(
st
->
codec
->
codec_tag
&&
st
->
codec
->
codec_tag
!=
format
&&
(
c
->
fc
->
video_codec_id
?
ff_codec_get_id
(
ff_codec_movvideo_tags
,
format
)
!=
c
->
fc
->
video_codec_id
:
st
->
codec
->
codec_tag
!=
MKTAG
(
'j'
,
'p'
,
'e'
,
'g'
))
){
/* Multiple fourcc, we skip JPEG. This is not correct, we should
* export it as a separate AVStream but this needs a few changes
* in the MOV demuxer, patch welcome. */
multiple_stsd:
av_log
(
c
->
fc
,
AV_LOG_WARNING
,
"multiple fourcc not supported
\n
"
);
avio_skip
(
pb
,
size
-
(
avio_tell
(
pb
)
-
start_pos
));
continue
;
}
/* we cannot demux concatenated h264 streams because of different extradata */
if
(
st
->
codec
->
codec_tag
&&
st
->
codec
->
codec_tag
==
AV_RL32
(
"avc1"
))
goto
multiple_stsd
;
sc
->
pseudo_stream_id
=
st
->
codec
->
codec_tag
?
-
1
:
pseudo_stream_id
;
sc
->
dref_id
=
dref_id
;
id
=
mov_codec_id
(
st
,
format
);
av_dlog
(
c
->
fc
,
"size=%d 4CC= %c%c%c%c codec_type=%d
\n
"
,
size
,
(
format
>>
0
)
&
0xff
,
(
format
>>
8
)
&
0xff
,
(
format
>>
16
)
&
0xff
,
(
format
>>
24
)
&
0xff
,
st
->
codec
->
codec_type
);
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
unsigned
int
color_depth
,
len
;
unsigned
int
color_depth
,
len
,
j
;
int
color_greyscale
;
int
color_table_id
;
st
->
codec
->
codec_id
=
id
;
avio_rb16
(
pb
);
/* version */
avio_rb16
(
pb
);
/* revision level */
avio_rb32
(
pb
);
/* vendor */
...
...
@@ -1184,9 +1129,9 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
avio_skip
(
pb
,
31
-
len
);
/* codec_tag YV12 triggers an UV swap in rawdec.c */
if
(
!
memcmp
(
st
->
codec
->
codec_name
,
"Planar Y'CbCr 8-bit 4:2:0"
,
25
))
st
->
codec
->
codec_tag
=
MKTAG
(
'I'
,
'4'
,
'2'
,
'0'
);
st
->
codec
->
codec_tag
=
MKTAG
(
'I'
,
'4'
,
'2'
,
'0'
);
/* Flash Media Server uses tag H263 with Sorenson Spark */
if
(
format
==
MKTAG
(
'H'
,
'2'
,
'6'
,
'3'
)
&&
if
(
st
->
codec
->
codec_tag
==
MKTAG
(
'H'
,
'2'
,
'6'
,
'3'
)
&&
!
memcmp
(
st
->
codec
->
codec_name
,
"Sorenson H263"
,
13
))
st
->
codec
->
codec_id
=
AV_CODEC_ID_FLV1
;
...
...
@@ -1199,8 +1144,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
color_greyscale
=
st
->
codec
->
bits_per_coded_sample
&
0x20
;
/* if the depth is 2, 4, or 8 bpp, file is palettized */
if
((
color_depth
==
2
)
||
(
color_depth
==
4
)
||
(
color_depth
==
8
))
{
if
((
color_depth
==
2
)
||
(
color_depth
==
4
)
||
(
color_depth
==
8
))
{
/* for palette traversal */
unsigned
int
color_start
,
color_count
,
color_end
;
unsigned
char
r
,
g
,
b
;
...
...
@@ -1214,8 +1158,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
color_dec
=
256
/
(
color_count
-
1
);
for
(
j
=
0
;
j
<
color_count
;
j
++
)
{
r
=
g
=
b
=
color_index
;
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
color_index
-=
color_dec
;
if
(
color_index
<
0
)
color_index
=
0
;
...
...
@@ -1235,16 +1178,14 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
r
=
color_table
[
j
*
3
+
0
];
g
=
color_table
[
j
*
3
+
1
];
b
=
color_table
[
j
*
3
+
2
];
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
}
else
{
/* load the palette from the file */
color_start
=
avio_rb32
(
pb
);
color_count
=
avio_rb16
(
pb
);
color_end
=
avio_rb16
(
pb
);
if
((
color_start
<=
255
)
&&
(
color_end
<=
255
))
{
if
((
color_start
<=
255
)
&&
(
color_end
<=
255
))
{
for
(
j
=
color_start
;
j
<=
color_end
;
j
++
)
{
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
...
...
@@ -1257,13 +1198,73 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
avio_r8
(
pb
);
b
=
avio_r8
(
pb
);
avio_r8
(
pb
);
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
}
}
sc
->
has_palette
=
1
;
}
}
int
ff_mov_read_stsd_entries
(
MOVContext
*
c
,
AVIOContext
*
pb
,
int
entries
)
{
AVStream
*
st
;
MOVStreamContext
*
sc
;
int
pseudo_stream_id
;
if
(
c
->
fc
->
nb_streams
<
1
)
return
0
;
st
=
c
->
fc
->
streams
[
c
->
fc
->
nb_streams
-
1
];
sc
=
st
->
priv_data
;
for
(
pseudo_stream_id
=
0
;
pseudo_stream_id
<
entries
&&
!
pb
->
eof_reached
;
pseudo_stream_id
++
)
{
//Parsing Sample description table
enum
AVCodecID
id
;
int
dref_id
=
1
;
MOVAtom
a
=
{
AV_RL32
(
"stsd"
)
};
int64_t
start_pos
=
avio_tell
(
pb
);
uint32_t
size
=
avio_rb32
(
pb
);
/* size */
uint32_t
format
=
avio_rl32
(
pb
);
/* data format */
if
(
size
>=
16
)
{
avio_rb32
(
pb
);
/* reserved */
avio_rb16
(
pb
);
/* reserved */
dref_id
=
avio_rb16
(
pb
);
}
else
{
av_log
(
c
->
fc
,
AV_LOG_ERROR
,
"invalid size %d in stsd
\n
"
,
size
);
return
AVERROR_INVALIDDATA
;
}
if
(
st
->
codec
->
codec_tag
&&
st
->
codec
->
codec_tag
!=
format
&&
(
c
->
fc
->
video_codec_id
?
ff_codec_get_id
(
ff_codec_movvideo_tags
,
format
)
!=
c
->
fc
->
video_codec_id
:
st
->
codec
->
codec_tag
!=
MKTAG
(
'j'
,
'p'
,
'e'
,
'g'
))
){
/* Multiple fourcc, we skip JPEG. This is not correct, we should
* export it as a separate AVStream but this needs a few changes
* in the MOV demuxer, patch welcome. */
multiple_stsd:
av_log
(
c
->
fc
,
AV_LOG_WARNING
,
"multiple fourcc not supported
\n
"
);
avio_skip
(
pb
,
size
-
(
avio_tell
(
pb
)
-
start_pos
));
continue
;
}
/* we cannot demux concatenated h264 streams because of different extradata */
if
(
st
->
codec
->
codec_tag
&&
st
->
codec
->
codec_tag
==
AV_RL32
(
"avc1"
))
goto
multiple_stsd
;
sc
->
pseudo_stream_id
=
st
->
codec
->
codec_tag
?
-
1
:
pseudo_stream_id
;
sc
->
dref_id
=
dref_id
;
id
=
mov_codec_id
(
st
,
format
);
av_dlog
(
c
->
fc
,
"size=%d 4CC= %c%c%c%c codec_type=%d
\n
"
,
size
,
(
format
>>
0
)
&
0xff
,
(
format
>>
8
)
&
0xff
,
(
format
>>
16
)
&
0xff
,
(
format
>>
24
)
&
0xff
,
st
->
codec
->
codec_type
);
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
st
->
codec
->
codec_id
=
id
;
mov_parse_stsd_video
(
c
,
pb
,
st
,
sc
);
}
else
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
int
bits_per_sample
,
flags
;
uint16_t
version
=
avio_rb16
(
pb
);
...
...
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