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
0ca36b4d
Commit
0ca36b4d
authored
Sep 06, 2011
by
Kieran Kunhya
Committed by
Janne Grunau
Sep 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LATM muxer
Signed-off-by:
Janne Grunau
<
janne-libav@jannau.net
>
parent
635bbecf
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
196 additions
and
1 deletion
+196
-1
Changelog
Changelog
+1
-0
general.texi
doc/general.texi
+1
-0
Makefile
libavcodec/Makefile
+1
-0
Makefile
libavformat/Makefile
+1
-0
allformats.c
libavformat/allformats.c
+1
-0
latmenc.c
libavformat/latmenc.c
+190
-0
version.h
libavformat/version.h
+1
-1
No files found.
Changelog
View file @
0ca36b4d
...
...
@@ -42,6 +42,7 @@ easier to use. The changes are:
* -intra option was removed, it's equivalent to -g 0.
- XMV demuxer
- Windows Media Image decoder
- LATM muxer
version 0.7:
...
...
doc/general.texi
View file @
0ca36b4d
...
...
@@ -118,6 +118,7 @@ library:
@tab A format generated by IndigoVision 8000 video server.
@item IVF (On2) @tab X @tab X
@tab A format used by libvpx
@item LATM @tab X @tab X
@item LMLM4 @tab @tab X
@tab Used by Linux Media Labs MPEG-4 PCI boards
@item LXF @tab @tab X
...
...
libavcodec/Makefile
View file @
0ca36b4d
...
...
@@ -531,6 +531,7 @@ OBJS-$(CONFIG_FLAC_MUXER) += flacdec.o flacdata.o flac.o
OBJS-$(CONFIG_FLV_DEMUXER)
+=
mpeg4audio.o
OBJS-$(CONFIG_GXF_DEMUXER)
+=
mpeg12data.o
OBJS-$(CONFIG_IFF_DEMUXER)
+=
iff.o
OBJS-$(CONFIG_LATM_MUXER)
+=
mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)
+=
xiph.o
mpeg4audio.o
\
flacdec.o
flacdata.o
flac.o
OBJS-$(CONFIG_MATROSKA_DEMUXER)
+=
mpeg4audio.o
mpegaudiodata.o
...
...
libavformat/Makefile
View file @
0ca36b4d
...
...
@@ -109,6 +109,7 @@ OBJS-$(CONFIG_IV8_DEMUXER) += iv8.o
OBJS-$(CONFIG_IVF_DEMUXER)
+=
ivfdec.o
riff.o
OBJS-$(CONFIG_IVF_MUXER)
+=
ivfenc.o
OBJS-$(CONFIG_JV_DEMUXER)
+=
jvdec.o
OBJS-$(CONFIG_LATM_MUXER)
+=
latmenc.o
OBJS-$(CONFIG_LMLM4_DEMUXER)
+=
lmlm4.o
OBJS-$(CONFIG_LXF_DEMUXER)
+=
lxfdec.o
OBJS-$(CONFIG_M4V_DEMUXER)
+=
m4vdec.o
rawdec.o
...
...
libavformat/allformats.c
View file @
0ca36b4d
...
...
@@ -113,6 +113,7 @@ void av_register_all(void)
REGISTER_DEMUXER
(
IV8
,
iv8
);
REGISTER_MUXDEMUX
(
IVF
,
ivf
);
REGISTER_DEMUXER
(
JV
,
jv
);
REGISTER_MUXER
(
LATM
,
latm
);
REGISTER_DEMUXER
(
LMLM4
,
lmlm4
);
REGISTER_DEMUXER
(
LXF
,
lxf
);
REGISTER_MUXDEMUX
(
M4V
,
m4v
);
...
...
libavformat/latmenc.c
0 → 100644
View file @
0ca36b4d
/*
* LATM/LOAS muxer
* Copyright (c) 2011 Kieran Kunhya <kieran@kunhya.com>
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavcodec/get_bits.h"
#include "libavcodec/put_bits.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/mpeg4audio.h"
#include "libavutil/opt.h"
#include "avformat.h"
typedef
struct
{
int
off
;
int
channel_conf
;
int
object_type
;
int
counter
;
int
mod
;
}
LATMContext
;
static
const
AVOption
options
[]
=
{
{
"smc-interval"
,
"StreamMuxConfig interval."
,
offsetof
(
LATMContext
,
mod
),
FF_OPT_TYPE_INT
,
{.
dbl
=
0x0014
},
0x0001
,
0xffff
,
AV_OPT_FLAG_ENCODING_PARAM
},
{
NULL
},
};
static
const
AVClass
latm_muxer_class
=
{
.
class_name
=
"LATM/LOAS muxer"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
int
latm_decode_extradata
(
LATMContext
*
ctx
,
uint8_t
*
buf
,
int
size
)
{
GetBitContext
gb
;
MPEG4AudioConfig
m4ac
;
init_get_bits
(
&
gb
,
buf
,
size
*
8
);
ctx
->
off
=
ff_mpeg4audio_get_config
(
&
m4ac
,
buf
,
size
);
if
(
ctx
->
off
<
0
)
return
ctx
->
off
;
skip_bits_long
(
&
gb
,
ctx
->
off
);
/* FIXME: are any formats not allowed in LATM? */
if
(
m4ac
.
object_type
>
AOT_SBR
&&
m4ac
.
object_type
!=
AOT_ALS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Muxing MPEG-4 AOT %d in LATM is not supported
\n
"
,
m4ac
.
object_type
);
return
AVERROR_INVALIDDATA
;
}
ctx
->
channel_conf
=
m4ac
.
chan_config
;
ctx
->
object_type
=
m4ac
.
object_type
;
return
0
;
}
static
int
latm_write_header
(
AVFormatContext
*
s
)
{
LATMContext
*
ctx
=
s
->
priv_data
;
AVCodecContext
*
avctx
=
s
->
streams
[
0
]
->
codec
;
if
(
avctx
->
extradata_size
>
0
&&
latm_decode_extradata
(
ctx
,
avctx
->
extradata
,
avctx
->
extradata_size
)
<
0
)
return
AVERROR_INVALIDDATA
;
return
0
;
}
static
int
latm_write_frame_header
(
AVFormatContext
*
s
,
PutBitContext
*
bs
)
{
LATMContext
*
ctx
=
s
->
priv_data
;
AVCodecContext
*
avctx
=
s
->
streams
[
0
]
->
codec
;
GetBitContext
gb
;
int
header_size
;
/* AudioMuxElement */
put_bits
(
bs
,
1
,
!!
ctx
->
counter
);
if
(
!
ctx
->
counter
)
{
init_get_bits
(
&
gb
,
avctx
->
extradata
,
avctx
->
extradata_size
*
8
);
/* StreamMuxConfig */
put_bits
(
bs
,
1
,
0
);
/* audioMuxVersion */
put_bits
(
bs
,
1
,
1
);
/* allStreamsSameTimeFraming */
put_bits
(
bs
,
6
,
0
);
/* numSubFrames */
put_bits
(
bs
,
4
,
0
);
/* numProgram */
put_bits
(
bs
,
3
,
0
);
/* numLayer */
/* AudioSpecificConfig */
if
(
ctx
->
object_type
==
AOT_ALS
)
{
header_size
=
avctx
->
extradata_size
-
(
ctx
->
off
+
7
)
>>
3
;
ff_copy_bits
(
bs
,
&
avctx
->
extradata
[
ctx
->
off
],
header_size
);
}
else
{
ff_copy_bits
(
bs
,
avctx
->
extradata
,
ctx
->
off
+
3
);
if
(
!
ctx
->
channel_conf
)
{
ff_copy_pce_data
(
bs
,
&
gb
);
}
}
put_bits
(
bs
,
3
,
0
);
/* frameLengthType */
put_bits
(
bs
,
8
,
0
);
/* latmBufferFullness */
put_bits
(
bs
,
1
,
0
);
/* otherDataPresent */
put_bits
(
bs
,
1
,
0
);
/* crcCheckPresent */
}
ctx
->
counter
++
;
ctx
->
counter
%=
ctx
->
mod
;
return
0
;
}
static
int
latm_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
AVIOContext
*
pb
=
s
->
pb
;
PutBitContext
bs
;
int
i
,
len
;
uint8_t
loas_header
[]
=
"
\x56\xe0\x00
"
;
uint8_t
*
buf
;
if
(
pkt
->
size
>
2
&&
pkt
->
data
[
0
]
==
0xff
&&
(
pkt
->
data
[
1
]
>>
4
)
==
0xf
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"ADTS header detected - ADTS will not be incorrectly muxed into LATM
\n
"
);
return
AVERROR_INVALIDDATA
;
}
buf
=
av_malloc
(
pkt
->
size
+
1024
);
if
(
!
buf
)
return
AVERROR
(
ENOMEM
);
init_put_bits
(
&
bs
,
buf
,
pkt
->
size
+
1024
);
latm_write_frame_header
(
s
,
&
bs
);
/* PayloadLengthInfo() */
for
(
i
=
0
;
i
<=
pkt
->
size
-
255
;
i
+=
255
)
put_bits
(
&
bs
,
8
,
255
);
put_bits
(
&
bs
,
8
,
pkt
->
size
-
i
);
/* The LATM payload is written unaligned */
/* PayloadMux() */
for
(
i
=
0
;
i
<
pkt
->
size
;
i
++
)
put_bits
(
&
bs
,
8
,
pkt
->
data
[
i
]);
align_put_bits
(
&
bs
);
flush_put_bits
(
&
bs
);
len
=
put_bits_count
(
&
bs
)
>>
3
;
loas_header
[
1
]
|=
(
len
>>
8
)
&
0x1f
;
loas_header
[
2
]
|=
len
&
0xff
;
avio_write
(
pb
,
loas_header
,
3
);
avio_write
(
pb
,
buf
,
len
);
av_free
(
buf
);
return
0
;
}
AVOutputFormat
ff_latm_muxer
=
{
.
name
=
"latm"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"LOAS/LATM"
),
.
mime_type
=
"audio/MP4A-LATM"
,
.
extensions
=
"latm"
,
.
priv_data_size
=
sizeof
(
LATMContext
),
.
audio_codec
=
CODEC_ID_AAC
,
.
video_codec
=
CODEC_ID_NONE
,
.
write_header
=
latm_write_header
,
.
write_packet
=
latm_write_packet
,
.
priv_class
=
&
latm_muxer_class
,
};
libavformat/version.h
View file @
0ca36b4d
...
...
@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR
6
#define LIBAVFORMAT_VERSION_MINOR
7
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
...
...
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