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
e19d48df
Commit
e19d48df
authored
May 26, 2014
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flac muxer: support reading updated extradata from side data
parent
0097cbea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
15 deletions
+37
-15
flacenc.c
libavformat/flacenc.c
+29
-8
flacenc.h
libavformat/flacenc.h
+2
-2
flacenc_header.c
libavformat/flacenc_header.c
+4
-4
matroskaenc.c
libavformat/matroskaenc.c
+2
-1
No files found.
libavformat/flacenc.c
View file @
e19d48df
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
typedef
struct
FlacMuxerContext
{
typedef
struct
FlacMuxerContext
{
const
AVClass
*
class
;
const
AVClass
*
class
;
int
write_header
;
int
write_header
;
/* updated streaminfo sent by the encoder at the end */
uint8_t
*
streaminfo
;
}
FlacMuxerContext
;
}
FlacMuxerContext
;
static
int
flac_write_block_padding
(
AVIOContext
*
pb
,
unsigned
int
n_padding_bytes
,
static
int
flac_write_block_padding
(
AVIOContext
*
pb
,
unsigned
int
n_padding_bytes
,
...
@@ -80,7 +83,8 @@ static int flac_write_header(struct AVFormatContext *s)
...
@@ -80,7 +83,8 @@ static int flac_write_header(struct AVFormatContext *s)
if
(
!
c
->
write_header
)
if
(
!
c
->
write_header
)
return
0
;
return
0
;
ret
=
ff_flac_write_header
(
s
->
pb
,
codec
,
0
);
ret
=
ff_flac_write_header
(
s
->
pb
,
codec
->
extradata
,
codec
->
extradata_size
,
0
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
...
@@ -118,17 +122,14 @@ static int flac_write_header(struct AVFormatContext *s)
...
@@ -118,17 +122,14 @@ static int flac_write_header(struct AVFormatContext *s)
static
int
flac_write_trailer
(
struct
AVFormatContext
*
s
)
static
int
flac_write_trailer
(
struct
AVFormatContext
*
s
)
{
{
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
uint8_t
*
streaminfo
;
enum
FLACExtradataFormat
format
;
int64_t
file_size
;
int64_t
file_size
;
FlacMuxerContext
*
c
=
s
->
priv_data
;
FlacMuxerContext
*
c
=
s
->
priv_data
;
uint8_t
*
streaminfo
=
c
->
streaminfo
?
c
->
streaminfo
:
s
->
streams
[
0
]
->
codec
->
extradata
;
if
(
!
c
->
write_header
)
if
(
!
c
->
write_header
||
!
streaminfo
)
return
0
;
return
0
;
if
(
!
avpriv_flac_is_extradata_valid
(
s
->
streams
[
0
]
->
codec
,
&
format
,
&
streaminfo
))
return
-
1
;
if
(
pb
->
seekable
)
{
if
(
pb
->
seekable
)
{
/* rewrite the STREAMINFO header block data */
/* rewrite the STREAMINFO header block data */
file_size
=
avio_tell
(
pb
);
file_size
=
avio_tell
(
pb
);
...
@@ -139,12 +140,32 @@ static int flac_write_trailer(struct AVFormatContext *s)
...
@@ -139,12 +140,32 @@ static int flac_write_trailer(struct AVFormatContext *s)
}
else
{
}
else
{
av_log
(
s
,
AV_LOG_WARNING
,
"unable to rewrite FLAC header.
\n
"
);
av_log
(
s
,
AV_LOG_WARNING
,
"unable to rewrite FLAC header.
\n
"
);
}
}
av_freep
(
&
c
->
streaminfo
);
return
0
;
return
0
;
}
}
static
int
flac_write_packet
(
struct
AVFormatContext
*
s
,
AVPacket
*
pkt
)
static
int
flac_write_packet
(
struct
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
{
avio_write
(
s
->
pb
,
pkt
->
data
,
pkt
->
size
);
FlacMuxerContext
*
c
=
s
->
priv_data
;
uint8_t
*
streaminfo
;
int
streaminfo_size
;
/* check for updated streaminfo */
streaminfo
=
av_packet_get_side_data
(
pkt
,
AV_PKT_DATA_NEW_EXTRADATA
,
&
streaminfo_size
);
if
(
streaminfo
&&
streaminfo_size
==
FLAC_STREAMINFO_SIZE
)
{
av_freep
(
&
c
->
streaminfo
);
c
->
streaminfo
=
av_malloc
(
FLAC_STREAMINFO_SIZE
);
if
(
!
c
->
streaminfo
)
return
AVERROR
(
ENOMEM
);
memcpy
(
c
->
streaminfo
,
streaminfo
,
FLAC_STREAMINFO_SIZE
);
}
if
(
pkt
->
size
)
avio_write
(
s
->
pb
,
pkt
->
data
,
pkt
->
size
);
return
0
;
return
0
;
}
}
...
...
libavformat/flacenc.h
View file @
e19d48df
...
@@ -26,8 +26,8 @@
...
@@ -26,8 +26,8 @@
#include "libavcodec/bytestream.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
#include "avformat.h"
int
ff_flac_write_header
(
AVIOContext
*
pb
,
AVCodecContext
*
codec
,
int
ff_flac_write_header
(
AVIOContext
*
pb
,
uint8_t
*
extradata
,
int
last_block
);
int
extradata_size
,
int
last_block
);
int
ff_flac_is_native_layout
(
uint64_t
channel_layout
);
int
ff_flac_is_native_layout
(
uint64_t
channel_layout
);
...
...
libavformat/flacenc_header.c
View file @
e19d48df
...
@@ -26,8 +26,8 @@
...
@@ -26,8 +26,8 @@
#include "avformat.h"
#include "avformat.h"
#include "flacenc.h"
#include "flacenc.h"
int
ff_flac_write_header
(
AVIOContext
*
pb
,
AVCodecContext
*
codec
,
int
ff_flac_write_header
(
AVIOContext
*
pb
,
uint8_t
*
extradata
,
int
last_block
)
int
extradata_size
,
int
last_block
)
{
{
uint8_t
header
[
8
]
=
{
uint8_t
header
[
8
]
=
{
0x66
,
0x4C
,
0x61
,
0x43
,
0x00
,
0x00
,
0x00
,
0x22
0x66
,
0x4C
,
0x61
,
0x43
,
0x00
,
0x00
,
0x00
,
0x22
...
@@ -35,14 +35,14 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
...
@@ -35,14 +35,14 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
header
[
4
]
=
last_block
?
0x80
:
0x00
;
header
[
4
]
=
last_block
?
0x80
:
0x00
;
if
(
codec
->
extradata_size
<
FLAC_STREAMINFO_SIZE
)
if
(
extradata_size
<
FLAC_STREAMINFO_SIZE
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
/* write "fLaC" stream marker and first metadata block header */
/* write "fLaC" stream marker and first metadata block header */
avio_write
(
pb
,
header
,
8
);
avio_write
(
pb
,
header
,
8
);
/* write STREAMINFO */
/* write STREAMINFO */
avio_write
(
pb
,
codec
->
extradata
,
FLAC_STREAMINFO_SIZE
);
avio_write
(
pb
,
extradata
,
FLAC_STREAMINFO_SIZE
);
return
0
;
return
0
;
}
}
...
...
libavformat/matroskaenc.c
View file @
e19d48df
...
@@ -477,7 +477,8 @@ static int put_flac_codecpriv(AVFormatContext *s,
...
@@ -477,7 +477,8 @@ static int put_flac_codecpriv(AVFormatContext *s,
int
write_comment
=
(
codec
->
channel_layout
&&
int
write_comment
=
(
codec
->
channel_layout
&&
!
(
codec
->
channel_layout
&
~
0x3ffffULL
)
&&
!
(
codec
->
channel_layout
&
~
0x3ffffULL
)
&&
!
ff_flac_is_native_layout
(
codec
->
channel_layout
));
!
ff_flac_is_native_layout
(
codec
->
channel_layout
));
int
ret
=
ff_flac_write_header
(
pb
,
codec
,
!
write_comment
);
int
ret
=
ff_flac_write_header
(
pb
,
codec
->
extradata
,
codec
->
extradata_size
,
!
write_comment
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
...
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