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
01656fd4
Commit
01656fd4
authored
May 28, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
matroskaenc: support muxing WavPack
parent
794ca87d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
2 deletions
+85
-2
Makefile
libavformat/Makefile
+1
-1
matroskaenc.c
libavformat/matroskaenc.c
+72
-1
Makefile
tests/Makefile
+2
-0
wavpack.mak
tests/fate/wavpack.mak
+10
-0
No files found.
libavformat/Makefile
View file @
01656fd4
...
@@ -160,7 +160,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
...
@@ -160,7 +160,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
isom.o
rmsipr.o
isom.o
rmsipr.o
OBJS-$(CONFIG_MATROSKA_MUXER)
+=
matroskaenc.o
matroska.o
\
OBJS-$(CONFIG_MATROSKA_MUXER)
+=
matroskaenc.o
matroska.o
\
isom.o
avc.o
\
isom.o
avc.o
\
flacenc_header.o
avlanguage.o
flacenc_header.o
avlanguage.o
wv.o
OBJS-$(CONFIG_MD5_MUXER)
+=
md5enc.o
OBJS-$(CONFIG_MD5_MUXER)
+=
md5enc.o
OBJS-$(CONFIG_MJPEG_DEMUXER)
+=
rawdec.o
OBJS-$(CONFIG_MJPEG_DEMUXER)
+=
rawdec.o
OBJS-$(CONFIG_MJPEG_MUXER)
+=
rawenc.o
OBJS-$(CONFIG_MJPEG_MUXER)
+=
rawenc.o
...
...
libavformat/matroskaenc.c
View file @
01656fd4
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "isom.h"
#include "isom.h"
#include "matroska.h"
#include "matroska.h"
#include "riff.h"
#include "riff.h"
#include "wv.h"
#include "libavutil/avstring.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/dict.h"
...
@@ -450,6 +451,15 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex
...
@@ -450,6 +451,15 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex
return
0
;
return
0
;
}
}
static
int
put_wv_codecpriv
(
AVIOContext
*
pb
,
AVCodecContext
*
codec
)
{
if
(
codec
->
extradata
&&
codec
->
extradata_size
==
2
)
avio_write
(
pb
,
codec
->
extradata
,
2
);
else
avio_wl16
(
pb
,
0x403
);
// fallback to the version mentioned in matroska specs
return
0
;
}
static
void
get_aac_sample_rates
(
AVFormatContext
*
s
,
AVCodecContext
*
codec
,
int
*
sample_rate
,
int
*
output_sample_rate
)
static
void
get_aac_sample_rates
(
AVFormatContext
*
s
,
AVCodecContext
*
codec
,
int
*
sample_rate
,
int
*
output_sample_rate
)
{
{
MPEG4AudioConfig
mp4ac
;
MPEG4AudioConfig
mp4ac
;
...
@@ -479,6 +489,8 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo
...
@@ -479,6 +489,8 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo
ret
=
put_xiph_codecpriv
(
s
,
dyn_cp
,
codec
);
ret
=
put_xiph_codecpriv
(
s
,
dyn_cp
,
codec
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_FLAC
)
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_FLAC
)
ret
=
ff_flac_write_header
(
dyn_cp
,
codec
,
1
);
ret
=
ff_flac_write_header
(
dyn_cp
,
codec
,
1
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_WAVPACK
)
ret
=
put_wv_codecpriv
(
dyn_cp
,
codec
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_H264
)
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_H264
)
ret
=
ff_isom_write_avcc
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
);
ret
=
ff_isom_write_avcc
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_ALAC
)
{
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_ALAC
)
{
...
@@ -1054,6 +1066,59 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p
...
@@ -1054,6 +1066,59 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p
return
max_duration
;
return
max_duration
;
}
}
static
int
mkv_strip_wavpack
(
const
uint8_t
*
src
,
uint8_t
**
pdst
,
int
*
size
)
{
uint8_t
*
dst
;
int
srclen
=
*
size
;
int
offset
=
0
;
int
ret
;
dst
=
av_malloc
(
srclen
);
if
(
!
dst
)
return
AVERROR
(
ENOMEM
);
while
(
srclen
>=
WV_HEADER_SIZE
)
{
WvHeader
header
;
ret
=
ff_wv_parse_header
(
&
header
,
src
);
if
(
ret
<
0
)
goto
fail
;
src
+=
WV_HEADER_SIZE
;
srclen
-=
WV_HEADER_SIZE
;
if
(
srclen
<
header
.
blocksize
)
{
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
}
if
(
header
.
initial
)
{
AV_WL32
(
dst
+
offset
,
header
.
samples
);
offset
+=
4
;
}
AV_WL32
(
dst
+
offset
,
header
.
flags
);
AV_WL32
(
dst
+
offset
+
4
,
header
.
crc
);
offset
+=
8
;
if
(
!
(
header
.
initial
&&
header
.
final
))
{
AV_WL32
(
dst
+
offset
,
header
.
blocksize
);
offset
+=
4
;
}
memcpy
(
dst
+
offset
,
src
,
header
.
blocksize
);
src
+=
header
.
blocksize
;
srclen
-=
header
.
blocksize
;
offset
+=
header
.
blocksize
;
}
*
pdst
=
dst
;
*
size
=
offset
;
return
0
;
fail:
av_freep
(
&
dst
);
return
ret
;
}
static
void
mkv_write_block
(
AVFormatContext
*
s
,
AVIOContext
*
pb
,
static
void
mkv_write_block
(
AVFormatContext
*
s
,
AVIOContext
*
pb
,
unsigned
int
blockid
,
AVPacket
*
pkt
,
int
flags
)
unsigned
int
blockid
,
AVPacket
*
pkt
,
int
flags
)
{
{
...
@@ -1069,7 +1134,13 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
...
@@ -1069,7 +1134,13 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
if
(
codec
->
codec_id
==
AV_CODEC_ID_H264
&&
codec
->
extradata_size
>
0
&&
if
(
codec
->
codec_id
==
AV_CODEC_ID_H264
&&
codec
->
extradata_size
>
0
&&
(
AV_RB24
(
codec
->
extradata
)
==
1
||
AV_RB32
(
codec
->
extradata
)
==
1
))
(
AV_RB24
(
codec
->
extradata
)
==
1
||
AV_RB32
(
codec
->
extradata
)
==
1
))
ff_avc_parse_nal_units_buf
(
pkt
->
data
,
&
data
,
&
size
);
ff_avc_parse_nal_units_buf
(
pkt
->
data
,
&
data
,
&
size
);
else
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_WAVPACK
)
{
int
ret
=
mkv_strip_wavpack
(
pkt
->
data
,
&
data
,
&
size
);
if
(
ret
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Error stripping a WavPack packet.
\n
"
);
return
;
}
}
else
data
=
pkt
->
data
;
data
=
pkt
->
data
;
if
(
codec
->
codec_id
==
AV_CODEC_ID_PRORES
)
{
if
(
codec
->
codec_id
==
AV_CODEC_ID_PRORES
)
{
...
...
tests/Makefile
View file @
01656fd4
...
@@ -42,6 +42,8 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER \
...
@@ -42,6 +42,8 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER \
DEMDEC
=
$
(
call ALLYES,
$
(
1
)
_DEMUXER
$
(
2:%
=
%_DECODER
))
DEMDEC
=
$
(
call ALLYES,
$
(
1
)
_DEMUXER
$
(
2:%
=
%_DECODER
))
ENCMUX
=
$
(
call ALLYES,
$
(
1:%
=
%_ENCODER
)
$
(
2
)
_MUXER
)
ENCMUX
=
$
(
call ALLYES,
$
(
1:%
=
%_ENCODER
)
$
(
2
)
_MUXER
)
DEMMUX
=
$
(
call ALLYES,
$
(
1
)
_DEMUXER
$
(
2
)
_MUXER
)
FILTERDEMDEC
=
$
(
call ALLYES,
$
(
1
)
_FILTER
$
(
2
)
_DEMUXER
$
(
3
)
_DECODER
)
FILTERDEMDEC
=
$
(
call ALLYES,
$
(
1
)
_FILTER
$
(
2
)
_DEMUXER
$
(
3
)
_DECODER
)
FILTERDEMDECMUX
=
$
(
call ALLYES,
$
(
1
)
_FILTER
$
(
2
)
_DEMUXER
$
(
3
)
_DECODER
$
(
4
)
_MUXER
)
FILTERDEMDECMUX
=
$
(
call ALLYES,
$
(
1
)
_FILTER
$
(
2
)
_DEMUXER
$
(
3
)
_DECODER
$
(
4
)
_MUXER
)
FILTERDEMDECENCMUX
=
$
(
call ALLYES,
$
(
1
)
_FILTER
$
(
2
)
_DEMUXER
$
(
3
)
_DECODER
$
(
4
)
_ENCODER
$
(
5
)
_MUXER
)
FILTERDEMDECENCMUX
=
$
(
call ALLYES,
$
(
1
)
_FILTER
$
(
2
)
_DEMUXER
$
(
3
)
_DECODER
$
(
4
)
_ENCODER
$
(
5
)
_MUXER
)
...
...
tests/fate/wavpack.mak
View file @
01656fd4
...
@@ -88,5 +88,15 @@ FATE_WAVPACK-$(call DEMDEC, WV, WAVPACK) += $(FATE_WAVPACK)
...
@@ -88,5 +88,15 @@ FATE_WAVPACK-$(call DEMDEC, WV, WAVPACK) += $(FATE_WAVPACK)
FATE_WAVPACK-$(call DEMDEC, MATROSKA, WAVPACK) += fate-wavpack-matroskamode
FATE_WAVPACK-$(call DEMDEC, MATROSKA, WAVPACK) += fate-wavpack-matroskamode
fate-wavpack-matroskamode: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/special/matroska_mode.mka -f s16le
fate-wavpack-matroskamode: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/special/matroska_mode.mka -f s16le
FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-mono
fate-wavpack-matroska_mux-mono: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/num_channels/mono_16bit_int.wv -c copy -flags +bitexact -f matroska
fate-wavpack-matroska_mux-mono: CMP = oneline
fate-wavpack-matroska_mux-mono: REF = f471da7c71cd01d5fb81efb1d740504f
FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-61
fate-wavpack-matroska_mux-61: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv -c copy -flags +bitexact -f matroska
fate-wavpack-matroska_mux-61: CMP = oneline
fate-wavpack-matroska_mux-61: REF = cbbd0ce7eabef52235bcdd2cb0690f24
FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes)
FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes)
fate-wavpack: $(FATE_WAVPACK-yes)
fate-wavpack: $(FATE_WAVPACK-yes)
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