Libav
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 Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 
27  {"A_AAC" , AV_CODEC_ID_AAC},
28  {"A_AC3" , AV_CODEC_ID_AC3},
29  {"A_ALAC" , AV_CODEC_ID_ALAC},
30  {"A_DTS" , AV_CODEC_ID_DTS},
31  {"A_EAC3" , AV_CODEC_ID_EAC3},
32  {"A_FLAC" , AV_CODEC_ID_FLAC},
33  {"A_MLP" , AV_CODEC_ID_MLP},
34  {"A_MPEG/L2" , AV_CODEC_ID_MP2},
35  {"A_MPEG/L1" , AV_CODEC_ID_MP2},
36  {"A_MPEG/L3" , AV_CODEC_ID_MP3},
37  {"A_OPUS" , AV_CODEC_ID_OPUS},
38  {"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F32LE},
39  {"A_PCM/FLOAT/IEEE" , AV_CODEC_ID_PCM_F64LE},
40  {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S16BE},
41  {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S24BE},
42  {"A_PCM/INT/BIG" , AV_CODEC_ID_PCM_S32BE},
43  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S16LE},
44  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S24LE},
45  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_S32LE},
46  {"A_PCM/INT/LIT" , AV_CODEC_ID_PCM_U8},
47  {"A_QUICKTIME/QDM2" , AV_CODEC_ID_QDM2},
48  {"A_REAL/14_4" , AV_CODEC_ID_RA_144},
49  {"A_REAL/28_8" , AV_CODEC_ID_RA_288},
50  {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
51  {"A_REAL/COOK" , AV_CODEC_ID_COOK},
52  {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
53  {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
54  {"A_TTA1" , AV_CODEC_ID_TTA},
55  {"A_VORBIS" , AV_CODEC_ID_VORBIS},
56  {"A_WAVPACK4" , AV_CODEC_ID_WAVPACK},
57 
58  {"S_TEXT/UTF8" , AV_CODEC_ID_SRT},
59  {"S_TEXT/UTF8" , AV_CODEC_ID_TEXT},
60  {"S_TEXT/ASCII" , AV_CODEC_ID_TEXT},
61  {"S_TEXT/ASS" , AV_CODEC_ID_SSA},
62  {"S_TEXT/SSA" , AV_CODEC_ID_SSA},
63  {"S_ASS" , AV_CODEC_ID_SSA},
64  {"S_SSA" , AV_CODEC_ID_SSA},
65  {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE},
66  {"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE},
67 
68  {"V_DIRAC" , AV_CODEC_ID_DIRAC},
69  {"V_MJPEG" , AV_CODEC_ID_MJPEG},
70  {"V_MPEG1" , AV_CODEC_ID_MPEG1VIDEO},
71  {"V_MPEG2" , AV_CODEC_ID_MPEG2VIDEO},
72  {"V_MPEG4/ISO/ASP" , AV_CODEC_ID_MPEG4},
73  {"V_MPEG4/ISO/AP" , AV_CODEC_ID_MPEG4},
74  {"V_MPEG4/ISO/SP" , AV_CODEC_ID_MPEG4},
75  {"V_MPEG4/ISO/AVC" , AV_CODEC_ID_H264},
76  {"V_MPEGH/ISO/HEVC" , AV_CODEC_ID_HEVC},
77  {"V_MPEG4/MS/V3" , AV_CODEC_ID_MSMPEG4V3},
78  {"V_PRORES" , AV_CODEC_ID_PRORES},
79  {"V_REAL/RV10" , AV_CODEC_ID_RV10},
80  {"V_REAL/RV20" , AV_CODEC_ID_RV20},
81  {"V_REAL/RV30" , AV_CODEC_ID_RV30},
82  {"V_REAL/RV40" , AV_CODEC_ID_RV40},
83  {"V_THEORA" , AV_CODEC_ID_THEORA},
84  {"V_UNCOMPRESSED" , AV_CODEC_ID_RAWVIDEO},
85  {"V_VP8" , AV_CODEC_ID_VP8},
86  {"V_VP9" , AV_CODEC_ID_VP9},
87 
88  {"" , AV_CODEC_ID_NONE}
89 };
90 
92  {"text/plain" , AV_CODEC_ID_TEXT},
93  {"image/gif" , AV_CODEC_ID_GIF},
94  {"image/jpeg" , AV_CODEC_ID_MJPEG},
95  {"image/png" , AV_CODEC_ID_PNG},
96  {"image/tiff" , AV_CODEC_ID_TIFF},
97  {"application/x-truetype-font", AV_CODEC_ID_TTF},
98  {"application/x-font" , AV_CODEC_ID_TTF},
99 
100  {"" , AV_CODEC_ID_NONE}
101 };
102 
104  { "LEAD_PERFORMER", "performer" },
105  { "PART_NUMBER" , "track" },
106  { 0 }
107 };
108 
110 {
111  AVPacketSideData *sd, *tmp;
112  AVStereo3D *stereo;
113 
114  stereo = av_stereo3d_alloc();
115  if (!stereo)
116  return AVERROR(ENOMEM);
117 
118  tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
119  if (!tmp) {
120  av_freep(&stereo);
121  return AVERROR(ENOMEM);
122  }
123  st->side_data = tmp;
124  st->nb_side_data++;
125 
126  sd = &st->side_data[st->nb_side_data - 1];
128  sd->data = (uint8_t *)stereo;
129  sd->size = sizeof(*stereo);
130 
131  // note: the missing breaks are intentional
132  switch (stereo_mode) {
134  stereo->type = AV_STEREO3D_2D;
135  break;
137  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
139  stereo->type = AV_STEREO3D_SIDEBYSIDE;
140  break;
142  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
144  stereo->type = AV_STEREO3D_TOPBOTTOM;
145  break;
147  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
149  stereo->type = AV_STEREO3D_CHECKERBOARD;
150  break;
152  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
154  stereo->type = AV_STEREO3D_LINES;
155  break;
157  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
159  stereo->type = AV_STEREO3D_COLUMNS;
160  break;
162  stereo->flags |= AV_STEREO3D_FLAG_INVERT;
165  break;
166  }
167 
168  return 0;
169 }
Views are packed per line, as if interlaced.
Definition: stereo3d.h:97
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:919
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
Definition: avformat.h:807
MatroskaVideoStereoModeType
Definition: matroska.h:224
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
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:109
int nb_side_data
The number of elements in the AVStream.side_data array.
Definition: avformat.h:811
uint8_t * data
Definition: avcodec.h:923
int flags
Additional information about the frame packing.
Definition: stereo3d.h:132
#define AVERROR(e)
Definition: error.h:43
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:379
enum AVPacketSideDataType type
Definition: avcodec.h:925
Video is not stereoscopic (and metadata has to be there).
Definition: stereo3d.h:35
const CodecMime ff_mkv_mime_tags[]
Definition: matroska.c:91
#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:110
Stream structure.
Definition: avformat.h:699
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:103
Views are next to each other.
Definition: stereo3d.h:45
raw UTF-8 text
Definition: avcodec.h:452
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:160
Views are packed in a checkerboard-like structure per pixel.
Definition: stereo3d.h:76
Views are packed per column.
Definition: stereo3d.h:107
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:26