Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
08504380
Commit
08504380
authored
11 years ago
by
Luca Barbato
Browse files
Options
Downloads
Patches
Plain Diff
mov: Refactor codec specific final steps in mov_finalize_stsd_codec
parent
dc518a3a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavformat/mov.c
+65
-58
65 additions, 58 deletions
libavformat/mov.c
with
65 additions
and
58 deletions
libavformat/mov.c
+
65
−
58
View file @
08504380
...
...
@@ -1306,6 +1306,70 @@ static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb,
st
->
codec
->
height
=
sc
->
height
;
}
static
int
mov_finalize_stsd_codec
(
MOVContext
*
c
,
AVIOContext
*
pb
,
AVStream
*
st
,
MOVStreamContext
*
sc
)
{
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
&&
!
st
->
codec
->
sample_rate
&&
sc
->
time_scale
>
1
)
st
->
codec
->
sample_rate
=
sc
->
time_scale
;
/* special codec parameters handling */
switch
(
st
->
codec
->
codec_id
)
{
#if CONFIG_DV_DEMUXER
case
AV_CODEC_ID_DVAUDIO
:
c
->
dv_fctx
=
avformat_alloc_context
();
c
->
dv_demux
=
avpriv_dv_init_demux
(
c
->
dv_fctx
);
if
(
!
c
->
dv_demux
)
{
av_log
(
c
->
fc
,
AV_LOG_ERROR
,
"dv demux context init error
\n
"
);
return
AVERROR
(
ENOMEM
);
}
sc
->
dv_audio_container
=
1
;
st
->
codec
->
codec_id
=
AV_CODEC_ID_PCM_S16LE
;
break
;
#endif
/* no ifdef since parameters are always those */
case
AV_CODEC_ID_QCELP
:
st
->
codec
->
channels
=
1
;
// force sample rate for qcelp when not stored in mov
if
(
st
->
codec
->
codec_tag
!=
MKTAG
(
'Q'
,
'c'
,
'l'
,
'p'
))
st
->
codec
->
sample_rate
=
8000
;
break
;
case
AV_CODEC_ID_AMR_NB
:
st
->
codec
->
channels
=
1
;
/* force sample rate for amr, stsd in 3gp does not store sample rate */
st
->
codec
->
sample_rate
=
8000
;
break
;
case
AV_CODEC_ID_AMR_WB
:
st
->
codec
->
channels
=
1
;
st
->
codec
->
sample_rate
=
16000
;
break
;
case
AV_CODEC_ID_MP2
:
case
AV_CODEC_ID_MP3
:
/* force type after stsd for m1a hdlr */
st
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
st
->
need_parsing
=
AVSTREAM_PARSE_FULL
;
break
;
case
AV_CODEC_ID_GSM
:
case
AV_CODEC_ID_ADPCM_MS
:
case
AV_CODEC_ID_ADPCM_IMA_WAV
:
case
AV_CODEC_ID_ILBC
:
st
->
codec
->
block_align
=
sc
->
bytes_per_frame
;
break
;
case
AV_CODEC_ID_ALAC
:
if
(
st
->
codec
->
extradata_size
==
36
)
{
st
->
codec
->
channels
=
AV_RB8
(
st
->
codec
->
extradata
+
21
);
st
->
codec
->
sample_rate
=
AV_RB32
(
st
->
codec
->
extradata
+
32
);
}
break
;
case
AV_CODEC_ID_VC1
:
st
->
need_parsing
=
AVSTREAM_PARSE_FULL
;
break
;
default:
break
;
}
return
0
;
}
int
ff_mov_read_stsd_entries
(
MOVContext
*
c
,
AVIOContext
*
pb
,
int
entries
)
{
AVStream
*
st
;
...
...
@@ -1389,64 +1453,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
if
(
pb
->
eof_reached
)
return
AVERROR_EOF
;
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
&&
st
->
codec
->
sample_rate
==
0
&&
sc
->
time_scale
>
1
)
st
->
codec
->
sample_rate
=
sc
->
time_scale
;
/* special codec parameters handling */
switch
(
st
->
codec
->
codec_id
)
{
#if CONFIG_DV_DEMUXER
case
AV_CODEC_ID_DVAUDIO
:
c
->
dv_fctx
=
avformat_alloc_context
();
c
->
dv_demux
=
avpriv_dv_init_demux
(
c
->
dv_fctx
);
if
(
!
c
->
dv_demux
)
{
av_log
(
c
->
fc
,
AV_LOG_ERROR
,
"dv demux context init error
\n
"
);
return
AVERROR
(
ENOMEM
);
}
sc
->
dv_audio_container
=
1
;
st
->
codec
->
codec_id
=
AV_CODEC_ID_PCM_S16LE
;
break
;
#endif
/* no ifdef since parameters are always those */
case
AV_CODEC_ID_QCELP
:
// force sample rate for qcelp when not stored in mov
if
(
st
->
codec
->
codec_tag
!=
MKTAG
(
'Q'
,
'c'
,
'l'
,
'p'
))
st
->
codec
->
sample_rate
=
8000
;
st
->
codec
->
channels
=
1
;
/* really needed */
break
;
case
AV_CODEC_ID_AMR_NB
:
st
->
codec
->
channels
=
1
;
/* really needed */
/* force sample rate for amr, stsd in 3gp does not store sample rate */
st
->
codec
->
sample_rate
=
8000
;
break
;
case
AV_CODEC_ID_AMR_WB
:
st
->
codec
->
channels
=
1
;
st
->
codec
->
sample_rate
=
16000
;
break
;
case
AV_CODEC_ID_MP2
:
case
AV_CODEC_ID_MP3
:
st
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
/* force type after stsd for m1a hdlr */
st
->
need_parsing
=
AVSTREAM_PARSE_FULL
;
break
;
case
AV_CODEC_ID_GSM
:
case
AV_CODEC_ID_ADPCM_MS
:
case
AV_CODEC_ID_ADPCM_IMA_WAV
:
case
AV_CODEC_ID_ILBC
:
st
->
codec
->
block_align
=
sc
->
bytes_per_frame
;
break
;
case
AV_CODEC_ID_ALAC
:
if
(
st
->
codec
->
extradata_size
==
36
)
{
st
->
codec
->
channels
=
AV_RB8
(
st
->
codec
->
extradata
+
21
);
st
->
codec
->
sample_rate
=
AV_RB32
(
st
->
codec
->
extradata
+
32
);
}
break
;
case
AV_CODEC_ID_VC1
:
st
->
need_parsing
=
AVSTREAM_PARSE_FULL
;
break
;
default:
break
;
}
return
0
;
return
mov_finalize_stsd_codec
(
c
,
pb
,
st
,
sc
);
}
static
int
mov_read_stsd
(
MOVContext
*
c
,
AVIOContext
*
pb
,
MOVAtom
atom
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment