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
4d686fb7
Commit
4d686fb7
authored
Aug 05, 2014
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
matroskaenc: convert avstream stereo3d side data during encoding
Write the StereoMode Embl to bitstream.
parent
d4ae8ac9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
18 deletions
+76
-18
matroskaenc.c
libavformat/matroskaenc.c
+76
-18
No files found.
libavformat/matroskaenc.c
View file @
4d686fb7
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavutil/random_seed.h"
#include "libavutil/samplefmt.h"
#include "libavutil/samplefmt.h"
#include "libavutil/stereo3d.h"
#include "libavcodec/xiph.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
#include "libavcodec/mpeg4audio.h"
...
@@ -624,25 +625,78 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
...
@@ -624,25 +625,78 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
return
ret
;
return
ret
;
}
}
static
void
mkv_write_stereo_mode
(
AVIOContext
*
pb
,
uint8_t
stereo_fmt
,
static
int
mkv_write_stereo_mode
(
AVFormatContext
*
s
,
AVIOContext
*
pb
,
int
mode
)
AVStream
*
st
,
int
mode
)
{
{
int
valid_fmt
=
0
;
int
i
;
AVDictionaryEntry
*
tag
;
MatroskaVideoStereoModeType
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_NB
;
// convert metadata into proper side data and add it to the stream
if
((
tag
=
av_dict_get
(
s
->
metadata
,
"stereo_mode"
,
NULL
,
0
)))
{
int
stereo_mode
=
atoi
(
tag
->
value
);
if
(
stereo_mode
<
MATROSKA_VIDEO_STEREOMODE_TYPE_NB
&&
stereo_mode
!=
10
&&
stereo_mode
!=
12
)
{
int
ret
=
ff_mkv_stereo3d_conv
(
st
,
stereo_mode
);
if
(
ret
<
0
)
return
ret
;
}
}
for
(
i
=
0
;
i
<
st
->
nb_side_data
;
i
++
)
{
AVPacketSideData
sd
=
st
->
side_data
[
i
];
if
(
sd
.
type
==
AV_PKT_DATA_STEREO3D
)
{
AVStereo3D
*
stereo
=
(
AVStereo3D
*
)
sd
.
data
;
switch
(
mode
)
{
switch
(
stereo
->
type
)
{
case
MODE_WEBM
:
case
AV_STEREO3D_2D
:
if
(
stereo_fmt
<=
MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM
||
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_MONO
;
stereo_fmt
==
MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
)
break
;
valid_fmt
=
1
;
case
AV_STEREO3D_SIDEBYSIDE
:
format
=
(
stereo
->
flags
&
AV_STEREO3D_FLAG_INVERT
)
?
MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
:
MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT
;
break
;
case
AV_STEREO3D_TOPBOTTOM
:
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM
;
if
(
stereo
->
flags
&
AV_STEREO3D_FLAG_INVERT
)
format
--
;
break
;
case
AV_STEREO3D_CHECKERBOARD
:
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR
;
if
(
stereo
->
flags
&
AV_STEREO3D_FLAG_INVERT
)
format
--
;
break
;
case
AV_STEREO3D_LINES
:
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR
;
if
(
stereo
->
flags
&
AV_STEREO3D_FLAG_INVERT
)
format
--
;
break
;
case
AV_STEREO3D_COLUMNS
:
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR
;
if
(
stereo
->
flags
&
AV_STEREO3D_FLAG_INVERT
)
format
--
;
break
;
break
;
case
MODE_MATROSKAv2
:
case
AV_STEREO3D_FRAMESEQUENCE
:
if
(
stereo_fmt
<=
MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL
)
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR
;
valid_fmt
=
1
;
if
(
stereo
->
flags
&
AV_STEREO3D_FLAG_INVERT
)
format
++
;
break
;
break
;
}
}
if
(
valid_fmt
)
break
;
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOSTEREOMODE
,
stereo_fmt
);
}
}
if
(
mode
==
MODE_WEBM
&&
(
format
>
MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM
&&
format
!=
MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
))
format
=
MATROSKA_VIDEO_STEREOMODE_TYPE_NB
;
if
(
format
<
MATROSKA_VIDEO_STEREOMODE_TYPE_NB
)
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOSTEREOMODE
,
format
);
return
0
;
}
}
static
int
mkv_write_track
(
AVFormatContext
*
s
,
MatroskaMuxContext
*
mkv
,
static
int
mkv_write_track
(
AVFormatContext
*
s
,
MatroskaMuxContext
*
mkv
,
...
@@ -743,9 +797,13 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
...
@@ -743,9 +797,13 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
// XXX: interlace flag?
// XXX: interlace flag?
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOPIXELWIDTH
,
codec
->
width
);
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOPIXELWIDTH
,
codec
->
width
);
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOPIXELHEIGHT
,
codec
->
height
);
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOPIXELHEIGHT
,
codec
->
height
);
if
((
tag
=
av_dict_get
(
s
->
metadata
,
"stereo_mode"
,
NULL
,
0
)))
{
mkv_write_stereo_mode
(
pb
,
atoi
(
tag
->
value
),
mkv
->
mode
);
// check both side data and metadata for stereo information,
}
// write the result to the bitstream if any is found
ret
=
mkv_write_stereo_mode
(
s
,
pb
,
st
,
mkv
->
mode
);
if
(
ret
<
0
)
return
ret
;
if
(
st
->
sample_aspect_ratio
.
num
)
{
if
(
st
->
sample_aspect_ratio
.
num
)
{
int
d_width
=
codec
->
width
*
av_q2d
(
st
->
sample_aspect_ratio
);
int
d_width
=
codec
->
width
*
av_q2d
(
st
->
sample_aspect_ratio
);
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEODISPLAYWIDTH
,
d_width
);
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEODISPLAYWIDTH
,
d_width
);
...
...
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