FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
matroska.c
Go to the documentation of this file.
1 /*
2  * Matroska common data
3  * Copyright (c) 2003-2004 The FFmpeg Project
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/stereo3d.h"
23 
24 #include "matroska.h"
25 
26 /* If you add a tag here that is not in ff_codec_bmp_tags[]
27  or ff_codec_wav_tags[], add it also to additional_audio_tags[]
28  or additional_video_tags[] in matroskaenc.c */
30  {"A_AAC" , AV_CODEC_ID_AAC},
31  {"A_AC3" , AV_CODEC_ID_AC3},
32  {"A_ALAC" , AV_CODEC_ID_ALAC},
33  {"A_DTS" , AV_CODEC_ID_DTS},
34  {"A_EAC3" , AV_CODEC_ID_EAC3},
35  {"A_FLAC" , AV_CODEC_ID_FLAC},
36  {"A_MLP" , AV_CODEC_ID_MLP},
37  {"A_MPEG/L2" , AV_CODEC_ID_MP2},
38  {"A_MPEG/L1" , AV_CODEC_ID_MP2},
39  {"A_MPEG/L3" , AV_CODEC_ID_MP3},
40  {"A_OPUS" , AV_CODEC_ID_OPUS},
41  {"A_OPUS/EXPERIMENTAL",AV_CODEC_ID_OPUS},
42  {"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F32LE},
43  {"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F64LE},
44  {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S16BE},
45  {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S24BE},
46  {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S32BE},
47  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S16LE},
48  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S24LE},
49  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S32LE},
50  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_U8},
51  {"A_QUICKTIME/QDM2" , AV_CODEC_ID_QDM2},
52  {"A_REAL/14_4" , AV_CODEC_ID_RA_144},
53  {"A_REAL/28_8" , AV_CODEC_ID_RA_288},
54  {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
55  {"A_REAL/COOK" , AV_CODEC_ID_COOK},
56  {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
57  {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
58  {"A_TTA1" , AV_CODEC_ID_TTA},
59  {"A_VORBIS" , AV_CODEC_ID_VORBIS},
60  {"A_WAVPACK4" , AV_CODEC_ID_WAVPACK},
61 
62  {"D_WEBVTT/SUBTITLES" , AV_CODEC_ID_WEBVTT},
63  {"D_WEBVTT/CAPTIONS" , AV_CODEC_ID_WEBVTT},
64  {"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
65  {"D_WEBVTT/METADATA" , AV_CODEC_ID_WEBVTT},
66 
67  {"S_TEXT/UTF8" , AV_CODEC_ID_SUBRIP},
68  {"S_TEXT/UTF8" , AV_CODEC_ID_TEXT},
69  {"S_TEXT/ASCII" , AV_CODEC_ID_TEXT},
70  {"S_TEXT/ASS" , AV_CODEC_ID_ASS},
71  {"S_TEXT/SSA" , AV_CODEC_ID_ASS},
72  {"S_ASS" , AV_CODEC_ID_ASS},
73  {"S_SSA" , AV_CODEC_ID_ASS},
74  {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE},
75  {"S_DVBSUB" , AV_CODEC_ID_DVB_SUBTITLE},
76  {"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE},
77 
78  {"V_DIRAC" , AV_CODEC_ID_DIRAC},
79  {"V_MJPEG" , AV_CODEC_ID_MJPEG},
80  {"V_MPEG1" , AV_CODEC_ID_MPEG1VIDEO},
81  {"V_MPEG2" , AV_CODEC_ID_MPEG2VIDEO},
82  {"V_MPEG4/ISO/ASP" , AV_CODEC_ID_MPEG4},
83  {"V_MPEG4/ISO/AP" , AV_CODEC_ID_MPEG4},
84  {"V_MPEG4/ISO/SP" , AV_CODEC_ID_MPEG4},
85  {"V_MPEG4/ISO/AVC" , AV_CODEC_ID_H264},
86  {"V_MPEGH/ISO/HEVC" , AV_CODEC_ID_HEVC},
87  {"V_MPEG4/MS/V3" , AV_CODEC_ID_MSMPEG4V3},
88  {"V_PRORES" , AV_CODEC_ID_PRORES},
89  {"V_REAL/RV10" , AV_CODEC_ID_RV10},
90  {"V_REAL/RV20" , AV_CODEC_ID_RV20},
91  {"V_REAL/RV30" , AV_CODEC_ID_RV30},
92  {"V_REAL/RV40" , AV_CODEC_ID_RV40},
93  {"V_SNOW" , AV_CODEC_ID_SNOW},
94  {"V_THEORA" , AV_CODEC_ID_THEORA},
95  {"V_UNCOMPRESSED" , AV_CODEC_ID_RAWVIDEO},
96  {"V_VP8" , AV_CODEC_ID_VP8},
97  {"V_VP9" , AV_CODEC_ID_VP9},
98 
99  {"" , AV_CODEC_ID_NONE}
100 };
101 
103  {"image/gif" , AV_CODEC_ID_GIF},
104  {"image/jpeg" , AV_CODEC_ID_MJPEG},
105  {"image/png" , AV_CODEC_ID_PNG},
106  {"image/tiff" , AV_CODEC_ID_TIFF},
107 
108  {"" , AV_CODEC_ID_NONE}
109 };
110 
112  {"text/plain" , AV_CODEC_ID_TEXT},
113  {"application/x-truetype-font", AV_CODEC_ID_TTF},
114  {"application/x-font" , AV_CODEC_ID_TTF},
115  {"application/vnd.ms-opentype", AV_CODEC_ID_OTF},
116  {"binary" , AV_CODEC_ID_BIN_DATA},
117 
118  {"" , AV_CODEC_ID_NONE}
119 };
120 
122  { "LEAD_PERFORMER", "performer" },
123  { "PART_NUMBER" , "track" },
124  { 0 }
125 };
126 
128  "mono",
129  "left_right",
130  "bottom_top",
131  "top_bottom",
132  "checkerboard_rl",
133  "checkerboard_lr",
134  "row_interleaved_rl",
135  "row_interleaved_lr",
136  "col_interleaved_rl",
137  "col_interleaved_lr",
138  "anaglyph_cyan_red",
139  "right_left",
140  "anaglyph_green_magenta",
141  "block_lr",
142  "block_rl",
143 };
144 
146  "left",
147  "right",
148  "background",
149 };
150 
152 {
153  AVPacketSideData *sd, *tmp;
154  AVStereo3D *stereo;
155 
156  stereo = av_stereo3d_alloc();
157  if (!stereo)
158  return AVERROR(ENOMEM);
159 
160  tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
161  if (!tmp) {
162  av_freep(&stereo);
163  return AVERROR(ENOMEM);
164  }
165  st->side_data = tmp;
166  st->nb_side_data++;
167 
168  sd = &st->side_data[st->nb_side_data - 1];
170  sd->data = (uint8_t *)stereo;
171  sd->size = sizeof(*stereo);
172 
173  // note: the missing breaks are intentional
174  switch (stereo_mode) {
176  stereo->type = AV_STEREO3D_2D;
177  break;
179  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
181  stereo->type = AV_STEREO3D_SIDEBYSIDE;
182  break;
184  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
186  stereo->type = AV_STEREO3D_TOPBOTTOM;
187  break;
189  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
191  stereo->type = AV_STEREO3D_CHECKERBOARD;
192  break;
194  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
196  stereo->type = AV_STEREO3D_LINES;
197  break;
199  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
201  stereo->type = AV_STEREO3D_COLUMNS;
202  break;
204  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
207  break;
208  }
209 
210  return 0;
211 }
Views are packed per line, as if interlaced.
Definition: stereo3d.h:97
const char *const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_COUNT]
Definition: matroska.c:145
Views are alternated temporally.
Definition: stereo3d.h:66
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: avcodec.h:1038
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
Definition: avformat.h:954
MatroskaVideoStereoModeType
Definition: matroska.h:248
uint8_t
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
Definition: stereo3d.h:123
int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
Definition: matroska.c:151
int nb_side_data
The number of elements in the AVStream.side_data array.
Definition: avformat.h:958
uint8_t * data
Definition: avcodec.h:1112
int flags
Additional information about the frame packing.
Definition: stereo3d.h:132
#define AVERROR(e)
Definition: error.h:43
const char *const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB]
Definition: matroska.c:127
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:421
enum AVPacketSideDataType type
Definition: avcodec.h:1114
Video is not stereoscopic (and metadata has to be there).
Definition: stereo3d.h:35
const CodecMime ff_mkv_mime_tags[]
Definition: matroska.c:111
#define MATROSKA_VIDEO_STEREO_PLANE_COUNT
Definition: matroska.h:279
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
Definition: stereo3d.h:114
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:107
Stream structure.
Definition: avformat.h:842
enum AVStereo3DType type
How views are packed within the video.
Definition: stereo3d.h:127
Views are on top of each other.
Definition: stereo3d.h:55
const AVMetadataConv ff_mkv_metadata_conv[]
Definition: matroska.c:121
Views are next to each other.
Definition: stereo3d.h:45
raw UTF-8 text
Definition: avcodec.h:507
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:206
ASS as defined in Matroska.
Definition: avcodec.h:527
Views are packed in a checkerboard-like structure per pixel.
Definition: stereo3d.h:76
Views are packed per column.
Definition: stereo3d.h:107
#define av_freep(p)
const CodecMime ff_mkv_image_mime_tags[]
Definition: matroska.c:102
AVStereo3D * av_stereo3d_alloc(void)
Allocate an AVStereo3D structure and set its fields to default values.
Definition: stereo3d.c:27
const CodecTags ff_mkv_codec_tags[]
Definition: matroska.c:29